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:
baldurk
2022-01-31 19:14:08 +00:00
parent 0d7dcabdac
commit 3ac4bd0ebd
37 changed files with 1382 additions and 613 deletions
+7 -1
View File
@@ -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)
+2
View File
@@ -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;
};
+7
View File
@@ -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();
+1
View File
@@ -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,
+1
View File
@@ -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;