2
0
Бранимир Караџић 6 жил өмнө
parent
commit
e273602cd5

+ 11 - 1
3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-glsl-ssbo-1.asm.comp.json

@@ -2,7 +2,17 @@
     "entryPoints" : [
         {
             "name" : "main",
-            "mode" : "comp"
+            "mode" : "comp",
+            "workgroup_size" : [
+                1,
+                1,
+                1
+            ],
+            "workgroup_size_is_spec_constant_id" : [
+                false,
+                false,
+                false
+            ]
         }
     ],
     "types" : {

+ 11 - 1
3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-glsl-ssbo-2.asm.comp.json

@@ -2,7 +2,17 @@
     "entryPoints" : [
         {
             "name" : "main",
-            "mode" : "comp"
+            "mode" : "comp",
+            "workgroup_size" : [
+                1,
+                1,
+                1
+            ],
+            "workgroup_size_is_spec_constant_id" : [
+                false,
+                false,
+                false
+            ]
         }
     ],
     "types" : {

+ 11 - 1
3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-hlsl-uav-1.asm.comp.json

@@ -2,7 +2,17 @@
     "entryPoints" : [
         {
             "name" : "main",
-            "mode" : "comp"
+            "mode" : "comp",
+            "workgroup_size" : [
+                1,
+                1,
+                1
+            ],
+            "workgroup_size_is_spec_constant_id" : [
+                false,
+                false,
+                false
+            ]
         }
     ],
     "types" : {

+ 11 - 1
3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-hlsl-uav-2.asm.comp.json

@@ -2,7 +2,17 @@
     "entryPoints" : [
         {
             "name" : "main",
-            "mode" : "comp"
+            "mode" : "comp",
+            "workgroup_size" : [
+                1,
+                1,
+                1
+            ],
+            "workgroup_size_is_spec_constant_id" : [
+                false,
+                false,
+                false
+            ]
         }
     ],
     "types" : {

+ 11 - 1
3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-none-ssbo-1.asm.comp.json

@@ -2,7 +2,17 @@
     "entryPoints" : [
         {
             "name" : "main",
-            "mode" : "comp"
+            "mode" : "comp",
+            "workgroup_size" : [
+                1,
+                1,
+                1
+            ],
+            "workgroup_size_is_spec_constant_id" : [
+                false,
+                false,
+                false
+            ]
         }
     ],
     "types" : {

+ 11 - 1
3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-none-ssbo-2.asm.comp.json

@@ -2,7 +2,17 @@
     "entryPoints" : [
         {
             "name" : "main",
-            "mode" : "comp"
+            "mode" : "comp",
+            "workgroup_size" : [
+                1,
+                1,
+                1
+            ],
+            "workgroup_size_is_spec_constant_id" : [
+                false,
+                false,
+                false
+            ]
         }
     ],
     "types" : {

+ 11 - 1
3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-none-uav-1.asm.comp.json

@@ -2,7 +2,17 @@
     "entryPoints" : [
         {
             "name" : "main",
-            "mode" : "comp"
+            "mode" : "comp",
+            "workgroup_size" : [
+                1,
+                1,
+                1
+            ],
+            "workgroup_size_is_spec_constant_id" : [
+                false,
+                false,
+                false
+            ]
         }
     ],
     "types" : {

+ 11 - 1
3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-none-uav-2.asm.comp.json

@@ -2,7 +2,17 @@
     "entryPoints" : [
         {
             "name" : "main",
-            "mode" : "comp"
+            "mode" : "comp",
+            "workgroup_size" : [
+                1,
+                1,
+                1
+            ],
+            "workgroup_size_is_spec_constant_id" : [
+                false,
+                false,
+                false
+            ]
         }
     ],
     "types" : {

+ 11 - 1
3rdparty/spirv-cross/reference/shaders-reflection/comp/struct-layout.comp.json

@@ -2,7 +2,17 @@
     "entryPoints" : [
         {
             "name" : "main",
-            "mode" : "comp"
+            "mode" : "comp",
+            "workgroup_size" : [
+                1,
+                1,
+                1
+            ],
+            "workgroup_size_is_spec_constant_id" : [
+                false,
+                false,
+                false
+            ]
         }
     ],
     "types" : {

+ 11 - 1
3rdparty/spirv-cross/reference/shaders-reflection/comp/struct-packing.comp.json

@@ -2,7 +2,17 @@
     "entryPoints" : [
         {
             "name" : "main",
-            "mode" : "comp"
+            "mode" : "comp",
+            "workgroup_size" : [
+                1,
+                1,
+                1
+            ],
+            "workgroup_size_is_spec_constant_id" : [
+                false,
+                false,
+                false
+            ]
         }
     ],
     "types" : {

+ 56 - 0
3rdparty/spirv-cross/reference/shaders-reflection/comp/workgroup-size-spec-constant.comp.json

@@ -0,0 +1,56 @@
+{
+    "entryPoints" : [
+        {
+            "name" : "main",
+            "mode" : "comp",
+            "workgroup_size" : [
+                10,
+                40,
+                60
+            ],
+            "workgroup_size_is_spec_constant_id" : [
+                true,
+                true,
+                true
+            ]
+        }
+    ],
+    "types" : {
+        "_8" : {
+            "name" : "SSBO",
+            "members" : [
+                {
+                    "name" : "v",
+                    "type" : "vec4",
+                    "offset" : 0
+                }
+            ]
+        }
+    },
+    "ssbos" : [
+        {
+            "type" : "_8",
+            "name" : "SSBO",
+            "block_size" : 16,
+            "set" : 0,
+            "binding" : 0
+        }
+    ],
+    "specialization_constants" : [
+        {
+            "id" : 10,
+            "type" : "uint",
+            "default_value" : 1
+        },
+        {
+            "id" : 40,
+            "type" : "uint",
+            "default_value" : 1
+        },
+        {
+            "id" : 60,
+            "type" : "uint",
+            "default_value" : 1
+        }
+    ]
+}

+ 13 - 0
3rdparty/spirv-cross/shaders-reflection/comp/workgroup-size-spec-constant.comp

@@ -0,0 +1,13 @@
+#version 450
+
+layout(local_size_x_id = 10, local_size_y_id = 40, local_size_z_id = 60) in;
+
+layout(std430, set = 0, binding = 0) buffer SSBO
+{
+	vec4 v;
+};
+
+void main()
+{
+	v = vec4(10.0);
+}

+ 30 - 0
3rdparty/spirv-cross/spirv_reflect.cpp

@@ -61,6 +61,7 @@ public:
 	void end_json_array();
 	void emit_json_array_value(const std::string &value);
 	void emit_json_array_value(uint32_t value);
+	void emit_json_array_value(bool value);
 
 	std::string str() const
 	{
@@ -158,6 +159,16 @@ void Stream::emit_json_array_value(uint32_t value)
 	stack.top().second = true;
 }
 
+void Stream::emit_json_array_value(bool value)
+{
+	if (stack.empty() || stack.top().first != Type::Array)
+		SPIRV_CROSS_THROW("Invalid JSON state");
+	if (stack.top().second)
+		statement_inner(",\n");
+	statement_no_return(value ? "true" : "false");
+	stack.top().second = true;
+}
+
 void Stream::begin_json_object()
 {
 	if (!stack.empty() && stack.top().second)
@@ -424,6 +435,25 @@ void CompilerReflection::emit_entry_points()
 			json_stream->begin_json_object();
 			json_stream->emit_json_key_value("name", e.name);
 			json_stream->emit_json_key_value("mode", execution_model_to_str(e.execution_model));
+			if (e.execution_model == ExecutionModelGLCompute)
+			{
+				const auto &spv_entry = get_entry_point(e.name, e.execution_model);
+
+				SpecializationConstant spec_x, spec_y, spec_z;
+				get_work_group_size_specialization_constants(spec_x, spec_y, spec_z);
+
+				json_stream->emit_json_key_array("workgroup_size");
+				json_stream->emit_json_array_value(spec_x.id != ID(0) ? spec_x.constant_id : spv_entry.workgroup_size.x);
+				json_stream->emit_json_array_value(spec_y.id != ID(0) ? spec_y.constant_id : spv_entry.workgroup_size.y);
+				json_stream->emit_json_array_value(spec_z.id != ID(0) ? spec_z.constant_id : spv_entry.workgroup_size.z);
+				json_stream->end_json_array();
+
+				json_stream->emit_json_key_array("workgroup_size_is_spec_constant_id");
+				json_stream->emit_json_array_value(spec_x.id != ID(0));
+				json_stream->emit_json_array_value(spec_y.id != ID(0));
+				json_stream->emit_json_array_value(spec_z.id != ID(0));
+				json_stream->end_json_array();
+			}
 			json_stream->end_json_object();
 		}
 		json_stream->end_json_array();

+ 3 - 19
3rdparty/spirv-cross/test_shaders.py

@@ -438,30 +438,14 @@ def reference_path(directory, relpath, opt):
     reference_dir = os.path.join(reference_dir, split_paths[1])
     return os.path.join(reference_dir, relpath)
 
-def json_ordered(obj):
-    if isinstance(obj, dict):
-        return sorted((k, json_ordered(v)) for k, v in obj.items())
-    if isinstance(obj, list):
-        return sorted(json_ordered(x) for x in obj)
-    else:
-        return obj
-    
-def json_compare(json_a, json_b):
-    return json_ordered(json_a) == json_ordered(json_b)
-
 def regression_check_reflect(shader, json_file, args):
     reference = reference_path(shader[0], shader[1], args.opt) + '.json'
     joined_path = os.path.join(shader[0], shader[1])
     print('Reference shader reflection path:', reference)
     if os.path.exists(reference):
-        actual = ''
-        expected = ''
-        with open(json_file) as f:
-            actual_json = f.read();
-            actual = json.loads(actual_json)
-        with open(reference) as f:
-            expected = json.load(f)
-        if (json_compare(actual, expected) != True):
+        actual = md5_for_file(json_file)
+        expected = md5_for_file(reference)
+        if actual != expected:
             if args.update:
                 print('Generated reflection json has changed for {}!'.format(reference))
                 # If we expect changes, update the reference file.