mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-21 13:15:57 +00:00
Refactor custom shaders to abstract binding differences. Closes #2458
* Newly written shaders and any updated shaders can now use pre-defined macros to abstract away binding differences between APIs, so custom shaders will be more portable in particular shaders written in HLSL for D3D or GLSL on OpenGL won't break on vulkan because they refer to incorrect binds.
This commit is contained in:
@@ -42,6 +42,7 @@ DummyDriver::DummyDriver(IReplayDriver *original, const rdcarray<ShaderReflectio
|
||||
m_GPUs = original->GetAvailableGPUs();
|
||||
m_WindowSystems = original->GetSupportedWindowSystems();
|
||||
m_CustomEncodings = original->GetCustomShaderEncodings();
|
||||
m_CustomPrefixes = original->GetCustomShaderSourcePrefixes();
|
||||
}
|
||||
|
||||
DummyDriver::~DummyDriver()
|
||||
@@ -478,7 +479,12 @@ void DummyDriver::BuildCustomShader(ShaderEncoding sourceEncoding, const bytebuf
|
||||
|
||||
rdcarray<ShaderEncoding> DummyDriver::GetCustomShaderEncodings()
|
||||
{
|
||||
return {ShaderEncoding::HLSL, ShaderEncoding::GLSL};
|
||||
return m_CustomEncodings;
|
||||
}
|
||||
|
||||
rdcarray<ShaderSourcePrefix> DummyDriver::GetCustomShaderSourcePrefixes()
|
||||
{
|
||||
return m_CustomPrefixes;
|
||||
}
|
||||
|
||||
ResourceId DummyDriver::ApplyCustomShader(TextureDisplay &display)
|
||||
|
||||
@@ -167,6 +167,7 @@ public:
|
||||
const ShaderCompileFlags &compileFlags, ShaderStage type, ResourceId &id,
|
||||
rdcstr &errors);
|
||||
rdcarray<ShaderEncoding> GetCustomShaderEncodings();
|
||||
rdcarray<ShaderSourcePrefix> GetCustomShaderSourcePrefixes();
|
||||
ResourceId ApplyCustomShader(TextureDisplay &display);
|
||||
void FreeCustomShader(ResourceId id);
|
||||
|
||||
@@ -195,4 +196,5 @@ private:
|
||||
rdcarray<GPUDevice> m_GPUs;
|
||||
rdcarray<WindowingSystem> m_WindowSystems;
|
||||
rdcarray<ShaderEncoding> m_CustomEncodings;
|
||||
rdcarray<ShaderSourcePrefix> m_CustomPrefixes;
|
||||
};
|
||||
|
||||
@@ -1955,6 +1955,13 @@ rdcarray<ShaderEncoding> ReplayController::GetCustomShaderEncodings()
|
||||
return m_pDevice->GetCustomShaderEncodings();
|
||||
}
|
||||
|
||||
rdcarray<ShaderSourcePrefix> ReplayController::GetCustomShaderSourcePrefixes()
|
||||
{
|
||||
CHECK_REPLAY_THREAD();
|
||||
|
||||
return m_pDevice->GetCustomShaderSourcePrefixes();
|
||||
}
|
||||
|
||||
rdcarray<ShaderEncoding> ReplayController::GetTargetShaderEncodings()
|
||||
{
|
||||
CHECK_REPLAY_THREAD();
|
||||
|
||||
@@ -153,6 +153,7 @@ public:
|
||||
void FreeCustomShader(ResourceId id);
|
||||
|
||||
rdcarray<ShaderEncoding> GetCustomShaderEncodings();
|
||||
rdcarray<ShaderSourcePrefix> GetCustomShaderSourcePrefixes();
|
||||
rdcarray<ShaderEncoding> GetTargetShaderEncodings();
|
||||
rdcpair<ResourceId, rdcstr> BuildTargetShader(const rdcstr &entry, ShaderEncoding sourceEncoding,
|
||||
bytebuf source,
|
||||
|
||||
@@ -269,6 +269,7 @@ public:
|
||||
const rdcstr &entry, const ShaderCompileFlags &compileFlags,
|
||||
ShaderStage type, ResourceId &id, rdcstr &errors) = 0;
|
||||
virtual rdcarray<ShaderEncoding> GetCustomShaderEncodings() = 0;
|
||||
virtual rdcarray<ShaderSourcePrefix> GetCustomShaderSourcePrefixes() = 0;
|
||||
virtual ResourceId ApplyCustomShader(TextureDisplay &display) = 0;
|
||||
virtual void FreeCustomShader(ResourceId id) = 0;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user