SleakEngine
0.1.0
C++23 multi-backend game engine
Toggle main menu visibility
Loading...
Searching...
No Matches
DirectX12Shader.hpp
Go to the documentation of this file.
1
#ifndef _DIRECTX12_SHADER_H_
2
#define _DIRECTX12_SHADER_H_
3
4
#include <d3d12.h>
5
#include <d3dcompiler.h>
6
#include <wrl/client.h>
7
8
#include <stdexcept>
9
#include <string>
10
#include <vector>
11
12
#include "
../Common/Shader.hpp
"
13
14
namespace
Sleak
{
15
namespace
RenderEngine
{
16
class
DirectX12Renderer;
17
18
/// D3D12 vertex+pixel shader pair; the pipeline state object itself is owned per-shader.
19
class
DirectX12Shader
:
public
Shader
{
20
public
:
21
DirectX12Shader
(ID3D12Device* device);
22
~DirectX12Shader
()
override
;
23
24
/// Compiles the combined-path convention (vs_main/ps_main entry points) from a single HLSL file.
25
bool
compile
(
const
std::string& shaderPath)
override
;
26
/// Compiles separate vertex and pixel shader HLSL files.
27
bool
compile
(
const
std::string& vertPath,
28
const
std::string& fragPath)
override
;
29
/// Binds the shader's cached PSO to the current command list.
30
void
bind
()
override
;
31
32
ID3DBlob*
getVertexShaderBlob
()
const
;
33
ID3DBlob*
getPixelShaderBlob
()
const
;
34
35
// Per-shader PSO
36
void
SetPipelineState
(Microsoft::WRL::ComPtr<ID3D12PipelineState> pso);
37
ID3D12PipelineState*
GetPipelineState
()
const
;
38
void
SetCommandList
(ID3D12GraphicsCommandList* cmdList);
39
/// Routes bind() through the renderer so pass-specific PSOs are respected.
40
void
SetRenderer
(DirectX12Renderer* renderer);
41
42
private
:
43
/// Compiles one HLSL entry point/profile via D3DCompileFromFile into bytecode.
44
bool
compileShader(
const
std::string& filePath,
45
const
std::string& entryPoint,
46
const
std::string& profile,
47
Microsoft::WRL::ComPtr<ID3DBlob>& blob);
48
49
Microsoft::WRL::ComPtr<ID3D12Device> m_device;
50
51
Microsoft::WRL::ComPtr<ID3DBlob> m_vertexShaderBlob;
52
Microsoft::WRL::ComPtr<ID3DBlob> m_pixelShaderBlob;
53
Microsoft::WRL::ComPtr<ID3D12PipelineState> m_pipelineState;
54
ID3D12GraphicsCommandList* m_commandList =
nullptr
;
55
DirectX12Renderer* m_renderer =
nullptr
;
56
};
57
58
}
// namespace RenderEngine
59
}
// namespace Sleak
60
#endif
// _DIRECTX12_SHADER_H_
Shader.hpp
Sleak::RenderEngine::DirectX12Shader::bind
void bind() override
Binds the shader's cached PSO to the current command list.
Definition
DirectX12Shader.cpp:59
Sleak::RenderEngine::DirectX12Shader::SetCommandList
void SetCommandList(ID3D12GraphicsCommandList *cmdList)
Definition
DirectX12Shader.cpp:84
Sleak::RenderEngine::DirectX12Shader::getVertexShaderBlob
ID3DBlob * getVertexShaderBlob() const
Definition
DirectX12Shader.cpp:68
Sleak::RenderEngine::DirectX12Shader::getPixelShaderBlob
ID3DBlob * getPixelShaderBlob() const
Definition
DirectX12Shader.cpp:72
Sleak::RenderEngine::DirectX12Shader::SetPipelineState
void SetPipelineState(Microsoft::WRL::ComPtr< ID3D12PipelineState > pso)
Definition
DirectX12Shader.cpp:76
Sleak::RenderEngine::DirectX12Shader::~DirectX12Shader
~DirectX12Shader() override
Sleak::RenderEngine::DirectX12Shader::GetPipelineState
ID3D12PipelineState * GetPipelineState() const
Definition
DirectX12Shader.cpp:80
Sleak::RenderEngine::DirectX12Shader::DirectX12Shader
DirectX12Shader(ID3D12Device *device)
Definition
DirectX12Shader.cpp:14
Sleak::RenderEngine::DirectX12Shader::compile
bool compile(const std::string &shaderPath) override
Compiles the combined-path convention (vs_main/ps_main entry points) from a single HLSL file.
Definition
DirectX12Shader.cpp:20
Sleak::RenderEngine::DirectX12Shader::SetRenderer
void SetRenderer(DirectX12Renderer *renderer)
Routes bind() through the renderer so pass-specific PSOs are respected.
Definition
DirectX12Shader.cpp:88
Sleak::RenderEngine::Shader
Backend-agnostic compiled shader program.
Definition
Shader.hpp:11
Sleak::RenderEngine
Backend-facing rendering layer shared by the four graphics backends.
Definition
Application.hpp:60
Sleak
Root namespace for everything the engine exposes.
Definition
Camera.hpp:10
include
private
Graphics
DirectX12
DirectX12Shader.hpp
Generated on
for SleakEngine by
1.18.0