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 committed 2022-01-31 19:14:08 +00:00
1 parent 0d7dcabdac
commit 3ac4bd0ebd
37 files changed
+1382 -613

No files matched your search

+12 -1
View File
@@ -4246,7 +4246,8 @@ void TextureViewer::reloadCustomShaders(const QString &filter)
bytebuf shaderBytes(source.toUtf8());
rdcarray<ShaderEncoding> supported = m_Ctx.TargetShaderEncodings();
rdcarray<ShaderEncoding> supported = m_Ctx.CustomShaderEncodings();
rdcarray<ShaderSourcePrefix> prefixes = m_Ctx.CustomShaderSourcePrefixes();
rdcstr errors;
@@ -4258,6 +4259,16 @@ void TextureViewer::reloadCustomShaders(const QString &filter)
// pick the first tool that can convert to an accepted format
if(tool.input == encoding && supported.contains(tool.output))
{
// apply any prefix needed
for(const ShaderSourcePrefix &prefix : prefixes)
{
if(prefix.encoding == encoding)
{
source = QString(prefix.prefix) + source;
break;
}
}
ShaderToolOutput out =
tool.CompileShader(this, source, "main", ShaderStage::Pixel, "");