diff --git a/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-glsl-ssbo-1.asm.comp.json b/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-glsl-ssbo-1.asm.comp.json index 6cd7f95d7..76ddd8122 100644 --- a/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-glsl-ssbo-1.asm.comp.json +++ b/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" : { diff --git a/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-glsl-ssbo-2.asm.comp.json b/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-glsl-ssbo-2.asm.comp.json index c2fa56405..3d7e0e5bc 100644 --- a/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-glsl-ssbo-2.asm.comp.json +++ b/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" : { diff --git a/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-hlsl-uav-1.asm.comp.json b/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-hlsl-uav-1.asm.comp.json index 12b0677f6..0e58d68d6 100644 --- a/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-hlsl-uav-1.asm.comp.json +++ b/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" : { diff --git a/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-hlsl-uav-2.asm.comp.json b/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-hlsl-uav-2.asm.comp.json index 8da2c74eb..1cfec5c66 100644 --- a/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-hlsl-uav-2.asm.comp.json +++ b/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" : { diff --git a/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-none-ssbo-1.asm.comp.json b/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-none-ssbo-1.asm.comp.json index 6cd7f95d7..76ddd8122 100644 --- a/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-none-ssbo-1.asm.comp.json +++ b/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" : { diff --git a/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-none-ssbo-2.asm.comp.json b/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-none-ssbo-2.asm.comp.json index c2fa56405..3d7e0e5bc 100644 --- a/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-none-ssbo-2.asm.comp.json +++ b/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" : { diff --git a/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-none-uav-1.asm.comp.json b/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-none-uav-1.asm.comp.json index 12b0677f6..0e58d68d6 100644 --- a/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-none-uav-1.asm.comp.json +++ b/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" : { diff --git a/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-none-uav-2.asm.comp.json b/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-none-uav-2.asm.comp.json index 8da2c74eb..1cfec5c66 100644 --- a/3rdparty/spirv-cross/reference/shaders-reflection/asm/op-source-none-uav-2.asm.comp.json +++ b/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" : { diff --git a/3rdparty/spirv-cross/reference/shaders-reflection/comp/struct-layout.comp.json b/3rdparty/spirv-cross/reference/shaders-reflection/comp/struct-layout.comp.json index 3004454b8..ef147ee03 100644 --- a/3rdparty/spirv-cross/reference/shaders-reflection/comp/struct-layout.comp.json +++ b/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" : { diff --git a/3rdparty/spirv-cross/reference/shaders-reflection/comp/struct-packing.comp.json b/3rdparty/spirv-cross/reference/shaders-reflection/comp/struct-packing.comp.json index 22a41584d..c586ff739 100644 --- a/3rdparty/spirv-cross/reference/shaders-reflection/comp/struct-packing.comp.json +++ b/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" : { diff --git a/3rdparty/spirv-cross/reference/shaders-reflection/comp/workgroup-size-spec-constant.comp.json b/3rdparty/spirv-cross/reference/shaders-reflection/comp/workgroup-size-spec-constant.comp.json new file mode 100644 index 000000000..fb63729a6 --- /dev/null +++ b/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 + } + ] +} \ No newline at end of file diff --git a/3rdparty/spirv-cross/shaders-reflection/comp/workgroup-size-spec-constant.comp b/3rdparty/spirv-cross/shaders-reflection/comp/workgroup-size-spec-constant.comp new file mode 100644 index 000000000..376a35162 --- /dev/null +++ b/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); +} diff --git a/3rdparty/spirv-cross/spirv_reflect.cpp b/3rdparty/spirv-cross/spirv_reflect.cpp index f3eac7c49..4fe377ade 100644 --- a/3rdparty/spirv-cross/spirv_reflect.cpp +++ b/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(); diff --git a/3rdparty/spirv-cross/test_shaders.py b/3rdparty/spirv-cross/test_shaders.py index a47f41b39..f58018e9a 100755 --- a/3rdparty/spirv-cross/test_shaders.py +++ b/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.