Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/KhronosGroup/SPIRV-Cross.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErfan Ahmadi <ahmadierfan99@gmail.com>2021-10-19 09:09:55 +0300
committerHans-Kristian Arntzen <post@arntzen-software.no>2021-10-25 11:50:10 +0300
commit43eecb23603a5eccaefdc423a8b488931609c85f (patch)
tree12cf58dd1f6032464b3f40ab04a4136e2b3c95e6 /spirv_glsl.cpp
parent94dea2507e4fb65fb155359b19780382fb7542bf (diff)
SPIRV-Cross contribution needed for `INTEL_fragment_shader_ordering`
Diffstat (limited to 'spirv_glsl.cpp')
-rw-r--r--spirv_glsl.cpp68
1 files changed, 42 insertions, 26 deletions
diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp
index 264d0273..aa891c13 100644
--- a/spirv_glsl.cpp
+++ b/spirv_glsl.cpp
@@ -686,15 +686,9 @@ string CompilerGLSL::compile()
statement("void main()");
begin_scope();
statement("// Interlocks were used in a way not compatible with GLSL, this is very slow.");
- if (options.es)
- statement("beginInvocationInterlockNV();");
- else
- statement("beginInvocationInterlockARB();");
+ statement("SPIRV_Cross_beginInvocationInterlock();");
statement("spvMainInterlockedBody();");
- if (options.es)
- statement("endInvocationInterlockNV();");
- else
- statement("endInvocationInterlockARB();");
+ statement("SPIRV_Cross_endInvocationInterlock();");
end_scope();
}
@@ -784,10 +778,12 @@ void CompilerGLSL::emit_header()
require_extension_internal("GL_ARB_post_depth_coverage");
// Needed for: layout({pixel,sample}_interlock_[un]ordered) in;
- if (execution.flags.get(ExecutionModePixelInterlockOrderedEXT) ||
- execution.flags.get(ExecutionModePixelInterlockUnorderedEXT) ||
- execution.flags.get(ExecutionModeSampleInterlockOrderedEXT) ||
- execution.flags.get(ExecutionModeSampleInterlockUnorderedEXT))
+ bool interlock_used = execution.flags.get(ExecutionModePixelInterlockOrderedEXT) ||
+ execution.flags.get(ExecutionModePixelInterlockUnorderedEXT) ||
+ execution.flags.get(ExecutionModeSampleInterlockOrderedEXT) ||
+ execution.flags.get(ExecutionModeSampleInterlockUnorderedEXT);
+
+ if (interlock_used)
{
if (options.es)
{
@@ -876,6 +872,24 @@ void CompilerGLSL::emit_header()
statement("#define SPIRV_CROSS_LOOP");
statement("#endif");
}
+ else if (ext == "GL_NV_fragment_shader_interlock")
+ {
+ statement("#extension GL_NV_fragment_shader_interlock : require");
+ statement("#define SPIRV_Cross_beginInvocationInterlock() beginInvocationInterlockNV()");
+ statement("#define SPIRV_Cross_endInvocationInterlock() endInvocationInterlockNV()");
+ }
+ else if (ext == "GL_ARB_fragment_shader_interlock")
+ {
+ statement("#ifdef GL_ARB_fragment_shader_interlock");
+ statement("#extension GL_ARB_fragment_shader_interlock : enable");
+ statement("#define SPIRV_Cross_beginInvocationInterlock() beginInvocationInterlockARB()");
+ statement("#define SPIRV_Cross_endInvocationInterlock() endInvocationInterlockARB()");
+ statement("#elif defined(GL_INTEL_fragment_shader_ordering)");
+ statement("#extension GL_INTEL_fragment_shader_ordering : enable");
+ statement("#define SPIRV_Cross_beginInvocationInterlock() beginFragmentShaderOrderingINTEL()");
+ statement("#define SPIRV_Cross_endInvocationInterlock()");
+ statement("#endif");
+ }
else
statement("#extension ", ext, " : require");
}
@@ -1056,14 +1070,24 @@ void CompilerGLSL::emit_header()
if (execution.flags.get(ExecutionModePostDepthCoverage))
inputs.push_back("post_depth_coverage");
+ if (interlock_used)
+ statement("#if defined(GL_ARB_fragment_shader_interlock)");
+
if (execution.flags.get(ExecutionModePixelInterlockOrderedEXT))
- inputs.push_back("pixel_interlock_ordered");
+ statement("layout(pixel_interlock_ordered) in;");
else if (execution.flags.get(ExecutionModePixelInterlockUnorderedEXT))
- inputs.push_back("pixel_interlock_unordered");
+ statement("layout(pixel_interlock_unordered) in;");
else if (execution.flags.get(ExecutionModeSampleInterlockOrderedEXT))
- inputs.push_back("sample_interlock_ordered");
+ statement("layout(sample_interlock_ordered) in;");
else if (execution.flags.get(ExecutionModeSampleInterlockUnorderedEXT))
- inputs.push_back("sample_interlock_unordered");
+ statement("layout(sample_interlock_unordered) in;");
+
+ if (interlock_used)
+ {
+ statement("#elif !defined(GL_INTEL_fragment_shader_ordering)");
+ statement("#error Fragment Shader Interlock/Ordering extension missing!");
+ statement("#endif");
+ }
if (!options.es && execution.flags.get(ExecutionModeDepthGreater))
statement("layout(depth_greater) out float gl_FragDepth;");
@@ -12664,11 +12688,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
// If the interlock is complex, we emit this elsewhere.
if (!interlocked_is_complex)
{
- if (options.es)
- statement("beginInvocationInterlockNV();");
- else
- statement("beginInvocationInterlockARB();");
-
+ statement("SPIRV_Cross_beginInvocationInterlock();");
flush_all_active_variables();
// Make sure forwarding doesn't propagate outside interlock region.
}
@@ -12678,11 +12698,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
// If the interlock is complex, we emit this elsewhere.
if (!interlocked_is_complex)
{
- if (options.es)
- statement("endInvocationInterlockNV();");
- else
- statement("endInvocationInterlockARB();");
-
+ statement("SPIRV_Cross_endInvocationInterlock();");
flush_all_active_variables();
// Make sure forwarding doesn't propagate outside interlock region.
}