-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathShaderStageState.h
59 lines (48 loc) · 2.16 KB
/
ShaderStageState.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once
#include <cstdint>
#include <d3d11.h>
#include <vector>
class Shader;
class ShaderStage;
/// <summary>A shader stage state class.</summary>
class ShaderStageState
{
public:
using ConstantBufferContainerType = std::vector<ID3D11Buffer*>;
using ShaderResourceViewContainerType = std::vector<ID3D11ShaderResourceView*>;
using SamplerContainerType = std::vector<ID3D11SamplerState*>;
ShaderStageState(ShaderStage* stage);
virtual ~ShaderStageState();
virtual bool UpdateRequired() { return updated_; }
virtual bool ApplyUpdate();
// shader
virtual bool SetShader(Shader* shader);
virtual Shader* GetShader(Shader* shader) { return shader_; }
// constant buffers
virtual bool SetConstantBuffer(uint32_t slot, ID3D11Buffer* buffer);
virtual bool SetConstantBuffers(uint32_t start_slot, uint32_t count, ID3D11Buffer **buffers);
virtual void RemoveConstantBuffer(uint32_t slot);
virtual void RemoveConstantBuffers();
// shader resource views
virtual bool SetShaderResourveView(uint32_t slot, ID3D11ShaderResourceView* view);
virtual bool SetShaderResourceViews(uint32_t start_slot, uint32_t count, ID3D11ShaderResourceView **views);
virtual void RemoveShaderResourveView(uint32_t slot);
virtual void RemoveShaderResourveViews();
// samplers
virtual bool SetSampler(uint32_t slot, ID3D11SamplerState * sampler);
virtual bool SetSamplers(uint32_t start_slot, uint32_t count, ID3D11SamplerState **samplers);
virtual void RemoveSampler(uint32_t slot);
virtual void RemoveSamplers();
// unordered access views - NOT IMPLEMENTED YET
protected:
virtual uint32_t ConstantBuffersMax() { return D3D11_COMMONSHADER_CONSTANT_BUFFER_HW_SLOT_COUNT; }
virtual uint32_t SamplersMax() { return D3D11_COMMONSHADER_SAMPLER_SLOT_COUNT; }
virtual uint32_t ShaderResourceViewsMax() { return D3D11_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT; }
virtual uint32_t UnorderedAccessViewsMax() { return 0; }
Shader* shader_ = nullptr;
ShaderStage* stage_ = nullptr;
bool updated_ = true;
ConstantBufferContainerType* constant_buffers_ = nullptr;
ShaderResourceViewContainerType* shader_resource_views_ = nullptr;
SamplerContainerType* samplers_ = nullptr;
};