From 8e86f79c72222db81020ac530877c31838702dc1 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 29 Apr 2025 12:09:38 +0100 Subject: [PATCH] Fix compiling pixel history shaders on GLES breaking --- .../data/glsl/pixelhistory_mscopy_depth.comp | 2 +- renderdoc/driver/gl/gl_pixelhistory.cpp | 27 ++++++++++++------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/renderdoc/data/glsl/pixelhistory_mscopy_depth.comp b/renderdoc/data/glsl/pixelhistory_mscopy_depth.comp index ee1c3fc2d..24d19abf4 100644 --- a/renderdoc/data/glsl/pixelhistory_mscopy_depth.comp +++ b/renderdoc/data/glsl/pixelhistory_mscopy_depth.comp @@ -72,7 +72,7 @@ void main() float depth = 0.0; if(hasDepth == 1) depth = texelFetch(depthMS, loc, currentSample).r; - uint stencil = 0; + uint stencil = 0u; if(hasStencil == 1) stencil = texelFetch(stencilMS, loc, currentSample).r; dest.result[dstOffset] = uvec4(floatBitsToUint(depth), stencil, 0, 0); diff --git a/renderdoc/driver/gl/gl_pixelhistory.cpp b/renderdoc/driver/gl/gl_pixelhistory.cpp index 132d3ae07..dba3b3bf4 100644 --- a/renderdoc/driver/gl/gl_pixelhistory.cpp +++ b/renderdoc/driver/gl/gl_pixelhistory.cpp @@ -584,29 +584,36 @@ bool PixelHistorySetupResources(WrappedOpenGL *driver, GLPixelHistoryResources & // If the GLSL version is greater than or equal to 330, we can use IntBitsToFloat, otherwise we // need to write the float value directly. + + ShaderType shaderType = IsGLES ? ShaderType::GLSLES : ShaderType::GLSL; + rdcstr glslSource; - if(glslVersion >= 330) + if(glslVersion >= 330 || (IsGLES && glslVersion >= 300)) { - glslSource = GenerateGLSLShader(GetEmbeddedResource(glsl_pixelhistory_primid_frag), - ShaderType::GLSL, glslVersion); + glslSource = GenerateGLSLShader(GetEmbeddedResource(glsl_pixelhistory_primid_frag), shaderType, + glslVersion); } else { - glslSource = - GenerateGLSLShader(GetEmbeddedResource(glsl_pixelhistory_primid_frag), ShaderType::GLSL, - glslVersion, "#define INT_BITS_TO_FLOAT_NOT_SUPPORTED\n"); + glslSource = GenerateGLSLShader(GetEmbeddedResource(glsl_pixelhistory_primid_frag), shaderType, + glslVersion, "#define INT_BITS_TO_FLOAT_NOT_SUPPORTED\n"); } // SPIR-V shaders are always generated as desktop GL 430, for ease rdcstr spirvSource = GenerateGLSLShader(GetEmbeddedResource(glsl_pixelhistory_primid_frag), ShaderType::GLSPIRV, 430); - rdcstr msCopySource = - GenerateGLSLShader(GetEmbeddedResource(glsl_pixelhistory_mscopy_comp), ShaderType::GLSL, 430); + + rdcstr msCopySource = GenerateGLSLShader(GetEmbeddedResource(glsl_pixelhistory_mscopy_comp), + shaderType, glslVersion); rdcstr msCopySourceDepth = GenerateGLSLShader( - GetEmbeddedResource(glsl_pixelhistory_mscopy_depth_comp), ShaderType::GLSL, 430); - resources.primitiveIdFragmentShaderSPIRV = CreateSPIRVShader(eGL_FRAGMENT_SHADER, spirvSource); + GetEmbeddedResource(glsl_pixelhistory_mscopy_depth_comp), shaderType, glslVersion); + + if(HasExt[ARB_gl_spirv]) + resources.primitiveIdFragmentShaderSPIRV = CreateSPIRVShader(eGL_FRAGMENT_SHADER, spirvSource); + resources.primitiveIdFragmentShader = CreateShader(eGL_FRAGMENT_SHADER, glslSource); resources.msCopyComputeProgram = CreateCShaderProgram(msCopySource); resources.msCopyDepthComputeProgram = CreateCShaderProgram(msCopySourceDepth); + return true; }