diff --git a/renderdoc/data/glsl/fixedcol.frag b/renderdoc/data/glsl/fixedcol.frag index c9d14d3f4..a0f560f66 100644 --- a/renderdoc/data/glsl/fixedcol.frag +++ b/renderdoc/data/glsl/fixedcol.frag @@ -36,8 +36,15 @@ IO_LOCATION(0) out vec4 color_out; #endif -#ifndef VULKAN // OpenGL can't use SPIR-V patching -uniform vec4 RENDERDOC_Fixed_Color; +#ifndef VULKAN // Vulkan uses SPIR-V patching + +// if we're compiling for GL SPIR-V, give the uniform an explicit location +#ifdef GL_SPIRV +layout(location = 99) +#endif + + uniform vec4 RENDERDOC_Fixed_Color; + #endif void main(void) diff --git a/renderdoc/data/glsl/glsl_globals.h b/renderdoc/data/glsl/glsl_globals.h index 0417e9b7e..f24656000 100644 --- a/renderdoc/data/glsl/glsl_globals.h +++ b/renderdoc/data/glsl/glsl_globals.h @@ -38,6 +38,16 @@ #else // ifdef VULKAN +// GL SPIR-V compilation uses a mixture +#ifdef GL_SPIRV + +#define BINDING(b) layout(binding = b, std140) +#define IO_LOCATION(l) layout(location = l) +#define VERTEX_ID gl_VertexID +#define INSTANCE_ID gl_InstanceID + +#else + // drop I/O location specifiers and bindings on GL, we don't use separate programs so I/O variables // can be matched by name, and we don't want to require GL_ARB_shading_language_420pack so we can't // specify bindings in shaders. @@ -46,6 +56,8 @@ #define VERTEX_ID gl_VertexID #define INSTANCE_ID gl_InstanceID +#endif + #endif // ifdef VULKAN #define INST_NAME(name) name diff --git a/renderdoc/data/glsl/quadwrite.frag b/renderdoc/data/glsl/quadwrite.frag index f6921bc3f..85422085c 100644 --- a/renderdoc/data/glsl/quadwrite.frag +++ b/renderdoc/data/glsl/quadwrite.frag @@ -42,7 +42,16 @@ // descriptor set will be patched from 0 to whichever descriptor set we're using in code layout(set = 0, binding = 0, r32ui) uniform coherent uimage2DArray overdrawImage; #else // OPENGL and OPENGL_ES -layout(r32ui) uniform coherent uimage2DArray overdrawImage; + +// if we're compiling for GL SPIR-V, give the image an explicit binding +#ifdef GL_SPIRV +layout(binding = 0, r32ui) +#else +layout(r32ui) +#endif + + uniform coherent uimage2DArray overdrawImage; + #endif layout(early_fragment_tests) in; diff --git a/renderdoc/data/glsl_shaders.cpp b/renderdoc/data/glsl_shaders.cpp index baf68a3f3..af955dab9 100644 --- a/renderdoc/data/glsl_shaders.cpp +++ b/renderdoc/data/glsl_shaders.cpp @@ -125,6 +125,8 @@ std::string GenerateGLSLShader(const std::string &shader, ShaderType type, int v if(type == eShaderVulkan) flags = EShMessages(flags | EShMsgSpvRules | EShMsgVulkanRules); + else if(type == eShaderGLSPIRV) + flags = EShMessages(flags | EShMsgSpvRules); std::string ret; diff --git a/renderdoc/data/glsl_shaders.h b/renderdoc/data/glsl_shaders.h index bbca2fad3..3cdf908c0 100644 --- a/renderdoc/data/glsl_shaders.h +++ b/renderdoc/data/glsl_shaders.h @@ -26,7 +26,8 @@ enum ShaderType { eShaderGLSL, eShaderGLSLES, - eShaderVulkan + eShaderVulkan, + eShaderGLSPIRV, }; #include