From 1ae2afc05a16cc1833b13b437e48b36530d1e194 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 22 Apr 2022 12:52:05 +0100 Subject: [PATCH] Apply shader prefix even if encoding is directly accepted. Closes #2561 * The prefix, if available, must always be applied for custom shaders to compile correctly. --- qrenderdoc/Windows/TextureViewer.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/qrenderdoc/Windows/TextureViewer.cpp b/qrenderdoc/Windows/TextureViewer.cpp index a3b4c5cd9..feadb776d 100644 --- a/qrenderdoc/Windows/TextureViewer.cpp +++ b/qrenderdoc/Windows/TextureViewer.cpp @@ -4244,16 +4244,30 @@ void TextureViewer::reloadCustomShaders(const QString &filter) QTextStream stream(&fileHandle); QString source = stream.readAll(); - bytebuf shaderBytes(source.toUtf8()); + bytebuf shaderBytes; rdcarray supported = m_Ctx.CustomShaderEncodings(); rdcarray prefixes = m_Ctx.CustomShaderSourcePrefixes(); rdcstr errors; - // we don't accept this encoding directly, need to compile - if(!supported.contains(encoding)) + if(supported.contains(encoding)) { + // apply any prefix needed + for(const ShaderSourcePrefix &prefix : prefixes) + { + if(prefix.encoding == encoding) + { + source = QString(prefix.prefix) + source; + break; + } + } + + shaderBytes = bytebuf(source.toUtf8()); + } + else + { + // we don't accept this encoding directly, need to compile for(const ShaderProcessingTool &tool : m_Ctx.Config().ShaderProcessors) { // pick the first tool that can convert to an accepted format