summaryrefslogtreecommitdiffstats
path: root/Graphics/GLSLTools
diff options
context:
space:
mode:
Diffstat (limited to 'Graphics/GLSLTools')
-rw-r--r--Graphics/GLSLTools/include/GLSLSourceBuilder.h8
-rw-r--r--Graphics/GLSLTools/src/GLSL2SPIRV.cpp4
-rw-r--r--Graphics/GLSLTools/src/GLSLSourceBuilder.cpp9
3 files changed, 18 insertions, 3 deletions
diff --git a/Graphics/GLSLTools/include/GLSLSourceBuilder.h b/Graphics/GLSLTools/include/GLSLSourceBuilder.h
index c0ab5a7d..572ea180 100644
--- a/Graphics/GLSLTools/include/GLSLSourceBuilder.h
+++ b/Graphics/GLSLTools/include/GLSLSourceBuilder.h
@@ -29,6 +29,12 @@
namespace Diligent
{
-String BuildGLSLSourceString(const ShaderCreationAttribs &CreationAttribs);
+enum TargetGLSLCompiler
+{
+ glslang,
+ driver
+};
+
+String BuildGLSLSourceString(const ShaderCreationAttribs &CreationAttribs, TargetGLSLCompiler TargetCompiler);
} \ No newline at end of file
diff --git a/Graphics/GLSLTools/src/GLSL2SPIRV.cpp b/Graphics/GLSLTools/src/GLSL2SPIRV.cpp
index e36a3196..69cadd2c 100644
--- a/Graphics/GLSLTools/src/GLSL2SPIRV.cpp
+++ b/Graphics/GLSLTools/src/GLSL2SPIRV.cpp
@@ -201,7 +201,9 @@ std::vector<unsigned int> GLSLtoSPIRV(const SHADER_TYPE ShaderType, const char *
const char *ShaderStrings[] = { ShaderSource };
Shader.setStrings(ShaderStrings, 1);
- if (!Shader.parse(&Resources, 100, false, messages))
+ Shader.setAutoMapBindings(true);
+ Shader.setAutoMapLocations(true);
+ if (!Shader.parse(&Resources, 100, false, messages))
{
LOG_ERROR_MESSAGE("Failed to parse shader source: \n", Shader.getInfoLog(), '\n', Shader.getInfoDebugLog());
return std::move(spirv);
diff --git a/Graphics/GLSLTools/src/GLSLSourceBuilder.cpp b/Graphics/GLSLTools/src/GLSLSourceBuilder.cpp
index 064f18aa..f9140a53 100644
--- a/Graphics/GLSLTools/src/GLSLSourceBuilder.cpp
+++ b/Graphics/GLSLTools/src/GLSLSourceBuilder.cpp
@@ -32,7 +32,7 @@
namespace Diligent
{
-String BuildGLSLSourceString(const ShaderCreationAttribs &CreationAttribs)
+String BuildGLSLSourceString(const ShaderCreationAttribs &CreationAttribs, TargetGLSLCompiler TargetCompiler)
{
String GLSLSource;
@@ -169,6 +169,13 @@ String BuildGLSLSourceString(const ShaderCreationAttribs &CreationAttribs)
"layout(std140) uniform;\n"
);
+ if(ShaderType == SHADER_TYPE_VERTEX && TargetCompiler == TargetGLSLCompiler::glslang)
+ {
+ // https://github.com/KhronosGroup/GLSL/blob/master/extensions/khr/GL_KHR_vulkan_glsl.txt
+ GLSLSource.append("#define gl_VertexID gl_VertexIndex\n"
+ "#define gl_InstanceID gl_InstanceIndex\n");
+ }
+
const Char* ShaderTypeDefine = nullptr;
switch (ShaderType)
{