Add support for generating SPIR-V shaders for OpenGL

* Only a couple of these are needed - ones we might link with user shaders in a
  program
This commit is contained in:
baldurk
2019-06-07 18:44:13 +01:00
parent 9e09de40ce
commit 28cde37849
5 changed files with 35 additions and 4 deletions
+9 -2
View File
@@ -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)
+12
View File
@@ -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
+10 -1
View File
@@ -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;
+2
View File
@@ -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;
+2 -1
View File
@@ -26,7 +26,8 @@ enum ShaderType
{
eShaderGLSL,
eShaderGLSLES,
eShaderVulkan
eShaderVulkan,
eShaderGLSPIRV,
};
#include <string>