From baa55a15916cc0a58d981f053c3604766173451e Mon Sep 17 00:00:00 2001 From: Dejan Mircevski Date: Mon, 18 Jan 2016 17:12:59 -0500 Subject: [PATCH] Add spv.branch-return.vert and fix inReadableOrder(). --- SPIRV/InReadableOrder.cpp | 7 ++-- Test/baseResults/spv.branch-return.vert.out | 63 +++++++++++++++++++++++++++++ Test/spv.branch-return.vert | 10 +++++ Test/test-spirv-list | 1 + 4 files changed, 78 insertions(+), 3 deletions(-) create mode 100644 Test/baseResults/spv.branch-return.vert.out create mode 100644 Test/spv.branch-return.vert diff --git a/SPIRV/InReadableOrder.cpp b/SPIRV/InReadableOrder.cpp index f081212..f88e41a 100644 --- a/SPIRV/InReadableOrder.cpp +++ b/SPIRV/InReadableOrder.cpp @@ -27,10 +27,11 @@ using BlockSet = std::unordered_set; using IdToBool = std::unordered_map; namespace { -// True if any of prerequisites have not yet been visited. -bool delay(const BlockSet& prereqs, const IdToBool& visited) { +// True if any of prerequisites have not yet been visited. May add new, +// zero-initialized, values to visited, but doesn't modify any existing values. +bool delay(const BlockSet& prereqs, IdToBool& visited) { return std::any_of(prereqs.begin(), prereqs.end(), - [&visited](Id b) { return !visited.count(b); }); + [&visited](Id b) { return !visited[b]; }); } } diff --git a/Test/baseResults/spv.branch-return.vert.out b/Test/baseResults/spv.branch-return.vert.out new file mode 100644 index 0000000..75ebefe --- /dev/null +++ b/Test/baseResults/spv.branch-return.vert.out @@ -0,0 +1,63 @@ +spv.branch-return.vert + +Linked vertex stage: + + +// Module Version 10000 +// Generated by (magic number): 80001 +// Id's are bound by 35 + + Capability Shader + 1: ExtInstImport "GLSL.std.450" + MemoryModel Logical GLSL450 + EntryPoint Vertex 4 "main" 8 19 34 + Source ESSL 300 + Name 4 "main" + Name 8 "gl_InstanceID" + Name 19 "gl_Position" + Name 34 "gl_VertexID" + Decorate 8(gl_InstanceID) BuiltIn InstanceId + Decorate 19(gl_Position) BuiltIn Position + Decorate 34(gl_VertexID) BuiltIn VertexId + 2: TypeVoid + 3: TypeFunction 2 + 6: TypeInt 32 1 + 7: TypePointer Input 6(int) +8(gl_InstanceID): 7(ptr) Variable Input + 16: TypeFloat 32 + 17: TypeVector 16(float) 4 + 18: TypePointer Output 17(fvec4) + 19(gl_Position): 18(ptr) Variable Output + 20: 16(float) Constant 0 + 21: 17(fvec4) ConstantComposite 20 20 20 20 + 26: 16(float) Constant 1039918957 + 27: TypeInt 32 0 + 28: 27(int) Constant 0 + 29: TypePointer Output 16(float) + 34(gl_VertexID): 7(ptr) Variable Input + 4(main): 2 Function None 3 + 5: Label + 9: 6(int) Load 8(gl_InstanceID) + SelectionMerge 14 None + Switch 9 14 + case 0: 10 + case 1: 11 + case 2: 12 + case 3: 13 + 10: Label + Return + 11: Label + Store 19(gl_Position) 21 + Branch 14 + 12: Label + Return + 13: Label + Return + 14: Label + 30: 29(ptr) AccessChain 19(gl_Position) 28 + 31: 16(float) Load 30 + 32: 16(float) FAdd 31 26 + 33: 29(ptr) AccessChain 19(gl_Position) 28 + Store 33 32 + Return + FunctionEnd diff --git a/Test/spv.branch-return.vert b/Test/spv.branch-return.vert new file mode 100644 index 0000000..0b5897b --- /dev/null +++ b/Test/spv.branch-return.vert @@ -0,0 +1,10 @@ +#version 300 es +void main() { + switch (gl_InstanceID) { + case 0: return; + case 1: gl_Position = vec4(0.0); break; + case 2: return; + case 3: return; + } + gl_Position.x += 0.123; +} diff --git a/Test/test-spirv-list b/Test/test-spirv-list index af96262..13ff7c0 100644 --- a/Test/test-spirv-list +++ b/Test/test-spirv-list @@ -32,6 +32,7 @@ spv.always-discard.frag spv.always-discard2.frag spv.bitCast.frag spv.bool.vert +spv.branch-return.vert spv.conditionalDiscard.frag spv.conversion.frag spv.dataOut.frag -- 2.7.4