From fdd1e2f926fba6361a0c834d5c044bb60a6e252c Mon Sep 17 00:00:00 2001 From: spencer-lunarg Date: Thu, 9 Jan 2025 14:12:35 -0500 Subject: [PATCH] Detect first level of BDA pointers --- spirv_reflect.c | 23 +- spirv_reflect.h | 2 +- ...r_access_chain_phy_storage_buffer.spv.yaml | 4 +- tests/glsl/buffer_handle_1.spv.yaml | 4 +- .../push_constants/pointer_in_struct.spv.yaml | 2 +- .../pointer_in_struct_2.spv.yaml | 2 +- .../push_constant_basic_2.spv.yaml | 2 +- tests/test-spirv-reflect.cpp | 4 + .../phy_storage_buffer_used_0.glsl | 21 + .../phy_storage_buffer_used_0.spv | Bin 0 -> 1036 bytes .../phy_storage_buffer_used_0.spv.yaml | 291 ++++++++++++ .../phy_storage_buffer_used_1.glsl | 26 ++ .../phy_storage_buffer_used_1.spv | Bin 0 -> 1204 bytes .../phy_storage_buffer_used_1.spv.yaml | 439 ++++++++++++++++++ .../phy_storage_buffer_used_2.slang | 15 + .../phy_storage_buffer_used_2.spv | Bin 0 -> 1020 bytes .../phy_storage_buffer_used_2.spv.yaml | 291 ++++++++++++ .../phy_storage_buffer_used_3.slang | 20 + .../phy_storage_buffer_used_3.spv | Bin 0 -> 1040 bytes .../phy_storage_buffer_used_3.spv.yaml | 380 +++++++++++++++ 20 files changed, 1504 insertions(+), 22 deletions(-) create mode 100644 tests/variable_access/phy_storage_buffer_used_0.glsl create mode 100644 tests/variable_access/phy_storage_buffer_used_0.spv create mode 100644 tests/variable_access/phy_storage_buffer_used_0.spv.yaml create mode 100644 tests/variable_access/phy_storage_buffer_used_1.glsl create mode 100644 tests/variable_access/phy_storage_buffer_used_1.spv create mode 100644 tests/variable_access/phy_storage_buffer_used_1.spv.yaml create mode 100644 tests/variable_access/phy_storage_buffer_used_2.slang create mode 100644 tests/variable_access/phy_storage_buffer_used_2.spv create mode 100644 tests/variable_access/phy_storage_buffer_used_2.spv.yaml create mode 100644 tests/variable_access/phy_storage_buffer_used_3.slang create mode 100644 tests/variable_access/phy_storage_buffer_used_3.spv create mode 100644 tests/variable_access/phy_storage_buffer_used_3.spv.yaml diff --git a/spirv_reflect.c b/spirv_reflect.c index 9f66705..50986b5 100644 --- a/spirv_reflect.c +++ b/spirv_reflect.c @@ -2829,19 +2829,11 @@ static void MarkSelfAndAllMemberVarsAsUsed(SpvReflectBlockVariable* p_var) { p_var->flags &= ~SPV_REFLECT_VARIABLE_FLAGS_UNUSED; SpvOp op_type = p_var->type_description->op; - switch (op_type) { - default: - break; - - case SpvOpTypeArray: { - } break; - - case SpvOpTypeStruct: { - for (uint32_t i = 0; i < p_var->member_count; ++i) { - SpvReflectBlockVariable* p_member_var = &p_var->members[i]; - MarkSelfAndAllMemberVarsAsUsed(p_member_var); - } - } break; + if (op_type == SpvOpTypeStruct) { + for (uint32_t i = 0; i < p_var->member_count; ++i) { + SpvReflectBlockVariable* p_member_var = &p_var->members[i]; + MarkSelfAndAllMemberVarsAsUsed(p_member_var); + } } } @@ -2958,7 +2950,10 @@ static SpvReflectResult ParseDescriptorBlockVariableUsage(SpvReflectPrvParser* p if (result != SPV_REFLECT_RESULT_SUCCESS) { return result; } - } else if (!is_pointer_to_pointer) { + } else if (is_pointer_to_pointer) { + // Clear UNUSED flag, but only for the pointer + p_member_var->flags &= ~SPV_REFLECT_VARIABLE_FLAGS_UNUSED; + } else { // Clear UNUSED flag for remaining variables MarkSelfAndAllMemberVarsAsUsed(p_member_var); } diff --git a/spirv_reflect.h b/spirv_reflect.h index 09ebc1f..eea30bd 100644 --- a/spirv_reflect.h +++ b/spirv_reflect.h @@ -431,7 +431,7 @@ typedef struct SpvReflectInterfaceVariable { SpvStorageClass storage_class; const char* semantic; SpvReflectDecorationFlags decoration_flags; - + // The builtin id (SpvBuiltIn) if the variable is a builtin, and -1 otherwise. int built_in; SpvReflectNumericTraits numeric; diff --git a/tests/access_chains/pointer_access_chain_phy_storage_buffer.spv.yaml b/tests/access_chains/pointer_access_chain_phy_storage_buffer.spv.yaml index 51369c7..7f78149 100644 --- a/tests/access_chains/pointer_access_chain_phy_storage_buffer.spv.yaml +++ b/tests/access_chains/pointer_access_chain_phy_storage_buffer.spv.yaml @@ -102,7 +102,7 @@ all_block_variables: vector: { component_count: 0 } matrix: { column_count: 0, row_count: 0, stride: 0 } array: { dims_count: 0, dims: [], stride: 0 } - flags: 0x00000001 # UNUSED + flags: 0x00000000 # NONE member_count: 0 members: type_description: *td0 @@ -134,7 +134,7 @@ all_block_variables: vector: { component_count: 0 } matrix: { column_count: 0, row_count: 0, stride: 0 } array: { dims_count: 0, dims: [], stride: 0 } - flags: 0x00000001 # UNUSED + flags: 0x00000000 # NONE member_count: 1 members: - *bv1 diff --git a/tests/glsl/buffer_handle_1.spv.yaml b/tests/glsl/buffer_handle_1.spv.yaml index cacc516..fa05b2f 100644 --- a/tests/glsl/buffer_handle_1.spv.yaml +++ b/tests/glsl/buffer_handle_1.spv.yaml @@ -512,7 +512,7 @@ all_block_variables: vector: { component_count: 0 } matrix: { column_count: 0, row_count: 0, stride: 0 } array: { dims_count: 0, dims: [], stride: 0 } - flags: 0x00000001 # UNUSED + flags: 0x00000000 # NONE member_count: 2 members: - *bv0 @@ -613,7 +613,7 @@ all_block_variables: vector: { component_count: 0 } matrix: { column_count: 0, row_count: 0, stride: 0 } array: { dims_count: 0, dims: [], stride: 0 } - flags: 0x00000001 # UNUSED + flags: 0x00000000 # NONE member_count: 2 members: - *bv6 diff --git a/tests/push_constants/pointer_in_struct.spv.yaml b/tests/push_constants/pointer_in_struct.spv.yaml index 19d9087..ebf19fc 100644 --- a/tests/push_constants/pointer_in_struct.spv.yaml +++ b/tests/push_constants/pointer_in_struct.spv.yaml @@ -169,7 +169,7 @@ all_block_variables: vector: { component_count: 0 } matrix: { column_count: 0, row_count: 0, stride: 0 } array: { dims_count: 0, dims: [], stride: 0 } - flags: 0x00000001 # UNUSED + flags: 0x00000000 # NONE member_count: 0 members: type_description: *td3 diff --git a/tests/push_constants/pointer_in_struct_2.spv.yaml b/tests/push_constants/pointer_in_struct_2.spv.yaml index 6903235..cb36c52 100644 --- a/tests/push_constants/pointer_in_struct_2.spv.yaml +++ b/tests/push_constants/pointer_in_struct_2.spv.yaml @@ -271,7 +271,7 @@ all_block_variables: vector: { component_count: 0 } matrix: { column_count: 0, row_count: 0, stride: 0 } array: { dims_count: 0, dims: [], stride: 0 } - flags: 0x00000001 # UNUSED + flags: 0x00000000 # NONE member_count: 2 members: - *bv3 diff --git a/tests/push_constants/push_constant_basic_2.spv.yaml b/tests/push_constants/push_constant_basic_2.spv.yaml index 6e3c881..5925b96 100644 --- a/tests/push_constants/push_constant_basic_2.spv.yaml +++ b/tests/push_constants/push_constant_basic_2.spv.yaml @@ -324,7 +324,7 @@ all_block_variables: vector: { component_count: 0 } matrix: { column_count: 0, row_count: 0, stride: 0 } array: { dims_count: 0, dims: [], stride: 0 } - flags: 0x00000001 # UNUSED + flags: 0x00000000 # NONE member_count: 0 members: type_description: *td8 diff --git a/tests/test-spirv-reflect.cpp b/tests/test-spirv-reflect.cpp index 56f84c0..e501f3b 100644 --- a/tests/test-spirv-reflect.cpp +++ b/tests/test-spirv-reflect.cpp @@ -906,6 +906,10 @@ const std::vector all_spirv_paths = { "../tests/variable_access/copy_struct_1.spv", "../tests/variable_access/descriptor_indexing_0.spv", "../tests/variable_access/descriptor_indexing_1.spv", + "../tests/variable_access/phy_storage_buffer_used_0.spv", + "../tests/variable_access/phy_storage_buffer_used_1.spv", + "../tests/variable_access/phy_storage_buffer_used_2.spv", + "../tests/variable_access/phy_storage_buffer_used_3.spv", // clang-format on }; } // namespace diff --git a/tests/variable_access/phy_storage_buffer_used_0.glsl b/tests/variable_access/phy_storage_buffer_used_0.glsl new file mode 100644 index 0000000..5d79419 --- /dev/null +++ b/tests/variable_access/phy_storage_buffer_used_0.glsl @@ -0,0 +1,21 @@ +#version 450 +#extension GL_EXT_buffer_reference : enable + +layout(buffer_reference, std430) buffer Node { + uint payload; +}; + +layout(buffer_reference, std430) buffer BadNode { + uint bad_payload; +}; + +layout(set = 0, binding = 0, std430) buffer SSBO { + Node first_node; + BadNode bad_node; // used + uint placeholder; +} x; + +void main() { + x.placeholder = 0; + x.first_node.payload = 3; +} diff --git a/tests/variable_access/phy_storage_buffer_used_0.spv b/tests/variable_access/phy_storage_buffer_used_0.spv new file mode 100644 index 0000000000000000000000000000000000000000..79c92e90ec5cc0de7d621d59289fc50c1434346e GIT binary patch literal 1036 zcmY+CT}vBL5QfL>8b4zFs2|l{NNg^=D2Nxf6iNjJiD0PGNa@{j%x*NWO+q$>`uF-* z+Wv>$6nvkPJqeDCXXc%E-kEcZVC+k!P)$;G$ZaS3>0J@z{t_%8G&`I|D|R42U$(uqo)Lq%1^fA#wk>!b7WwtCsKF30xEd%=Z6 zZC`wLobckQ4j47|3$>sNR+sjQPMo*;SmwMZ7_(P(*5z~Zw`IPjnElDo<;^hk`1a@p z5ByEV75pITc3EPRvH@zi$6Q{sfP}TSx!^ literal 0 HcmV?d00001 diff --git a/tests/variable_access/phy_storage_buffer_used_0.spv.yaml b/tests/variable_access/phy_storage_buffer_used_0.spv.yaml new file mode 100644 index 0000000..10a887f --- /dev/null +++ b/tests/variable_access/phy_storage_buffer_used_0.spv.yaml @@ -0,0 +1,291 @@ +%YAML 1.1 +--- +all_type_descriptions: + - &td0 + id: 8 + op: 21 + type_name: + struct_member_name: "payload" + storage_class: 0 # UniformConstant + type_flags: 0x00000004 # INT + decoration_flags: 0x00000000 # NONE + traits: + numeric: + scalar: { width: 32, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + array: { dims_count: 0, dims: [], stride: 0 } + member_count: 0 + members: + - &td1 + id: 6 + op: 32 + type_name: "Node" + struct_member_name: "first_node" + storage_class: 5349 # PhysicalStorageBuffer + type_flags: 0x50080000 # STRUCT REF EXTERNAL_BLOCK + decoration_flags: 0x00000001 # BLOCK + traits: + numeric: + scalar: { width: 0, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + array: { dims_count: 0, dims: [], stride: 0 } + member_count: 1 + members: + - *td0 + - &td2 + id: 8 + op: 21 + type_name: + struct_member_name: "bad_payload" + storage_class: 0 # UniformConstant + type_flags: 0x00000004 # INT + decoration_flags: 0x00000000 # NONE + traits: + numeric: + scalar: { width: 32, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + array: { dims_count: 0, dims: [], stride: 0 } + member_count: 0 + members: + - &td3 + id: 7 + op: 32 + type_name: "BadNode" + struct_member_name: "bad_node" + storage_class: 5349 # PhysicalStorageBuffer + type_flags: 0x50080000 # STRUCT REF EXTERNAL_BLOCK + decoration_flags: 0x00000001 # BLOCK + traits: + numeric: + scalar: { width: 0, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + array: { dims_count: 0, dims: [], stride: 0 } + member_count: 1 + members: + - *td2 + - &td4 + id: 8 + op: 21 + type_name: + struct_member_name: "placeholder" + storage_class: 0 # UniformConstant + type_flags: 0x00000004 # INT + decoration_flags: 0x00000000 # NONE + traits: + numeric: + scalar: { width: 32, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + array: { dims_count: 0, dims: [], stride: 0 } + member_count: 0 + members: + - &td5 + id: 9 + op: 30 + type_name: "SSBO" + struct_member_name: + storage_class: -1 # NOT APPLICABLE + type_flags: 0x10080000 # STRUCT EXTERNAL_BLOCK + decoration_flags: 0x00000001 # BLOCK + traits: + numeric: + scalar: { width: 0, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + array: { dims_count: 0, dims: [], stride: 0 } + member_count: 3 + members: + - *td1 + - *td3 + - *td4 + - &td6 + id: 8 + op: 21 + type_name: + struct_member_name: "payload" + storage_class: 0 # UniformConstant + type_flags: 0x00000004 # INT + decoration_flags: 0x00000000 # NONE + traits: + numeric: + scalar: { width: 32, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + array: { dims_count: 0, dims: [], stride: 0 } + member_count: 0 + members: + - &td7 + id: 8 + op: 21 + type_name: + struct_member_name: "bad_payload" + storage_class: 0 # UniformConstant + type_flags: 0x00000004 # INT + decoration_flags: 0x00000000 # NONE + traits: + numeric: + scalar: { width: 32, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + array: { dims_count: 0, dims: [], stride: 0 } + member_count: 0 + members: +all_block_variables: + - &bv0 + name: "payload" + offset: 0 + absolute_offset: 0 + size: 4 + padded_size: 4 + decorations: 0x00000000 # NONE + numeric: + scalar: { width: 32, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + array: { dims_count: 0, dims: [], stride: 0 } + flags: 0x00000001 # UNUSED + member_count: 0 + members: + type_description: *td6 + - &bv1 + name: "first_node" + offset: 0 + absolute_offset: 0 + size: 8 + padded_size: 8 + decorations: 0x00000000 # NONE + numeric: + scalar: { width: 0, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + array: { dims_count: 0, dims: [], stride: 0 } + flags: 0x00000000 # NONE + member_count: 1 + members: + - *bv0 + type_description: *td1 + - &bv2 + name: "bad_payload" + offset: 0 + absolute_offset: 0 + size: 4 + padded_size: 4 + decorations: 0x00000000 # NONE + numeric: + scalar: { width: 32, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + array: { dims_count: 0, dims: [], stride: 0 } + flags: 0x00000001 # UNUSED + member_count: 0 + members: + type_description: *td7 + - &bv3 + name: "bad_node" + offset: 8 + absolute_offset: 8 + size: 8 + padded_size: 8 + decorations: 0x00000000 # NONE + numeric: + scalar: { width: 0, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + array: { dims_count: 0, dims: [], stride: 0 } + flags: 0x00000001 # UNUSED + member_count: 1 + members: + - *bv2 + type_description: *td3 + - &bv4 + name: "placeholder" + offset: 16 + absolute_offset: 16 + size: 4 + padded_size: 4 + decorations: 0x00000000 # NONE + numeric: + scalar: { width: 32, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + array: { dims_count: 0, dims: [], stride: 0 } + flags: 0x00000000 # NONE + member_count: 0 + members: + type_description: *td4 + - &bv5 + name: "x" + offset: 0 + absolute_offset: 0 + size: 0 + padded_size: 0 + decorations: 0x00000000 # NONE + numeric: + scalar: { width: 0, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + array: { dims_count: 0, dims: [], stride: 0 } + flags: 0x00000000 # NONE + member_count: 3 + members: + - *bv1 + - *bv3 + - *bv4 + type_description: *td5 +all_descriptor_bindings: + - &db0 + spirv_id: 13 + name: "x" + binding: 0 + input_attachment_index: 0 + set: 0 + decoration_flags: 0x00000000 # NONE + descriptor_type: 7 # VK_DESCRIPTOR_TYPE_STORAGE_BUFFER + resource_type: 8 # UAV + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + block: *bv5 # "x" + array: { dims_count: 0, dims: [] } + accessed: 1 + uav_counter_id: 4294967295 + uav_counter_binding: + type_description: *td5 + word_offset: { binding: 144, set: 148 } +all_interface_variables: +module: + generator: 8 # Khronos Glslang Reference Front End + entry_point_name: "main" + entry_point_id: 4 + source_language: 2 # GLSL + source_language_version: 450 + spirv_execution_model: 5 # GLCompute + shader_stage: 0x00000020 # CS + descriptor_binding_count: 1 + descriptor_bindings: + - *db0 # "x" + descriptor_set_count: 1 + descriptor_sets: + - set: 0 + binding_count: 1 + bindings: + - *db0 # "x" + input_variable_count: 0, + input_variables: + output_variable_count: 0, + output_variables: + push_constant_count: 0, + push_constants: + specialization_constant_count: 0, + specialization_constants: +... diff --git a/tests/variable_access/phy_storage_buffer_used_1.glsl b/tests/variable_access/phy_storage_buffer_used_1.glsl new file mode 100644 index 0000000..7838a40 --- /dev/null +++ b/tests/variable_access/phy_storage_buffer_used_1.glsl @@ -0,0 +1,26 @@ +#version 450 +#extension GL_EXT_buffer_reference : enable + +layout(buffer_reference) buffer Node; + +layout(buffer_reference, std430) buffer Node { + Node next; + uint payload; +}; + +layout(buffer_reference) buffer BadNode; +layout(buffer_reference, std430) buffer BadNode { + BadNode bad_next; + uint bad_payload; +}; + +layout(set = 0, binding = 0, std430) buffer SSBO { + Node first_node; + BadNode bad_node; // used + uint placeholder; +} x; + +void main() { + x.placeholder = 0; + x.first_node.next.payload = 3; +} diff --git a/tests/variable_access/phy_storage_buffer_used_1.spv b/tests/variable_access/phy_storage_buffer_used_1.spv new file mode 100644 index 0000000000000000000000000000000000000000..13c9e8b1471acb326f78321b39fa2ee54201fdff GIT binary patch literal 1204 zcmY+DTWb?h6oq#))ASPU)p|Fi_Q8ij=|dGkELe~f3@S#%w_%!@*ua>CObYGa>t9j- zgD-;XJ2PjJoU*&mUT5uf);^sEwSyJ2C2QEKHLY0NRuf`I{&ml6-PWx8`CIhi{7W>x zyvYZ>IE(V>XcGTOql>G4Kb?rvs5py96|TLxaAA$O6s&55^wqos0^#1$T(pfY~Ydem#` z>vqpRDM`KVYWDrXB%emZQIgJZ?z@PS5}o1PJ1K!allgc+0L9WW)4& zO7<9<nvX7M`gS@Swz^E&k4+xPex=6k>vdqU@ZUpT9+H)NLQt}@$|8hZQE4wTuy z(5|lhN8b#4eaLRVr(Wi1DOk;Neza9zDOM+UtW;-%%!b+c#y6 zXD~c$D7O?#io>$r)E@8D+{+uY(Br$N7u@rAwP$gzG2J)~M^cycb3g*G{sTkDwused_var = 1; +} diff --git a/tests/variable_access/phy_storage_buffer_used_2.spv b/tests/variable_access/phy_storage_buffer_used_2.spv new file mode 100644 index 0000000000000000000000000000000000000000..10a3c832fb831e3b685e7ba0bda8222114eeeaf7 GIT binary patch literal 1020 zcmYk5SxZAf429Fy)_vav#pOZ47X=YP6huKm1X1wyGPYF<-MEY3?^XYUFM{X0cSfBO zW^$68oTP1~yftXmlI@t;s*E#jWqY41?vnfw8@Bt~hv@q1F6zI$C9S$^M@ia?-E%W~ z%$}Z_u}xUTK2$^gq}8mdyDaOtR#%se%BF;aP0Pp&R#7c+{HjTg?#p)X(Y0?~>^g~h zHTDnoR9)~YYz>#XsGr8XYrcm1fJa%9CC$cf4Sn-ilEzs*RgYTU^Z8#NxT^Y)Tkm!H zS=zioKDk4}F6h~HX%@RSx#$7sWL?@tuTF{rj-EeMGueQY5;wgHf7tu*Txt(tZ&$ez zfjV2oWdVa1jGBO<8Ei^MANIK+;{<=RaC3iI@1O&YFvtI1V4)X!XSEsp4e6}-*t~kd zvo7PT`x!s=TL9lyCNtu%`I*=O22TEnZuB!dd}BFY^xpOUxG)a+6S~QVgE)O=WF_xY zuXcG3`SbowzreSoH~GZb1^TF4lh53|3mpT$`oWJCM=$$D!=Y5e!<)lizT~m5GsVz4 zDI=d5P82~m-xK(`a`5?2fRS@544;|c4P4BzAcKqf;9{ml894ozWyNF62p2x@!1XP~ GN3tJhu225} literal 0 HcmV?d00001 diff --git a/tests/variable_access/phy_storage_buffer_used_2.spv.yaml b/tests/variable_access/phy_storage_buffer_used_2.spv.yaml new file mode 100644 index 0000000..4ed8046 --- /dev/null +++ b/tests/variable_access/phy_storage_buffer_used_2.spv.yaml @@ -0,0 +1,291 @@ +%YAML 1.1 +--- +all_type_descriptions: + - &td0 + id: 7 + op: 32 + type_name: + struct_member_name: "data_ptr" + storage_class: 5349 # PhysicalStorageBuffer + type_flags: 0x40000004 # REF INT + decoration_flags: 0x00000000 # NONE + traits: + numeric: + scalar: { width: 32, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + array: { dims_count: 0, dims: [], stride: 0 } + member_count: 0 + members: + - &td1 + id: 7 + op: 32 + type_name: + struct_member_name: "data_ptr_usused" + storage_class: 5349 # PhysicalStorageBuffer + type_flags: 0x40000004 # REF INT + decoration_flags: 0x00000000 # NONE + traits: + numeric: + scalar: { width: 32, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + array: { dims_count: 0, dims: [], stride: 0 } + member_count: 0 + members: + - &td2 + id: 12 + op: 21 + type_name: + struct_member_name: "unused_var" + storage_class: 0 # UniformConstant + type_flags: 0x00000004 # INT + decoration_flags: 0x00000000 # NONE + traits: + numeric: + scalar: { width: 32, signedness: 1 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + array: { dims_count: 0, dims: [], stride: 0 } + member_count: 0 + members: + - &td3 + id: 12 + op: 21 + type_name: + struct_member_name: "used_var" + storage_class: 0 # UniformConstant + type_flags: 0x00000004 # INT + decoration_flags: 0x00000000 # NONE + traits: + numeric: + scalar: { width: 32, signedness: 1 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + array: { dims_count: 0, dims: [], stride: 0 } + member_count: 0 + members: + - &td4 + id: 9 + op: 32 + type_name: "Data_natural" + struct_member_name: "data_struct" + storage_class: 5349 # PhysicalStorageBuffer + type_flags: 0x50080000 # STRUCT REF EXTERNAL_BLOCK + decoration_flags: 0x00000000 # NONE + traits: + numeric: + scalar: { width: 0, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + array: { dims_count: 0, dims: [], stride: 0 } + member_count: 2 + members: + - *td2 + - *td3 + - &td5 + id: 5 + op: 30 + type_name: "GlobalParams_std140" + struct_member_name: + storage_class: -1 # NOT APPLICABLE + type_flags: 0x10080000 # STRUCT EXTERNAL_BLOCK + decoration_flags: 0x00000001 # BLOCK + traits: + numeric: + scalar: { width: 0, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + array: { dims_count: 0, dims: [], stride: 0 } + member_count: 3 + members: + - *td0 + - *td1 + - *td4 + - &td6 + id: 12 + op: 21 + type_name: + struct_member_name: "unused_var" + storage_class: 0 # UniformConstant + type_flags: 0x00000004 # INT + decoration_flags: 0x00000000 # NONE + traits: + numeric: + scalar: { width: 32, signedness: 1 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + array: { dims_count: 0, dims: [], stride: 0 } + member_count: 0 + members: + - &td7 + id: 12 + op: 21 + type_name: + struct_member_name: "used_var" + storage_class: 0 # UniformConstant + type_flags: 0x00000004 # INT + decoration_flags: 0x00000000 # NONE + traits: + numeric: + scalar: { width: 32, signedness: 1 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + array: { dims_count: 0, dims: [], stride: 0 } + member_count: 0 + members: +all_block_variables: + - &bv0 + name: "data_ptr" + offset: 0 + absolute_offset: 0 + size: 8 + padded_size: 8 + decorations: 0x00000000 # NONE + numeric: + scalar: { width: 32, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + array: { dims_count: 0, dims: [], stride: 0 } + flags: 0x00000000 # NONE + member_count: 0 + members: + type_description: *td0 + - &bv1 + name: "data_ptr_usused" + offset: 8 + absolute_offset: 8 + size: 8 + padded_size: 8 + decorations: 0x00000000 # NONE + numeric: + scalar: { width: 32, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + array: { dims_count: 0, dims: [], stride: 0 } + flags: 0x00000001 # UNUSED + member_count: 0 + members: + type_description: *td1 + - &bv2 + name: "unused_var" + offset: 0 + absolute_offset: 0 + size: 4 + padded_size: 4 + decorations: 0x00000000 # NONE + numeric: + scalar: { width: 32, signedness: 1 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + array: { dims_count: 0, dims: [], stride: 0 } + flags: 0x00000001 # UNUSED + member_count: 0 + members: + type_description: *td6 + - &bv3 + name: "used_var" + offset: 4 + absolute_offset: 4 + size: 4 + padded_size: 12 + decorations: 0x00000000 # NONE + numeric: + scalar: { width: 32, signedness: 1 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + array: { dims_count: 0, dims: [], stride: 0 } + flags: 0x00000001 # UNUSED + member_count: 0 + members: + type_description: *td7 + - &bv4 + name: "data_struct" + offset: 16 + absolute_offset: 16 + size: 8 + padded_size: 16 + decorations: 0x00000000 # NONE + numeric: + scalar: { width: 0, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + array: { dims_count: 0, dims: [], stride: 0 } + flags: 0x00000000 # NONE + member_count: 2 + members: + - *bv2 + - *bv3 + type_description: *td4 + - &bv5 + name: "globalParams" + offset: 0 + absolute_offset: 0 + size: 32 + padded_size: 32 + decorations: 0x00000000 # NONE + numeric: + scalar: { width: 0, signedness: 0 } + vector: { component_count: 0 } + matrix: { column_count: 0, row_count: 0, stride: 0 } + array: { dims_count: 0, dims: [], stride: 0 } + flags: 0x00000000 # NONE + member_count: 3 + members: + - *bv0 + - *bv1 + - *bv4 + type_description: *td5 +all_descriptor_bindings: + - &db0 + spirv_id: 11 + name: "globalParams" + binding: 0 + input_attachment_index: 0 + set: 0 + decoration_flags: 0x00000000 # NONE + descriptor_type: 6 # VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER + resource_type: 2 # CBV + image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown + block: *bv5 # "globalParams" + array: { dims_count: 0, dims: [] } + accessed: 1 + uav_counter_id: 4294967295 + uav_counter_binding: + type_description: *td5 + word_offset: { binding: 120, set: 124 } +all_interface_variables: +module: + generator: 0 # ??? + entry_point_name: "main" + entry_point_id: 2 + source_language: 11 # Unknown + source_language_version: 1 + spirv_execution_model: 5 # GLCompute + shader_stage: 0x00000020 # CS + descriptor_binding_count: 1 + descriptor_bindings: + - *db0 # "globalParams" + descriptor_set_count: 1 + descriptor_sets: + - set: 0 + binding_count: 1 + bindings: + - *db0 # "globalParams" + input_variable_count: 0, + input_variables: + output_variable_count: 0, + output_variables: + push_constant_count: 0, + push_constants: + specialization_constant_count: 0, + specialization_constants: +... diff --git a/tests/variable_access/phy_storage_buffer_used_3.slang b/tests/variable_access/phy_storage_buffer_used_3.slang new file mode 100644 index 0000000..e7bfbbe --- /dev/null +++ b/tests/variable_access/phy_storage_buffer_used_3.slang @@ -0,0 +1,20 @@ +struct DataUsed{ + int unused_var_2; + int used_var_2; +}; + +struct DataUnused{ + int unused_var_3; +}; + +struct Data{ + DataUnused unused_struct; + DataUsed used_struct; +} +uniform Data* data_struct; + +[numthreads(1,1,1)] +void computeMain() +{ + data_struct->used_struct.used_var_2 = 1; +} diff --git a/tests/variable_access/phy_storage_buffer_used_3.spv b/tests/variable_access/phy_storage_buffer_used_3.spv new file mode 100644 index 0000000000000000000000000000000000000000..84dfcd291523ff709ac943c4ad87bbe7517c862f GIT binary patch literal 1040 zcmZ9L-D^`p5XC2-YOHBul=>v5d9cuz)`|$Ff*>Ryg`nu`W%JoWKFZC#1^-^#|G^i* z^SisNFw%J+iOE@5$%Em*nQ^$L4zM z7Re@Cr*1w?M)_CXsYznw-8p5!>r3Z4;L{;b}h3R9`Rj=UW_VYWkz!c)h&Iv*{(Hpno9jllb3O z`DQvvRxZm^w=k*r9NgUJZe5z35yNZgE_na3JdYe_i}!|@naQzh(G5jqn7J+ty?+yU zEpSfI3R`+Da(}f#rf*eEN8W5t*4KN+_aDf^=k)xge6@J5?oNET74wbIdnlv66XL3F zG