CommonLibSSE (powerof3)
BSShader.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "RE/B/BSReloadShaderI.h"
4 #include "RE/B/BSTHashMap.h"
6 #include "RE/N/NiRefObject.h"
7 
8 namespace RE
9 {
10  class BSRenderPass;
11  class BSShaderMaterial;
12 
13  struct ID3D11Buffer;
14  struct ID3D11PixelShader;
15  struct ID3D11VertexShader;
16  struct ID3D11ComputeShader;
17 
18  namespace BSGraphics
19  {
21  {
22  public:
23  // members
24  ID3D11Buffer* buffer; // 00
25  void* data; // 08
26  };
27  static_assert(sizeof(ConstantGroup) == 0x10);
28 
30  {
31  public:
32  // members
33  std::uint32_t id; // 00
34  ID3D11PixelShader* shader; // 08
36  std::array<std::int8_t, 64> constantTable; // 58
37  };
38  static_assert(sizeof(PixelShader) == 0x80);
39 
41  {
42  public:
43  // members
44  std::uint32_t id; // 00
45  ID3D11VertexShader* shader; // 08
46  std::uint32_t byteCodeSize; // 10
48  std::uint64_t shaderDesc; // 48
49  std::array<std::int8_t, 20> constantTable; // 50
50  std::uint32_t pad64; // 64
51  std::uint8_t rawBytecode[0]; // 68
52  };
53  static_assert(sizeof(VertexShader) == 0x68);
54 
56  {
57  public:
58  // members
59  uint64_t unk00; // 00
60  uint64_t unk08; // 08
61  uint64_t unk10; // 10
62  uint32_t unk18; // 18
63  uint64_t unk20; // 20
64  uint64_t unk28; // 28
65  uint64_t unk30; // 30
66  uint32_t unk38; // 38
67  uint64_t unk40; // 40
68  uint64_t unk48; // 38
69  uint64_t unk50; // 50
70  uint32_t unk58; // 58
71  ID3D11ComputeShader* shader; // 60
72  uint32_t id; // 68
73  uint32_t byteCodeSize; // 6C
74  std::array<std::int8_t, 32> constantTable; // 70
75  uint8_t rawBytecode[0]; // 90
76  };
77  static_assert(sizeof(ComputeShader) == 0x90);
78  }
79 
80  namespace BSShaderTechniqueIDMap
81  {
82  template <class T>
83  struct HashPolicy
84  {
85  [[nodiscard]] std::uint32_t operator()(const T a_shader) const noexcept
86  {
87  assert(a_shader != nullptr);
88  return a_shader->id;
89  }
90  };
91 
92  template <class T>
94  {
95  [[nodiscard]] bool operator()(const T a_lhs, const T a_rhs) const noexcept
96  {
97  assert(a_lhs != nullptr);
98  assert(a_rhs != nullptr);
99  return a_lhs->id == a_rhs->id;
100  }
101  };
102 
103  template <class T>
105  }
106 
107  class BSShader :
108  public NiRefObject, // 00
109  public NiBoneMatrixSetterI, // 10
110  public BSReloadShaderI // 18
111  {
112  public:
113  inline static constexpr auto RTTI = RTTI_BSShader;
114  inline static constexpr auto VTABLE = VTABLE_BSShader;
115 
116  ~BSShader() override; // 00
117 
118  // add
119  virtual bool SetupTechnique(std::uint32_t a_technique) = 0; // 02
120  virtual void RestoreTechnique(std::uint32_t a_technique) = 0; // 03
121  virtual void SetupMaterial(const BSShaderMaterial* a_material); // 04
122  virtual void RestoreMaterial(const BSShaderMaterial* a_material); // 05
123  virtual void SetupGeometry(BSRenderPass* a_currentPass, std::uint32_t a_flags) = 0; // 06
124  virtual void RestoreGeometry(BSRenderPass* a_currentPass, std::uint32_t a_renderFlags) = 0; // 07
125  virtual void GetTechniqueName(std::uint32_t a_techniqueID, char* a_buffer, std::uint32_t a_bufferSize); // 08
126  virtual void ReloadShaders(bool a_clear); // 09
127 
128  RE::BSRenderPass* MakeRenderPass(BSShaderProperty* a_property, BSGeometry* a_geometry, uint32_t a_technique, uint8_t a_numLights, BSLight** a_lights)
129  {
130  using func_t = decltype(&BSShader::MakeRenderPass);
131  static REL::Relocation<func_t> func{ RELOCATION_ID(100717, 107497) };
132  return func(this, a_property, a_geometry, a_technique, a_numLights, a_lights);
133  }
134 
135  // members
136  std::int32_t shaderType; // 20
139  const char* fxpFilename; // 88
140  };
141  static_assert(sizeof(BSShader) == 0x90);
142 }
#define RELOCATION_ID(SE, AE)
Definition: PCH.h:505
Definition: Relocation.h:210
Definition: BSGeometry.h:15
Definition: BSShader.h:56
uint32_t byteCodeSize
Definition: BSShader.h:73
uint64_t unk30
Definition: BSShader.h:65
uint8_t rawBytecode[0]
Definition: BSShader.h:75
ID3D11ComputeShader * shader
Definition: BSShader.h:71
uint32_t id
Definition: BSShader.h:72
uint64_t unk00
Definition: BSShader.h:59
uint64_t unk50
Definition: BSShader.h:69
uint32_t unk18
Definition: BSShader.h:62
uint32_t unk38
Definition: BSShader.h:66
uint64_t unk40
Definition: BSShader.h:67
uint64_t unk20
Definition: BSShader.h:63
uint32_t unk58
Definition: BSShader.h:70
uint64_t unk28
Definition: BSShader.h:64
uint64_t unk08
Definition: BSShader.h:60
uint64_t unk48
Definition: BSShader.h:68
uint64_t unk10
Definition: BSShader.h:61
std::array< std::int8_t, 32 > constantTable
Definition: BSShader.h:74
Definition: BSShader.h:21
ID3D11Buffer * buffer
Definition: BSShader.h:24
void * data
Definition: BSShader.h:25
Definition: BSShader.h:30
ID3D11PixelShader * shader
Definition: BSShader.h:34
ConstantGroup constantBuffers[3]
Definition: BSShader.h:35
std::uint32_t id
Definition: BSShader.h:33
std::array< std::int8_t, 64 > constantTable
Definition: BSShader.h:36
Definition: BSShader.h:41
std::uint64_t shaderDesc
Definition: BSShader.h:48
std::uint32_t id
Definition: BSShader.h:44
std::uint8_t rawBytecode[0]
Definition: BSShader.h:51
std::uint32_t pad64
Definition: BSShader.h:50
std::uint32_t byteCodeSize
Definition: BSShader.h:46
ConstantGroup constantBuffers[3]
Definition: BSShader.h:47
ID3D11VertexShader * shader
Definition: BSShader.h:45
std::array< std::int8_t, 20 > constantTable
Definition: BSShader.h:49
Definition: BSLight.h:21
Definition: BSReloadShaderI.h:8
Definition: BSRenderPass.h:11
Definition: BSShaderMaterial.h:9
Definition: BSShaderProperty.h:17
Definition: BSShader.h:111
virtual void SetupGeometry(BSRenderPass *a_currentPass, std::uint32_t a_flags)=0
static constexpr auto RTTI
Definition: BSShader.h:113
BSShaderTechniqueIDMap::MapType< BSGraphics::PixelShader * > pixelShaders
Definition: BSShader.h:138
std::int32_t shaderType
Definition: BSShader.h:136
virtual bool SetupTechnique(std::uint32_t a_technique)=0
BSShaderTechniqueIDMap::MapType< BSGraphics::VertexShader * > vertexShaders
Definition: BSShader.h:137
virtual void GetTechniqueName(std::uint32_t a_techniqueID, char *a_buffer, std::uint32_t a_bufferSize)
virtual void ReloadShaders(bool a_clear)
virtual void RestoreGeometry(BSRenderPass *a_currentPass, std::uint32_t a_renderFlags)=0
RE::BSRenderPass * MakeRenderPass(BSShaderProperty *a_property, BSGeometry *a_geometry, uint32_t a_technique, uint8_t a_numLights, BSLight **a_lights)
Definition: BSShader.h:128
~BSShader() override
const char * fxpFilename
Definition: BSShader.h:139
virtual void RestoreMaterial(const BSShaderMaterial *a_material)
static constexpr auto VTABLE
Definition: BSShader.h:114
virtual void SetupMaterial(const BSShaderMaterial *a_material)
virtual void RestoreTechnique(std::uint32_t a_technique)=0
Definition: BSTHashMap.h:21
Definition: NiBoneMatrixSetterI.h:6
Definition: NiRefObject.h:8
Definition: AbsorbEffect.h:6
constexpr std::array< REL::ID, 3 > VTABLE_BSShader
Definition: Offsets_VTABLE.h:9833
constexpr REL::ID RTTI_BSShader(static_cast< std::uint64_t >(691881))
bool operator()(const T a_lhs, const T a_rhs) const noexcept
Definition: BSShader.h:95
std::uint32_t operator()(const T a_shader) const noexcept
Definition: BSShader.h:85