1 // Copyright 2019 Dolphin Emulator Project
2 // Licensed under GPLv2+
3 // Refer to the license.txt file included.
4 
5 #pragma once
6 
7 #include <memory>
8 #include <string_view>
9 #include "VideoBackends/D3D12/Common.h"
10 #include "VideoBackends/D3DCommon/Shader.h"
11 
12 namespace DX12
13 {
14 class DXShader final : public D3DCommon::Shader
15 {
16 public:
17   ~DXShader() override;
18 
GetComputePipeline()19   ID3D12PipelineState* GetComputePipeline() const { return m_compute_pipeline.Get(); }
20   D3D12_SHADER_BYTECODE GetD3DByteCode() const;
21 
22   static std::unique_ptr<DXShader> CreateFromBytecode(ShaderStage stage, BinaryData bytecode);
23   static std::unique_ptr<DXShader> CreateFromSource(ShaderStage stage, std::string_view source);
24 
25 private:
26   DXShader(ShaderStage stage, BinaryData bytecode);
27 
28   bool CreateComputePipeline();
29 
30   ComPtr<ID3D12PipelineState> m_compute_pipeline;
31 };
32 
33 }  // namespace DX12
34