diff --git a/src/rendering/gl/shaders/gl_shader.cpp b/src/rendering/gl/shaders/gl_shader.cpp index cf06e8574..1dc6f2c87 100644 --- a/src/rendering/gl/shaders/gl_shader.cpp +++ b/src/rendering/gl/shaders/gl_shader.cpp @@ -300,7 +300,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char * i_data += "uniform sampler2D texture6;\n"; // timer data - i_data += "uniform float timer;\n"; // To do: we must search user shaders for this declaration and remove it + i_data += "uniform float timer;\n"; // material types i_data += "#if defined(SPECULAR)\n"; diff --git a/src/rendering/hwrenderer/utility/hw_shaderpatcher.cpp b/src/rendering/hwrenderer/utility/hw_shaderpatcher.cpp index 50c07f59d..c0bf52782 100644 --- a/src/rendering/hwrenderer/utility/hw_shaderpatcher.cpp +++ b/src/rendering/hwrenderer/utility/hw_shaderpatcher.cpp @@ -69,6 +69,10 @@ static bool isShaderType(const char *name) FString RemoveLegacyUserUniforms(FString code) { // User shaders must declare their uniforms via the GLDEFS file. + + code.Substitute("uniform sampler2D tex;", " "); + code.Substitute("uniform float timer;", " "); + // The following code searches for legacy uniform declarations in the shader itself and replaces them with whitespace. long len = (long)code.Len(); diff --git a/src/rendering/vulkan/renderer/vk_postprocess.cpp b/src/rendering/vulkan/renderer/vk_postprocess.cpp index fbdd1cb10..e0f489144 100644 --- a/src/rendering/vulkan/renderer/vk_postprocess.cpp +++ b/src/rendering/vulkan/renderer/vk_postprocess.cpp @@ -394,12 +394,12 @@ VkPPShader::VkPPShader(PPShader *shader) ShaderBuilder vertbuilder; vertbuilder.setVertexShader(LoadShaderCode(shader->VertexShader, "", shader->Version)); - VertexShader = vertbuilder.create(fb->device); + VertexShader = vertbuilder.create(shader->VertexShader.GetChars(), fb->device); VertexShader->SetDebugName(shader->VertexShader.GetChars()); ShaderBuilder fragbuilder; fragbuilder.setFragmentShader(LoadShaderCode(shader->FragmentShader, prolog, shader->Version)); - FragmentShader = fragbuilder.create(fb->device); + FragmentShader = fragbuilder.create(shader->FragmentShader.GetChars(), fb->device); FragmentShader->SetDebugName(shader->FragmentShader.GetChars()); } diff --git a/src/rendering/vulkan/shaders/vk_shader.cpp b/src/rendering/vulkan/shaders/vk_shader.cpp index c0fee6dbd..e0c5a2fd2 100644 --- a/src/rendering/vulkan/shaders/vk_shader.cpp +++ b/src/rendering/vulkan/shaders/vk_shader.cpp @@ -226,7 +226,7 @@ std::unique_ptr VkShaderManager::LoadVertShader(FString shadername ShaderBuilder builder; builder.setVertexShader(code); - return builder.create(device); + return builder.create(shadername.GetChars(), device); } std::unique_ptr VkShaderManager::LoadFragShader(FString shadername, const char *frag_lump, const char *material_lump, const char *light_lump, const char *defines, bool alphatest, bool gbufferpass) @@ -293,7 +293,7 @@ std::unique_ptr VkShaderManager::LoadFragShader(FString shadername ShaderBuilder builder; builder.setFragmentShader(code); - return builder.create(device); + return builder.create(shadername.GetChars(), device); } FString VkShaderManager::GetTargetGlslVersion() diff --git a/src/rendering/vulkan/system/vk_builders.cpp b/src/rendering/vulkan/system/vk_builders.cpp index e79e5f24b..c0baed821 100644 --- a/src/rendering/vulkan/system/vk_builders.cpp +++ b/src/rendering/vulkan/system/vk_builders.cpp @@ -128,7 +128,7 @@ void ShaderBuilder::setFragmentShader(const FString &c) stage = EShLanguage::EShLangFragment; } -std::unique_ptr ShaderBuilder::create(VulkanDevice *device) +std::unique_ptr ShaderBuilder::create(const char *shadername, VulkanDevice *device) { EShLanguage stage = (EShLanguage)this->stage; const char *sources[] = { code.GetChars() }; @@ -143,7 +143,7 @@ std::unique_ptr ShaderBuilder::create(VulkanDevice *device) bool compileSuccess = shader.parse(&resources, 110, false, EShMsgVulkanRules); if (!compileSuccess) { - I_FatalError("Shader compile failed: %s\n", shader.getInfoLog()); + I_FatalError("Shader '%s' could not be compiled:\n%s\n", shadername, shader.getInfoLog()); } glslang::TProgram program; @@ -151,13 +151,13 @@ std::unique_ptr ShaderBuilder::create(VulkanDevice *device) bool linkSuccess = program.link(EShMsgDefault); if (!linkSuccess) { - I_FatalError("Shader link failed: %s\n", program.getInfoLog()); + I_FatalError("Shader '%s' could not be linked:\n%s\n", shadername, program.getInfoLog()); } glslang::TIntermediate *intermediate = program.getIntermediate(stage); if (!intermediate) { - I_FatalError("Internal shader compiler error"); + I_FatalError("Internal shader compiler error while processing '%s'\n", shadername); } glslang::SpvOptions spvOptions; @@ -177,7 +177,7 @@ std::unique_ptr ShaderBuilder::create(VulkanDevice *device) VkShaderModule shaderModule; VkResult result = vkCreateShaderModule(device->device, &createInfo, nullptr, &shaderModule); if (result != VK_SUCCESS) - I_FatalError("Could not create vulkan shader module"); + I_FatalError("Could not create vulkan shader module for '%s'", shadername); return std::make_unique(device, shaderModule); } diff --git a/src/rendering/vulkan/system/vk_builders.h b/src/rendering/vulkan/system/vk_builders.h index e415466a9..c2f221865 100644 --- a/src/rendering/vulkan/system/vk_builders.h +++ b/src/rendering/vulkan/system/vk_builders.h @@ -108,7 +108,7 @@ public: void setVertexShader(const FString &code); void setFragmentShader(const FString &code); - std::unique_ptr create(VulkanDevice *device); + std::unique_ptr create(const char *shadername, VulkanDevice *device); private: FString code;