HatchitGraphics
ht_d3d11shader.h
1 
15 #pragma once
16 
17 #include <ht_platform.h>
18 #include <ht_directx.h>
19 #include <ht_d3d11types.h>
20 #include <ht_shader.h>
21 #include <unordered_map>
22 
23 namespace Hatchit {
24 
25  namespace Graphics {
26 
27  namespace DirectX {
28 
29  class HT_API D3D11Shader : public IShader
30  {
31  typedef std::unordered_map<std::string, ConstantBuffer*> ConstantBufferTable;
32  typedef std::unordered_map<std::string, uint32_t> TextureTable;
33  typedef std::unordered_map<std::string, uint32_t> SampleTable;
34  typedef std::unordered_map<std::string, ConstantBufferVariable> ConstantBufferVariableTable;
35  public:
36  D3D11Shader(ID3D11Device* device, ID3D11DeviceContext* context);
37 
38  virtual ~D3D11Shader();
39 
40  bool VInitFromFile(Core::File* file) override;
41 
42  void VOnLoaded() override;
43 
44  bool VSetData(std::string name, const void* data, size_t size) override;
45  bool VSetInt(std::string name, int data) override;
46  bool VSetFloat(std::string name, float data) override;
47  bool VSetFloat2(std::string name, Math::Vector2 data) override;
48  bool VSetFloat3(std::string name, Math::Vector3 data) override;
49  bool VSetFloat4(std::string name, Math::Vector4 data) override;
50  bool VSetMatrix3(std::string name, Math::Matrix3 data) override;
51  bool VSetMatrix4(std::string name, Math::Matrix4 data) override;
52 
53  void Activate();
54 
55  void DeActivate();
56 
57  protected:
58  uint32_t m_constantBufferCount;
59  ConstantBuffer* m_constantBufferArray;
60  ConstantBufferVariableTable m_constantBufferVarTable;
61  SampleTable m_sampleTable;
62  TextureTable m_textureTable;
63 
64  ID3D11Device* m_device;
65  ID3D11DeviceContext* m_context;
66  ID3DBlob* m_blob;
67  ID3D11ShaderReflection* m_reflection;
68 
69 
70 
71  protected:
72  ConstantBufferVariable* FindVariable(std::string name, size_t size);
73  ConstantBuffer* FindBuffer(std::string name);
74  int32_t FindTextureBindIndex(std::string name);
75  int32_t FindSampleBindIndex(std::string name);
76 
77  void UpdateAllBuffers();
78 
79 
80  virtual void VBind() = 0;
81  virtual void VUnbind() = 0;
82  virtual bool VInitShader() = 0;
83 
84  virtual bool VSetShaderResourceView(std::string name, ID3D11ShaderResourceView* rv) = 0;
85  virtual bool VSetSamplerState(std::string name, ID3D11SamplerState* ss) = 0;
86  };
87  }
88  }
89 }
Definition: ht_d3d11types.h:28
Hatchit Engine Copyright(c) 2015-2016 Third-Degree.
Hatchit Engine Copyright(c) 2015-2016 Third-Degree.
Definition: ht_color.h:19
Definition: ht_d3d11shader.h:29