Add spv.branch-return.vert and fix inReadableOrder().
authorDejan Mircevski <deki@google.com>
Mon, 18 Jan 2016 22:12:59 +0000 (17:12 -0500)
committerDejan Mircevski <deki@google.com>
Tue, 19 Jan 2016 15:11:34 +0000 (10:11 -0500)
SPIRV/InReadableOrder.cpp
Test/baseResults/spv.branch-return.vert.out [new file with mode: 0644]
Test/spv.branch-return.vert [new file with mode: 0644]
Test/test-spirv-list

index f081212..f88e41a 100644 (file)
@@ -27,10 +27,11 @@ using BlockSet = std::unordered_set<Id>;
 using IdToBool = std::unordered_map<Id, bool>;
 
 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 (file)
index 0000000..75ebefe
--- /dev/null
@@ -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 (file)
index 0000000..0b5897b
--- /dev/null
@@ -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;
+}
index af96262..13ff7c0 100644 (file)
@@ -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