Skip to content

Commit

Permalink
Merge pull request #128 from Jonahex/MoreISStuff
Browse files Browse the repository at this point in the history
feat: BSComputeShader and some improvements for BSImagespaceSahder.
  • Loading branch information
powerof3 authored Aug 20, 2024
2 parents 14e3ddf + 0b02646 commit 27f6b0f
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 24 deletions.
1 change: 1 addition & 0 deletions cmake/sourcelist.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ set(SOURCES
include/RE/B/BSBitField.h
include/RE/B/BSBloodSplatterShaderProperty.h
include/RE/B/BSBound.h
include/RE/B/BSComputeShader.h
include/RE/B/BSContainer.h
include/RE/B/BSCoreTypes.h
include/RE/B/BSCullingProcess.h
Expand Down
28 changes: 28 additions & 0 deletions include/RE/B/BSComputeShader.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#pragma once

#include "RE/B/BSReloadShaderI.h"
#include "RE/B/BSShader.h"
#include "RE/N/NiRefObject.h"

namespace RE
{
class BSComputeShader : public NiRefObject, public BSReloadShaderI
{
public:
inline static constexpr auto RTTI = RTTI_BSComputeShader;
inline static constexpr auto VTABLE = VTABLE_BSComputeShader;

~BSComputeShader() override; // 00

// override (BSReloadShaderI)
void ReloadShaders(void* a_stream) override; // 00

// add
virtual void Dispatch(uint32_t a_techniqueId, uint32_t a_threadGroupCountX, uint32_t a_threadGroupCountY, uint32_t a_threadGroupCountZ); // 02

// members
const char* name; // 18
BSTHashMap<uint32_t, BSGraphics::ComputeShader*> shadersMap; // 20
};
static_assert(sizeof(BSComputeShader) == 0x50);
}
44 changes: 36 additions & 8 deletions include/RE/B/BSImagespaceShader.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ namespace RE
inline static constexpr auto RTTI = RTTI_BSImagespaceShader;
inline static constexpr auto VTABLE = VTABLE_BSImagespaceShader;

struct ShaderMacro
{
// members
const char* name; // 00
const char* definition; // 08
};
static_assert(sizeof(ShaderMacro) == 0x10);

~BSImagespaceShader() override; // 00

// override (BSShader)
Expand All @@ -25,23 +33,43 @@ namespace RE
bool RestoreRenderStates(ImageSpaceEffectParam* a_param) override; // 09

// add
virtual void Unk_0A(void); // 0A - { return; }
virtual void Unk_0B(void); // 0B - { return; }
virtual void Unk_0C(void); // 0C
virtual void Unk_0D(void); // 0D
virtual void Unk_0E(void); // 0E
virtual void PreRender(); // 0A - { return; }
virtual void PostRender(); // 0B - { return; }
virtual void DispatchComputeShader(uint32_t a_threadGroupCountX, uint32_t a_threadGroupCountY, uint32_t a_threadGroupCountZ); // 0C
virtual void GetShaderMacros(ShaderMacro* a_macros); // 0D
virtual void LoadShaders(); // 0E

static BSImagespaceShader* Create()
{
auto isShader = malloc<BSImagespaceShader>();
std::memset(reinterpret_cast<void*>(isShader), 0, sizeof(BSImagespaceShader));
if (isShader) {
isShader->Ctor();
}
return isShader;
}

// members
BSFixedString name; // 120
BSFixedString originalShaderName; // 128
const char* name; // 120
const char* originalShaderName; // 128
std::uint64_t unk130; // 130
BSTArray<BSFixedString> vsConstantNames; // 138
BSTArray<BSFixedString> psConstantNames; // 150
BSTArray<BSFixedString> samplerNames; // 158
BSTArray<BSFixedString> unk180; // 180
BSTArray<BSFixedString> uavNames; // 180
BSComputeShader* computeShader; // 198
bool unk1A0; // 1A0
bool isComputeShader; // 1A1

private:
BSImagespaceShader* Ctor()
{
using func_t = decltype(&BSImagespaceShader::Ctor);
static REL::Relocation<func_t> func{ RELOCATION_ID(100943, 107725) };
BSImagespaceShader* isShader = func(this);
stl::emplace_vtable<BSImagespaceShader>(isShader);
return isShader;
}
};
static_assert(sizeof(BSImagespaceShader) == 0x1A8);
}
2 changes: 1 addition & 1 deletion include/RE/B/BSImagespaceShaderBlur3.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace RE
~BSImagespaceShaderBlur3() override; // 00

// override (BSImagespaceShader)
void Unk_0D(void) override; // 0D
void GetShaderMacros(ShaderMacro* a_macros) override; // 0D
};
static_assert(sizeof(BSImagespaceShaderBlur3) == 0x1A8);
}
2 changes: 1 addition & 1 deletion include/RE/B/BSReloadShaderI.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace RE
inline static constexpr auto RTTI = RTTI_BSReloadShaderI;
inline static constexpr auto VTABLE = VTABLE_BSReloadShaderI;

virtual void Unk_00(void) = 0; // 00
virtual void ReloadShaders(void* a_stream) = 0; // 00
};
static_assert(sizeof(BSReloadShaderI) == 0x8);
}
53 changes: 39 additions & 14 deletions include/RE/B/BSShader.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ namespace RE
struct ID3D11Buffer;
struct ID3D11PixelShader;
struct ID3D11VertexShader;
struct ID3D11ComputeShader;

namespace BSGraphics
{
Expand All @@ -29,27 +30,51 @@ namespace RE
{
public:
// members
std::uint32_t id; // 00
ID3D11PixelShader* shader; // 08
ConstantGroup constantBuffers[3]; // 10
std::int8_t constantTable[64]; // 58
std::uint32_t id; // 00
ID3D11PixelShader* shader; // 08
ConstantGroup constantBuffers[3]; // 10
std::array<std::int8_t, 64> constantTable; // 58
};
static_assert(sizeof(PixelShader) == 0x80);

class VertexShader
{
public:
// members
std::uint32_t id; // 00
ID3D11VertexShader* shader; // 08
std::uint32_t byteCodeSize; // 10
ConstantGroup constantBuffers[3]; // 18
std::uint64_t shaderDesc; // 48
std::int8_t constantTable[20]; // 50
std::uint32_t pad64; // 64
std::uint8_t rawBytecode[0]; // 68
std::uint32_t id; // 00
ID3D11VertexShader* shader; // 08
std::uint32_t byteCodeSize; // 10
ConstantGroup constantBuffers[3]; // 18
std::uint64_t shaderDesc; // 48
std::array<std::int8_t, 20> constantTable; // 50
std::uint32_t pad64; // 64
std::uint8_t rawBytecode[0]; // 68
};
static_assert(sizeof(VertexShader) == 0x68);

class ComputeShader
{
public:
// members
uint64_t unk00; // 00
uint64_t unk08; // 08
uint64_t unk10; // 10
uint32_t unk18; // 18
uint64_t unk20; // 20
uint64_t unk28; // 28
uint64_t unk30; // 30
uint32_t unk38; // 38
uint64_t unk40; // 40
uint64_t unk48; // 38
uint64_t unk50; // 50
uint32_t unk58; // 58
ID3D11ComputeShader* shader; // 60
uint32_t id; // 68
uint32_t byteCodeSize; // 6C
std::array<std::int8_t, 32> constantTable; // 70
uint8_t rawBytecode[0]; // 90
};
static_assert(sizeof(ComputeShader) == 0x90);
}

namespace BSShaderTechniqueIDMap
Expand Down Expand Up @@ -100,11 +125,11 @@ namespace RE
virtual void GetTechniqueName(std::uint32_t a_techniqueID, char* a_buffer, std::uint32_t a_bufferSize); // 08
virtual void ReloadShaders(bool a_clear); // 09

RE::BSRenderPass* MakeRenderPass(BSShaderProperty* property, BSGeometry* geometry, uint32_t technique, uint8_t numLights, BSLight** lights)
RE::BSRenderPass* MakeRenderPass(BSShaderProperty* a_property, BSGeometry* a_geometry, uint32_t a_technique, uint8_t a_numLights, BSLight** a_lights)
{
using func_t = decltype(&BSShader::MakeRenderPass);
static REL::Relocation<func_t> func{ RELOCATION_ID(100717, 107497) };
return func(this, property, geometry, technique, numLights, lights);
return func(this, a_property, a_geometry, a_technique, a_numLights, a_lights);
}

// members
Expand Down
1 change: 1 addition & 0 deletions include/RE/Skyrim.h
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
#include "RE/B/BSBitField.h"
#include "RE/B/BSBloodSplatterShaderProperty.h"
#include "RE/B/BSBound.h"
#include "RE/B/BSComputeShader.h"
#include "RE/B/BSContainer.h"
#include "RE/B/BSCullingProcess.h"
#include "RE/B/BSDirectInputManager.h"
Expand Down

0 comments on commit 27f6b0f

Please sign in to comment.