Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #30

Merged
merged 2 commits into from
Oct 10, 2024
Merged

Dev #30

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions common/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
#include <stdint.h>
#include <vulkan/vulkan.h>

#define VKSP_EXTINST_STR "NonSemantic.VkspReflection.4"

#define PRINT_IMPL(file, message, ...) \
do { \
fprintf(file, "[VKSP] %s: " message "\n", __func__, ##__VA_ARGS__); \
Expand Down
182 changes: 97 additions & 85 deletions common/spirv-extract.hpp

Large diffs are not rendered by default.

186 changes: 96 additions & 90 deletions extractor/spirv.cpp

Large diffs are not rendered by default.

29 changes: 19 additions & 10 deletions tests/checksum.spvasm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "NonSemantic.ClspvReflection.5"
%82 = OpExtInstImport "NonSemantic.VkspReflection.2"
%82 = OpExtInstImport "NonSemantic.VkspReflection.4"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %2 "test_simple" %gl_GlobalInvocationID %4 %5 %6 %7

Expand Down Expand Up @@ -76,15 +76,24 @@
%7 = OpVariable %_ptr_PushConstant__struct_18 PushConstant
%5 = OpVariable %_ptr_StorageBuffer__struct_20 StorageBuffer
%6 = OpVariable %_ptr_StorageBuffer__struct_20 StorageBuffer
%83 = OpExtInst %void %82 Configuration ".VK_KHR_8bit_storage.VK_KHR_16bit_storage.VK_KHR_buffer_device_address.VK_KHR_driver_properties.VK_KHR_shader_float16_int8.VK_KHR_shader_float_controls.VK_KHR_shader_non_semantic_info.VK_KHR_storage_buffer_storage_class.VK_KHR_uniform_buffer_standard_layout.VK_KHR_variable_pointers.VK_KHR_vulkan_memory_model.VK_EXT_calibrated_timestamps.VK_EXT_descriptor_indexing" 12 "020000000100000001000000" "vksp_s0" "test_simple" 16 1 1 0
%84 = OpExtInst %void %82 PushConstants 16 12 "000000000000000000000000" 32
%85 = OpExtInst %void %82 PushConstants 32 4 "20000000" 32
%86 = OpExtInst %void %82 PushConstants 0 12 "000000000000000000000000" 32
%87 = OpExtInst %void %82 DescriptorSetBuffer 0 0 7 0 0 0 4096 63 4096 0 4096 0 0 0 0
%88 = OpExtInst %void %82 DescriptorSetBuffer 0 1 7 0 0 0 128 63 128 0 128 0 0 0 0
%89 = OpExtInst %void %82 SpecializationMapEntry 0 0 4
%90 = OpExtInst %void %82 SpecializationMapEntry 1 4 4
%91 = OpExtInst %void %82 SpecializationMapEntry 2 8 4
%173 = OpString ".VK_KHR_8bit_storage.VK_KHR_16bit_storage.VK_KHR_buffer_device_address.VK_KHR_driver_properties.VK_KHR_shader_float16_int8.VK_KHR_shader_float_controls.VK_KHR_shader_non_semantic_info.VK_KHR_storage_buffer_storage_class.VK_KHR_uniform_buffer_standard_layout.VK_KHR_variable_pointers.VK_KHR_vulkan_memory_model.VK_EXT_calibrated_timestamps.VK_EXT_descriptor_indexing.VK_KHR_shader_clock"
%174 = OpString "020000000100000001000000"
%175 = OpString "vksp_s0"
%176 = OpString "test_simple"
%uint_36 = OpConstant %uint 36
%179 = OpString "000000000000000000000000000000000000000000000000000000000000000020000000"
%uint_7 = OpConstant %uint 7
%uint_4096 = OpConstant %uint 4096
%uint_63 = OpConstant %uint 63
%uint_128 = OpConstant %uint 128
%uint_8 = OpConstant %uint 8
%172 = OpExtInst %void %82 Configuration %173 %uint_12 %174 %175 %176 %uint_16 %uint_1 %uint_1 %uint_0
%177 = OpExtInst %void %82 PushConstants %uint_0 %uint_36 %179 %uint_32
%180 = OpExtInst %void %82 DescriptorSetBuffer %uint_0 %uint_0 %uint_7 %uint_0 %uint_0 %uint_0 %uint_4096 %uint_63 %uint_4096 %uint_0 %uint_4096 %uint_0 %uint_0 %uint_0 %uint_0
%184 = OpExtInst %void %82 DescriptorSetBuffer %uint_0 %uint_1 %uint_7 %uint_0 %uint_0 %uint_0 %uint_128 %uint_63 %uint_128 %uint_0 %uint_128 %uint_0 %uint_0 %uint_0 %uint_0
%186 = OpExtInst %void %82 SpecializationMapEntry %uint_0 %uint_0 %uint_4
%187 = OpExtInst %void %82 SpecializationMapEntry %uint_1 %uint_4 %uint_4
%188 = OpExtInst %void %82 SpecializationMapEntry %uint_2 %uint_8 %uint_4

; Function 2
%2 = OpFunction %void None %31
Expand Down
31 changes: 22 additions & 9 deletions tests/example-counter.spvasm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
; Schema: 0
OpCapability Shader
%1 = OpExtInstImport "NonSemantic.ClspvReflection.5"
%49 = OpExtInstImport "NonSemantic.VkspReflection.2"
%49 = OpExtInstImport "NonSemantic.VkspReflection.4"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %2 "test_simple" %gl_GlobalInvocationID %4 %5 %6

Expand Down Expand Up @@ -61,13 +61,26 @@
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
%4 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize
%5 = OpVariable %_ptr_StorageBuffer__struct_14 StorageBuffer
%50 = OpExtInst %void %49 Configuration ".VK_KHR_8bit_storage.VK_KHR_16bit_storage.VK_KHR_buffer_device_address.VK_KHR_driver_properties.VK_KHR_shader_float16_int8.VK_KHR_shader_float_controls.VK_KHR_shader_non_semantic_info.VK_KHR_storage_buffer_storage_class.VK_KHR_uniform_buffer_standard_layout.VK_KHR_variable_pointers.VK_KHR_vulkan_memory_model.VK_EXT_calibrated_timestamps.VK_EXT_descriptor_indexing" 12 "020000000100000001000000" "vksp_s0" "test_simple" 128 1 1 0
%51 = OpExtInst %void %49 PushConstants 16 12 "000000000000000000000000" 32
%52 = OpExtInst %void %49 PushConstants 0 12 "000000000000000000000000" 32
%53 = OpExtInst %void %49 DescriptorSetBuffer 0 0 7 0 0 0 1024 63 1024 0 1024 0 0 0 0
%54 = OpExtInst %void %49 SpecializationMapEntry 0 0 4
%55 = OpExtInst %void %49 SpecializationMapEntry 1 4 4
%56 = OpExtInst %void %49 SpecializationMapEntry 2 8 4
%counterName = OpString "my_section"
%144 = OpString ".VK_KHR_8bit_storage.VK_KHR_16bit_storage.VK_KHR_buffer_device_address.VK_KHR_driver_properties.VK_KHR_shader_float16_int8.VK_KHR_shader_float_controls.VK_KHR_shader_non_semantic_info.VK_KHR_storage_buffer_storage_class.VK_KHR_uniform_buffer_standard_layout.VK_KHR_variable_pointers.VK_KHR_vulkan_memory_model.VK_EXT_calibrated_timestamps.VK_EXT_descriptor_indexing.VK_KHR_shader_clock"
%145 = OpString "020000000100000001000000"
%146 = OpString "vksp_s0"
%147 = OpString "test_simple"
%uint_128 = OpConstant %uint 128
%uint_28 = OpConstant %uint 28
%151 = OpString "00000000000000000000000000000000000000000000000000000000"
%uint_32 = OpConstant %uint 32
%uint_7 = OpConstant %uint 7
%uint_1024 = OpConstant %uint 1024
%uint_63 = OpConstant %uint 63
%uint_4 = OpConstant %uint 4
%uint_8 = OpConstant %uint 8
%143 = OpExtInst %void %49 Configuration %144 %uint_12 %145 %146 %147 %uint_128 %uint_1 %uint_1 %uint_0
%149 = OpExtInst %void %49 PushConstants %uint_0 %uint_28 %151 %uint_32
%153 = OpExtInst %void %49 DescriptorSetBuffer %uint_0 %uint_0 %uint_7 %uint_0 %uint_0 %uint_0 %uint_1024 %uint_63 %uint_1024 %uint_0 %uint_1024 %uint_0 %uint_0 %uint_0 %uint_0
%157 = OpExtInst %void %49 SpecializationMapEntry %uint_0 %uint_0 %uint_4
%159 = OpExtInst %void %49 SpecializationMapEntry %uint_1 %uint_4 %uint_4
%160 = OpExtInst %void %49 SpecializationMapEntry %uint_2 %uint_8 %uint_4

; Function 2
%2 = OpFunction %void None %25
Expand All @@ -76,7 +89,7 @@
%38 = OpLoad %uint %37
%39 = OpAccessChain %_ptr_PushConstant_uint %6 %uint_1 %uint_0
%40 = OpLoad %uint %39
%counter = OpExtInst %void %49 StartCounter "my_section"
%counter = OpExtInst %void %49 StartCounter %counterName
%41 = OpIAdd %uint %40 %38
%unused = OpExtInst %void %49 StopCounter %counter
%42 = OpAccessChain %_ptr_StorageBuffer_uint %5 %uint_0 %41
Expand Down
118 changes: 68 additions & 50 deletions tests/example-expectation.spvasm
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
; SPIR-V
; Version: 1.6
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 66
; Bound: 84
; Schema: 0
OpCapability Shader
OpCapability ShaderClockKHR
OpCapability Int64
OpCapability Int64Atomics
OpExtension "SPV_KHR_shader_clock"
OpExtension "SPV_KHR_storage_buffer_storage_class"
%58 = OpExtInstImport "NonSemantic.VkspReflection.2"
%70 = OpExtInstImport "NonSemantic.VkspReflection.4"
OpMemoryModel Logical GLSL450
OpEntryPoint GLCompute %1 "test_simple" %gl_GlobalInvocationID %3 %4 %5 %6

Expand All @@ -19,43 +19,48 @@
%8 = OpString " kernel"
%9 = OpString "out"
%10 = OpString "uint*"
%11 = OpString ".VK_KHR_8bit_storage.VK_KHR_16bit_storage.VK_KHR_buffer_device_address.VK_KHR_driver_properties.VK_KHR_shader_float16_int8.VK_KHR_shader_float_controls.VK_KHR_shader_non_semantic_info.VK_KHR_storage_buffer_storage_class.VK_KHR_uniform_buffer_standard_layout.VK_KHR_variable_pointers.VK_KHR_vulkan_memory_model.VK_EXT_calibrated_timestamps.VK_EXT_descriptor_indexing.VK_KHR_shader_clock"
%12 = OpString "020000000100000001000000"
%13 = OpString "vksp_s0"
%14 = OpString "test_simple"
%15 = OpString "00000000000000000000000000000000000000000000000000000000"

; Annotations
OpMemberDecorate %_struct_11 0 Offset 0
OpMemberDecorate %_struct_11 1 Offset 16
OpDecorate %_struct_11 Block
OpMemberDecorate %_struct_16 0 Offset 0
OpMemberDecorate %_struct_16 1 Offset 16
OpDecorate %_struct_16 Block
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
OpDecorate %gl_WorkGroupSize BuiltIn WorkgroupSize
OpDecorate %_runtimearr_uint ArrayStride 4
OpMemberDecorate %_struct_14 0 Offset 0
OpDecorate %_struct_14 Block
OpMemberDecorate %_struct_19 0 Offset 0
OpDecorate %_struct_19 Block
OpDecorate %4 DescriptorSet 0
OpDecorate %4 Binding 0
OpDecorate %15 SpecId 0
OpDecorate %16 SpecId 1
OpDecorate %17 SpecId 2
OpDecorate %20 SpecId 0
OpDecorate %21 SpecId 1
OpDecorate %22 SpecId 2
OpDecorate %_runtimearr_ulong ArrayStride 8
OpMemberDecorate %_struct_19 0 Offset 0
OpDecorate %_struct_19 Block
OpMemberDecorate %_struct_24 0 Offset 0
OpDecorate %_struct_24 Block
OpDecorate %6 DescriptorSet 0
OpDecorate %6 Binding 1

; Types, variables and constants
%uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3
%_struct_11 = OpTypeStruct %v3uint %v3uint ; Block
%_ptr_PushConstant__struct_11 = OpTypePointer PushConstant %_struct_11
%_struct_16 = OpTypeStruct %v3uint %v3uint ; Block
%_ptr_PushConstant__struct_16 = OpTypePointer PushConstant %_struct_16
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
%15 = OpSpecConstant %uint 1 ; SpecId 0
%16 = OpSpecConstant %uint 1 ; SpecId 1
%17 = OpSpecConstant %uint 1 ; SpecId 2
%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %15 %16 %17 ; BuiltIn WorkgroupSize
%20 = OpSpecConstant %uint 1 ; SpecId 0
%21 = OpSpecConstant %uint 1 ; SpecId 1
%22 = OpSpecConstant %uint 1 ; SpecId 2
%gl_WorkGroupSize = OpSpecConstantComposite %v3uint %20 %21 %22 ; BuiltIn WorkgroupSize
%_ptr_Private_v3uint = OpTypePointer Private %v3uint
%_runtimearr_uint = OpTypeRuntimeArray %uint ; ArrayStride 4
%_struct_14 = OpTypeStruct %_runtimearr_uint ; Block
%_ptr_StorageBuffer__struct_14 = OpTypePointer StorageBuffer %_struct_14
%_struct_19 = OpTypeStruct %_runtimearr_uint ; Block
%_ptr_StorageBuffer__struct_19 = OpTypePointer StorageBuffer %_struct_19
%void = OpTypeVoid
%27 = OpTypeFunction %void
%32 = OpTypeFunction %void
%_ptr_Input_uint = OpTypePointer Input %uint
%uint_0 = OpConstant %uint 0
%_ptr_PushConstant_uint = OpTypePointer PushConstant %uint
Expand All @@ -66,43 +71,56 @@
%uint_12 = OpConstant %uint 12
%uint_16 = OpConstant %uint 16
%uint_2 = OpConstant %uint 2
%5 = OpVariable %_ptr_PushConstant__struct_11 PushConstant
%5 = OpVariable %_ptr_PushConstant__struct_16 PushConstant
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input ; BuiltIn GlobalInvocationId
%3 = OpVariable %_ptr_Private_v3uint Private %gl_WorkGroupSize
%4 = OpVariable %_ptr_StorageBuffer__struct_14 StorageBuffer ; DescriptorSet 0, Binding 0
%4 = OpVariable %_ptr_StorageBuffer__struct_19 StorageBuffer ; DescriptorSet 0, Binding 0
%uint_128 = OpConstant %uint 128
%uint_28 = OpConstant %uint 28
%uint_32 = OpConstant %uint 32
%uint_7 = OpConstant %uint 7
%uint_1024 = OpConstant %uint 1024
%uint_63 = OpConstant %uint 63
%uint_4 = OpConstant %uint 4
%uint_8 = OpConstant %uint 8
%ulong = OpTypeInt 64 0
%_runtimearr_ulong = OpTypeRuntimeArray %ulong ; ArrayStride 8
%_struct_19 = OpTypeStruct %_runtimearr_ulong ; Block
%_ptr_StorageBuffer__struct_19 = OpTypePointer StorageBuffer %_struct_19
%_struct_24 = OpTypeStruct %_runtimearr_ulong ; Block
%_ptr_StorageBuffer__struct_24 = OpTypePointer StorageBuffer %_struct_24
%_ptr_StorageBuffer_ulong = OpTypePointer StorageBuffer %ulong
%uint_3 = OpConstant %uint 3
%uint_8 = OpConstant %uint 8
%6 = OpVariable %_ptr_StorageBuffer__struct_19 StorageBuffer ; DescriptorSet 0, Binding 1
%6 = OpVariable %_ptr_StorageBuffer__struct_24 StorageBuffer ; DescriptorSet 0, Binding 1
%ulong_0 = OpConstant %ulong 0
%59 = OpExtInst %void %58 Configuration ".VK_KHR_8bit_storage.VK_KHR_16bit_storage.VK_KHR_buffer_device_address.VK_KHR_driver_properties.VK_KHR_shader_float16_int8.VK_KHR_shader_float_controls.VK_KHR_shader_non_semantic_info.VK_KHR_storage_buffer_storage_class.VK_KHR_uniform_buffer_standard_layout.VK_KHR_variable_pointers.VK_KHR_vulkan_memory_model.VK_EXT_calibrated_timestamps.VK_EXT_descriptor_indexing.VK_KHR_shader_clock" 12 "020000000100000001000000" "vksp_s0" "test_simple" 128 1 1 0
%60 = OpExtInst %void %58 PushConstants 0 28 "00000000000000000000000000000000000000000000000000000000" 32
%61 = OpExtInst %void %58 DescriptorSetBuffer 0 0 7 0 0 0 1024 63 1024 0 1024 0 0 0 0
%62 = OpExtInst %void %58 DescriptorSetBuffer 0 1 7 0 0 0 16 34 16 0 16 0 0 0 0
%63 = OpExtInst %void %58 SpecializationMapEntry 0 0 4
%64 = OpExtInst %void %58 SpecializationMapEntry 1 4 4
%65 = OpExtInst %void %58 SpecializationMapEntry 2 8 4
%72 = OpString ".VK_KHR_8bit_storage.VK_KHR_16bit_storage.VK_KHR_buffer_device_address.VK_KHR_driver_properties.VK_KHR_shader_float16_int8.VK_KHR_shader_float_controls.VK_KHR_shader_non_semantic_info.VK_KHR_storage_buffer_storage_class.VK_KHR_uniform_buffer_standard_layout.VK_KHR_variable_pointers.VK_KHR_vulkan_memory_model.VK_EXT_calibrated_timestamps.VK_EXT_descriptor_indexing.VK_KHR_shader_clock.VK_KHR_shader_clock"
%73 = OpString "020000000100000001000000"
%74 = OpString "vksp_s0"
%75 = OpString "test_simple"
%77 = OpString "00000000000000000000000000000000000000000000000000000000"
%uint_34 = OpConstant %uint 34
%71 = OpExtInst %void %70 Configuration %72 %uint_12 %73 %74 %75 %uint_128 %uint_1 %uint_1 %uint_0
%76 = OpExtInst %void %70 PushConstants %uint_0 %uint_28 %77 %uint_32
%78 = OpExtInst %void %70 DescriptorSetBuffer %uint_0 %uint_0 %uint_7 %uint_0 %uint_0 %uint_0 %uint_1024 %uint_63 %uint_1024 %uint_0 %uint_1024 %uint_0 %uint_0 %uint_0 %uint_0
%79 = OpExtInst %void %70 DescriptorSetBuffer %uint_0 %uint_1 %uint_7 %uint_0 %uint_0 %uint_0 %uint_16 %uint_34 %uint_16 %uint_0 %uint_16 %uint_0 %uint_0 %uint_0 %uint_0
%81 = OpExtInst %void %70 SpecializationMapEntry %uint_0 %uint_0 %uint_4
%82 = OpExtInst %void %70 SpecializationMapEntry %uint_1 %uint_4 %uint_4
%83 = OpExtInst %void %70 SpecializationMapEntry %uint_2 %uint_8 %uint_4

; Function 1
%1 = OpFunction %void None %27
%44 = OpLabel
%45 = OpReadClockKHR %ulong %uint_3
%46 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0
%47 = OpLoad %uint %46
%48 = OpAccessChain %_ptr_PushConstant_uint %5 %uint_1 %uint_0
%49 = OpLoad %uint %48
%50 = OpIAdd %uint %49 %47
%51 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %50
OpStore %51 %50
%52 = OpReadClockKHR %ulong %uint_3
%53 = OpISub %ulong %52 %45
%54 = OpAccessChain %_ptr_StorageBuffer_ulong %6 %uint_0 %uint_0
%55 = OpAtomicIIncrement %ulong %54 %uint_1 %uint_8
%56 = OpAccessChain %_ptr_StorageBuffer_ulong %6 %uint_0 %uint_1
%57 = OpAtomicIAdd %ulong %56 %uint_1 %uint_8 %53
%1 = OpFunction %void None %32
%56 = OpLabel
%57 = OpReadClockKHR %ulong %uint_3
%58 = OpAccessChain %_ptr_Input_uint %gl_GlobalInvocationID %uint_0
%59 = OpLoad %uint %58
%60 = OpAccessChain %_ptr_PushConstant_uint %5 %uint_1 %uint_0
%61 = OpLoad %uint %60
%62 = OpIAdd %uint %61 %59
%63 = OpAccessChain %_ptr_StorageBuffer_uint %4 %uint_0 %62
OpStore %63 %62
%64 = OpReadClockKHR %ulong %uint_3
%65 = OpISub %ulong %64 %57
%66 = OpAccessChain %_ptr_StorageBuffer_ulong %6 %uint_0 %uint_0
%67 = OpAtomicIIncrement %ulong %66 %uint_1 %uint_8
%68 = OpAccessChain %_ptr_StorageBuffer_ulong %6 %uint_0 %uint_1
%69 = OpAtomicIAdd %ulong %68 %uint_1 %uint_8 %65
OpReturn
OpFunctionEnd
Loading