Merge remote-tracking branch 'upstream/master'
This commit is contained in:
commit
688a39e7f8
@ -0,0 +1,9 @@
|
||||
#version 450
|
||||
|
||||
layout(location = 0) out float FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
FragColor = 30.0;
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
struct T
|
||||
{
|
||||
float c;
|
||||
};
|
||||
|
||||
struct T_1
|
||||
{
|
||||
float b;
|
||||
};
|
||||
|
||||
static const T _18 = { 40.0f };
|
||||
|
||||
RWByteAddressBuffer _7 : register(u0);
|
||||
RWByteAddressBuffer _10 : register(u1);
|
||||
|
||||
void comp_main()
|
||||
{
|
||||
T v = _18;
|
||||
_7.Store(40, asuint(v.c));
|
||||
_10.Store(480, asuint(v.c));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
void main()
|
||||
{
|
||||
comp_main();
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
#pragma clang diagnostic ignored "-Wmissing-prototypes"
|
||||
#pragma clang diagnostic ignored "-Wmissing-braces"
|
||||
|
||||
#include <metal_stdlib>
|
||||
#include <simd/simd.h>
|
||||
|
||||
using namespace metal;
|
||||
|
||||
template<typename T, size_t Num>
|
||||
struct spvUnsafeArray
|
||||
{
|
||||
T elements[Num ? Num : 1];
|
||||
|
||||
thread T& operator [] (size_t pos) thread
|
||||
{
|
||||
return elements[pos];
|
||||
}
|
||||
constexpr const thread T& operator [] (size_t pos) const thread
|
||||
{
|
||||
return elements[pos];
|
||||
}
|
||||
|
||||
device T& operator [] (size_t pos) device
|
||||
{
|
||||
return elements[pos];
|
||||
}
|
||||
constexpr const device T& operator [] (size_t pos) const device
|
||||
{
|
||||
return elements[pos];
|
||||
}
|
||||
|
||||
constexpr const constant T& operator [] (size_t pos) const constant
|
||||
{
|
||||
return elements[pos];
|
||||
}
|
||||
|
||||
threadgroup T& operator [] (size_t pos) threadgroup
|
||||
{
|
||||
return elements[pos];
|
||||
}
|
||||
constexpr const threadgroup T& operator [] (size_t pos) const threadgroup
|
||||
{
|
||||
return elements[pos];
|
||||
}
|
||||
};
|
||||
|
||||
struct T
|
||||
{
|
||||
float a;
|
||||
};
|
||||
|
||||
struct T_1
|
||||
{
|
||||
float b;
|
||||
};
|
||||
|
||||
struct SSBO1
|
||||
{
|
||||
spvUnsafeArray<T_1, 1> foo;
|
||||
};
|
||||
|
||||
struct T_2
|
||||
{
|
||||
float c;
|
||||
char _m0_final_padding[12];
|
||||
};
|
||||
|
||||
struct SSBO2
|
||||
{
|
||||
spvUnsafeArray<T_2, 1> bar;
|
||||
};
|
||||
|
||||
kernel void main0(device SSBO1& _7 [[buffer(0)]], device SSBO2& _10 [[buffer(1)]])
|
||||
{
|
||||
T v = T{ 40.0 };
|
||||
_7.foo[10].b = v.a;
|
||||
_10.bar[30].c = v.a;
|
||||
}
|
||||
|
@ -0,0 +1,30 @@
|
||||
#version 450
|
||||
layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
|
||||
|
||||
struct T
|
||||
{
|
||||
float c;
|
||||
};
|
||||
|
||||
struct T_1
|
||||
{
|
||||
float b;
|
||||
};
|
||||
|
||||
layout(binding = 0, std430) buffer SSBO1
|
||||
{
|
||||
T_1 foo[];
|
||||
} _7;
|
||||
|
||||
layout(binding = 1, std140) buffer SSBO2
|
||||
{
|
||||
T bar[];
|
||||
} _10;
|
||||
|
||||
void main()
|
||||
{
|
||||
T v = T(40.0);
|
||||
_7.foo[10].b = v.c;
|
||||
_10.bar[30].c = v.c;
|
||||
}
|
||||
|
@ -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" : {
|
||||
|
@ -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" : {
|
||||
|
@ -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" : {
|
||||
|
@ -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" : {
|
||||
|
@ -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" : {
|
||||
|
@ -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" : {
|
||||
|
@ -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" : {
|
||||
|
@ -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" : {
|
||||
|
@ -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" : {
|
||||
|
@ -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" : {
|
||||
|
@ -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
|
||||
}
|
||||
]
|
||||
}
|
23
reference/shaders/frag/struct-type-unrelated-alias.frag
Normal file
23
reference/shaders/frag/struct-type-unrelated-alias.frag
Normal file
@ -0,0 +1,23 @@
|
||||
#version 450
|
||||
|
||||
struct T
|
||||
{
|
||||
float a;
|
||||
};
|
||||
|
||||
struct T_1
|
||||
{
|
||||
float b;
|
||||
};
|
||||
|
||||
layout(location = 0) out float FragColor;
|
||||
|
||||
void main()
|
||||
{
|
||||
T foo;
|
||||
foo.a = 10.0;
|
||||
T_1 bar;
|
||||
bar.b = 20.0;
|
||||
FragColor = foo.a + bar.b;
|
||||
}
|
||||
|
@ -0,0 +1,77 @@
|
||||
; SPIR-V
|
||||
; Version: 1.0
|
||||
; Generator: Khronos Glslang Reference Front End; 7
|
||||
; Bound: 37
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpSource GLSL 450
|
||||
OpName %main "main"
|
||||
OpName %T "T"
|
||||
OpMemberName %T 0 "a"
|
||||
OpName %v "v"
|
||||
OpName %T_0 "T"
|
||||
OpMemberName %T_0 0 "b"
|
||||
OpName %SSBO1 "SSBO1"
|
||||
OpMemberName %SSBO1 0 "foo"
|
||||
OpName %_ ""
|
||||
OpName %T_1 "T"
|
||||
OpMemberName %T_1 0 "c"
|
||||
OpName %SSBO2 "SSBO2"
|
||||
OpMemberName %SSBO2 0 "bar"
|
||||
OpName %__0 ""
|
||||
OpMemberDecorate %T_0 0 Offset 0
|
||||
OpDecorate %_runtimearr_T_0 ArrayStride 4
|
||||
OpMemberDecorate %SSBO1 0 Offset 0
|
||||
OpDecorate %SSBO1 BufferBlock
|
||||
OpDecorate %_ DescriptorSet 0
|
||||
OpDecorate %_ Binding 0
|
||||
OpMemberDecorate %T_1 0 Offset 0
|
||||
OpDecorate %_runtimearr_T_1 ArrayStride 16
|
||||
OpMemberDecorate %SSBO2 0 Offset 0
|
||||
OpDecorate %SSBO2 BufferBlock
|
||||
OpDecorate %__0 DescriptorSet 0
|
||||
OpDecorate %__0 Binding 1
|
||||
%void = OpTypeVoid
|
||||
%3 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%T = OpTypeStruct %float
|
||||
%_ptr_Function_T = OpTypePointer Function %T
|
||||
%float_40 = OpConstant %float 40
|
||||
%11 = OpConstantComposite %T %float_40
|
||||
%T_0 = OpTypeStruct %float
|
||||
%_runtimearr_T_0 = OpTypeRuntimeArray %T_0
|
||||
%SSBO1 = OpTypeStruct %_runtimearr_T_0
|
||||
%_ptr_Uniform_SSBO1 = OpTypePointer Uniform %SSBO1
|
||||
%_ = OpVariable %_ptr_Uniform_SSBO1 Uniform
|
||||
%int = OpTypeInt 32 1
|
||||
%int_0 = OpConstant %int 0
|
||||
%int_10 = OpConstant %int 10
|
||||
%_ptr_Uniform_T_0 = OpTypePointer Uniform %T_0
|
||||
%_ptr_Uniform_float = OpTypePointer Uniform %float
|
||||
%T_1 = OpTypeStruct %float
|
||||
%_runtimearr_T_1 = OpTypeRuntimeArray %T_1
|
||||
%SSBO2 = OpTypeStruct %_runtimearr_T_1
|
||||
%_ptr_Uniform_SSBO2 = OpTypePointer Uniform %SSBO2
|
||||
%__0 = OpVariable %_ptr_Uniform_SSBO2 Uniform
|
||||
%int_30 = OpConstant %int 30
|
||||
%_ptr_Uniform_T_1 = OpTypePointer Uniform %T_1
|
||||
%main = OpFunction %void None %3
|
||||
%5 = OpLabel
|
||||
%v = OpVariable %_ptr_Function_T Function
|
||||
OpStore %v %11
|
||||
%20 = OpLoad %T %v
|
||||
%22 = OpAccessChain %_ptr_Uniform_T_0 %_ %int_0 %int_10
|
||||
%23 = OpCompositeExtract %float %20 0
|
||||
%25 = OpAccessChain %_ptr_Uniform_float %22 %int_0
|
||||
OpStore %25 %23
|
||||
%32 = OpLoad %T %v
|
||||
%34 = OpAccessChain %_ptr_Uniform_T_1 %__0 %int_0 %int_30
|
||||
%35 = OpCompositeExtract %float %32 0
|
||||
%36 = OpAccessChain %_ptr_Uniform_float %34 %int_0
|
||||
OpStore %36 %35
|
||||
OpReturn
|
||||
OpFunctionEnd
|
@ -0,0 +1,77 @@
|
||||
; SPIR-V
|
||||
; Version: 1.0
|
||||
; Generator: Khronos Glslang Reference Front End; 7
|
||||
; Bound: 37
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpSource GLSL 450
|
||||
OpName %main "main"
|
||||
OpName %T "T"
|
||||
OpMemberName %T 0 "a"
|
||||
OpName %v "v"
|
||||
OpName %T_0 "T"
|
||||
OpMemberName %T_0 0 "b"
|
||||
OpName %SSBO1 "SSBO1"
|
||||
OpMemberName %SSBO1 0 "foo"
|
||||
OpName %_ ""
|
||||
OpName %T_1 "T"
|
||||
OpMemberName %T_1 0 "c"
|
||||
OpName %SSBO2 "SSBO2"
|
||||
OpMemberName %SSBO2 0 "bar"
|
||||
OpName %__0 ""
|
||||
OpMemberDecorate %T_0 0 Offset 0
|
||||
OpDecorate %_runtimearr_T_0 ArrayStride 4
|
||||
OpMemberDecorate %SSBO1 0 Offset 0
|
||||
OpDecorate %SSBO1 BufferBlock
|
||||
OpDecorate %_ DescriptorSet 0
|
||||
OpDecorate %_ Binding 0
|
||||
OpMemberDecorate %T_1 0 Offset 0
|
||||
OpDecorate %_runtimearr_T_1 ArrayStride 16
|
||||
OpMemberDecorate %SSBO2 0 Offset 0
|
||||
OpDecorate %SSBO2 BufferBlock
|
||||
OpDecorate %__0 DescriptorSet 0
|
||||
OpDecorate %__0 Binding 1
|
||||
%void = OpTypeVoid
|
||||
%3 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%T = OpTypeStruct %float
|
||||
%_ptr_Function_T = OpTypePointer Function %T
|
||||
%float_40 = OpConstant %float 40
|
||||
%11 = OpConstantComposite %T %float_40
|
||||
%T_0 = OpTypeStruct %float
|
||||
%_runtimearr_T_0 = OpTypeRuntimeArray %T_0
|
||||
%SSBO1 = OpTypeStruct %_runtimearr_T_0
|
||||
%_ptr_Uniform_SSBO1 = OpTypePointer Uniform %SSBO1
|
||||
%_ = OpVariable %_ptr_Uniform_SSBO1 Uniform
|
||||
%int = OpTypeInt 32 1
|
||||
%int_0 = OpConstant %int 0
|
||||
%int_10 = OpConstant %int 10
|
||||
%_ptr_Uniform_T_0 = OpTypePointer Uniform %T_0
|
||||
%_ptr_Uniform_float = OpTypePointer Uniform %float
|
||||
%T_1 = OpTypeStruct %float
|
||||
%_runtimearr_T_1 = OpTypeRuntimeArray %T_1
|
||||
%SSBO2 = OpTypeStruct %_runtimearr_T_1
|
||||
%_ptr_Uniform_SSBO2 = OpTypePointer Uniform %SSBO2
|
||||
%__0 = OpVariable %_ptr_Uniform_SSBO2 Uniform
|
||||
%int_30 = OpConstant %int 30
|
||||
%_ptr_Uniform_T_1 = OpTypePointer Uniform %T_1
|
||||
%main = OpFunction %void None %3
|
||||
%5 = OpLabel
|
||||
%v = OpVariable %_ptr_Function_T Function
|
||||
OpStore %v %11
|
||||
%20 = OpLoad %T %v
|
||||
%22 = OpAccessChain %_ptr_Uniform_T_0 %_ %int_0 %int_10
|
||||
%23 = OpCompositeExtract %float %20 0
|
||||
%25 = OpAccessChain %_ptr_Uniform_float %22 %int_0
|
||||
OpStore %25 %23
|
||||
%32 = OpLoad %T %v
|
||||
%34 = OpAccessChain %_ptr_Uniform_T_1 %__0 %int_0 %int_30
|
||||
%35 = OpCompositeExtract %float %32 0
|
||||
%36 = OpAccessChain %_ptr_Uniform_float %34 %int_0
|
||||
OpStore %36 %35
|
||||
OpReturn
|
||||
OpFunctionEnd
|
@ -0,0 +1,77 @@
|
||||
; SPIR-V
|
||||
; Version: 1.0
|
||||
; Generator: Khronos Glslang Reference Front End; 7
|
||||
; Bound: 37
|
||||
; Schema: 0
|
||||
OpCapability Shader
|
||||
%1 = OpExtInstImport "GLSL.std.450"
|
||||
OpMemoryModel Logical GLSL450
|
||||
OpEntryPoint GLCompute %main "main"
|
||||
OpExecutionMode %main LocalSize 1 1 1
|
||||
OpSource GLSL 450
|
||||
OpName %main "main"
|
||||
OpName %T "T"
|
||||
OpMemberName %T 0 "a"
|
||||
OpName %v "v"
|
||||
OpName %T_0 "T"
|
||||
OpMemberName %T_0 0 "b"
|
||||
OpName %SSBO1 "SSBO1"
|
||||
OpMemberName %SSBO1 0 "foo"
|
||||
OpName %_ ""
|
||||
OpName %T_1 "T"
|
||||
OpMemberName %T_1 0 "c"
|
||||
OpName %SSBO2 "SSBO2"
|
||||
OpMemberName %SSBO2 0 "bar"
|
||||
OpName %__0 ""
|
||||
OpMemberDecorate %T_0 0 Offset 0
|
||||
OpDecorate %_runtimearr_T_0 ArrayStride 4
|
||||
OpMemberDecorate %SSBO1 0 Offset 0
|
||||
OpDecorate %SSBO1 BufferBlock
|
||||
OpDecorate %_ DescriptorSet 0
|
||||
OpDecorate %_ Binding 0
|
||||
OpMemberDecorate %T_1 0 Offset 0
|
||||
OpDecorate %_runtimearr_T_1 ArrayStride 16
|
||||
OpMemberDecorate %SSBO2 0 Offset 0
|
||||
OpDecorate %SSBO2 BufferBlock
|
||||
OpDecorate %__0 DescriptorSet 0
|
||||
OpDecorate %__0 Binding 1
|
||||
%void = OpTypeVoid
|
||||
%3 = OpTypeFunction %void
|
||||
%float = OpTypeFloat 32
|
||||
%T = OpTypeStruct %float
|
||||
%_ptr_Function_T = OpTypePointer Function %T
|
||||
%float_40 = OpConstant %float 40
|
||||
%11 = OpConstantComposite %T %float_40
|
||||
%T_0 = OpTypeStruct %float
|
||||
%_runtimearr_T_0 = OpTypeRuntimeArray %T_0
|
||||
%SSBO1 = OpTypeStruct %_runtimearr_T_0
|
||||
%_ptr_Uniform_SSBO1 = OpTypePointer Uniform %SSBO1
|
||||
%_ = OpVariable %_ptr_Uniform_SSBO1 Uniform
|
||||
%int = OpTypeInt 32 1
|
||||
%int_0 = OpConstant %int 0
|
||||
%int_10 = OpConstant %int 10
|
||||
%_ptr_Uniform_T_0 = OpTypePointer Uniform %T_0
|
||||
%_ptr_Uniform_float = OpTypePointer Uniform %float
|
||||
%T_1 = OpTypeStruct %float
|
||||
%_runtimearr_T_1 = OpTypeRuntimeArray %T_1
|
||||
%SSBO2 = OpTypeStruct %_runtimearr_T_1
|
||||
%_ptr_Uniform_SSBO2 = OpTypePointer Uniform %SSBO2
|
||||
%__0 = OpVariable %_ptr_Uniform_SSBO2 Uniform
|
||||
%int_30 = OpConstant %int 30
|
||||
%_ptr_Uniform_T_1 = OpTypePointer Uniform %T_1
|
||||
%main = OpFunction %void None %3
|
||||
%5 = OpLabel
|
||||
%v = OpVariable %_ptr_Function_T Function
|
||||
OpStore %v %11
|
||||
%20 = OpLoad %T %v
|
||||
%22 = OpAccessChain %_ptr_Uniform_T_0 %_ %int_0 %int_10
|
||||
%23 = OpCompositeExtract %float %20 0
|
||||
%25 = OpAccessChain %_ptr_Uniform_float %22 %int_0
|
||||
OpStore %25 %23
|
||||
%32 = OpLoad %T %v
|
||||
%34 = OpAccessChain %_ptr_Uniform_T_1 %__0 %int_0 %int_30
|
||||
%35 = OpCompositeExtract %float %32 0
|
||||
%36 = OpAccessChain %_ptr_Uniform_float %34 %int_0
|
||||
OpStore %36 %35
|
||||
OpReturn
|
||||
OpFunctionEnd
|
13
shaders-reflection/comp/workgroup-size-spec-constant.comp
Normal file
13
shaders-reflection/comp/workgroup-size-spec-constant.comp
Normal file
@ -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);
|
||||
}
|
19
shaders/frag/struct-type-unrelated-alias.frag
Normal file
19
shaders/frag/struct-type-unrelated-alias.frag
Normal file
@ -0,0 +1,19 @@
|
||||
#version 450
|
||||
|
||||
layout(location = 0) out float FragColor;
|
||||
|
||||
struct T
|
||||
{
|
||||
float a;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
T foo;
|
||||
struct T { float b; };
|
||||
T bar;
|
||||
|
||||
foo.a = 10.0;
|
||||
bar.b = 20.0;
|
||||
FragColor = foo.a + bar.b;
|
||||
}
|
2
spirv.h
2
spirv.h
@ -53,7 +53,7 @@
|
||||
|
||||
typedef unsigned int SpvId;
|
||||
|
||||
#define SPV_VERSION 0x10400
|
||||
#define SPV_VERSION 0x10500
|
||||
#define SPV_REVISION 1
|
||||
|
||||
static const unsigned int SpvMagicNumber = 0x07230203;
|
||||
|
@ -49,7 +49,7 @@ namespace spv {
|
||||
|
||||
typedef unsigned int Id;
|
||||
|
||||
#define SPV_VERSION 0x10400
|
||||
#define SPV_VERSION 0x10500
|
||||
#define SPV_REVISION 1
|
||||
|
||||
static const unsigned int MagicNumber = 0x07230203;
|
||||
|
@ -10259,6 +10259,12 @@ void CompilerGLSL::append_global_func_args(const SPIRFunction &func, uint32_t in
|
||||
|
||||
string CompilerGLSL::to_member_name(const SPIRType &type, uint32_t index)
|
||||
{
|
||||
if (type.type_alias != TypeID(0) &&
|
||||
!has_extended_decoration(type.type_alias, SPIRVCrossDecorationBufferBlockRepacked))
|
||||
{
|
||||
return to_member_name(get<SPIRType>(type.type_alias), index);
|
||||
}
|
||||
|
||||
auto &memb = ir.meta[type.self].members;
|
||||
if (index < memb.size() && !memb[index].alias.empty())
|
||||
return memb[index].alias;
|
||||
@ -12812,6 +12818,14 @@ void CompilerGLSL::fixup_type_alias()
|
||||
// This is not allowed, drop the type_alias.
|
||||
type.type_alias = 0;
|
||||
}
|
||||
else if (type.type_alias && !type_is_block_like(this->get<SPIRType>(type.type_alias)))
|
||||
{
|
||||
// If the alias master is not a block-like type, there is no reason to use type aliasing.
|
||||
// This case can happen if two structs are declared with the same name, but they are unrelated.
|
||||
// Aliases are only used to deal with aliased types for structs which are used in different buffer types
|
||||
// which all create a variant of the same struct with different DecorationOffset values.
|
||||
type.type_alias = 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -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,28 @@ 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();
|
||||
|
@ -442,30 +442,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.
|
||||
|
Loading…
Reference in New Issue
Block a user