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:
authorHans-Kristian Arntzen <post@arntzen-software.no>2022-03-03 12:36:07 +0300
committerHans-Kristian Arntzen <post@arntzen-software.no>2022-03-03 12:36:07 +0300
commitdc62cc792b5e1a5522eaf8c5567d796fe6886a26 (patch)
tree2215c4124a1ff708248a70a20ba0119b0010c498
parent2a7f436135bbb74c0b721e1471b07732a523ef72 (diff)
Handle OpTerminateInvocation.
-rw-r--r--reference/shaders-no-opt/asm/frag/terminate-impure-function-call.spv16.asm.frag21
-rw-r--r--shaders-no-opt/asm/frag/terminate-impure-function-call.spv16.asm.frag59
-rw-r--r--spirv_parser.cpp1
3 files changed, 81 insertions, 0 deletions
diff --git a/reference/shaders-no-opt/asm/frag/terminate-impure-function-call.spv16.asm.frag b/reference/shaders-no-opt/asm/frag/terminate-impure-function-call.spv16.asm.frag
new file mode 100644
index 00000000..0fe71f64
--- /dev/null
+++ b/reference/shaders-no-opt/asm/frag/terminate-impure-function-call.spv16.asm.frag
@@ -0,0 +1,21 @@
+#version 450
+
+layout(location = 0) flat in int vA;
+layout(location = 0) out vec4 FragColor;
+
+vec4 foobar(int a)
+{
+ if (a < 0)
+ {
+ discard;
+ }
+ return vec4(10.0);
+}
+
+void main()
+{
+ int param = vA;
+ vec4 _25 = foobar(param);
+ FragColor = vec4(10.0);
+}
+
diff --git a/shaders-no-opt/asm/frag/terminate-impure-function-call.spv16.asm.frag b/shaders-no-opt/asm/frag/terminate-impure-function-call.spv16.asm.frag
new file mode 100644
index 00000000..d596e4ef
--- /dev/null
+++ b/shaders-no-opt/asm/frag/terminate-impure-function-call.spv16.asm.frag
@@ -0,0 +1,59 @@
+; SPIR-V
+; Version: 1.0
+; Generator: Khronos Glslang Reference Front End; 7
+; Bound: 34
+; Schema: 0
+ OpCapability Shader
+ %1 = OpExtInstImport "GLSL.std.450"
+ OpMemoryModel Logical GLSL450
+ OpEntryPoint Fragment %main "main" %vA %FragColor
+ OpExecutionMode %main OriginUpperLeft
+ OpSource GLSL 450
+ OpName %main "main"
+ OpName %foobar_i1_ "foobar(i1;"
+ OpName %a "a"
+ OpName %a_0 "a"
+ OpName %vA "vA"
+ OpName %param "param"
+ OpName %FragColor "FragColor"
+ OpDecorate %vA Flat
+ OpDecorate %vA Location 0
+ OpDecorate %FragColor Location 0
+ %void = OpTypeVoid
+ %3 = OpTypeFunction %void
+ %int = OpTypeInt 32 1
+%_ptr_Function_int = OpTypePointer Function %int
+ %float = OpTypeFloat 32
+ %v4float = OpTypeVector %float 4
+ %10 = OpTypeFunction %v4float %_ptr_Function_int
+ %int_0 = OpConstant %int 0
+ %bool = OpTypeBool
+ %float_10 = OpConstant %float 10
+ %22 = OpConstantComposite %v4float %float_10 %float_10 %float_10 %float_10
+%_ptr_Function_v4float = OpTypePointer Function %v4float
+%_ptr_Input_int = OpTypePointer Input %int
+ %vA = OpVariable %_ptr_Input_int Input
+%_ptr_Output_v4float = OpTypePointer Output %v4float
+ %FragColor = OpVariable %_ptr_Output_v4float Output
+ %main = OpFunction %void None %3
+ %5 = OpLabel
+ %a_0 = OpVariable %_ptr_Function_v4float Function
+ %param = OpVariable %_ptr_Function_int Function
+ %30 = OpLoad %int %vA
+ OpStore %param %30
+ %31 = OpFunctionCall %v4float %foobar_i1_ %param
+ OpStore %FragColor %22
+ OpReturn
+ OpFunctionEnd
+ %foobar_i1_ = OpFunction %v4float None %10
+ %a = OpFunctionParameter %_ptr_Function_int
+ %13 = OpLabel
+ %14 = OpLoad %int %a
+ %17 = OpSLessThan %bool %14 %int_0
+ OpSelectionMerge %19 None
+ OpBranchConditional %17 %18 %19
+ %18 = OpLabel
+ OpTerminateInvocation
+ %19 = OpLabel
+ OpReturnValue %22
+ OpFunctionEnd
diff --git a/spirv_parser.cpp b/spirv_parser.cpp
index 29782c26..1b293a86 100644
--- a/spirv_parser.cpp
+++ b/spirv_parser.cpp
@@ -1067,6 +1067,7 @@ void Parser::parse(const Instruction &instruction)
}
case OpKill:
+ case OpTerminateInvocation:
{
if (!current_block)
SPIRV_CROSS_THROW("Trying to end a non-existing block.");