├── .clang-format ├── .git-blame-ignore-revs ├── .github └── workflows │ ├── check-formatting.yml │ ├── linux-cmake-build.yml │ └── windows-cmake-build.yml ├── .gitignore ├── .gitmodules ├── CMakeLists.txt ├── CODE_OF_CONDUCT.adoc ├── LICENSE ├── README.md ├── SECURITY.md ├── common ├── output_stream.cpp └── output_stream.h ├── examples ├── CMakeLists.txt ├── arg_parser.cpp ├── arg_parser.h ├── build_sample_spv_h.sh ├── common.cpp ├── common.h ├── main_descriptors.cpp ├── main_explorer.cpp ├── main_hlsl_resource_types.cpp ├── main_io_variables.cpp ├── sample.hlsl ├── sample.spv └── sample_spv.h ├── include └── spirv │ └── unified1 │ └── spirv.h ├── main.cpp ├── spirv_reflect.c ├── spirv_reflect.cpp ├── spirv_reflect.h └── tests ├── 16bit ├── vert_in_out_16.spv ├── vert_in_out_16.spv.yaml └── vert_in_out_16.vert ├── access_chains ├── array_length_from_access_chain.spv ├── array_length_from_access_chain.spv.yaml ├── pointer_access_chain_phy_storage_buffer.slang ├── pointer_access_chain_phy_storage_buffer.spv └── pointer_access_chain_phy_storage_buffer.spv.yaml ├── build_all_shaders.py ├── build_golden_yaml.py ├── cbuffer_unused ├── cbuffer_unused_001.hlsl ├── cbuffer_unused_001.spv └── cbuffer_unused_001.spv.yaml ├── ci_database.py ├── cpp └── noncopyable │ ├── CMakeLists.txt │ └── main.cpp ├── entry_exec_mode ├── comp_local_size.glsl ├── comp_local_size.spv ├── comp_local_size.spv.yaml ├── geom_inv_out_vert.glsl ├── geom_inv_out_vert.spv └── geom_inv_out_vert.spv.yaml ├── execution_mode ├── local_size_id.spv ├── local_size_id.spv.yaml ├── local_size_id_spec.spv └── local_size_id_spec.spv.yaml ├── glsl ├── buffer_handle_0.glsl ├── buffer_handle_0.spv ├── buffer_handle_0.spv.yaml ├── buffer_handle_1.glsl ├── buffer_handle_1.spv ├── buffer_handle_1.spv.yaml ├── buffer_handle_2.glsl ├── buffer_handle_2.spv ├── buffer_handle_2.spv.yaml ├── buffer_handle_3.glsl ├── buffer_handle_3.spv ├── buffer_handle_3.spv.yaml ├── buffer_handle_4.glsl ├── buffer_handle_4.spv ├── buffer_handle_4.spv.yaml ├── buffer_handle_5.glsl ├── buffer_handle_5.spv ├── buffer_handle_5.spv.yaml ├── buffer_handle_6.glsl ├── buffer_handle_6.spv ├── buffer_handle_6.spv.yaml ├── buffer_handle_7.glsl ├── buffer_handle_7.spv ├── buffer_handle_7.spv.yaml ├── buffer_handle_8.glsl ├── buffer_handle_8.spv ├── buffer_handle_8.spv.yaml ├── buffer_handle_9.glsl ├── buffer_handle_9.spv ├── buffer_handle_9.spv.yaml ├── buffer_handle_uvec2_pc.glsl ├── buffer_handle_uvec2_pc.spv ├── buffer_handle_uvec2_pc.spv.yaml ├── buffer_handle_uvec2_ssbo.glsl ├── buffer_handle_uvec2_ssbo.spv ├── buffer_handle_uvec2_ssbo.spv.yaml ├── buffer_pointer.glsl ├── buffer_pointer.spv ├── buffer_pointer.spv.yaml ├── buffer_pointer.txt ├── built_in_format.glsl ├── built_in_format.spv ├── built_in_format.spv.yaml ├── fn_struct_param.glsl ├── fn_struct_param.spv ├── fn_struct_param.spv.yaml ├── frag_array_input.glsl ├── frag_array_input.spv ├── frag_array_input.spv.yaml ├── frag_barycentric.glsl ├── frag_barycentric.spv ├── frag_barycentric.spv.yaml ├── input_attachment.glsl ├── input_attachment.spv ├── input_attachment.spv.yaml ├── input_attachment.txt ├── io_vars_vs.glsl ├── io_vars_vs.spv ├── io_vars_vs.spv.yaml ├── matrix_major_order_glsl.glsl ├── matrix_major_order_glsl.spv ├── matrix_major_order_glsl.spv.yaml ├── non_writable_image.glsl ├── non_writable_image.spv ├── non_writable_image.spv.yaml ├── readonly_writeonly.glsl ├── readonly_writeonly.spv ├── readonly_writeonly.spv.yaml ├── runtime_array_of_array_of_struct.glsl ├── runtime_array_of_array_of_struct.spv ├── runtime_array_of_array_of_struct.spv.yaml ├── storage_buffer.glsl ├── storage_buffer.spv ├── storage_buffer.spv.yaml ├── storage_buffer.txt ├── struct_offset_order.glsl ├── struct_offset_order.spv ├── struct_offset_order.spv.yaml ├── texel_buffer.glsl ├── texel_buffer.spv ├── texel_buffer.spv.yaml └── texel_buffer.txt ├── hlsl ├── append_consume.hlsl ├── append_consume.spv ├── append_consume.spv.yaml ├── append_consume.txt ├── array_of_structured_buffer.hlsl ├── array_of_structured_buffer.spv ├── array_of_structured_buffer.spv.yaml ├── binding_array.hlsl ├── binding_array.spv ├── binding_array.spv.yaml ├── binding_array.txt ├── binding_types.hlsl ├── binding_types.spv ├── binding_types.spv.yaml ├── binding_types.txt ├── binding_types_hlsl_resource_types.txt ├── cbuffer.hlsl ├── cbuffer.spv ├── cbuffer.spv.yaml ├── constantbuffer.hlsl ├── constantbuffer.spv ├── constantbuffer.spv.yaml ├── constantbuffer_nested_structs.hlsl ├── constantbuffer_nested_structs.spv ├── constantbuffer_nested_structs.spv.yaml ├── counter_buffers.hlsl ├── counter_buffers.spv ├── counter_buffers.spv.yaml ├── localsize.hlsl ├── localsize.spv ├── localsize.spv.yaml ├── matrix_major_order_hlsl.hlsl ├── matrix_major_order_hlsl.spv ├── matrix_major_order_hlsl.spv.yaml ├── pushconstant.hlsl ├── pushconstant.spv ├── pushconstant.spv.yaml ├── semantics.hlsl ├── semantics.spv ├── semantics.spv.yaml ├── structuredbuffer.hlsl ├── structuredbuffer.spv ├── structuredbuffer.spv.yaml ├── user_type.hlsl ├── user_type.spv └── user_type.spv.yaml ├── interface ├── geom_input_builtin_array.glsl ├── geom_input_builtin_array.spv ├── geom_input_builtin_array.spv.yaml ├── vertex_input_builtin_block.spv ├── vertex_input_builtin_block.spv.yaml ├── vertex_input_builtin_non_block.glsl ├── vertex_input_builtin_non_block.spv └── vertex_input_builtin_non_block.spv.yaml ├── issues ├── 68 │ ├── 64_bit_float.glsl │ └── sample_spv.h ├── 77 │ └── hlsl │ │ ├── array_from_ubo.hlsl │ │ ├── array_from_ubo.spv │ │ ├── array_from_ubo.spv.yaml │ │ ├── array_from_ubo_with_O0.spv │ │ ├── array_from_ubo_with_O0.spv.yaml │ │ ├── rocketz.hlsl │ │ ├── rocketz.spv │ │ └── rocketz.spv.yaml ├── 102 │ ├── function_parameter_access.glsl │ ├── function_parameter_access.spv │ └── function_parameter_access.spv.yaml ├── 178 │ ├── vertex_input_struct.spv │ ├── vertex_input_struct.spv.yaml │ ├── vertex_input_struct2.spv │ └── vertex_input_struct2.spv.yaml └── 227 │ ├── README.md │ ├── null_node.spv │ └── null_node.spv.yaml ├── mesh_shader_ext ├── mesh_shader_ext.mesh.hlsl ├── mesh_shader_ext.mesh.hlsl.spv ├── mesh_shader_ext.mesh.hlsl.spv.yaml ├── mesh_shader_ext.task.hlsl ├── mesh_shader_ext.task.hlsl.spv └── mesh_shader_ext.task.hlsl.spv.yaml ├── multi_entrypoint ├── multi_entrypoint.glsl ├── multi_entrypoint.spv ├── multi_entrypoint.spv.dis ├── multi_entrypoint.spv.dis.diff ├── multi_entrypoint.spv.yaml └── rebuild.sh ├── push_constants ├── non_zero_block_offset.spv ├── non_zero_block_offset.spv.yaml ├── pointer_in_struct.slang ├── pointer_in_struct.spv ├── pointer_in_struct.spv.yaml ├── pointer_in_struct_2.slang ├── pointer_in_struct_2.spv ├── pointer_in_struct_2.spv.yaml ├── push_constant_basic_0.glsl ├── push_constant_basic_0.spv ├── push_constant_basic_0.spv.yaml ├── push_constant_basic_1.glsl ├── push_constant_basic_1.spv ├── push_constant_basic_1.spv.yaml ├── push_constant_basic_2.slang ├── push_constant_basic_2.spv ├── push_constant_basic_2.spv.yaml ├── push_constant_basic_3.slang ├── push_constant_basic_3.spv └── push_constant_basic_3.spv.yaml ├── raytrace ├── compile_shaders.sh ├── rayquery_assign.cs.hlsl ├── rayquery_equal.cs.hlsl ├── rayquery_equal.cs.spv ├── rayquery_equal.cs.spv.yaml ├── rayquery_init_ds.hlsl ├── rayquery_init_ds.spv ├── rayquery_init_ds.spv.yaml ├── rayquery_init_gs.hlsl ├── rayquery_init_gs.spv ├── rayquery_init_gs.spv.yaml ├── rayquery_init_hs.hlsl ├── rayquery_init_hs.spv ├── rayquery_init_hs.spv.yaml ├── rayquery_init_ps.hlsl ├── rayquery_init_ps.spv ├── rayquery_init_ps.spv.yaml ├── rayquery_init_rahit.hlsl ├── rayquery_init_rahit.spv ├── rayquery_init_rahit.spv.yaml ├── rayquery_init_rcall.hlsl ├── rayquery_init_rcall.spv ├── rayquery_init_rcall.spv.yaml ├── rayquery_init_rchit.hlsl ├── rayquery_init_rchit.spv ├── rayquery_init_rchit.spv.yaml ├── rayquery_init_rgen.hlsl ├── rayquery_init_rgen.spv ├── rayquery_init_rgen.spv.yaml ├── rayquery_init_rint.hlsl ├── rayquery_init_rmiss.hlsl ├── rayquery_init_rmiss.spv ├── rayquery_init_rmiss.spv.yaml ├── rayquery_init_vs.hlsl ├── rayquery_tryAllOps.cs.hlsl ├── raytracing.acceleration-structure.hlsl ├── raytracing.acceleration-structure.spv ├── raytracing.acceleration-structure.spv.yaml ├── raytracing.khr.closesthit.hlsl ├── raytracing.khr.closesthit.spv ├── raytracing.khr.closesthit.spv.yaml ├── raytracing.nv.acceleration-structure.hlsl ├── raytracing.nv.acceleration-structure.spv ├── raytracing.nv.acceleration-structure.spv.yaml ├── raytracing.nv.anyhit.hlsl ├── raytracing.nv.anyhit.spv ├── raytracing.nv.anyhit.spv.yaml ├── raytracing.nv.callable.hlsl ├── raytracing.nv.callable.spv ├── raytracing.nv.callable.spv.yaml ├── raytracing.nv.closesthit.hlsl ├── raytracing.nv.closesthit.spv ├── raytracing.nv.closesthit.spv.yaml ├── raytracing.nv.enum.hlsl ├── raytracing.nv.enum.spv ├── raytracing.nv.enum.spv.yaml ├── raytracing.nv.intersection.hlsl ├── raytracing.nv.intersection.spv ├── raytracing.nv.intersection.spv.yaml ├── raytracing.nv.library.hlsl ├── raytracing.nv.library.spv ├── raytracing.nv.library.spv.yaml ├── raytracing.nv.miss.hlsl ├── raytracing.nv.miss.spv ├── raytracing.nv.miss.spv.yaml ├── raytracing.nv.raygen.hlsl ├── raytracing.nv.raygen.spv └── raytracing.nv.raygen.spv.yaml ├── spec_constants ├── basic.comp ├── basic.spv ├── basic.spv.yaml ├── convert.comp ├── convert.spv ├── convert.spv.yaml ├── local_size_id.comp ├── local_size_id_10.spv ├── local_size_id_10.spv.yaml ├── local_size_id_13.spv ├── local_size_id_13.spv.yaml ├── ssbo_array.glsl ├── ssbo_array.spv ├── ssbo_array.spv.yaml ├── test_32bit.comp ├── test_32bit.spv ├── test_32bit.spv.yaml ├── test_64bit.spv └── test_64bit.spv.yaml ├── spirv15 ├── VertexShader.hlsl ├── VertexShader.spv └── VertexShader.spv.yaml ├── test-spirv-reflect.cpp ├── user_type ├── byte_address_buffer_0.hlsl ├── byte_address_buffer_0.spv ├── byte_address_buffer_0.spv.yaml ├── byte_address_buffer_1.hlsl ├── byte_address_buffer_1.spv ├── byte_address_buffer_1.spv.yaml ├── byte_address_buffer_2.hlsl ├── byte_address_buffer_2.spv ├── byte_address_buffer_2.spv.yaml ├── byte_address_buffer_3.hlsl ├── byte_address_buffer_3.spv ├── byte_address_buffer_3.spv.yaml ├── rw_byte_address_buffer.hlsl ├── rw_byte_address_buffer.spv └── rw_byte_address_buffer.spv.yaml └── variable_access ├── atomics_0.glsl ├── atomics_0.spv ├── atomics_0.spv.yaml ├── atomics_1.slang ├── atomics_1.spv ├── atomics_1.spv.yaml ├── copy_array_0.glsl ├── copy_array_0.spv ├── copy_array_0.spv.yaml ├── copy_array_1.slang ├── copy_array_1.spv ├── copy_array_1.spv.yaml ├── copy_array_2.glsl ├── copy_array_2.spv ├── copy_array_2.spv.yaml ├── copy_array_3.slang ├── copy_array_3.spv ├── copy_array_3.spv.yaml ├── copy_memory.spv ├── copy_memory.spv.yaml ├── copy_struct_0.glsl ├── copy_struct_0.spv ├── copy_struct_0.spv.yaml ├── copy_struct_1.slang ├── copy_struct_1.spv ├── copy_struct_1.spv.yaml ├── descriptor_indexing_0.glsl ├── descriptor_indexing_0.spv ├── descriptor_indexing_0.spv.yaml ├── descriptor_indexing_1.slang ├── descriptor_indexing_1.spv ├── descriptor_indexing_1.spv.yaml ├── phy_storage_buffer_used_0.glsl ├── phy_storage_buffer_used_0.spv ├── phy_storage_buffer_used_0.spv.yaml ├── phy_storage_buffer_used_1.glsl ├── phy_storage_buffer_used_1.spv ├── phy_storage_buffer_used_1.spv.yaml ├── phy_storage_buffer_used_2.slang ├── phy_storage_buffer_used_2.spv ├── phy_storage_buffer_used_2.spv.yaml ├── phy_storage_buffer_used_3.slang ├── phy_storage_buffer_used_3.spv └── phy_storage_buffer_used_3.spv.yaml /.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: Google 4 | DerivePointerAlignment: false 5 | SortIncludes: true 6 | ColumnLimit: 132 7 | ... 8 | -------------------------------------------------------------------------------- /.git-blame-ignore-revs: -------------------------------------------------------------------------------- 1 | # rerun clang-format with 132 line width 2 | dc6582bf8c1520a632dca98b11974048ad89fe16 3 | -------------------------------------------------------------------------------- /.github/workflows/check-formatting.yml: -------------------------------------------------------------------------------- 1 | name: Code formatting check 2 | 3 | on: 4 | pull_request: 5 | 6 | # Cancel previous runs if a more recent commit is pushed. 7 | concurrency: 8 | group: ${{ github.workflow }}-${{ github.head_ref }} 9 | cancel-in-progress: true 10 | 11 | permissions: read-all 12 | 13 | jobs: 14 | clang-format-check: 15 | name: clang-format 16 | runs-on: "ubuntu-20.04" 17 | steps: 18 | - name: Setup clang-format 19 | run: | 20 | sudo apt-get install -yqq clang-format-12 21 | - name: Checkout repository 22 | uses: actions/checkout@v3 23 | with: 24 | fetch-depth: '0' 25 | - name: Switch to pull request branch 26 | run: | 27 | git checkout ${GITHUB_SHA} 28 | - name: Run clang-format 29 | run: | 30 | git diff origin/${{ github.base_ref }} -U0 --no-color -- '**/*.cpp' '**/*.cc' '**/*.h' '**/*.hh' '**/*.hpp' \ 31 | | clang-format-diff-12 -p1 >not-formatted.diff 2>&1 32 | - name: Check formatting 33 | run: | 34 | if ! grep -q '[^[:space:]]' not-formatted.diff ; then 35 | echo "Code is formatted." 36 | else 37 | echo "Code is not formatted." 38 | echo "Run clang-format-diff on your changes:" 39 | echo " git diff origin/${{ github.base_ref }} -U0 --no-color | clang-format-diff -p1 -i" 40 | echo "" 41 | echo "You can disable clang-format for specific code blocks. Follow https://clang.llvm.org/docs/ClangFormatStyleOptions.html#disabling-formatting-on-a-piece-of-code." 42 | echo "" 43 | echo "Diff:" 44 | cat not-formatted.diff 45 | echo "" 46 | exit 3 47 | fi 48 | -------------------------------------------------------------------------------- /.github/workflows/linux-cmake-build.yml: -------------------------------------------------------------------------------- 1 | name: Linux build 2 | 3 | on: 4 | pull_request: 5 | 6 | # Cancel previous runs if a more recent commit is pushed. 7 | concurrency: 8 | group: ${{ github.workflow }}-${{ github.head_ref }} 9 | cancel-in-progress: true 10 | 11 | permissions: read-all 12 | 13 | jobs: 14 | linux-build: 15 | name: Build and run tests on Linux using CMake 16 | runs-on: ubuntu-latest 17 | strategy: 18 | matrix: 19 | asan: ["ON", "OFF"] 20 | 21 | steps: 22 | - name: Checkout repository 23 | uses: actions/checkout@v3 24 | with: 25 | fetch-depth: '0' 26 | - name: Clone submodules 27 | run: git submodule update --init --recursive 28 | - name: Build 29 | run: | 30 | mkdir build 31 | cd build 32 | cmake .. -DCMAKE_BUILD_TYPE=Release -DSPIRV_REFLECT_BUILD_TESTS=ON -DSPIRV_REFLECT_ENABLE_ASAN=${{matrix.asan}} 33 | make -j $(nproc) 34 | - name: Run unit tests 35 | run: | 36 | cd build 37 | ./test-spirv-reflect 38 | - name: Clone SPIRV-Database 39 | run: | 40 | git clone https://github.com/LunarG/SPIRV-Database.git build/SPIRV-Database 41 | - name: Test - SaschaWillemsVulkan 42 | run: | 43 | python tests/ci_database.py --dir build/SPIRV-Database/vulkan/SaschaWillemsVulkan/ 44 | - name: Test - clspv 45 | run: | 46 | python tests/ci_database.py --dir build/SPIRV-Database/vulkan/clspv/ 47 | - name: Test - dawn 48 | run: | 49 | python tests/ci_database.py --dir build/SPIRV-Database/vulkan/dawn/ 50 | - name: Test - gl_cts 51 | run: | 52 | python tests/ci_database.py --dir build/SPIRV-Database/vulkan/gl_cts/ 53 | - name: Test - naga 54 | run: | 55 | python tests/ci_database.py --dir build/SPIRV-Database/vulkan/naga/remaps/ 56 | - name: Test - tint 57 | run: | 58 | python tests/ci_database.py --dir build/SPIRV-Database/vulkan/tint/ 59 | -------------------------------------------------------------------------------- /.github/workflows/windows-cmake-build.yml: -------------------------------------------------------------------------------- 1 | name: Windows build 2 | 3 | on: 4 | pull_request: 5 | 6 | # Cancel previous runs if a more recent commit is pushed. 7 | concurrency: 8 | group: ${{ github.workflow }}-${{ github.head_ref }} 9 | cancel-in-progress: true 10 | 11 | permissions: read-all 12 | 13 | jobs: 14 | windows-build: 15 | name: Build and run tests on Windows using CMake 16 | runs-on: windows-latest 17 | steps: 18 | - name: Checkout repository 19 | uses: actions/checkout@v3 20 | with: 21 | fetch-depth: '0' 22 | - name: Clone submodules 23 | run: git submodule update --init --recursive 24 | - name: Build 25 | run: | 26 | mkdir build 27 | cd build 28 | cmake -DSPIRV_REFLECT_BUILD_TESTS=ON .. 29 | 30 | cmake --build . --config Release -- /nologo /verbosity:minimal /maxcpucount 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build* 2 | /bin/* 3 | bazel-bin 4 | bazel-genfiles 5 | bazel-out 6 | bazel-spirv-reflect 7 | bazel-SPIRV-Reflect 8 | bazel-testlogs 9 | /.vs 10 | /.vscode -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "third_party/googletest"] 2 | path = third_party/googletest 3 | url = https://github.com/google/googletest 4 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.adoc: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018-2020 The Khronos Group Inc. 2 | // 3 | // SPDX-License-Identifier: CC-BY-4.0 4 | 5 | = Code of Conduct 6 | 7 | A reminder that this issue tracker is managed by the Khronos Group. 8 | Interactions here should follow the 9 | https://www.khronos.org/developers/code-of-conduct[Khronos Code of Conduct], 10 | which prohibits aggressive or derogatory language. Please keep the 11 | discussion friendly and civil. 12 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Security updates are applied only to the latest release. 6 | 7 | ## Reporting a Vulnerability 8 | 9 | If you have discovered a security vulnerability in this project, please report it privately. **Do not disclose it as a public issue.** This gives us time to work with you to fix the issue before public exposure, reducing the chance that the exploit will be used before a patch is released. 10 | 11 | Please disclose it at [security advisory](https://github.com/KhronosGroup/SPIRV-Reflect/security/advisories/new). 12 | 13 | This project is maintained by a team of volunteers on a reasonable-effort basis. As such, please give us at least 90 days to work on a fix before public exposure. 14 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(examples) 4 | 5 | list(APPEND SPIRV_REFLECT_FILES 6 | ${CMAKE_SOURCE_DIR}/spirv_reflect.h 7 | ${CMAKE_SOURCE_DIR}/spirv_reflect.c 8 | ) 9 | 10 | list(APPEND COMMON_FILES 11 | common.h 12 | common.cpp 13 | ../common/output_stream.h 14 | ../common/output_stream.cpp 15 | sample_spv.h 16 | ) 17 | 18 | ################################################################################ 19 | # descriptors 20 | ################################################################################ 21 | add_executable(descriptors ${CMAKE_CURRENT_SOURCE_DIR}/main_descriptors.cpp ${COMMON_FILES} ${SPIRV_REFLECT_FILES}) 22 | target_include_directories(descriptors PRIVATE ${CMAKE_SOURCE_DIR}) 23 | if (${VULKAN_DIR_FOUND}) 24 | target_compile_definitions(descriptors PRIVATE SPIRV_REFLECT_HAS_VULKAN_H) 25 | target_include_directories(descriptors PRIVATE ${VULKAN_DIR}/include) 26 | set_target_properties(descriptors PROPERTIES CXX_STANDARD 11) 27 | endif() 28 | if(WIN32) 29 | target_compile_definitions(descriptors PRIVATE _CRT_SECURE_NO_WARNINGS) 30 | set_target_properties(descriptors PROPERTIES FOLDER "examples") 31 | endif() 32 | 33 | ################################################################################ 34 | # io_variables 35 | ################################################################################ 36 | add_executable(io_variables ${CMAKE_CURRENT_SOURCE_DIR}/main_io_variables.cpp ${COMMON_FILES} ${SPIRV_REFLECT_FILES}) 37 | target_include_directories(io_variables PRIVATE ${CMAKE_SOURCE_DIR}) 38 | if (${VULKAN_DIR_FOUND}) 39 | target_compile_definitions(io_variables PRIVATE SPIRV_REFLECT_HAS_VULKAN_H) 40 | target_include_directories(io_variables PRIVATE ${VULKAN_DIR}/include) 41 | set_target_properties(io_variables PROPERTIES CXX_STANDARD 11) 42 | endif() 43 | if(WIN32) 44 | target_compile_definitions(io_variables PRIVATE _CRT_SECURE_NO_WARNINGS) 45 | set_target_properties(io_variables PROPERTIES FOLDER "examples") 46 | endif() 47 | 48 | ################################################################################ 49 | # hlsl_resource_types 50 | ################################################################################ 51 | add_executable(hlsl_resource_types ${CMAKE_CURRENT_SOURCE_DIR}/main_hlsl_resource_types.cpp ${COMMON_FILES} ${SPIRV_REFLECT_FILES}) 52 | target_include_directories(hlsl_resource_types PRIVATE ${CMAKE_SOURCE_DIR}) 53 | if (${VULKAN_DIR_FOUND}) 54 | target_compile_definitions(hlsl_resource_types PRIVATE SPIRV_REFLECT_HAS_VULKAN_H) 55 | target_include_directories(hlsl_resource_types PRIVATE ${VULKAN_DIR}/include) 56 | set_target_properties(hlsl_resource_types PROPERTIES CXX_STANDARD 11) 57 | endif() 58 | if(WIN32) 59 | target_compile_definitions(hlsl_resource_types PRIVATE _CRT_SECURE_NO_WARNINGS) 60 | set_target_properties(hlsl_resource_types PROPERTIES FOLDER "examples") 61 | endif() 62 | 63 | ################################################################################ 64 | # explorer 65 | ################################################################################ 66 | add_executable(explorer ${CMAKE_CURRENT_SOURCE_DIR}/main_explorer.cpp ${COMMON_FILES} ${SPIRV_REFLECT_FILES}) 67 | target_include_directories(explorer PRIVATE ${CMAKE_SOURCE_DIR}) 68 | if (${VULKAN_DIR_FOUND}) 69 | target_compile_definitions(explorer PRIVATE SPIRV_REFLECT_HAS_VULKAN_H) 70 | target_include_directories(explorer PRIVATE ${VULKAN_DIR}/include) 71 | set_target_properties(explorer PROPERTIES CXX_STANDARD 11) 72 | endif() 73 | if(WIN32) 74 | target_compile_definitions(explorer PRIVATE _CRT_SECURE_NO_WARNINGS) 75 | set_target_properties(explorer PROPERTIES FOLDER "examples") 76 | endif() 77 | -------------------------------------------------------------------------------- /examples/arg_parser.h: -------------------------------------------------------------------------------- 1 | #ifndef __VERIFLECT_ARG_PARSER_H__ 2 | #define __VERIFLECT_ARG_PARSER_H__ 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | class ArgParser { 10 | public: 11 | enum OptionType { OPTION_TYPE_UNDEFINED = 0, OPTION_TYPE_FLAG, OPTION_TYPE_STRING, OPTION_TYPE_INT, OPTION_TYPE_FLOAT }; 12 | 13 | struct OptionValue { 14 | std::string str; 15 | union { 16 | int i32; 17 | float f32; 18 | }; 19 | }; 20 | 21 | struct Option { 22 | std::string short_name; 23 | std::string long_name; 24 | OptionType type; 25 | std::string desc; 26 | OptionValue value; 27 | OptionValue default_value; 28 | bool parsed; 29 | }; 30 | 31 | ArgParser(); 32 | ~ArgParser(); 33 | 34 | bool AddFlag(const std::string& short_name, const std::string& long_name, const std::string& desc); 35 | bool AddOptionString(const std::string& short_name, const std::string& long_name, const std::string& desc, 36 | const std::string& default_value = ""); 37 | bool AddOptionInt(const std::string& short_name, const std::string& long_name, const std::string& desc, int default_value = 0); 38 | bool AddOptionFloat(const std::string& short_name, const std::string& long_name, const std::string& desc, 39 | float default_value = 0); 40 | 41 | bool Parse(int argc, char** argv, std::ostream& os); 42 | 43 | size_t GetArgCount() const; 44 | bool GetArg(size_t i, std::string* p_value) const; 45 | const std::vector& GetArgs() const; 46 | 47 | bool GetFlag(const std::string& short_name, const std::string& long_name) const; 48 | bool GetString(const std::string& short_name, const std::string& long_name, std::string* p_value) const; 49 | bool GetInt(const std::string& short_name, const std::string& long_name, int* p_value) const; 50 | bool GetFloat(const std::string& short_name, const std::string& long_name, float* p_value) const; 51 | 52 | void PrintHelp(std::ostream& os); 53 | 54 | private: 55 | ArgParser::Option* FindOptionByShortName(const std::string& short_name); 56 | const ArgParser::Option* FindOptionByShortName(const std::string& short_name) const; 57 | ArgParser::Option* FindOptionByLongName(const std::string& long_name); 58 | const ArgParser::Option* FindOptionByLongName(const std::string& long_name) const; 59 | 60 | private: 61 | std::vector m_options; 62 | std::vector m_args; 63 | }; 64 | 65 | #endif // __VERIFLECT_ARG_PARSER_H__ -------------------------------------------------------------------------------- /examples/build_sample_spv_h.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo -e "#ifndef SAMPLE_SPV_H" > sample_spv.h 4 | echo -e "#define SAMPLE_SPV_H" >> sample_spv.h 5 | 6 | echo -e "" >> sample_spv.h 7 | echo -e "/* Source from sample.hlsl" >> sample_spv.h 8 | echo -e "" >> sample_spv.h 9 | cat sample.hlsl >> sample_spv.h 10 | echo -e "\n" >> sample_spv.h 11 | echo -e "*/" >> sample_spv.h 12 | 13 | echo -e "" >> sample_spv.h 14 | 15 | echo -e "// Imported from file 'sample.spv'" >> sample_spv.h 16 | echo -e "const uint32_t k_sample_spv[] = {" >> sample_spv.h 17 | glslc.exe -fshader-stage=frag -fentry-point=main -mfmt=num -o - sample.hlsl >> sample_spv.h 18 | echo -e "};" >> sample_spv.h 19 | echo -e "" >> sample_spv.h 20 | 21 | echo -e "/* SPIRV Disassembly" >> sample_spv.h 22 | echo -e "" >> sample_spv.h 23 | spirv-dis --raw-id sample.spv >> sample_spv.h 24 | echo -e "" >> sample_spv.h 25 | echo -e "*/" >> sample_spv.h 26 | 27 | echo -e "" >> sample_spv.h 28 | echo -e "#endif // SAMPLE_SPV_H" >> sample_spv.h 29 | 30 | dos2unix sample_spv.h 31 | 32 | rm -f tmp_sample_spv_h -------------------------------------------------------------------------------- /examples/common.h: -------------------------------------------------------------------------------- 1 | #ifndef SPIRV_REFLECT_EXAMPLES_COMMON_H 2 | #define SPIRV_REFLECT_EXAMPLES_COMMON_H 3 | 4 | #include 5 | 6 | #include "spirv_reflect.h" 7 | 8 | void PrintModuleInfo(std::ostream& os, const SpvReflectShaderModule& obj, const char* indent = ""); 9 | void PrintDescriptorSet(std::ostream& os, const SpvReflectDescriptorSet& obj, const char* indent = ""); 10 | void PrintDescriptorBinding(std::ostream& os, const SpvReflectDescriptorBinding& obj, bool write_set, const char* indent = ""); 11 | void PrintInterfaceVariable(std::ostream& os, SpvSourceLanguage src_lang, const SpvReflectInterfaceVariable& obj, 12 | const char* indent); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /examples/main_descriptors.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "common.h" 4 | #include "sample_spv.h" 5 | 6 | #if defined(SPIRV_REFLECT_HAS_VULKAN_H) 7 | #include 8 | struct DescriptorSetLayoutData { 9 | uint32_t set_number; 10 | VkDescriptorSetLayoutCreateInfo create_info; 11 | std::vector bindings; 12 | }; 13 | #endif 14 | 15 | int main(int argn, char** argv) { 16 | SpvReflectShaderModule module = {}; 17 | SpvReflectResult result = spvReflectCreateShaderModule(sizeof(k_sample_spv), k_sample_spv, &module); 18 | assert(result == SPV_REFLECT_RESULT_SUCCESS); 19 | 20 | uint32_t count = 0; 21 | result = spvReflectEnumerateDescriptorSets(&module, &count, NULL); 22 | assert(result == SPV_REFLECT_RESULT_SUCCESS); 23 | 24 | std::vector sets(count); 25 | result = spvReflectEnumerateDescriptorSets(&module, &count, sets.data()); 26 | assert(result == SPV_REFLECT_RESULT_SUCCESS); 27 | 28 | #if defined(SPIRV_REFLECT_HAS_VULKAN_H) 29 | // Demonstrates how to generate all necessary data structures to create a 30 | // VkDescriptorSetLayout for each descriptor set in this shader. 31 | std::vector set_layouts(sets.size(), DescriptorSetLayoutData{}); 32 | for (size_t i_set = 0; i_set < sets.size(); ++i_set) { 33 | const SpvReflectDescriptorSet& refl_set = *(sets[i_set]); 34 | DescriptorSetLayoutData& layout = set_layouts[i_set]; 35 | layout.bindings.resize(refl_set.binding_count); 36 | for (uint32_t i_binding = 0; i_binding < refl_set.binding_count; ++i_binding) { 37 | const SpvReflectDescriptorBinding& refl_binding = *(refl_set.bindings[i_binding]); 38 | VkDescriptorSetLayoutBinding& layout_binding = layout.bindings[i_binding]; 39 | layout_binding.binding = refl_binding.binding; 40 | layout_binding.descriptorType = static_cast(refl_binding.descriptor_type); 41 | layout_binding.descriptorCount = 1; 42 | for (uint32_t i_dim = 0; i_dim < refl_binding.array.dims_count; ++i_dim) { 43 | layout_binding.descriptorCount *= refl_binding.array.dims[i_dim]; 44 | } 45 | layout_binding.stageFlags = static_cast(module.shader_stage); 46 | } 47 | layout.set_number = refl_set.set; 48 | layout.create_info.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO; 49 | layout.create_info.bindingCount = refl_set.binding_count; 50 | layout.create_info.pBindings = layout.bindings.data(); 51 | } 52 | // Nothing further is done with set_layouts in this sample; in a real 53 | // application they would be merged with similar structures from other shader 54 | // stages and/or pipelines to create a VkPipelineLayout. 55 | #endif 56 | 57 | // Log the descriptor set contents to stdout 58 | const char* t = " "; 59 | const char* tt = " "; 60 | 61 | PrintModuleInfo(std::cout, module); 62 | std::cout << "\n\n"; 63 | 64 | std::cout << "Descriptor sets:" 65 | << "\n"; 66 | for (size_t index = 0; index < sets.size(); ++index) { 67 | auto p_set = sets[index]; 68 | 69 | // descriptor sets can also be retrieved directly from the module, by set 70 | // index 71 | auto p_set2 = spvReflectGetDescriptorSet(&module, p_set->set, &result); 72 | assert(result == SPV_REFLECT_RESULT_SUCCESS); 73 | assert(p_set == p_set2); 74 | (void)p_set2; 75 | 76 | std::cout << t << index << ":" 77 | << "\n"; 78 | PrintDescriptorSet(std::cout, *p_set, tt); 79 | std::cout << "\n\n"; 80 | } 81 | 82 | spvReflectDestroyShaderModule(&module); 83 | 84 | return 0; 85 | } -------------------------------------------------------------------------------- /examples/sample.hlsl: -------------------------------------------------------------------------------- 1 | Texture2D MyTexture : register(t0, space0); 2 | SamplerState MySampler : register(s1, space1); 3 | 4 | struct RGB { 5 | float r; 6 | float g; 7 | float b; 8 | }; 9 | 10 | struct UBO { 11 | float4x4 XformMatrix; 12 | float3 Scale; 13 | RGB Rgb; 14 | float t; 15 | float2 uv; 16 | }; 17 | 18 | ConstantBuffer MyConstants : register(b2, space2); 19 | 20 | struct Data { 21 | float4 Element; 22 | }; 23 | 24 | ConsumeStructuredBuffer MyBufferIn : register(u3, space2); 25 | AppendStructuredBuffer MyBufferOut : register(u4, space2); 26 | 27 | struct PSInput { 28 | float4 Position : SV_POSITION; 29 | float3 Normal : NORMAL; 30 | float3 Color : COLOR; 31 | float Alpha : OPACITY; 32 | float4 Scaling : SCALE; 33 | float2 TexCoord0 : TEXCOORD0; 34 | float2 TexCoord1 : TEXCOORD1; 35 | float2 TexCoord2 : TEXCOORD2; 36 | }; 37 | 38 | struct PSOutput { 39 | float4 oColor0 : SV_TARGET0; 40 | float4 oColor1 : SV_TARGET1; 41 | float4 oColor2 : SV_TARGET2; 42 | float4 oColor3 : SV_TARGET3; 43 | float4 oColor4 : SV_TARGET4; 44 | float4 oColor5 : SV_TARGET5; 45 | float4 oColor6 : SV_TARGET6; 46 | float4 oColor7 : SV_TARGET7; 47 | }; 48 | 49 | PSOutput main(PSInput input) 50 | { 51 | Data val = MyBufferIn[0]; 52 | MyBufferOut[0] = val; 53 | 54 | PSOutput ret; 55 | ret.oColor0 = mul(MyConstants.XformMatrix, input.Position); 56 | ret.oColor1 = float4(input.Normal, 1) + float4(MyConstants.Scale, 0); 57 | ret.oColor2 = float4(input.Color, 1); 58 | ret.oColor3 = float4(MyTexture.Sample(MySampler, input.TexCoord0).xyz, input.Alpha); 59 | ret.oColor4 = input.Scaling; 60 | ret.oColor5 = float4(input.TexCoord0, 0, 0); 61 | ret.oColor6 = float4(input.TexCoord1, 0, 0); 62 | ret.oColor7 = float4(input.TexCoord2, 0, 0); 63 | return ret; 64 | } -------------------------------------------------------------------------------- /examples/sample.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/examples/sample.spv -------------------------------------------------------------------------------- /spirv_reflect.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // This file exists to force compiling spirv_reflect.c as C++. 3 | // 4 | #include "spirv_reflect.c" -------------------------------------------------------------------------------- /tests/16bit/vert_in_out_16.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/16bit/vert_in_out_16.spv -------------------------------------------------------------------------------- /tests/16bit/vert_in_out_16.vert: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_EXT_shader_explicit_arithmetic_types_int16 : require 3 | #extension GL_EXT_shader_explicit_arithmetic_types_float16 : require 4 | 5 | layout(location = 0) in float16_t a; 6 | layout(location = 1) in f16vec3 b; 7 | layout(location = 2) in uint16_t c; 8 | layout(location = 3) in u16vec3 d; 9 | layout(location = 4) in int16_t e; 10 | layout(location = 5) in i16vec3 f; 11 | 12 | layout(location = 0) out float16_t _a; 13 | layout(location = 1) out f16vec3 _b; 14 | layout(location = 2) out uint16_t _c; 15 | layout(location = 3) out u16vec3 _d; 16 | layout(location = 4) out int16_t _e; 17 | layout(location = 5) out i16vec3 _f; 18 | 19 | void main() 20 | { 21 | _a = a * float16_t(2.0); 22 | _b = b * f16vec3(2.0); 23 | _c = c * 2us; 24 | _d = d * u16vec3(2); 25 | _e = e * 2s; 26 | _f = f * i16vec3(2); 27 | } 28 | -------------------------------------------------------------------------------- /tests/access_chains/array_length_from_access_chain.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/access_chains/array_length_from_access_chain.spv -------------------------------------------------------------------------------- /tests/access_chains/pointer_access_chain_phy_storage_buffer.slang: -------------------------------------------------------------------------------- 1 | uniform uint* data_ptr; // creates a ptr chain access 2 | 3 | struct Data{ 4 | int x; 5 | } 6 | uniform Data* data_struct; 7 | 8 | [numthreads(1,1,1)] 9 | void computeMain() 10 | { 11 | data_ptr[0] = 1; 12 | data_struct->x = 1; 13 | } 14 | -------------------------------------------------------------------------------- /tests/access_chains/pointer_access_chain_phy_storage_buffer.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/access_chains/pointer_access_chain_phy_storage_buffer.spv -------------------------------------------------------------------------------- /tests/build_all_shaders.py: -------------------------------------------------------------------------------- 1 | # Usage: 2 | # python tests/build_all_shaders.py 3 | import argparse 4 | import os 5 | import pathlib 6 | import shutil 7 | import subprocess 8 | import sys 9 | 10 | def my_which(cmd): 11 | if sys.hexversion >= 0x03030000: 12 | return shutil.which(cmd) 13 | else: 14 | try: 15 | subprocess.check_output([cmd], stderr=subprocess.STDOUT) 16 | return cmd 17 | except subprocess.CalledProcessError: 18 | return cmd # that's fine, it exists though 19 | except OSError: 20 | return None 21 | 22 | shaders = [ 23 | {'source':"glsl/built_in_format.glsl", 'entry':"main", 'stage':'vert'}, 24 | {'source':"glsl/buffer_pointer.glsl", 'entry':"main", 'stage':'frag', 'target-env':'vulkan1.3'}, 25 | {'source':"glsl/input_attachment.glsl", 'entry':"main", 'stage':'frag'}, 26 | {'source':"glsl/texel_buffer.glsl", 'entry':"main", 'stage':'vert'}, 27 | {'source':"glsl/storage_buffer.glsl", 'entry':"main", 'stage':'comp', 'target-env':'vulkan1.1'}, 28 | {'source':"glsl/runtime_array_of_array_of_struct.glsl", 'entry':"main", 'stage':'comp'}, 29 | 30 | {'source':"hlsl/append_consume.hlsl", 'entry':"main", 'profile':'ps_6_0', 'stage':'frag'}, 31 | {'source':"hlsl/binding_array.hlsl", 'entry':"main", 'profile':'ps_6_0', 'stage':'frag'}, 32 | {'source':"hlsl/binding_types.hlsl", 'entry':"main", 'profile':'ps_6_0', 'stage':'frag'}, 33 | {'source':"hlsl/cbuffer.hlsl", 'entry':"main", 'profile':'vs_6_0', 'stage':'vert'}, 34 | {'source':"hlsl/counter_buffers.hlsl", 'entry':"main", 'profile':'ps_6_0', 'stage':'frag'}, 35 | {'source':"hlsl/semantics.hlsl", 'entry':"main", 'profile':'ps_6_0', 'stage':'frag'}, 36 | {'source':"hlsl/user_type.hlsl", 'entry':"main", 'profile':'ps_6_0', 'stage':'frag'}, 37 | ] 38 | 39 | if __name__ == "__main__": 40 | parser = argparse.ArgumentParser(description="Compile test shaders") 41 | parser.add_argument("--glslc", help="path to glslc compiler", default=my_which("glslc")) 42 | parser.add_argument("--dxc", help="path to dxc compiler", default=my_which("dxc")) 43 | parser.add_argument("--verbose", "-v", help="enable verbose output", action='store_true') 44 | args = parser.parse_args() 45 | 46 | test_dir = pathlib.Path(__file__).parent.resolve() 47 | root_dir = test_dir.parent.resolve() 48 | 49 | if not args.dxc: 50 | print("WARNING: dxc not found in PATH; HLSL shaders will be compiled with glslc.") 51 | if not args.glslc: 52 | print("WARNING: glslc not found in PATH. This is a bad sign.") 53 | for shader in shaders: 54 | src_path = os.path.join(test_dir, shader['source']) 55 | base, ext = os.path.splitext(src_path) 56 | spv_path = base + ".spv" 57 | if ext.lower() == ".glsl" or (ext.lower() == ".hlsl" and not args.dxc): 58 | compile_cmd_args = [args.glslc, "-g", "-fshader-stage=" + shader['stage'], "-fentry-point=" + shader['entry'], "-o", spv_path, src_path] 59 | if 'target-env' in shader: 60 | compile_cmd_args.append("--target-env=" + shader['target-env']) 61 | elif ext.lower() == ".hlsl": 62 | compile_cmd_args = [args.dxc, "-spirv", "-Zi", "-fspv-reflect", "-O0", "-T", shader['profile'], "-E", shader['entry'], "-Fo", spv_path, src_path] 63 | 64 | print("%s -> %s" % (src_path, spv_path)) 65 | if args.verbose: 66 | print(" ".join(compile_cmd_args)) 67 | 68 | try: 69 | compile_cmd_output = subprocess.check_output(compile_cmd_args, stderr = subprocess.STDOUT) 70 | except subprocess.CalledProcessError as error: 71 | print("Compilation failed for %s with error code %d:\n%s" % (src_path, error.returncode, error.output.decode('utf-8'))) 72 | 73 | print("") 74 | -------------------------------------------------------------------------------- /tests/build_golden_yaml.py: -------------------------------------------------------------------------------- 1 | # Usage: 2 | # Prereq: build spirv-reflect 3 | # Prereq: build shader SPVs 4 | # python tests/build_golden_yaml.py 5 | import argparse 6 | import os 7 | import pathlib 8 | import platform 9 | import subprocess 10 | import sys 11 | 12 | if __name__ == "__main__": 13 | parser = argparse.ArgumentParser(description="Generate golden YAML from test shader .spv files") 14 | parser.add_argument("--verbose", "-v", help="enable verbose output", action='store_true') 15 | args = parser.parse_args() 16 | 17 | print("""\ 18 | WARNING: This script regenerates the golden YAML output for all test shaders. 19 | The new YAML will be considered the expected correct output for future test 20 | runs. Before commiting the updated YAML to GitHub, it is therefore critical 21 | to carefully inspect the diffs between the old and new YAML output, to ensure 22 | that all differences can be traced back to intentional changes to either the 23 | reflection code or the test shaders. 24 | """) 25 | 26 | test_dir = pathlib.Path(__file__).parent.resolve() 27 | root_dir = test_dir.parent.resolve() 28 | 29 | spirv_reflect_exe_paths_windows = [ 30 | os.path.join(root_dir, "bin", "Debug", "spirv-reflect.exe"), 31 | os.path.join(root_dir, "bin", "Release", "spirv-reflect.exe"), 32 | ] 33 | spirv_reflect_exe_paths_unix = [ 34 | os.path.join(root_dir, "bin", "spirv-reflect"), 35 | ] 36 | spirv_reflect_exe = None 37 | if platform.system() == "Windows": 38 | for path in spirv_reflect_exe_paths_windows: 39 | if os.path.isfile(path): 40 | spirv_reflect_exe = path 41 | break 42 | else: 43 | for path in spirv_reflect_exe_paths_unix: 44 | if os.path.isfile(path): 45 | spirv_reflect_exe = path 46 | break 47 | 48 | if spirv_reflect_exe is None: 49 | exit("spirv-reflect executable not found!") 50 | 51 | spv_paths = [] 52 | for root, dirs, files in os.walk(test_dir): 53 | for f in files: 54 | base, ext = os.path.splitext(f) 55 | if ext.lower() == ".spv": 56 | spv_paths.append(os.path.normpath(os.path.join(root, f))) 57 | 58 | for spv_path in spv_paths: 59 | yaml_path = spv_path + ".yaml" 60 | try: 61 | # TODO Replace hard-coded EXE path with something less brittle. 62 | yaml_cmd_args = [spirv_reflect_exe, "-y", "-v", "1", spv_path] 63 | if args.verbose: 64 | print(" ".join(yaml_cmd_args)) 65 | subprocess.run(yaml_cmd_args, stdout=open(yaml_path, "w")) 66 | subprocess.run(yaml_cmd_args) 67 | print("%s -> %s" % (spv_path, yaml_path)) 68 | except NameError: 69 | print("spirv-reflect application not found; did you build it first?") 70 | sys.exit() 71 | except subprocess.CalledProcessError as error: 72 | print("YAML generation failed with error code %d:\n%s" % (error.returncode, error.output.decode('utf-8'))) 73 | -------------------------------------------------------------------------------- /tests/cbuffer_unused/cbuffer_unused_001.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/cbuffer_unused/cbuffer_unused_001.spv -------------------------------------------------------------------------------- /tests/ci_database.py: -------------------------------------------------------------------------------- 1 | import os 2 | import sys 3 | import argparse 4 | import subprocess 5 | 6 | if __name__ == '__main__': 7 | parser = argparse.ArgumentParser(description='run SPIRV-Database in CI') 8 | # Main reason for passing dir in is so GitHub Actions can group things, otherwise logs get VERY long for a single action 9 | parser.add_argument('--dir', action='store', required=True, type=str, help='path to SPIR-V files') 10 | args = parser.parse_args() 11 | 12 | root_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) 13 | exe_path = os.path.join(root_dir, 'bin/spirv-reflect') 14 | 15 | for currentpath, folders, files in os.walk(args.dir): 16 | for file in files: 17 | spirv_file = os.path.join(currentpath, file) 18 | command = f'{exe_path} {spirv_file} -ci' 19 | exit_code = subprocess.call(command.split()) 20 | if exit_code != 0: 21 | print(f'ERROR for {spirv_file}') 22 | sys.exit(1) -------------------------------------------------------------------------------- /tests/cpp/noncopyable/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.16) 2 | 3 | project(noncopyable) 4 | 5 | list(APPEND SPIRV_REFLECT_FILES 6 | ${CMAKE_CURRENT_SOURCE_DIR}/../../../spirv_reflect.h 7 | ${CMAKE_CURRENT_SOURCE_DIR}/../../../spirv_reflect.c 8 | ) 9 | 10 | add_executable(noncopyable ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${COMMON_FILES} ${SPIRV_REFLECT_FILES}) 11 | target_include_directories(noncopyable PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../..) 12 | set_target_properties(noncopyable PROPERTIES CXX_STANDARD 11) 13 | 14 | if(WIN32) 15 | target_compile_definitions(noncopyable PRIVATE _CRT_SECURE_NO_WARNINGS) 16 | set_target_properties(noncopyable PROPERTIES FOLDER "tests") 17 | endif() 18 | -------------------------------------------------------------------------------- /tests/cpp/noncopyable/main.cpp: -------------------------------------------------------------------------------- 1 | #include "spirv_reflect.h" 2 | 3 | int main(int argc, char** argv) { 4 | spv_reflect::ShaderModule shaderModule; 5 | shaderModule = spv_reflect::ShaderModule(); 6 | return 0; 7 | } -------------------------------------------------------------------------------- /tests/entry_exec_mode/comp_local_size.glsl: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | 3 | layout(set = 0, binding = 0) buffer buf 4 | { 5 | uint buf_Data[]; 6 | }; 7 | 8 | layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; 9 | 10 | void main() 11 | { 12 | buf_Data[0] = buf_Data[32]; 13 | buf_Data[100] = buf_Data[132]; 14 | buf_Data[200] = buf_Data[232]; 15 | } 16 | -------------------------------------------------------------------------------- /tests/entry_exec_mode/comp_local_size.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/entry_exec_mode/comp_local_size.spv -------------------------------------------------------------------------------- /tests/entry_exec_mode/comp_local_size.spv.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | all_type_descriptions: 4 | - &td0 5 | id: 7 6 | op: 29 7 | type_name: 8 | struct_member_name: "buf_Data" 9 | storage_class: 0 # UniformConstant 10 | type_flags: 0x20000004 # ARRAY INT 11 | decoration_flags: 0x00000000 # NONE 12 | traits: 13 | numeric: 14 | scalar: { width: 32, signedness: 0 } 15 | vector: { component_count: 0 } 16 | matrix: { column_count: 0, row_count: 0, stride: 0 } 17 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 18 | array: { dims_count: 1, dims: [0,], stride: 4 } 19 | member_count: 0 20 | members: 21 | - &td1 22 | id: 8 23 | op: 30 24 | type_name: "buf" 25 | struct_member_name: 26 | storage_class: -1 # NOT APPLICABLE 27 | type_flags: 0x10080000 # STRUCT EXTERNAL_BLOCK 28 | decoration_flags: 0x00000002 # BUFFER_BLOCK 29 | traits: 30 | numeric: 31 | scalar: { width: 0, signedness: 0 } 32 | vector: { component_count: 0 } 33 | matrix: { column_count: 0, row_count: 0, stride: 0 } 34 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 35 | array: { dims_count: 0, dims: [], stride: 0 } 36 | member_count: 1 37 | members: 38 | - *td0 39 | all_block_variables: 40 | - &bv0 41 | name: "buf_Data" 42 | offset: 0 43 | absolute_offset: 0 44 | size: 0 45 | padded_size: 0 46 | decorations: 0x00000000 # NONE 47 | numeric: 48 | scalar: { width: 32, signedness: 0 } 49 | vector: { component_count: 0 } 50 | matrix: { column_count: 0, row_count: 0, stride: 0 } 51 | array: { dims_count: 0, dims: [], stride: 0 } 52 | flags: 0x00000000 # NONE 53 | member_count: 0 54 | members: 55 | type_description: *td0 56 | - &bv1 57 | name: "" 58 | offset: 0 59 | absolute_offset: 0 60 | size: 0 61 | padded_size: 0 62 | decorations: 0x00000000 # NONE 63 | numeric: 64 | scalar: { width: 0, signedness: 0 } 65 | vector: { component_count: 0 } 66 | matrix: { column_count: 0, row_count: 0, stride: 0 } 67 | array: { dims_count: 0, dims: [], stride: 0 } 68 | flags: 0x00000000 # NONE 69 | member_count: 1 70 | members: 71 | - *bv0 72 | type_description: *td1 73 | all_descriptor_bindings: 74 | - &db0 75 | spirv_id: 10 76 | name: "" 77 | binding: 0 78 | input_attachment_index: 0 79 | set: 0 80 | decoration_flags: 0x00000000 # NONE 81 | descriptor_type: 7 # VK_DESCRIPTOR_TYPE_STORAGE_BUFFER 82 | resource_type: 8 # UAV 83 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 84 | block: *bv1 # "" 85 | array: { dims_count: 0, dims: [] } 86 | accessed: 1 87 | uav_counter_id: 4294967295 88 | uav_counter_binding: 89 | type_description: *td1 90 | word_offset: { binding: 65, set: 61 } 91 | all_interface_variables: 92 | module: 93 | generator: 8 # Khronos Glslang Reference Front End 94 | entry_point_name: "main" 95 | entry_point_id: 4 96 | source_language: 2 # GLSL 97 | source_language_version: 450 98 | spirv_execution_model: 5 # GLCompute 99 | shader_stage: 0x00000020 # CS 100 | descriptor_binding_count: 1 101 | descriptor_bindings: 102 | - *db0 # "" 103 | descriptor_set_count: 1 104 | descriptor_sets: 105 | - set: 0 106 | binding_count: 1 107 | bindings: 108 | - *db0 # "" 109 | input_variable_count: 0, 110 | input_variables: 111 | output_variable_count: 0, 112 | output_variables: 113 | push_constant_count: 0, 114 | push_constants: 115 | specialization_constant_count: 0, 116 | specialization_constants: 117 | ... 118 | -------------------------------------------------------------------------------- /tests/entry_exec_mode/geom_inv_out_vert.glsl: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | layout (points, invocations = 2) in; 3 | layout (line_strip, max_vertices = 2) out; 4 | 5 | void main() { 6 | gl_Position = gl_in[0].gl_Position + vec4(-0.1, 0.0, 0.0, 0.0); 7 | EmitVertex(); 8 | 9 | gl_Position = gl_in[0].gl_Position + vec4( 0.1, 0.0, 0.0, 0.0); 10 | EmitVertex(); 11 | 12 | EndPrimitive(); 13 | } -------------------------------------------------------------------------------- /tests/entry_exec_mode/geom_inv_out_vert.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/entry_exec_mode/geom_inv_out_vert.spv -------------------------------------------------------------------------------- /tests/execution_mode/local_size_id.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/execution_mode/local_size_id.spv -------------------------------------------------------------------------------- /tests/execution_mode/local_size_id.spv.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | all_type_descriptions: 4 | all_block_variables: 5 | all_descriptor_bindings: 6 | all_interface_variables: 7 | module: 8 | generator: 7 # Khronos SPIR-V Tools Assembler 9 | entry_point_name: "main" 10 | entry_point_id: 2 11 | source_language: 2 # GLSL 12 | source_language_version: 450 13 | spirv_execution_model: 5 # GLCompute 14 | shader_stage: 0x00000020 # CS 15 | descriptor_binding_count: 0 16 | descriptor_bindings: 17 | descriptor_set_count: 0 18 | descriptor_sets: 19 | input_variable_count: 0, 20 | input_variables: 21 | output_variable_count: 0, 22 | output_variables: 23 | push_constant_count: 0, 24 | push_constants: 25 | specialization_constant_count: 0, 26 | specialization_constants: 27 | ... 28 | -------------------------------------------------------------------------------- /tests/execution_mode/local_size_id_spec.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/execution_mode/local_size_id_spec.spv -------------------------------------------------------------------------------- /tests/execution_mode/local_size_id_spec.spv.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | all_type_descriptions: 4 | all_block_variables: 5 | all_descriptor_bindings: 6 | all_interface_variables: 7 | module: 8 | generator: 7 # Khronos SPIR-V Tools Assembler 9 | entry_point_name: "main" 10 | entry_point_id: 2 11 | source_language: 2 # GLSL 12 | source_language_version: 450 13 | spirv_execution_model: 5 # GLCompute 14 | shader_stage: 0x00000020 # CS 15 | descriptor_binding_count: 0 16 | descriptor_bindings: 17 | descriptor_set_count: 0 18 | descriptor_sets: 19 | input_variable_count: 0, 20 | input_variables: 21 | output_variable_count: 0, 22 | output_variables: 23 | push_constant_count: 0, 24 | push_constants: 25 | specialization_constant_count: 0, 26 | specialization_constants: 27 | ... 28 | -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_0.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_EXT_buffer_reference : enable 3 | 4 | layout(buffer_reference) buffer t1; 5 | layout(buffer_reference) buffer t2; 6 | layout(buffer_reference) buffer t3; 7 | layout(buffer_reference) buffer t4; 8 | 9 | layout(buffer_reference, std430) buffer t1 { 10 | t4 i_1; 11 | }; 12 | 13 | layout(buffer_reference, std430) buffer t2 { 14 | t4 i_2; 15 | }; 16 | 17 | layout(buffer_reference, std430) buffer t3 { 18 | t2 i_3; 19 | }; 20 | 21 | layout(set = 1, binding = 2, buffer_reference, std430) buffer t4 { 22 | layout(offset = 0) int j; 23 | t1 k_1; 24 | t2 k_2; 25 | t3 k_3; 26 | } x; 27 | 28 | layout(set = 0, binding = 0, std430) buffer t5 { 29 | t4 m; 30 | } s5; 31 | 32 | void main() {} 33 | -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_0.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/buffer_handle_0.spv -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_1.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | // Taken from glslang/Test/spv.bufferhandle4.frag 3 | #extension GL_EXT_buffer_reference : enable 4 | 5 | layout(buffer_reference) buffer t4; 6 | 7 | layout(buffer_reference, std430) buffer t3 { 8 | int h; 9 | t4 i; 10 | }; 11 | 12 | layout(set = 1, binding = 2, buffer_reference, std430) buffer t4 { 13 | layout(offset = 0) int j; 14 | t3 k; 15 | } x; 16 | 17 | layout(set = 0, binding = 0, std430) buffer t5 { 18 | t4 m; 19 | } s5; 20 | 21 | void main() { 22 | x.k.h = s5.m.k.i.k.i.k.h; 23 | 24 | bool b = true; 25 | s5.m = b ? s5.m : s5.m.k.i; 26 | } 27 | -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_1.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/buffer_handle_1.spv -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_2.glsl: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | // Taken from glslang/Test/spv.bufferhandle6.frag 3 | #extension GL_EXT_buffer_reference : enable 4 | layout (push_constant, std430) uniform Block { int identity[32]; } pc; 5 | layout(r32ui, set = 3, binding = 0) uniform uimage2D image0_0; 6 | layout(buffer_reference) buffer T1; 7 | layout(set = 3, binding = 1, buffer_reference) buffer T1 { 8 | layout(offset = 0) int a[2]; // stride = 4 for std430, 16 for std140 9 | layout(offset = 32) int b; 10 | layout(offset = 48) T1 c[2]; // stride = 8 for std430, 16 for std140 11 | layout(offset = 80) T1 d; 12 | } x; 13 | void main() 14 | { 15 | int accum = 0, temp; 16 | accum |= x.a[0] - 0; 17 | accum |= x.a[pc.identity[1]] - 1; 18 | accum |= x.b - 2; 19 | accum |= x.c[0].a[0] - 3; 20 | accum |= x.c[0].a[pc.identity[1]] - 4; 21 | accum |= x.c[0].b - 5; 22 | accum |= x.c[pc.identity[1]].a[0] - 6; 23 | accum |= x.c[pc.identity[1]].a[pc.identity[1]] - 7; 24 | accum |= x.c[pc.identity[1]].b - 8; 25 | accum |= x.d.a[0] - 9; 26 | accum |= x.d.a[pc.identity[1]] - 10; 27 | accum |= x.d.b - 11; 28 | uvec4 color = (accum != 0) ? uvec4(0,0,0,0) : uvec4(1,0,0,1); 29 | imageStore(image0_0, ivec2(gl_FragCoord.x, gl_FragCoord.y), color); 30 | } -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_2.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/buffer_handle_2.spv -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_3.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_EXT_buffer_reference : enable 3 | 4 | layout(buffer_reference) buffer t1; 5 | 6 | layout(buffer_reference, std430) buffer t1 { 7 | t1 i; 8 | }; 9 | 10 | layout(set = 1, binding = 2, buffer_reference, std430) buffer t4 { 11 | layout(offset = 0) int j; 12 | t1 k; 13 | } x; 14 | 15 | layout(set = 0, binding = 0, std430) buffer t5 { 16 | t4 m; 17 | } s5; 18 | 19 | void main() {} 20 | -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_3.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/buffer_handle_3.spv -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_4.glsl: -------------------------------------------------------------------------------- 1 | #version 460 core 2 | #extension GL_EXT_buffer_reference : require 3 | #extension GL_EXT_shader_explicit_arithmetic_types_float32 : require 4 | #extension GL_EXT_shader_explicit_arithmetic_types_int64 : require 5 | #extension GL_EXT_shader_explicit_arithmetic_types_int32 : require 6 | 7 | layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; 8 | 9 | layout(buffer_reference, buffer_reference_align = 4) readonly buffer ReadVecf 10 | { 11 | float32_t values[]; 12 | }; 13 | 14 | layout(buffer_reference, buffer_reference_align = 4) writeonly buffer WriteVecf 15 | { 16 | float32_t values[]; 17 | }; 18 | 19 | layout(push_constant, std430) uniform Parameters 20 | { 21 | ReadVecf a; 22 | ReadVecf b; 23 | WriteVecf c; 24 | uint64_t n; 25 | } params; 26 | 27 | void main() 28 | { 29 | uint32_t idx = gl_GlobalInvocationID.x; 30 | uint32_t stride = gl_NumWorkGroups.x * gl_WorkGroupSize.x; 31 | for (; idx < params.n; idx += stride) { 32 | params.c.values[idx] = params.a.values[idx] + params.b.values[idx]; 33 | } 34 | } -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_4.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/buffer_handle_4.spv -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_5.glsl: -------------------------------------------------------------------------------- 1 | #version 460 core 2 | #extension GL_EXT_buffer_reference : require 3 | 4 | layout(buffer_reference, buffer_reference_align = 4) readonly buffer t2 { 5 | int values[]; 6 | }; 7 | 8 | layout(buffer_reference, buffer_reference_align = 4) readonly buffer t1 { 9 | t2 c; 10 | }; 11 | 12 | layout(push_constant, std430) uniform Parameters { 13 | t1 a; 14 | t2 b; 15 | } params; 16 | 17 | void main() { 18 | params.a.c.values[0] = params.b.values[0] + 1; 19 | } 20 | -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_5.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/buffer_handle_5.spv -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_6.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_EXT_buffer_reference : require 3 | #extension GL_ARB_enhanced_layouts : require 4 | #extension GL_EXT_nonuniform_qualifier : require 5 | #extension GL_KHR_shader_subgroup_arithmetic : require 6 | layout(row_major) uniform; 7 | layout(row_major) buffer; 8 | 9 | struct BDAGlobals_t_0 { 10 | vec4 g_vTest; 11 | vec4 g_vTest2; 12 | }; 13 | 14 | layout(buffer_reference, std430, buffer_reference_align = 16) readonly buffer BufferPointer_BDAGlobals_t_0_1 { 15 | BDAGlobals_t_0 _data; 16 | }; 17 | 18 | struct GlobalsBDAPushConstant_t_0 { 19 | BufferPointer_BDAGlobals_t_0_1 g_GlobalsBDAPerStage_0[6]; 20 | }; 21 | 22 | layout(push_constant) 23 | layout(std140) uniform _S2 { 24 | BufferPointer_BDAGlobals_t_0_1 g_GlobalsBDAPerStage_0[6]; 25 | } g_GlobalsBDAPushConstant_0; 26 | 27 | struct PS_OUTPUT_0 { 28 | vec4 vColor_1; 29 | }; 30 | 31 | layout(location = 0) out vec4 _S149; 32 | 33 | void main() { 34 | _S149 = g_GlobalsBDAPushConstant_0.g_GlobalsBDAPerStage_0[0]._data.g_vTest; 35 | return; 36 | } -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_6.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/buffer_handle_6.spv -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_7.glsl: -------------------------------------------------------------------------------- 1 | #version 460 core 2 | #extension GL_EXT_buffer_reference : require 3 | 4 | layout(buffer_reference, buffer_reference_align = 4) readonly buffer t2 { 5 | int values[]; 6 | }; 7 | 8 | layout(buffer_reference, buffer_reference_align = 4) readonly buffer t1 { 9 | t2 c; 10 | }; 11 | 12 | layout(buffer_reference, buffer_reference_align = 4) readonly buffer t0 { 13 | t1 a; 14 | t2 b; 15 | }; 16 | 17 | layout(push_constant, std430) uniform Parameters { 18 | t0 x; 19 | } params; 20 | 21 | void main() { 22 | params.x.a.c.values[0] = params.x.b.values[0] + 1; 23 | } 24 | -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_7.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/buffer_handle_7.spv -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_8.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_EXT_buffer_reference : enable 3 | 4 | layout(buffer_reference) buffer T1; 5 | layout(set = 3, binding = 1, buffer_reference) buffer T1 { 6 | layout(offset = 48) T1 c[2]; // stride = 8 for std430, 16 for std140 7 | } x; 8 | 9 | void main() {} -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_8.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/buffer_handle_8.spv -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_9.glsl: -------------------------------------------------------------------------------- 1 | #version 460 2 | #extension GL_EXT_buffer_reference2: require 3 | #extension GL_EXT_scalar_block_layout : enable 4 | 5 | layout(buffer_reference, scalar) readonly buffer VertexBufferPtr { 6 | vec4 v[]; 7 | }; 8 | 9 | // Has a OpTypeRuntimeArray 10 | layout(binding = 1, set = 0, scalar) readonly buffer Vertices { 11 | VertexBufferPtr vertex_buffers[]; 12 | }; 13 | 14 | void main() { 15 | gl_Position = vertex_buffers[gl_VertexIndex].v[gl_VertexIndex]; 16 | } -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_9.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/buffer_handle_9.spv -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_uvec2_pc.glsl: -------------------------------------------------------------------------------- 1 | #version 460 2 | #extension GL_EXT_buffer_reference2 : require 3 | #extension GL_EXT_buffer_reference_uvec2 : require 4 | 5 | layout(buffer_reference) buffer VertexBuffer; 6 | layout(buffer_reference, buffer_reference_align = 16, std430) buffer VertexBuffer { 7 | int x; 8 | }; 9 | 10 | layout(push_constant, std430) uniform PerFrameData { 11 | uvec2 bufferId; 12 | } pc; 13 | 14 | void main() { 15 | VertexBuffer(pc.bufferId).x = 0; 16 | } -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_uvec2_pc.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/buffer_handle_uvec2_pc.spv -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_uvec2_pc.spv.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | all_type_descriptions: 4 | - &td0 5 | id: 7 6 | op: 23 7 | type_name: 8 | struct_member_name: "bufferId" 9 | storage_class: 0 # UniformConstant 10 | type_flags: 0x00000104 # VECTOR INT 11 | decoration_flags: 0x00000000 # NONE 12 | traits: 13 | numeric: 14 | scalar: { width: 32, signedness: 0 } 15 | vector: { component_count: 2 } 16 | matrix: { column_count: 0, row_count: 0, stride: 0 } 17 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 18 | array: { dims_count: 0, dims: [], stride: 0 } 19 | member_count: 0 20 | members: 21 | - &td1 22 | id: 8 23 | op: 30 24 | type_name: "PerFrameData" 25 | struct_member_name: 26 | storage_class: -1 # NOT APPLICABLE 27 | type_flags: 0x10080000 # STRUCT EXTERNAL_BLOCK 28 | decoration_flags: 0x00000001 # BLOCK 29 | traits: 30 | numeric: 31 | scalar: { width: 0, signedness: 0 } 32 | vector: { component_count: 0 } 33 | matrix: { column_count: 0, row_count: 0, stride: 0 } 34 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 35 | array: { dims_count: 0, dims: [], stride: 0 } 36 | member_count: 1 37 | members: 38 | - *td0 39 | all_block_variables: 40 | - &bv0 41 | name: "bufferId" 42 | offset: 0 43 | absolute_offset: 0 44 | size: 8 45 | padded_size: 8 46 | decorations: 0x00000000 # NONE 47 | numeric: 48 | scalar: { width: 32, signedness: 0 } 49 | vector: { component_count: 2 } 50 | matrix: { column_count: 0, row_count: 0, stride: 0 } 51 | array: { dims_count: 0, dims: [], stride: 0 } 52 | flags: 0x00000000 # NONE 53 | member_count: 0 54 | members: 55 | type_description: *td0 56 | - &bv1 57 | name: "pc" 58 | offset: 0 59 | absolute_offset: 0 60 | size: 8 61 | padded_size: 8 62 | decorations: 0x00000000 # NONE 63 | numeric: 64 | scalar: { width: 0, signedness: 0 } 65 | vector: { component_count: 0 } 66 | matrix: { column_count: 0, row_count: 0, stride: 0 } 67 | array: { dims_count: 0, dims: [], stride: 0 } 68 | flags: 0x00000000 # NONE 69 | member_count: 1 70 | members: 71 | - *bv0 72 | type_description: *td1 73 | all_descriptor_bindings: 74 | all_interface_variables: 75 | module: 76 | generator: 8 # Khronos Glslang Reference Front End 77 | entry_point_name: "main" 78 | entry_point_id: 4 79 | source_language: 2 # GLSL 80 | source_language_version: 460 81 | spirv_execution_model: 5 # GLCompute 82 | shader_stage: 0x00000020 # CS 83 | descriptor_binding_count: 0 84 | descriptor_bindings: 85 | descriptor_set_count: 0 86 | descriptor_sets: 87 | input_variable_count: 0, 88 | input_variables: 89 | output_variable_count: 0, 90 | output_variables: 91 | push_constant_count: 1, 92 | push_constants: 93 | - *bv1 # "pc" 94 | specialization_constant_count: 0, 95 | specialization_constants: 96 | ... 97 | -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_uvec2_ssbo.glsl: -------------------------------------------------------------------------------- 1 | #version 460 2 | #extension GL_EXT_buffer_reference2 : require 3 | #extension GL_EXT_buffer_reference_uvec2 : require 4 | 5 | layout(buffer_reference) buffer VertexBuffer; 6 | layout(buffer_reference, buffer_reference_align = 16, std430) buffer VertexBuffer { 7 | int x; 8 | }; 9 | 10 | layout(set = 0, binding = 0) buffer T1 { 11 | uvec2 bufferId; 12 | } ssbo; 13 | 14 | void main() { 15 | VertexBuffer(ssbo.bufferId).x = 0; 16 | } -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_uvec2_ssbo.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/buffer_handle_uvec2_ssbo.spv -------------------------------------------------------------------------------- /tests/glsl/buffer_handle_uvec2_ssbo.spv.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | all_type_descriptions: 4 | - &td0 5 | id: 7 6 | op: 23 7 | type_name: 8 | struct_member_name: "bufferId" 9 | storage_class: 0 # UniformConstant 10 | type_flags: 0x00000104 # VECTOR INT 11 | decoration_flags: 0x00000000 # NONE 12 | traits: 13 | numeric: 14 | scalar: { width: 32, signedness: 0 } 15 | vector: { component_count: 2 } 16 | matrix: { column_count: 0, row_count: 0, stride: 0 } 17 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 18 | array: { dims_count: 0, dims: [], stride: 0 } 19 | member_count: 0 20 | members: 21 | - &td1 22 | id: 8 23 | op: 30 24 | type_name: "T1" 25 | struct_member_name: 26 | storage_class: -1 # NOT APPLICABLE 27 | type_flags: 0x10080000 # STRUCT EXTERNAL_BLOCK 28 | decoration_flags: 0x00000001 # BLOCK 29 | traits: 30 | numeric: 31 | scalar: { width: 0, signedness: 0 } 32 | vector: { component_count: 0 } 33 | matrix: { column_count: 0, row_count: 0, stride: 0 } 34 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 35 | array: { dims_count: 0, dims: [], stride: 0 } 36 | member_count: 1 37 | members: 38 | - *td0 39 | all_block_variables: 40 | - &bv0 41 | name: "bufferId" 42 | offset: 0 43 | absolute_offset: 0 44 | size: 8 45 | padded_size: 8 46 | decorations: 0x00000000 # NONE 47 | numeric: 48 | scalar: { width: 32, signedness: 0 } 49 | vector: { component_count: 2 } 50 | matrix: { column_count: 0, row_count: 0, stride: 0 } 51 | array: { dims_count: 0, dims: [], stride: 0 } 52 | flags: 0x00000000 # NONE 53 | member_count: 0 54 | members: 55 | type_description: *td0 56 | - &bv1 57 | name: "ssbo" 58 | offset: 0 59 | absolute_offset: 0 60 | size: 0 61 | padded_size: 0 62 | decorations: 0x00000000 # NONE 63 | numeric: 64 | scalar: { width: 0, signedness: 0 } 65 | vector: { component_count: 0 } 66 | matrix: { column_count: 0, row_count: 0, stride: 0 } 67 | array: { dims_count: 0, dims: [], stride: 0 } 68 | flags: 0x00000000 # NONE 69 | member_count: 1 70 | members: 71 | - *bv0 72 | type_description: *td1 73 | all_descriptor_bindings: 74 | - &db0 75 | spirv_id: 10 76 | name: "ssbo" 77 | binding: 0 78 | input_attachment_index: 0 79 | set: 0 80 | decoration_flags: 0x00000000 # NONE 81 | descriptor_type: 7 # VK_DESCRIPTOR_TYPE_STORAGE_BUFFER 82 | resource_type: 8 # UAV 83 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 84 | block: *bv1 # "ssbo" 85 | array: { dims_count: 0, dims: [] } 86 | accessed: 1 87 | uav_counter_id: 4294967295 88 | uav_counter_binding: 89 | type_description: *td1 90 | word_offset: { binding: 118, set: 114 } 91 | all_interface_variables: 92 | module: 93 | generator: 8 # Khronos Glslang Reference Front End 94 | entry_point_name: "main" 95 | entry_point_id: 4 96 | source_language: 2 # GLSL 97 | source_language_version: 460 98 | spirv_execution_model: 5 # GLCompute 99 | shader_stage: 0x00000020 # CS 100 | descriptor_binding_count: 1 101 | descriptor_bindings: 102 | - *db0 # "ssbo" 103 | descriptor_set_count: 1 104 | descriptor_sets: 105 | - set: 0 106 | binding_count: 1 107 | bindings: 108 | - *db0 # "ssbo" 109 | input_variable_count: 0, 110 | input_variables: 111 | output_variable_count: 0, 112 | output_variables: 113 | push_constant_count: 0, 114 | push_constants: 115 | specialization_constant_count: 0, 116 | specialization_constants: 117 | ... 118 | -------------------------------------------------------------------------------- /tests/glsl/buffer_pointer.glsl: -------------------------------------------------------------------------------- 1 | #version 460 core 2 | 3 | #extension GL_EXT_buffer_reference : require 4 | 5 | layout(buffer_reference, buffer_reference_align = 16) buffer Data { 6 | float g0; 7 | float g1; 8 | float g2; 9 | }; 10 | 11 | layout(push_constant) uniform PushData { 12 | Data data_ptr; 13 | } push; 14 | 15 | layout(location = 0, index = 0) out vec4 Color; 16 | 17 | void main() 18 | { 19 | float f1 = push.data_ptr.g1; 20 | Color = vec4(f1, 0.0, 0.0, 0.0); 21 | } 22 | 23 | -------------------------------------------------------------------------------- /tests/glsl/buffer_pointer.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/buffer_pointer.spv -------------------------------------------------------------------------------- /tests/glsl/buffer_pointer.txt: -------------------------------------------------------------------------------- 1 | generator : Khronos Glslang Reference Front End 2 | source lang : GLSL 3 | source lang ver : 460 4 | source file : buffer_pointer.glsl 5 | entry point : main (stage=PS) 6 | 7 | 8 | Output variables: 1 9 | 10 | 0: 11 | spirv id : 26 12 | location : 0 13 | type : float4 14 | semantic : 15 | name : Color 16 | qualifier : 17 | 18 | 19 | Push constant blocks: 1 20 | 21 | 0: 22 | spirv id : 14 23 | name : push (PushData) 24 | // size = 16, padded size = 16 25 | struct PushData { 26 | 27 | // abs offset = 0, rel offset = 0, size = 8, padded size = 16 28 | ref struct Data { 29 | float g0; // abs offset = 0, rel offset = 0, size = 4, padded 30 | size = 4 UNUSED 31 | float g1; // abs offset = 4, rel offset = 4, size = 4, padded 32 | size = 4 33 | float g2; // abs offset = 8, rel offset = 8, size = 4, padded 34 | size = 8 UNUSED 35 | } data_ptr; 36 | 37 | } push; 38 | 39 | -------------------------------------------------------------------------------- /tests/glsl/built_in_format.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | #pragma shader_stage(vertex) 3 | 4 | layout (location = 0) out vec3 texcoord; 5 | 6 | void main() { 7 | gl_Position = vec4(gl_VertexIndex, 0, 0, 1); 8 | texcoord = vec3(0,0,0); 9 | } -------------------------------------------------------------------------------- /tests/glsl/built_in_format.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/built_in_format.spv -------------------------------------------------------------------------------- /tests/glsl/fn_struct_param.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | #extension GL_ARB_separate_shader_objects : enable 4 | #extension GL_ARB_shading_language_420pack : enable 5 | 6 | struct B { 7 | float a; 8 | }; 9 | layout (binding = 0) uniform Test { 10 | B b; 11 | } test; 12 | float dothing(const in B b) { 13 | return b.a; 14 | } 15 | layout(location = 0) out vec4 outColor; 16 | void main() { 17 | outColor = vec4(0); 18 | // this is fine 19 | outColor.z = test.b.a; 20 | // this line causes SPV_REFLECT_RESULT_ERROR_SPIRV_INVALID_BLOCK_MEMBER_REFERENCE 21 | outColor.z = dothing(test.b); 22 | } 23 | -------------------------------------------------------------------------------- /tests/glsl/fn_struct_param.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/fn_struct_param.spv -------------------------------------------------------------------------------- /tests/glsl/frag_array_input.glsl: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | 3 | struct structX 4 | { 5 | int x1_; 6 | int x2_; 7 | }; 8 | 9 | struct structY 10 | { 11 | int y1_; 12 | structX y2_[2]; 13 | }; 14 | 15 | struct structZ 16 | { 17 | structX z_[2][2]; 18 | }; 19 | 20 | layout(location = 0) flat in structY in_a; 21 | 22 | layout(location = 5) flat in structX int_b[2]; 23 | 24 | layout(location = 10) in inC { 25 | structX c_[2]; 26 | } in_c; 27 | 28 | layout(location = 14) flat in structX int_d[2][2]; 29 | 30 | layout(location = 22) in inE { 31 | structZ e_[2]; 32 | } in_e; 33 | 34 | layout(location = 38) flat in int in_f[2][2]; 35 | 36 | void main() { } 37 | -------------------------------------------------------------------------------- /tests/glsl/frag_array_input.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/frag_array_input.spv -------------------------------------------------------------------------------- /tests/glsl/frag_barycentric.glsl: -------------------------------------------------------------------------------- 1 | #version 320 es 2 | #extension GL_EXT_fragment_shader_barycentric : require 3 | 4 | precision highp float; 5 | 6 | layout(location = 0) pervertexEXT in float vertexIDs[3]; 7 | layout(location = 1) pervertexEXT in float vertexIDs2[3]; 8 | 9 | layout(location = 1) out float value; 10 | 11 | void main () { 12 | value = (gl_BaryCoordNoPerspEXT.x * vertexIDs[0] + 13 | gl_BaryCoordNoPerspEXT.y * vertexIDs[1] + 14 | gl_BaryCoordNoPerspEXT.z * vertexIDs[2]); 15 | 16 | value += (gl_BaryCoordNoPerspEXT.x * vertexIDs2[0] + 17 | gl_BaryCoordNoPerspEXT.y * vertexIDs2[1] + 18 | gl_BaryCoordNoPerspEXT.z * vertexIDs2[2]); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /tests/glsl/frag_barycentric.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/frag_barycentric.spv -------------------------------------------------------------------------------- /tests/glsl/input_attachment.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | #extension GL_ARB_separate_shader_objects : enable 4 | #extension GL_ARB_shading_language_420pack : enable 5 | 6 | layout (input_attachment_index = 0, set = 0, binding = 0) uniform subpassInput MyInputAttachment0; 7 | layout (input_attachment_index = 1, set = 0, binding = 1) uniform subpassInput MyInputAttachment1; 8 | layout (input_attachment_index = 4, set = 0, binding = 2) uniform subpassInput MyInputAttachment4; 9 | 10 | layout (location = 0) out vec4 oColor; 11 | 12 | void main() { 13 | oColor = subpassLoad(MyInputAttachment0) + 14 | subpassLoad(MyInputAttachment1) + 15 | subpassLoad(MyInputAttachment4); 16 | } -------------------------------------------------------------------------------- /tests/glsl/input_attachment.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/input_attachment.spv -------------------------------------------------------------------------------- /tests/glsl/input_attachment.txt: -------------------------------------------------------------------------------- 1 | generator : Google Shaderc over Glslang 2 | entry point : main 3 | source lang : GLSL 4 | source lang ver : 450 5 | source file : 6 | shader stage : PS 7 | 8 | 9 | Output variables: 1 10 | 11 | 0: 12 | spirv id : 9 13 | location : 0 14 | type : float4 15 | semantic : 16 | name : oColor 17 | qualifier : 18 | 19 | 20 | Descriptor bindings: 3 21 | 22 | Binding 0.0 23 | spirv id : 12 24 | set : 0 25 | binding : 0 26 | type : VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT (UNDEFINED) 27 | count : 1 28 | accessed : true 29 | name : MyInputAttachment0 30 | 31 | Binding 0.1 32 | spirv id : 19 33 | set : 0 34 | binding : 1 35 | type : VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT (UNDEFINED) 36 | count : 1 37 | accessed : true 38 | name : MyInputAttachment1 39 | 40 | Binding 0.2 41 | spirv id : 23 42 | set : 0 43 | binding : 2 44 | type : VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT (UNDEFINED) 45 | count : 1 46 | accessed : true 47 | name : MyInputAttachment4 48 | 49 | -------------------------------------------------------------------------------- /tests/glsl/io_vars_vs.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | #pragma shader_stage(vertex) 3 | 4 | layout (location = 0) out vec3 texcoord; 5 | layout (location = 1) out vec4 colors[4]; 6 | layout (location = 6) out vec3 normals[4][3][2]; 7 | 8 | void main() { 9 | gl_Position = vec4(gl_VertexIndex, 0, 0, 1); 10 | texcoord = vec3(0,0,0); 11 | colors[1] = vec4(0); 12 | normals[3][2][1] = vec3(0); 13 | } -------------------------------------------------------------------------------- /tests/glsl/io_vars_vs.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/io_vars_vs.spv -------------------------------------------------------------------------------- /tests/glsl/matrix_major_order_glsl.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | Build with DXC using -Od to preserve unused types: 3 | 4 | glslangValidator.exe -Od -V -R --aml --amb -e main -S frag -o matrix_major_order_glsl.spv matrix_major_order_glsl.glsl 5 | 6 | */ 7 | #version 450 8 | 9 | // 10 | // NOTE: GLSL does not have 1xN or Nx1 matrices 11 | // 12 | 13 | // ----------------------------------------------------------------------------- 14 | // Matrices without row / column major decoration 15 | // ----------------------------------------------------------------------------- 16 | 17 | uniform mat2x2 mat_2x2; 18 | uniform mat2x3 mat_2x3; 19 | uniform mat2x4 mat_2x4; 20 | 21 | uniform mat3x2 mat_3x2; 22 | uniform mat3x3 mat_3x3; 23 | uniform mat3x4 mat_3x4; 24 | 25 | uniform mat4x2 mat_4x2; 26 | uniform mat4x3 mat_4x3; 27 | uniform mat4x4 mat_4x4; 28 | 29 | // ----------------------------------------------------------------------------- 30 | // Matrices with row major decoration 31 | // ----------------------------------------------------------------------------- 32 | 33 | layout(row_major) uniform mat2x2 row_major_my_mat_2x2; 34 | layout(row_major) uniform mat2x3 row_major_my_mat_2x3; 35 | layout(row_major) uniform mat2x4 row_major_my_mat_2x4; 36 | 37 | layout(row_major) uniform mat3x2 row_major_my_mat_3x2; 38 | layout(row_major) uniform mat3x3 row_major_my_mat_3x3; 39 | layout(row_major) uniform mat3x4 row_major_my_mat_3x4; 40 | 41 | layout(row_major) uniform mat4x2 row_major_my_mat_4x2; 42 | layout(row_major) uniform mat4x3 row_major_my_mat_4x3; 43 | layout(row_major) uniform mat4x4 row_major_my_mat_4x4; 44 | 45 | // ----------------------------------------------------------------------------- 46 | // Matrices with column major decoration 47 | // ----------------------------------------------------------------------------- 48 | 49 | layout(column_major) uniform mat2x2 column_major_my_mat_2x2; 50 | layout(column_major) uniform mat2x3 column_major_my_mat_2x3; 51 | layout(column_major) uniform mat2x4 column_major_my_mat_2x4; 52 | 53 | layout(column_major) uniform mat3x2 column_major_my_mat_3x2; 54 | layout(column_major) uniform mat3x3 column_major_my_mat_3x3; 55 | layout(column_major) uniform mat3x4 column_major_my_mat_3x4; 56 | 57 | layout(column_major) uniform mat4x2 column_major_my_mat_4x2; 58 | layout(column_major) uniform mat4x3 column_major_my_mat_4x3; 59 | layout(column_major) uniform mat4x4 column_major_my_mat_4x4; 60 | 61 | layout(location = 1) in vec4 my_input; 62 | layout(location = 0) out vec4 my_output; 63 | 64 | void main() 65 | { 66 | my_output = my_input; 67 | } -------------------------------------------------------------------------------- /tests/glsl/matrix_major_order_glsl.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/matrix_major_order_glsl.spv -------------------------------------------------------------------------------- /tests/glsl/non_writable_image.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | Compile: 3 | glslangValidator.exe -V -S comp -o non_writable_image.spv non_writable_image.glsl 4 | */ 5 | #version 450 6 | #pragma shader_stage(compute) 7 | 8 | layout (local_size_x = 16, local_size_y = 16, local_size_z = 1) in; 9 | 10 | layout(set = 0, binding = 0, rgba32f) uniform readonly image2D input_image; 11 | layout(set = 0, binding = 1, rgba32f) uniform writeonly image2D output_image; 12 | 13 | void main() { 14 | ivec2 p = ivec2(gl_GlobalInvocationID.xy); 15 | imageStore(output_image, p, imageLoad(input_image, p)); 16 | } -------------------------------------------------------------------------------- /tests/glsl/non_writable_image.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/non_writable_image.spv -------------------------------------------------------------------------------- /tests/glsl/readonly_writeonly.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | Compile: 3 | glslangValidator.exe -V -S comp -o readonly_writeonly.spv readonly_writeonly.glsl 4 | */ 5 | #version 450 6 | #pragma shader_stage(compute) 7 | 8 | layout (local_size_x = 16, local_size_y = 16, local_size_z = 1) in; 9 | 10 | const int kArraySize = 64; 11 | 12 | layout(set = 0, binding = 0) buffer storage_buffer { 13 | readonly float a[kArraySize]; 14 | writeonly float b[kArraySize]; 15 | writeonly readonly float bar[kArraySize]; 16 | } foo; 17 | 18 | void main() { 19 | uint idx = gl_GlobalInvocationID.x; 20 | foo.b[idx] = foo.a[idx]; 21 | } 22 | -------------------------------------------------------------------------------- /tests/glsl/readonly_writeonly.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/readonly_writeonly.spv -------------------------------------------------------------------------------- /tests/glsl/runtime_array_of_array_of_struct.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | #pragma shader_stage(compute) 3 | 4 | #extension GL_EXT_nonuniform_qualifier : enable 5 | 6 | layout (local_size_x = 32, local_size_y = 1, local_size_z = 1) in; 7 | 8 | struct Foo { 9 | int a; 10 | int b; 11 | }; 12 | 13 | layout(set = 0, binding = 0) buffer InutBuffer { 14 | Foo input_values[][3]; 15 | }; 16 | 17 | layout(set = 0, binding = 1) buffer OutputBuffer { 18 | Foo output_values[][3]; 19 | }; 20 | 21 | void main() { 22 | uint index = gl_GlobalInvocationID.x; 23 | output_values[index] = input_values[index]; 24 | } 25 | -------------------------------------------------------------------------------- /tests/glsl/runtime_array_of_array_of_struct.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/runtime_array_of_array_of_struct.spv -------------------------------------------------------------------------------- /tests/glsl/storage_buffer.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | #pragma shader_stage(compute) 3 | 4 | layout (local_size_x = 32, local_size_y = 1, local_size_z = 1) in; 5 | 6 | const int kArraySize = 64; 7 | 8 | layout(set = 0, binding = 0) buffer InputBuffer { 9 | float input_values[kArraySize]; 10 | }; 11 | 12 | layout(set = 0, binding = 1) buffer OutputBuffer { 13 | float output_values[kArraySize]; 14 | }; 15 | 16 | void main() { 17 | uint index = gl_GlobalInvocationID.x; 18 | output_values[index] = input_values[index]; 19 | } 20 | -------------------------------------------------------------------------------- /tests/glsl/storage_buffer.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/storage_buffer.spv -------------------------------------------------------------------------------- /tests/glsl/storage_buffer.txt: -------------------------------------------------------------------------------- 1 | generator : Google Shaderc over Glslang 2 | source lang : GLSL 3 | source lang ver : 450 4 | source file : glsl/storage_buffer.glsl 5 | entry point : main 6 | local size : (32, 1, 1) 7 | 8 | 9 | Input variables: 1 10 | 11 | 0: 12 | spirv id : 12 13 | location : (built-in) GlobalInvocationId 14 | type : uint3 15 | semantic : 16 | name : gl_GlobalInvocationID 17 | qualifier : 18 | 19 | 20 | Descriptor bindings: 2 21 | 22 | Binding 0.0 23 | spirv id : 29 24 | set : 0 25 | binding : 0 26 | type : VK_DESCRIPTOR_TYPE_STORAGE_BUFFER (UAV) 27 | count : 1 28 | accessed : true 29 | name : (InputBuffer) 30 | // size = 0, padded size = 0 31 | struct InputBuffer { 32 | float input_values[64]; // abs offset = 0, rel offset = 0, size = 256, padded size = 256, array stride = 4 33 | } ; 34 | 35 | 36 | Binding 0.1 37 | spirv id : 22 38 | set : 0 39 | binding : 1 40 | type : VK_DESCRIPTOR_TYPE_STORAGE_BUFFER (UAV) 41 | count : 1 42 | accessed : true 43 | name : (OutputBuffer) 44 | // size = 0, padded size = 0 45 | struct OutputBuffer { 46 | float output_values[64]; // abs offset = 0, rel offset = 0, size = 256, padded size = 256, array stride = 4 47 | } ; 48 | 49 | 50 | -------------------------------------------------------------------------------- /tests/glsl/struct_offset_order.glsl: -------------------------------------------------------------------------------- 1 | #version 460 2 | 3 | layout(binding = 0, std430) uniform UniformBufferObject { 4 | layout(offset = 0) float a; 5 | layout(offset = 4) float b; 6 | layout(offset = 8) float c; 7 | layout(offset = 16) float d; 8 | } ubo; 9 | 10 | layout(binding = 0, std430) uniform UniformBufferObject2 { 11 | layout(offset = 4) float b; 12 | layout(offset = 0) float a; 13 | layout(offset = 16) float c; 14 | layout(offset = 8) float d; 15 | } ubo2; 16 | 17 | void main() {} -------------------------------------------------------------------------------- /tests/glsl/struct_offset_order.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/struct_offset_order.spv -------------------------------------------------------------------------------- /tests/glsl/texel_buffer.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_ARB_separate_shader_objects : enable 3 | #extension GL_ARB_shading_language_420pack : enable 4 | #pragma shader_stage(vertex) 5 | layout (set = 0, binding = 1) uniform isamplerBuffer texel_buffer_i; 6 | layout (set = 0, binding = 2) uniform samplerBuffer texel_buffer_f; 7 | 8 | void main() { 9 | int i = texelFetch(texel_buffer_i, gl_InstanceIndex).x; 10 | float f = texelFetch(texel_buffer_f, gl_InstanceIndex).x; 11 | gl_Position = vec4(i, f, 0, 1); 12 | } -------------------------------------------------------------------------------- /tests/glsl/texel_buffer.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/glsl/texel_buffer.spv -------------------------------------------------------------------------------- /tests/glsl/texel_buffer.txt: -------------------------------------------------------------------------------- 1 | generator : Google Shaderc over Glslang 2 | entry point : main 3 | source lang : GLSL 4 | source lang ver : 450 5 | source file : 6 | shader stage : VS 7 | 8 | 9 | Input variables: 1 10 | 11 | 0: 12 | spirv id : 15 13 | location : (built-in) InstanceIndex 14 | type : int 15 | semantic : 16 | name : gl_InstanceIndex 17 | qualifier : 18 | 19 | 20 | Output variables: 1 21 | 22 | 0: 23 | spirv id : 40 24 | location : (built-in) ??? 25 | type : 26 | semantic : 27 | name : 28 | qualifier : 29 | 30 | 31 | Descriptor bindings: 2 32 | 33 | Binding 0.1 34 | spirv id : 12 35 | set : 0 36 | binding : 1 37 | type : VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER (SRV) 38 | count : 1 39 | accessed : true 40 | name : texel_buffer_i 41 | 42 | Binding 0.2 43 | spirv id : 29 44 | set : 0 45 | binding : 2 46 | type : VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER (SRV) 47 | count : 1 48 | accessed : true 49 | name : texel_buffer_f 50 | 51 | -------------------------------------------------------------------------------- /tests/hlsl/append_consume.hlsl: -------------------------------------------------------------------------------- 1 | 2 | struct Data { 3 | uint rgba; 4 | }; 5 | 6 | ConsumeStructuredBuffer BufferIn : register(u0, space1); 7 | AppendStructuredBuffer BufferOut : register(u1, space2); 8 | 9 | float4 main(float4 sv_pos : SV_Position) : SV_TARGET 10 | { 11 | Data val = BufferIn.Consume(); 12 | BufferOut.Append(val); 13 | return float4(1, 0, 0, 0); 14 | } -------------------------------------------------------------------------------- /tests/hlsl/append_consume.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/hlsl/append_consume.spv -------------------------------------------------------------------------------- /tests/hlsl/append_consume.txt: -------------------------------------------------------------------------------- 1 | generator : Google spiregg 2 | entry point : main 3 | source lang : HLSL 4 | source lang ver : 600 5 | source file : hlsl/append_consume.hlsl 6 | shader stage : PS 7 | 8 | 9 | Input variables: 1 10 | 11 | 0: 12 | spirv id : 26 13 | location : (built-in) FragCoord 14 | type : float4 15 | semantic : SV_Position 16 | name : 17 | qualifier : 18 | 19 | 20 | Output variables: 1 21 | 22 | 0: 23 | spirv id : 30 24 | location : 0 25 | type : float4 26 | semantic : SV_TARGET 27 | name : out.var.SV_TARGET 28 | qualifier : 29 | 30 | 31 | Descriptor bindings: 4 32 | 33 | Binding 1.0 34 | spirv id : 7 35 | set : 1 36 | binding : 0 37 | type : VK_DESCRIPTOR_TYPE_STORAGE_BUFFER (UAV) 38 | count : 1 39 | counter : (set=1, binding=1, name=counter.var.BufferIn); 40 | accessed : true 41 | name : BufferIn (type.ConsumeStructuredBuffer.Data) 42 | // size = 0, padded size = 0 43 | struct type.ConsumeStructuredBuffer.Data { 44 | 45 | // abs offset = 0, rel offset = 0, size = 4, padded size = 4 46 | struct Data { 47 | uint rgba; // abs offset = 0, rel offset = 0, size = 4, padded size = 4 48 | } ; 49 | 50 | } BufferIn; 51 | 52 | 53 | Binding 1.1 54 | spirv id : 11 55 | set : 1 56 | binding : 1 57 | type : VK_DESCRIPTOR_TYPE_STORAGE_BUFFER (UAV) 58 | count : 1 59 | accessed : true 60 | name : counter.var.BufferIn (type.ACSBuffer.counter) 61 | // size = 0, padded size = 0 62 | struct type.ACSBuffer.counter { 63 | int ; // abs offset = 0, rel offset = 0, size = 4, padded size = 4 64 | } counter.var.BufferIn; 65 | 66 | 67 | Binding 2.0 68 | spirv id : 15 69 | set : 2 70 | binding : 0 71 | type : VK_DESCRIPTOR_TYPE_STORAGE_BUFFER (UAV) 72 | count : 1 73 | accessed : true 74 | name : counter.var.BufferOut (type.ACSBuffer.counter) 75 | // size = 0, padded size = 0 76 | struct type.ACSBuffer.counter { 77 | int ; // abs offset = 0, rel offset = 0, size = 4, padded size = 4 78 | } counter.var.BufferOut; 79 | 80 | 81 | Binding 2.1 82 | spirv id : 14 83 | set : 2 84 | binding : 1 85 | type : VK_DESCRIPTOR_TYPE_STORAGE_BUFFER (UAV) 86 | count : 1 87 | counter : (set=2, binding=0, name=counter.var.BufferOut); 88 | accessed : true 89 | name : BufferOut (type.AppendStructuredBuffer.Data) 90 | // size = 0, padded size = 0 91 | struct type.AppendStructuredBuffer.Data { 92 | 93 | // abs offset = 0, rel offset = 0, size = 4, padded size = 4 94 | struct Data { 95 | uint rgba; // abs offset = 0, rel offset = 0, size = 4, padded size = 4 96 | } ; 97 | 98 | } BufferOut; 99 | 100 | 101 | -------------------------------------------------------------------------------- /tests/hlsl/array_of_structured_buffer.hlsl: -------------------------------------------------------------------------------- 1 | StructuredBuffer Input[16] : register(t0); 2 | RWStructuredBuffer Output : register(u1); 3 | 4 | [numthreads(16, 16, 1)] 5 | void main(uint3 tid : SV_DispatchThreadID) 6 | { 7 | float3 value = (float3)0; 8 | for (int i = 0; i < 16; ++i) { 9 | value += Input[tid.x][i]; 10 | } 11 | Output[tid.x] = value; 12 | } -------------------------------------------------------------------------------- /tests/hlsl/array_of_structured_buffer.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/hlsl/array_of_structured_buffer.spv -------------------------------------------------------------------------------- /tests/hlsl/binding_array.hlsl: -------------------------------------------------------------------------------- 1 | 2 | //SamplerState MySampler[4][3][2][1] : register(s0); 3 | SamplerState MySampler[6] : register(s0); 4 | Texture2D MyTexture[2] : register(t8); 5 | 6 | float4 main(float4 sv_pos : SV_POSITION) : SV_TARGET { 7 | float4 ret0 = MyTexture[0].Sample(MySampler[0], float2(0, 0)); 8 | float4 ret1 = MyTexture[1].Sample(MySampler[3], float2(0, 0)); 9 | return ret0 + ret1; 10 | } -------------------------------------------------------------------------------- /tests/hlsl/binding_array.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/hlsl/binding_array.spv -------------------------------------------------------------------------------- /tests/hlsl/binding_array.txt: -------------------------------------------------------------------------------- 1 | generator : Google spiregg 2 | entry point : main 3 | source lang : HLSL 4 | source lang ver : 600 5 | source file : hlsl/binding_array.hlsl 6 | shader stage : PS 7 | 8 | 9 | Input variables: 1 10 | 11 | 0: 12 | spirv id : 23 13 | location : (built-in) FragCoord 14 | type : float4 15 | semantic : SV_POSITION 16 | name : 17 | qualifier : 18 | 19 | 20 | Output variables: 1 21 | 22 | 0: 23 | spirv id : 27 24 | location : 0 25 | type : float4 26 | semantic : SV_TARGET 27 | name : out.var.SV_TARGET 28 | qualifier : 29 | 30 | 31 | Descriptor bindings: 2 32 | 33 | Binding 0.0 34 | spirv id : 7 35 | set : 0 36 | binding : 0 37 | type : VK_DESCRIPTOR_TYPE_SAMPLER (SAMPLER) 38 | count : 6 39 | array : [6] 40 | accessed : true 41 | name : MySampler (type.sampler) 42 | 43 | Binding 0.8 44 | spirv id : 13 45 | set : 0 46 | binding : 8 47 | type : VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE (SRV) 48 | count : 2 49 | array : [2] 50 | accessed : true 51 | name : MyTexture (type.2d.image) 52 | 53 | -------------------------------------------------------------------------------- /tests/hlsl/binding_types.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | Build with DXC using -O0 to preserve unused types: 3 | 4 | dxc -spirv -O0 -T ps_5_0 -Fo binding_types.spv binding_types.hlsl 5 | 6 | */ 7 | 8 | cbuffer MyCBuffer { 9 | float x; 10 | }; 11 | 12 | struct Data { float x; }; 13 | ConstantBuffer MyConstantBuffer; 14 | 15 | Texture1D MyTexture1D; 16 | Texture2D MyTexture2D; 17 | Texture3D MyTexture3D; 18 | 19 | Texture1DArray MyTexture1DArray; 20 | Texture2DArray MyTexture2DArray; 21 | 22 | RWTexture1D MyRWTexture1D; 23 | RWTexture2D MyRWTexture2D; 24 | RWTexture3D MyRWTexture3D; 25 | 26 | RWTexture1DArray MyRWTexture1DArray; 27 | RWTexture2DArray MyRWTexture2DArray; 28 | 29 | Texture2DMS MyTexture2DMS; 30 | Texture2DMSArray MyTexture2DMSArray; 31 | 32 | TextureCube MyTextureCube; 33 | TextureCubeArray MyTextureCubeArray; 34 | 35 | tbuffer MyTBuffer { 36 | float q; 37 | }; 38 | 39 | struct Data2 { 40 | float4 x; 41 | }; 42 | 43 | TextureBuffer MyTextureBuffer; 44 | 45 | Buffer MyBuffer; 46 | RWBuffer MyRWBuffer; 47 | 48 | StructuredBuffer MyStructuredBuffer; 49 | RWStructuredBuffer MyRWStructuredBuffer; 50 | 51 | AppendStructuredBuffer MyAppendStructuredBuffer; 52 | ConsumeStructuredBuffer MyConsumeStructuredBuffer; 53 | 54 | ByteAddressBuffer MyByteAddressBuffer; 55 | RWByteAddressBuffer MyRWByteAddressBuffer; 56 | 57 | float4 main(float4 P : SV_POSITION) : SV_TARGET 58 | { 59 | return float4(0, 0, 0, 0); 60 | } 61 | -------------------------------------------------------------------------------- /tests/hlsl/binding_types.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/hlsl/binding_types.spv -------------------------------------------------------------------------------- /tests/hlsl/cbuffer.hlsl: -------------------------------------------------------------------------------- 1 | 2 | struct OmniNormalStength { 3 | float Front; 4 | float Back; 5 | float Top; 6 | float Bottom; 7 | float Left; 8 | float Right; 9 | }; 10 | 11 | struct ClothProperties { 12 | float3 NormalAdjust; 13 | OmniNormalStength Strengths; 14 | uint Type; 15 | }; 16 | 17 | struct AuxData { 18 | ClothProperties ClothProperties[8]; 19 | float3 ClothColors[8]; 20 | float Scales[8]; 21 | int EnableBitMask; 22 | }; 23 | 24 | struct MaterialData { 25 | float3 Color; 26 | float Specular; 27 | float Diffuse; 28 | AuxData AuxDatArray[10]; 29 | }; 30 | 31 | cbuffer MyCBuffer { 32 | MaterialData Material[2][2][3]; 33 | float4x4 ModelMatrix; 34 | float4x4 ProjectionMatrix; 35 | float Time; 36 | float3 Scale; 37 | float2 UvOffsets[12]; 38 | //MaterialData Material[12]; 39 | bool EnableTarget; 40 | }; 41 | 42 | float4 main(float4 pos : POSITION) : SV_Position 43 | { 44 | return float4(Time, 0, 0, 0); 45 | } -------------------------------------------------------------------------------- /tests/hlsl/cbuffer.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/hlsl/cbuffer.spv -------------------------------------------------------------------------------- /tests/hlsl/constantbuffer.hlsl: -------------------------------------------------------------------------------- 1 | 2 | struct OmniNormalStength { 3 | float Front; 4 | float Back; 5 | float Top; 6 | float Bottom; 7 | float Left; 8 | float Right; 9 | }; 10 | 11 | struct ClothProperties { 12 | float3 NormalAdjust; 13 | OmniNormalStength Strengths; 14 | uint Type; 15 | }; 16 | 17 | struct AuxData { 18 | ClothProperties ClothProperties[8]; 19 | float3 ClothColors[8]; 20 | float Scales[8]; 21 | int EnableBitMask; 22 | }; 23 | 24 | struct MaterialData { 25 | float3 Color; 26 | float Specular; 27 | float Diffuse; 28 | AuxData AuxDatArray[10]; 29 | }; 30 | 31 | struct Constants { 32 | MaterialData Material[2][2][3]; 33 | float4x4 ModelMatrix; 34 | float4x4 ProjectionMatrix; 35 | float Time; 36 | float3 Scale; 37 | float2 UvOffsets[12]; 38 | //MaterialData Material[12]; 39 | bool EnableTarget; 40 | }; 41 | 42 | ConstantBuffer MyConstants : register(b0); 43 | 44 | float4 main(float4 pos : POSITION) : SV_Position 45 | { 46 | return float4(MyConstants.Time, 0, 0, 0); 47 | } -------------------------------------------------------------------------------- /tests/hlsl/constantbuffer.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/hlsl/constantbuffer.spv -------------------------------------------------------------------------------- /tests/hlsl/constantbuffer_nested_structs.hlsl: -------------------------------------------------------------------------------- 1 | struct Nested5 { 2 | float d00; 3 | float d01; 4 | float d02; 5 | float d03; 6 | float d04; 7 | float d05; 8 | float d06; 9 | float d07; 10 | float d08; 11 | float d09; 12 | }; 13 | 14 | 15 | struct Nested4 { 16 | float c00; 17 | float c01; 18 | float c02; 19 | float c03; 20 | float c04; 21 | Nested5 nested5_00; 22 | float c05; 23 | float c06; 24 | float c07; 25 | float c08; 26 | float c09; 27 | Nested5 nested5_01; 28 | }; 29 | 30 | 31 | struct Nested3 { 32 | float b00; 33 | float b01; 34 | float b02; 35 | float b03; 36 | float b04; 37 | float b05; 38 | float b06; 39 | float b07; 40 | float b08; 41 | float b09; 42 | Nested4 nested4_00; 43 | }; 44 | 45 | struct Nested2 { 46 | Nested3 nested3_00; 47 | float a00; 48 | float a01; 49 | float a02; 50 | float a03; 51 | float a04; 52 | float a05; 53 | float a06; 54 | float a07; 55 | float a08; 56 | float a09; 57 | Nested4 nested4_00; 58 | }; 59 | 60 | struct Nested1 { 61 | Nested2 nested2_00; 62 | float word00; 63 | float word01; 64 | float word02; 65 | float word03; 66 | float word04; 67 | float word05; 68 | float word06; 69 | float word07; 70 | float word08; 71 | float word09; 72 | Nested2 nested2_01; 73 | }; 74 | 75 | struct Constants { 76 | float var00; 77 | float2 var01; 78 | Nested1 nested1; 79 | float Time; 80 | }; 81 | 82 | ConstantBuffer MyConstants : register(b0); 83 | 84 | float4 main(float4 pos : POSITION) : SV_Position 85 | { 86 | return float4(MyConstants.Time, 0, 0, 0); 87 | } -------------------------------------------------------------------------------- /tests/hlsl/constantbuffer_nested_structs.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/hlsl/constantbuffer_nested_structs.spv -------------------------------------------------------------------------------- /tests/hlsl/counter_buffers.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | Build with DXC using -fspv-reflect to enable counter buffers 3 | 4 | dxc -spirv -fspv-reflect -T ps_5_0 -Fo counter_buffers.spv counter_buffers.hlsl 5 | 6 | */ 7 | 8 | struct Data { 9 | float4 f4; 10 | int i; 11 | }; 12 | 13 | ConsumeStructuredBuffer MyBufferIn : register(u3, space2); 14 | AppendStructuredBuffer MyBufferOut : register(u4, space2); 15 | 16 | float4 main(float4 PosCS : SV_Position) : SV_TARGET0 17 | { 18 | Data val = MyBufferIn.Consume(); 19 | MyBufferOut.Append(val); 20 | 21 | return val.f4; 22 | } -------------------------------------------------------------------------------- /tests/hlsl/counter_buffers.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/hlsl/counter_buffers.spv -------------------------------------------------------------------------------- /tests/hlsl/localsize.hlsl: -------------------------------------------------------------------------------- 1 | 2 | [numthreads(16, 24, 4)] 3 | void csmain() 4 | { 5 | } -------------------------------------------------------------------------------- /tests/hlsl/localsize.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/hlsl/localsize.spv -------------------------------------------------------------------------------- /tests/hlsl/localsize.spv.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | all_type_descriptions: 4 | all_block_variables: 5 | all_descriptor_bindings: 6 | all_interface_variables: 7 | module: 8 | generator: 14 # Google spiregg 9 | entry_point_name: "csmain" 10 | entry_point_id: 1 11 | source_language: 5 # HLSL 12 | source_language_version: 600 13 | spirv_execution_model: 5 # GLCompute 14 | shader_stage: 0x00000020 # CS 15 | descriptor_binding_count: 0 16 | descriptor_bindings: 17 | descriptor_set_count: 0 18 | descriptor_sets: 19 | input_variable_count: 0, 20 | input_variables: 21 | output_variable_count: 0, 22 | output_variables: 23 | push_constant_count: 0, 24 | push_constants: 25 | specialization_constant_count: 0, 26 | specialization_constants: 27 | ... 28 | -------------------------------------------------------------------------------- /tests/hlsl/matrix_major_order_hlsl.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | Build with DXC using -O0 to preserve unused types: 3 | 4 | dxc -spirv -O0 -T ps_5_0 -Fo matrix_major_order_hlsl.spv matrix_major_order_hlsl.hlsl 5 | 6 | */ 7 | 8 | 9 | // 10 | // NOTE: 1xN and Nx1 matrices are aliased to floatN so they're not included. 11 | // 12 | 13 | // ----------------------------------------------------------------------------- 14 | // Matrices without row / column major decoration 15 | // ----------------------------------------------------------------------------- 16 | 17 | float2x2 mat_2x2; 18 | float2x3 mat_2x3; 19 | float2x4 mat_2x4; 20 | 21 | float3x2 mat_3x2; 22 | float3x3 mat_3x3; 23 | float3x4 mat_3x4; 24 | 25 | float4x2 mat_4x2; 26 | float4x3 mat_4x3; 27 | float4x4 mat_4x4; 28 | 29 | // ----------------------------------------------------------------------------- 30 | // Matrices with row major decoration 31 | // ----------------------------------------------------------------------------- 32 | 33 | row_major float2x2 row_major_my_mat_2x2; 34 | row_major float2x3 row_major_my_mat_2x3; 35 | row_major float2x4 row_major_my_mat_2x4; 36 | 37 | row_major float3x2 row_major_my_mat_3x2; 38 | row_major float3x3 row_major_my_mat_3x3; 39 | row_major float3x4 row_major_my_mat_3x4; 40 | 41 | row_major float4x2 row_major_my_mat_4x2; 42 | row_major float4x3 row_major_my_mat_4x3; 43 | row_major float4x4 row_major_my_mat_4x4; 44 | 45 | // ----------------------------------------------------------------------------- 46 | // Matrices with column major decoration 47 | // ----------------------------------------------------------------------------- 48 | 49 | column_major float2x2 column_major_my_mat_2x2; 50 | column_major float2x3 column_major_my_mat_2x3; 51 | column_major float2x4 column_major_my_mat_2x4; 52 | 53 | column_major float3x2 column_major_my_mat_3x2; 54 | column_major float3x3 column_major_my_mat_3x3; 55 | column_major float3x4 column_major_my_mat_3x4; 56 | 57 | column_major float4x2 column_major_my_mat_4x2; 58 | column_major float4x3 column_major_my_mat_4x3; 59 | column_major float4x4 column_major_my_mat_4x4; 60 | 61 | float4 main(float4 pos : SV_POSITION) : SV_TARGET 62 | { 63 | return pos; 64 | } -------------------------------------------------------------------------------- /tests/hlsl/matrix_major_order_hlsl.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/hlsl/matrix_major_order_hlsl.spv -------------------------------------------------------------------------------- /tests/hlsl/pushconstant.hlsl: -------------------------------------------------------------------------------- 1 | 2 | struct Constants_t { 3 | float3 Scale; 4 | float Time; 5 | float2 UvOffsets; 6 | }; 7 | 8 | [[vk::push_constant]] Constants_t g_PushConstants; 9 | 10 | float4 main(float4 pos : POSITION) : SV_Position 11 | { 12 | return float4(g_PushConstants.Time, 0, 0, 0); 13 | } 14 | -------------------------------------------------------------------------------- /tests/hlsl/pushconstant.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/hlsl/pushconstant.spv -------------------------------------------------------------------------------- /tests/hlsl/semantics.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | Build with DXC using -fspv-reflect to enable semantics 3 | 4 | dxc -spirv -fspv-reflect -T ps_5_0 -Fo semantics.spv semantics.hlsl 5 | 6 | */ 7 | 8 | struct UBO { 9 | float4x4 XformMatrix; 10 | float3 Scale; 11 | float t; 12 | float2 uv; 13 | }; 14 | 15 | ConstantBuffer MyConstants : register(b2, space2); 16 | 17 | struct PSInput { 18 | float4 Position : SV_POSITION; 19 | float3 Normal : NORMAL; 20 | float3 Color : COLOR_00001; 21 | float Alpha : OPACITY_512; 22 | float4 Scaling : SCALE_987654321; 23 | float2 TexCoord0 : TEXCOORD0; 24 | float2 TexCoord1 : TEXCOORD1; 25 | float2 TexCoord2 : TEXCOORD2; 26 | }; 27 | 28 | struct PSOutput { 29 | float4 oColor0 : SV_TARGET0; 30 | float4 oColor1 : SV_TARGET1; 31 | float4 oColor2 : SV_TARGET2; 32 | float4 oColor3 : SV_TARGET3; 33 | float4 oColor4 : SV_TARGET4; 34 | float4 oColor5 : SV_TARGET5; 35 | float4 oColor6 : SV_TARGET6; 36 | float4 oColor7 : SV_TARGET7; 37 | }; 38 | 39 | PSOutput main(PSInput input, uint prim_id : SV_PRIMITIVEID) 40 | { 41 | PSOutput ret; 42 | ret.oColor0 = mul(MyConstants.XformMatrix, input.Position); 43 | ret.oColor1 = float4(input.Normal, 1) + float4(MyConstants.Scale, 0); 44 | ret.oColor2 = float4(input.Color, 1); 45 | ret.oColor3 = float4(0, 0, 0, input.Alpha); 46 | ret.oColor4 = input.Scaling; 47 | ret.oColor5 = float4(input.TexCoord0, 0, 0); 48 | ret.oColor6 = float4(input.TexCoord1, 0, 0); 49 | ret.oColor7 = float4(input.TexCoord2, 0, 0); 50 | return ret; 51 | } -------------------------------------------------------------------------------- /tests/hlsl/semantics.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/hlsl/semantics.spv -------------------------------------------------------------------------------- /tests/hlsl/structuredbuffer.hlsl: -------------------------------------------------------------------------------- 1 | 2 | struct SepNormal { 3 | float x; 4 | float y; 5 | float z; 6 | }; 7 | 8 | struct Rgb { 9 | float r[5]; 10 | float g[5]; 11 | float b[5]; 12 | }; 13 | 14 | struct Uv { 15 | float u; 16 | float v; 17 | }; 18 | 19 | struct Data { 20 | float3 Position; 21 | SepNormal Normal; 22 | Rgb Colors[3]; 23 | Uv TexCoords; 24 | float Scales[3]; 25 | uint Id; 26 | }; 27 | 28 | StructuredBuffer MyData : register(t0); 29 | 30 | float4 main() : SV_Target 31 | { 32 | return float4(MyData[0].Position, 1); 33 | } -------------------------------------------------------------------------------- /tests/hlsl/structuredbuffer.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/hlsl/structuredbuffer.spv -------------------------------------------------------------------------------- /tests/hlsl/user_type.hlsl: -------------------------------------------------------------------------------- 1 | StructuredBuffer a; 2 | RWStructuredBuffer b; 3 | AppendStructuredBuffer c; 4 | ConsumeStructuredBuffer d; 5 | Texture1D e; 6 | Texture2D f; 7 | Texture3D g; 8 | TextureCube h; 9 | Texture1DArray i; 10 | Texture2DArray j; 11 | Texture2DMS k; 12 | Texture2DMSArray l; 13 | TextureCubeArray m; 14 | RWTexture1D n; 15 | RWTexture2D o; 16 | RWTexture3D p; 17 | RWTexture1DArray q; 18 | RWTexture2DArray r; 19 | Buffer s; 20 | RWBuffer t; 21 | Texture2DMSArray u; 22 | const Texture2DMSArray v; 23 | Texture1D t1; 24 | Texture2D t2; 25 | 26 | Texture1D eArr[5]; 27 | Texture2D fArr[5]; 28 | Texture3D gArr[5]; 29 | TextureCube hArr[5]; 30 | Texture1DArray iArr[5]; 31 | Texture2DArray jArr[5]; 32 | Texture2DMS kArr[5]; 33 | Texture2DMSArray lArr[5]; 34 | TextureCubeArray mArr[5]; 35 | RWTexture1D nArr[5]; 36 | RWTexture2D oArr[5]; 37 | RWTexture3D pArr[5]; 38 | RWTexture1DArray qArr[5]; 39 | RWTexture2DArray rArr[5]; 40 | Buffer sArr[5]; 41 | RWBuffer tArr[5]; 42 | 43 | cbuffer MyCBuffer { float x; }; 44 | 45 | tbuffer MyTBuffer { float y; }; 46 | 47 | ByteAddressBuffer bab; 48 | 49 | RWByteAddressBuffer rwbab; 50 | 51 | RaytracingAccelerationStructure rs; 52 | 53 | struct S { 54 | float f1; 55 | float3 f2; 56 | }; 57 | 58 | ConstantBuffer cb; 59 | 60 | TextureBuffer tb; 61 | 62 | void main(){ 63 | } 64 | -------------------------------------------------------------------------------- /tests/hlsl/user_type.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/hlsl/user_type.spv -------------------------------------------------------------------------------- /tests/interface/geom_input_builtin_array.glsl: -------------------------------------------------------------------------------- 1 | #version 450 core 2 | 3 | in gl_PerVertex { 4 | vec4 gl_Position; 5 | float gl_CullDistance[3]; 6 | } gl_in[]; 7 | 8 | out gl_PerVertex { 9 | float gl_CullDistance[3]; 10 | }; 11 | 12 | layout(triangles) in; 13 | layout(invocations = 4) in; 14 | layout(line_strip) out; 15 | layout(max_vertices = 127) out; 16 | 17 | void main() 18 | { 19 | vec4 pos = gl_in[2].gl_Position; 20 | gl_CullDistance[2] = gl_in[1].gl_CullDistance[2] * pos.x; 21 | } 22 | -------------------------------------------------------------------------------- /tests/interface/geom_input_builtin_array.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/interface/geom_input_builtin_array.spv -------------------------------------------------------------------------------- /tests/interface/vertex_input_builtin_block.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/interface/vertex_input_builtin_block.spv -------------------------------------------------------------------------------- /tests/interface/vertex_input_builtin_non_block.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | out gl_PerVertex { 4 | vec4 gl_Position; 5 | float gl_PointSize; 6 | }; 7 | 8 | void main() { 9 | float x[4]; 10 | gl_Position = vec4(x[gl_VertexIndex % 4]); 11 | gl_PointSize = x[gl_InstanceIndex % 4]; 12 | } -------------------------------------------------------------------------------- /tests/interface/vertex_input_builtin_non_block.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/interface/vertex_input_builtin_non_block.spv -------------------------------------------------------------------------------- /tests/issues/102/function_parameter_access.glsl: -------------------------------------------------------------------------------- 1 | /* 2 | glslangValidator -V -S frag -g0 --ku -o function_parameter_access.spv function_parameter_access.glsl 3 | */ 4 | 5 | #version 450 6 | 7 | layout(binding = 0) uniform sampler Sampler; 8 | layout(binding = 1) uniform texture2D Texture; 9 | layout(binding = 2) uniform sampler2D Sampler2D; 10 | 11 | layout(binding = 3) uniform sampler NeverAccessedSampler; 12 | layout(binding = 4) uniform texture2D NeverAccessedTexture; 13 | layout(binding = 5) uniform sampler2D NeverAccessedSampler2D; 14 | 15 | layout(location = 0) out vec4 color; 16 | 17 | vec4 access_sampler_and_texture(texture2D t, sampler s, vec2 coord) 18 | { 19 | vec4 ret = texture(sampler2D(t, s), coord); 20 | return vec4(5.0) * ret; 21 | } 22 | 23 | vec4 access_combined_sampler(sampler2D s) 24 | { 25 | vec2 coord = vec2(0.5, 0.5); 26 | vec4 ret = texture(s, coord); 27 | return vec4(1.0, 2.0, 3.0, 1.0) * ret; 28 | } 29 | 30 | vec4 call_access_functions(texture2D t, sampler s) 31 | { 32 | return access_combined_sampler(Sampler2D) + access_sampler_and_texture(t, s, vec2(0.25, 0.75)); 33 | } 34 | 35 | vec4 never_called(texture2D t, sampler s, float u, float v) 36 | { 37 | vec4 ret = texture(sampler2D(t, s), vec2(u, v)); 38 | return vec4(-3.0) * ret; 39 | } 40 | 41 | vec4 never_called_2(vec2 coord) 42 | { 43 | vec4 ret = texture(sampler2D(NeverAccessedTexture, NeverAccessedSampler), coord); 44 | ret *= texture(NeverAccessedSampler2D, coord); 45 | return ret; 46 | } 47 | 48 | void main() 49 | { 50 | color = vec4(-1.0) * call_access_functions(Texture, Sampler); 51 | } 52 | -------------------------------------------------------------------------------- /tests/issues/102/function_parameter_access.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/issues/102/function_parameter_access.spv -------------------------------------------------------------------------------- /tests/issues/178/vertex_input_struct.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/issues/178/vertex_input_struct.spv -------------------------------------------------------------------------------- /tests/issues/178/vertex_input_struct2.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/issues/178/vertex_input_struct2.spv -------------------------------------------------------------------------------- /tests/issues/227/README.md: -------------------------------------------------------------------------------- 1 | Note that null_node.spv and null_type.spv are not valid SPIR-V inputs, can not be decompiled into GLSL, and are solely provided to prevent regressions for a specific null pointer dereference bug (https://github.com/KhronosGroup/SPIRV-Reflect/issues/227). 2 | -------------------------------------------------------------------------------- /tests/issues/227/null_node.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/issues/227/null_node.spv -------------------------------------------------------------------------------- /tests/issues/68/64_bit_float.glsl: -------------------------------------------------------------------------------- 1 | #version 460 core 2 | #extension GL_ARB_separate_shader_objects : enable 3 | 4 | layout(location=0) in dvec2 position; 5 | layout(location=1) in double in_thing; 6 | 7 | layout(location=0) out VertexData { 8 | double out_thing; 9 | } VertexOut; 10 | 11 | void main() { 12 | gl_Position = vec4(position, 0.0, 1.0); 13 | VertexOut.out_thing = in_thing; 14 | } 15 | -------------------------------------------------------------------------------- /tests/issues/77/hlsl/array_from_ubo.hlsl: -------------------------------------------------------------------------------- 1 | struct S_cbPerObjectBones 2 | { 3 | float4 v4Bones[4095]; 4 | }; 5 | 6 | shared cbuffer _cbPerObjectBones : register(b4) 7 | { 8 | S_cbPerObjectBones cbPerObjectBones; 9 | }; 10 | 11 | struct v2f 12 | { 13 | float4 HPosition: SV_POSITION; 14 | float4 Position: POSITION; 15 | }; 16 | 17 | struct a2v_StandardWeighted 18 | { 19 | float4 Position: POSITION0; 20 | int4 Indices: BLENDINDICES; 21 | }; 22 | 23 | float3x4 FailFunc(int4 i, float4 v4Bones[4095]) 24 | { 25 | float4 mRow1 = v4Bones[i.x+0]; 26 | return float3x4(mRow1, mRow1, mRow1); 27 | } 28 | 29 | v2f Test_VS(a2v_StandardWeighted input) 30 | { 31 | v2f OUT=(v2f)0; 32 | float4 inputPosition = float4(input.Position.xyz, 1); 33 | int4 i = input.Indices; 34 | float3x4 mMatrix = FailFunc(i, cbPerObjectBones.v4Bones); 35 | float4 v4Position = float4(mul(mMatrix, inputPosition), 1); 36 | OUT.Position = v4Position; 37 | return OUT; 38 | } -------------------------------------------------------------------------------- /tests/issues/77/hlsl/array_from_ubo.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/issues/77/hlsl/array_from_ubo.spv -------------------------------------------------------------------------------- /tests/issues/77/hlsl/array_from_ubo_with_O0.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/issues/77/hlsl/array_from_ubo_with_O0.spv -------------------------------------------------------------------------------- /tests/issues/77/hlsl/rocketz.hlsl: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Compile command: 4 | dxc.exe -T vs_6_0 -spirv -E Test_VS -Fo rocketz.spv rocketz.hlsl 5 | 6 | */ 7 | 8 | struct S_cbPerObjectBones { 9 | float4 v4Bones[4095]; 10 | }; 11 | 12 | shared cbuffer _cbPerObjectBones : register(b4) 13 | { 14 | S_cbPerObjectBones cbPerObjectBones; 15 | }; 16 | 17 | struct v2f { 18 | float4 HPosition : SV_POSITION; 19 | float4 Position : POSITION; 20 | }; 21 | 22 | struct a2v_StandardWeighted { 23 | float4 Position : POSITION0; 24 | int4 Indices : BLENDINDICES; 25 | }; 26 | 27 | float3x4 FailFunc(int4 i, float4 v4Bones[4095]) 28 | { 29 | float4 mRow1 = v4Bones[i.x + 0]; 30 | return float3x4(mRow1, mRow1, mRow1); 31 | } 32 | 33 | v2f Test_VS(a2v_StandardWeighted input) 34 | { 35 | v2f OUT = (v2f)0; 36 | float4 inputPosition = float4(input.Position.xyz, 1); 37 | int4 i = input.Indices; 38 | float3x4 mMatrix = FailFunc(i, cbPerObjectBones.v4Bones); 39 | float4 v4Position = float4(mul(mMatrix, inputPosition), 1); 40 | OUT.Position = v4Position; 41 | return OUT; 42 | } -------------------------------------------------------------------------------- /tests/issues/77/hlsl/rocketz.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/issues/77/hlsl/rocketz.spv -------------------------------------------------------------------------------- /tests/mesh_shader_ext/mesh_shader_ext.mesh.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -spirv -fspv-target-env=vulkan1.3 -E main -T ms_6_7 -fspv-extension=SPV_EXT_mesh_shader 2 | 3 | struct PayLoad 4 | { 5 | uint data[8]; 6 | }; 7 | 8 | struct Vertex 9 | { 10 | float4 pos : SV_Position; 11 | }; 12 | 13 | struct Primitive 14 | { 15 | uint data : COLOR0; 16 | }; 17 | 18 | [outputtopology("triangle")] 19 | [numthreads(32, 1, 1)] 20 | void main(in uint3 dispatchThreadId : SV_DispatchThreadID, 21 | in uint3 groupThreadId : SV_GroupThreadID, 22 | in uint threadIndex : SV_GroupIndex, 23 | in uint3 groupId : SV_GroupID, 24 | out vertices Vertex verts[64], 25 | out indices uint3 tris[124], 26 | out primitives Primitive prims[124]) 27 | { 28 | SetMeshOutputCounts(3, 1); 29 | 30 | verts[0].pos = float4(1.f, 0.f, 0.f, 1.f); 31 | verts[1].pos = float4(1.f, 1.f, 0.f, 1.f); 32 | verts[2].pos = float4(1.f, 0.f, 1.f, 1.f); 33 | 34 | prims[0].data = 1; 35 | tris[0] = uint3(0, 1, 2); 36 | } -------------------------------------------------------------------------------- /tests/mesh_shader_ext/mesh_shader_ext.mesh.hlsl.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/mesh_shader_ext/mesh_shader_ext.mesh.hlsl.spv -------------------------------------------------------------------------------- /tests/mesh_shader_ext/mesh_shader_ext.task.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -spirv -fspv-target-env=vulkan1.3 -E main -T as_6_7 -fspv-extension=SPV_EXT_mesh_shader 2 | 3 | struct PayLoad 4 | { 5 | uint data[8]; 6 | }; 7 | 8 | groupshared PayLoad s_payload; 9 | 10 | [numthreads(8, 1, 1)] 11 | void main( 12 | in uint3 dispatchThreadId : SV_DispatchThreadID, 13 | in uint3 groupThreadId : SV_GroupThreadID, 14 | in uint threadIndex : SV_GroupIndex, 15 | in uint3 groupId : SV_GroupID) 16 | { 17 | s_payload.data[groupId.x] = 1; 18 | 19 | DispatchMesh(1, 1, 1, s_payload); 20 | } 21 | -------------------------------------------------------------------------------- /tests/mesh_shader_ext/mesh_shader_ext.task.hlsl.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/mesh_shader_ext/mesh_shader_ext.task.hlsl.spv -------------------------------------------------------------------------------- /tests/multi_entrypoint/multi_entrypoint.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout (set = 0, binding = 1) uniform Ubo { 4 | vec4 data; 5 | } ubo; 6 | 7 | layout (location = 1) in vec3 pos; 8 | layout (location = 0) in vec2 iUV; 9 | layout (location = 0) out vec2 oUV; 10 | 11 | layout (push_constant) uniform PushConstantVert { 12 | float val; 13 | } push_constant_vert; 14 | 15 | out gl_PerVertex { 16 | vec4 gl_Position; 17 | }; 18 | 19 | vec4 getData() { 20 | return ubo.data; 21 | } 22 | 23 | void entry_vert() { 24 | oUV = iUV; 25 | gl_Position = vec4(pos, 1.0) * push_constant_vert.val * getData(); 26 | } 27 | 28 | layout (set = 0, binding = 0) uniform sampler2D tex; 29 | layout (location = 1) out vec4 colour; 30 | 31 | /* 32 | layout (push_constant) uniform PushConstantFrag { 33 | float val; 34 | } push_constant_frag; 35 | */ 36 | 37 | void entry_frag() { 38 | colour = texture(tex, iUV) * push_constant_vert.val * getData(); 39 | } 40 | 41 | void main() { 42 | entry_vert(); 43 | entry_frag(); 44 | } 45 | -------------------------------------------------------------------------------- /tests/multi_entrypoint/multi_entrypoint.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/multi_entrypoint/multi_entrypoint.spv -------------------------------------------------------------------------------- /tests/multi_entrypoint/multi_entrypoint.spv.dis.diff: -------------------------------------------------------------------------------- 1 | 9c9,10 2 | < OpEntryPoint Vertex %main "main" %oUV %iUV %_ %pos %colour 3 | --- 4 | > OpEntryPoint Vertex %entry_vert_ "entry_vert" %_ %iUV %oUV %pos 5 | > OpEntryPoint Fragment %entry_frag_ "entry_frag" %iUV %colour 6 | 13d13 7 | < OpName %main "main" 8 | 28a29,31 9 | > OpName %PushConstantFrag "PushConstantFrag" 10 | > OpMemberName %PushConstantFrag 0 "val" 11 | > OpName %push_constant_frag "push_constant_frag" 12 | 42c45 13 | < OpDecorate %colour Location 1 14 | --- 15 | > OpDecorate %colour Location 0 16 | 70a74,76 17 | > %PushConstantFrag = OpTypeStruct %float 18 | > %_ptr_PushConstant_PushConstantFrag = OpTypePointer PushConstant %PushConstantFrag 19 | > %push_constant_frag = OpVariable %_ptr_PushConstant_PushConstantFrag PushConstant 20 | 79,84d84 21 | < %main = OpFunction %void None %3 22 | < %5 = OpLabel 23 | < %68 = OpFunctionCall %void %entry_vert_ 24 | < %69 = OpFunctionCall %void %entry_frag_ 25 | < OpReturn 26 | < OpFunctionEnd 27 | 114c114 28 | < %63 = OpAccessChain %_ptr_PushConstant_float %push_constant_vert %int_0 29 | --- 30 | > %63 = OpAccessChain %_ptr_PushConstant_float %push_constant_frag %int_0 31 | -------------------------------------------------------------------------------- /tests/multi_entrypoint/rebuild.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Creates multi_entrypoint.spv from multi_entrypoint.glsl and 3 | # multi_entrypoint.spv.dis.diff 4 | glslc -fshader-stage=vert multi_entrypoint.glsl -o multi_entrypoint.spv 5 | spirv-dis multi_entrypoint.spv > multi_entrypoint.spv.dis 6 | patch multi_entrypoint.spv.dis multi_entrypoint.spv.dis.diff 7 | spirv-as multi_entrypoint.spv.dis -o multi_entrypoint.spv 8 | -------------------------------------------------------------------------------- /tests/push_constants/non_zero_block_offset.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/push_constants/non_zero_block_offset.spv -------------------------------------------------------------------------------- /tests/push_constants/pointer_in_struct.slang: -------------------------------------------------------------------------------- 1 | RWStructuredBuffer result; 2 | 3 | struct Data{ 4 | int a; 5 | int* b; 6 | int c; 7 | }; 8 | [[vk::push_constant]] Data pc; 9 | 10 | [shader("compute")] 11 | [numthreads(1,1,1)] 12 | void computeMain(uint3 threadId : SV_DispatchThreadID) 13 | { 14 | result[0] = pc.b[2] + pc.c; 15 | } -------------------------------------------------------------------------------- /tests/push_constants/pointer_in_struct.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/push_constants/pointer_in_struct.spv -------------------------------------------------------------------------------- /tests/push_constants/pointer_in_struct_2.slang: -------------------------------------------------------------------------------- 1 | RWStructuredBuffer result; 2 | 3 | struct Data2{ 4 | int x; 5 | int* y; 6 | }; 7 | 8 | struct Data{ 9 | int a; 10 | Data2* b; 11 | int c; 12 | }; 13 | [[vk::push_constant]] Data pc; 14 | 15 | [shader("compute")] 16 | [numthreads(1,1,1)] 17 | void computeMain(uint3 threadId : SV_DispatchThreadID) 18 | { 19 | result[0] = pc.b[2].y[2] + pc.c; 20 | } -------------------------------------------------------------------------------- /tests/push_constants/pointer_in_struct_2.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/push_constants/pointer_in_struct_2.spv -------------------------------------------------------------------------------- /tests/push_constants/push_constant_basic_0.glsl: -------------------------------------------------------------------------------- 1 | #version 460 2 | #extension GL_EXT_buffer_reference : enable 3 | 4 | layout(buffer_reference) buffer Node { uint x; }; 5 | 6 | struct Bar { 7 | uint t; 8 | uint s; 9 | }; 10 | 11 | layout(push_constant, std430) uniform foo { 12 | uint a; 13 | uint b[4]; 14 | Bar bar; 15 | Node node; 16 | }; 17 | 18 | layout(set=0, binding=0) buffer SSBO { 19 | uint out_value; 20 | }; 21 | 22 | // Everything should be marked as UNUSED 23 | void main() {} -------------------------------------------------------------------------------- /tests/push_constants/push_constant_basic_0.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/push_constants/push_constant_basic_0.spv -------------------------------------------------------------------------------- /tests/push_constants/push_constant_basic_1.glsl: -------------------------------------------------------------------------------- 1 | #version 460 2 | #extension GL_EXT_buffer_reference : enable 3 | 4 | layout(buffer_reference) buffer Node { uint x; }; 5 | 6 | struct Bar { 7 | uint t; 8 | uint s; 9 | }; 10 | 11 | layout(push_constant, std430) uniform foo { 12 | uint a; 13 | uint b[4]; 14 | Bar bar; 15 | Node node; 16 | }; 17 | 18 | layout(set=0, binding=0) buffer SSBO { 19 | uint out_value; 20 | }; 21 | 22 | void main() { 23 | out_value = a; 24 | out_value = b[1]; 25 | out_value = bar.s; 26 | out_value = node.x; 27 | } -------------------------------------------------------------------------------- /tests/push_constants/push_constant_basic_1.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/push_constants/push_constant_basic_1.spv -------------------------------------------------------------------------------- /tests/push_constants/push_constant_basic_2.slang: -------------------------------------------------------------------------------- 1 | RWStructuredBuffer result; 2 | 3 | struct Bar{ 4 | uint t; 5 | uint s; 6 | }; 7 | 8 | struct Data{ 9 | uint a; 10 | uint b[4]; 11 | Bar bar; 12 | uint* node; 13 | }; 14 | [[vk::push_constant]] Data pc; 15 | 16 | [shader("compute")] 17 | [numthreads(1,1,1)] 18 | void computeMain(uint3 threadId : SV_DispatchThreadID) 19 | { 20 | result[0] += pc.a; 21 | result[0] += pc.b[1]; 22 | result[0] += pc.bar.s; 23 | result[0] += pc.node[3]; 24 | } -------------------------------------------------------------------------------- /tests/push_constants/push_constant_basic_2.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/push_constants/push_constant_basic_2.spv -------------------------------------------------------------------------------- /tests/push_constants/push_constant_basic_3.slang: -------------------------------------------------------------------------------- 1 | RWStructuredBuffer result; 2 | 3 | struct Foo{ 4 | uint s; 5 | uint t; 6 | }; 7 | 8 | struct Bar{ 9 | uint x_unused; 10 | uint y; 11 | }; 12 | 13 | struct Data{ 14 | uint a_unused; 15 | uint b[4]; 16 | uint c; 17 | uint d_unused[4]; 18 | Foo* foo_unused; 19 | Bar* bar; 20 | }; 21 | [[vk::push_constant]] Data pc; 22 | 23 | [shader("compute")] 24 | [numthreads(1,1,1)] 25 | void computeMain(uint3 threadId : SV_DispatchThreadID) 26 | { 27 | result[0] += pc.c; 28 | result[0] += pc.b[1]; 29 | result[0] += pc.bar->y; 30 | } -------------------------------------------------------------------------------- /tests/push_constants/push_constant_basic_3.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/push_constants/push_constant_basic_3.spv -------------------------------------------------------------------------------- /tests/raytrace/compile_shaders.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ "$#" -ne 1 ]; then 3 | echo -e "error: missing path to DXC" 4 | echo -e "\nUsage:\n compile_shaders.sh \n" 5 | fi 6 | 7 | DXC_EXE=$1 8 | 9 | echo "Using DXC at $DXC_EXE" 10 | 11 | function exec_dxc { 12 | echo $1 13 | eval $1 14 | } 15 | 16 | #exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T cs_6_5 -E CS -Fo rayquery_assign.cs.spv rayquery_assign.cs.hlsl" 17 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T cs_6_5 -E main -Fo rayquery_equal.cs.spv rayquery_equal.cs.hlsl" 18 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T ds_6_5 -E main -Fo rayquery_init_ds.spv rayquery_init_ds.hlsl" 19 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T gs_6_5 -E main -Fo rayquery_init_gs.spv rayquery_init_gs.hlsl" 20 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T hs_6_5 -E main -Fo rayquery_init_hs.spv rayquery_init_hs.hlsl" 21 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T ps_6_5 -E main -Fo rayquery_init_ps.spv rayquery_init_ps.hlsl" 22 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T lib_6_3 -Fo rayquery_init_rahit.spv rayquery_init_rahit.hlsl" 23 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T lib_6_3 -Fo rayquery_init_rcall.spv rayquery_init_rcall.hlsl" 24 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T lib_6_3 -Fo rayquery_init_rchit.spv rayquery_init_rchit.hlsl" 25 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T lib_6_3 -Fo rayquery_init_rgen.spv rayquery_init_rgen.hlsl" 26 | #exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T lib_6_3 -Fo rayquery_init_rint.spv rayquery_init_rint.hlsl" 27 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T lib_6_3 -Fo rayquery_init_rmiss.spv rayquery_init_rmiss.hlsl" 28 | #exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T lib_6_3 -Fo rayquery_init_vs.spv rayquery_init_vs.hlsl" 29 | #exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T lib_6_3 -Fo rayquery_tryAllOps.cs.spv rayquery_tryAllOps.cs.hlsl" 30 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T cs_6_4 -E main -Fo raytracing.acceleration-structure.spv raytracing.acceleration-structure.hlsl" 31 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T lib_6_3 -Fo raytracing.khr.closesthit.spv raytracing.khr.closesthit.hlsl" 32 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T cs_6_4 -E main -Fo raytracing.nv.acceleration-structure.spv raytracing.nv.acceleration-structure.hlsl" 33 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T lib_6_3 -fspv-extension=SPV_NV_ray_tracing -Fo raytracing.nv.anyhit.spv raytracing.nv.anyhit.hlsl" 34 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T lib_6_3 -Fo raytracing.nv.callable.spv raytracing.nv.callable.hlsl" 35 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T lib_6_3 -Fo raytracing.nv.closesthit.spv raytracing.nv.closesthit.hlsl" 36 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T lib_6_3 -Fo raytracing.nv.enum.spv raytracing.nv.enum.hlsl" 37 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T lib_6_3 -Fo raytracing.nv.intersection.spv raytracing.nv.intersection.hlsl" 38 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T lib_6_3 -fspv-extension=SPV_NV_ray_tracing -Fo raytracing.nv.library.spv raytracing.nv.library.hlsl" 39 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T lib_6_3 -Fo raytracing.nv.miss.spv raytracing.nv.miss.hlsl" 40 | exec_dxc "$DXC_EXE -spirv -fspv-target-env=vulkan1.2 -T lib_6_3 -Fo raytracing.nv.raygen.spv raytracing.nv.raygen.hlsl" 41 | -------------------------------------------------------------------------------- /tests/raytrace/rayquery_assign.cs.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T cs_6_5 -E CS -fspv-target-env=vulkan1.2 2 | // CHECK: error: store value of type 'RayQuery' is unsupported 3 | 4 | [numThreads(1,1,1)] 5 | void CS() 6 | { 7 | RayQuery q; 8 | RayQuery b = q; 9 | } -------------------------------------------------------------------------------- /tests/raytrace/rayquery_equal.cs.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T cs_6_5 -E main -fspv-target-env=vulkan1.2 2 | RaytracingAccelerationStructure g_topLevel : register(t0, space0); 3 | RWTexture2D g_output : register(u1, space0); 4 | 5 | [numthreads(64, 1, 1)] 6 | void main(uint2 launchIndex: SV_DispatchThreadID) 7 | { 8 | float3 T = (float3)0; 9 | float sampleCount = 0; 10 | RayDesc ray; 11 | 12 | ray.Origin = float3(0, 0, 0); 13 | ray.Direction = float3(0, 1, 0); 14 | ray.TMin = 0.0; 15 | ray.TMax = 1000.0; 16 | 17 | RayQuery q; 18 | 19 | q.TraceRayInline(g_topLevel, 0, 0xff, ray); 20 | // CHECK: [[rayquery:%\d+]] = OpVariable %_ptr_Function_rayQueryKHR Function 21 | q.Proceed(); 22 | // CHECK: OpRayQueryProceedKHR %bool [[rayquery]] 23 | if(q.CommittedStatus() == COMMITTED_TRIANGLE_HIT) 24 | // CHECK: [[status:%\d+]] = OpRayQueryGetIntersectionTypeKHR %uint [[rayquery]] %uint_1 25 | // CHECK: OpIEqual %bool [[status]] %uint_1 26 | { 27 | T += float3(1, 0, 1); 28 | } 29 | else 30 | { 31 | T += float3(0, 1, 0); 32 | } 33 | 34 | g_output[launchIndex] += float4(T, 1); 35 | } -------------------------------------------------------------------------------- /tests/raytrace/rayquery_equal.cs.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/rayquery_equal.cs.spv -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_ds.hlsl: -------------------------------------------------------------------------------- 1 | // RUN: %dxc -T ds_6_5 -E main -fspv-target-env=vulkan1.2 2 | // CHECK: OpCapability RayQueryKHR 3 | // CHECK: OpExtension "SPV_KHR_ray_query" 4 | 5 | struct VSSceneIn { 6 | float3 pos : POSITION; 7 | }; 8 | 9 | struct PSSceneIn { 10 | float4 pos : SV_Position; 11 | }; 12 | 13 | ////////////////////////////////////////////////////////////////////////////////////////// 14 | // Simple forwarding Tessellation shaders 15 | 16 | struct HSPerVertexData { 17 | // This is just the original vertex verbatim. In many real life cases this would be a 18 | // control point instead 19 | PSSceneIn v; 20 | }; 21 | 22 | struct HSPerPatchData { 23 | // We at least have to specify tess factors per patch 24 | // As we're tesselating triangles, there will be 4 tess factors 25 | // In real life case this might contain face normal, for example 26 | float edges[3] : SV_TessFactor; 27 | float inside : SV_InsideTessFactor; 28 | }; 29 | 30 | RaytracingAccelerationStructure AccelerationStructure : register(t0); 31 | RayDesc MakeRayDesc() 32 | { 33 | RayDesc desc; 34 | desc.Origin = float3(0,0,0); 35 | desc.Direction = float3(1,0,0); 36 | desc.TMin = 0.0f; 37 | desc.TMax = 9999.0; 38 | return desc; 39 | } 40 | void doInitialize(RayQuery query, RayDesc ray) 41 | { 42 | query.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_NON_OPAQUE,0xFF,ray); 43 | } 44 | 45 | // domain shader that actually outputs the triangle vertices 46 | [domain("tri")] PSSceneIn main(const float3 bary 47 | : SV_DomainLocation, 48 | const OutputPatch patch, 49 | const HSPerPatchData perPatchData) { 50 | PSSceneIn v; 51 | v.pos = patch[0].v.pos * bary.x + patch[1].v.pos * bary.y + patch[2].v.pos * bary.z + perPatchData.edges[1]; 52 | 53 | RayQuery q; 54 | RayDesc ray = MakeRayDesc(); 55 | // CHECK: [[accel:%\d+]] = OpLoad %accelerationStructureNV %AccelerationStructure 56 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_1 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 57 | 58 | q.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_OPAQUE, 0xFF, ray); 59 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_3 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 60 | doInitialize(q, ray); 61 | 62 | return v; 63 | } 64 | -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_ds.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/rayquery_init_ds.spv -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_gs.hlsl: -------------------------------------------------------------------------------- 1 | // RUN: %dxc -T gs_6_5 -E main -fspv-target-env=vulkan1.2 2 | // CHECK: OpCapability RayQueryKHR 3 | // CHECK: OpExtension "SPV_KHR_ray_query 4 | 5 | struct Out 6 | { 7 | float4 pos : SV_Position; 8 | }; 9 | 10 | struct Empty{}; 11 | 12 | RaytracingAccelerationStructure AccelerationStructure : register(t0); 13 | RayDesc MakeRayDesc() 14 | { 15 | RayDesc desc; 16 | desc.Origin = float3(0,0,0); 17 | desc.Direction = float3(1,0,0); 18 | desc.TMin = 0.0f; 19 | desc.TMax = 9999.0; 20 | return desc; 21 | } 22 | void doInitialize(RayQuery query, RayDesc ray) 23 | { 24 | query.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_NON_OPAQUE,0xFF,ray); 25 | } 26 | 27 | [maxvertexcount(3)] 28 | void main(line Empty e[4], inout PointStream OutputStream0) 29 | { 30 | RayQuery q; 31 | RayDesc ray = MakeRayDesc(); 32 | // CHECK: [[accel:%\d+]] = OpLoad %accelerationStructureNV %AccelerationStructure 33 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_1 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 34 | 35 | q.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_OPAQUE, 0xFF, ray); 36 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_3 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 37 | doInitialize(q, ray); 38 | 39 | Out output = (Out)0; 40 | 41 | OutputStream0.Append(output); 42 | OutputStream0.RestartStrip(); 43 | } 44 | -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_gs.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/rayquery_init_gs.spv -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_hs.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T hs_6_5 -E main -fspv-target-env=vulkan1.2 2 | // CHECK: OpCapability RayQueryKHR 3 | // CHECK: OpCapability RayTraversalPrimitiveCullingKHR 4 | // CHECK: OpExtension "SPV_KHR_ray_query" 5 | 6 | #define MAX_POINTS 3 7 | 8 | // Input control point 9 | struct VS_CONTROL_POINT_OUTPUT 10 | { 11 | float3 vPosition : WORLDPOS; 12 | }; 13 | 14 | // Output control point 15 | struct CONTROL_POINT 16 | { 17 | float3 vPosition : BEZIERPOS; 18 | }; 19 | 20 | // Output patch constant data. 21 | struct HS_CONSTANT_DATA_OUTPUT 22 | { 23 | float Edges[4] : SV_TessFactor; 24 | float Inside[2] : SV_InsideTessFactor; 25 | }; 26 | 27 | // Patch Constant Function 28 | HS_CONSTANT_DATA_OUTPUT mainConstant(InputPatch ip) { 29 | HS_CONSTANT_DATA_OUTPUT Output; 30 | 31 | // Must initialize Edges and Inside; otherwise HLSL validation will fail. 32 | Output.Edges[0] = 1.0; 33 | Output.Edges[1] = 2.0; 34 | Output.Edges[2] = 3.0; 35 | Output.Edges[3] = 4.0; 36 | Output.Inside[0] = 5.0; 37 | Output.Inside[1] = 6.0; 38 | 39 | return Output; 40 | } 41 | 42 | 43 | 44 | RaytracingAccelerationStructure AccelerationStructure : register(t0); 45 | RayDesc MakeRayDesc() 46 | { 47 | RayDesc desc; 48 | desc.Origin = float3(0,0,0); 49 | desc.Direction = float3(1,0,0); 50 | desc.TMin = 0.0f; 51 | desc.TMax = 9999.0; 52 | return desc; 53 | } 54 | void doInitialize(RayQuery query, RayDesc ray) 55 | { 56 | query.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_NON_OPAQUE,0xFF,ray); 57 | } 58 | 59 | [outputcontrolpoints(MAX_POINTS)] 60 | [patchconstantfunc("mainConstant")] 61 | CONTROL_POINT main(InputPatch ip, uint cpid : SV_OutputControlPointID) { 62 | // CHECK: %rayQueryKHR = OpTypeRayQueryKHR 63 | // CHECK: %_ptr_Function_rayQueryKHR = OpTypePointer Function %rayQueryKHR 64 | // CHECK: [[rayquery:%\d+]] = OpVariable %_ptr_Function_rayQueryKHR Function 65 | RayQuery q; 66 | RayDesc ray = MakeRayDesc(); 67 | // CHECK: [[accel:%\d+]] = OpLoad %accelerationStructureNV %AccelerationStructure 68 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_517 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 69 | 70 | q.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_OPAQUE, 0xFF, ray); 71 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_259 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 72 | doInitialize(q, ray); 73 | CONTROL_POINT result; 74 | return result; 75 | } -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_hs.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/rayquery_init_hs.spv -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_ps.hlsl: -------------------------------------------------------------------------------- 1 | // RUN: %dxc -E main -T ps_6_5 -fspv-target-env=vulkan1.2 2 | 3 | // RUN: %dxc -T gs_6_5 -E main 4 | // CHECK: OpCapability RayQueryKHR 5 | // CHECK: OpExtension "SPV_KHR_ray_query 6 | 7 | RaytracingAccelerationStructure AccelerationStructure : register(t0); 8 | RayDesc MakeRayDesc() 9 | { 10 | RayDesc desc; 11 | desc.Origin = float3(0,0,0); 12 | desc.Direction = float3(1,0,0); 13 | desc.TMin = 0.0f; 14 | desc.TMax = 9999.0; 15 | return desc; 16 | } 17 | void doInitialize(RayQuery query, RayDesc ray) 18 | { 19 | query.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_NON_OPAQUE,0xFF,ray); 20 | } 21 | 22 | uint4 main() : SV_Target 23 | { 24 | RayQuery q; 25 | RayDesc ray = MakeRayDesc(); 26 | // CHECK: [[accel:%\d+]] = OpLoad %accelerationStructureNV %AccelerationStructure 27 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_1 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 28 | 29 | q.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_OPAQUE, 0xFF, ray); 30 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_3 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 31 | doInitialize(q, ray); 32 | return float4(1.0, 0.0, 0.0, 1.0); 33 | } -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_ps.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/rayquery_init_ps.spv -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_rahit.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T lib_6_3 -fspv-target-env=vulkan1.2 2 | // CHECK: OpCapability RayTracingKHR 3 | // CHECK: OpCapability RayQueryKHR 4 | // CHECK: OpExtension "SPV_KHR_ray_tracing" 5 | // CHECK: OpExtension "SPV_KHR_ray_query" 6 | 7 | RaytracingAccelerationStructure AccelerationStructure : register(t0); 8 | RayDesc MakeRayDesc() 9 | { 10 | RayDesc desc; 11 | desc.Origin = float3(0,0,0); 12 | desc.Direction = float3(1,0,0); 13 | desc.TMin = 0.0f; 14 | desc.TMax = 9999.0; 15 | return desc; 16 | } 17 | void doInitialize(RayQuery query, RayDesc ray) 18 | { 19 | query.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_NON_OPAQUE,0xFF,ray); 20 | } 21 | 22 | struct Payload 23 | { 24 | float4 color; 25 | }; 26 | // CHECK: OpTypePointer HitAttributeNV %Attribute 27 | struct Attribute 28 | { 29 | float2 bary; 30 | }; 31 | 32 | [shader("anyhit")] 33 | void main(inout Payload MyPayload, in Attribute MyAttr) { 34 | Payload myPayload = { float4(0.0f,0.0f,0.0f,0.0f) }; 35 | RayQuery q; 36 | RayDesc ray = MakeRayDesc(); 37 | // CHECK: [[accel:%\d+]] = OpLoad %accelerationStructureNV %AccelerationStructure 38 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_1 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 39 | q.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_OPAQUE, 0xFF, ray); 40 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_3 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 41 | doInitialize(q, ray); 42 | } 43 | -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_rahit.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/rayquery_init_rahit.spv -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_rahit.spv.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | all_type_descriptions: 4 | - &td0 5 | id: 4 6 | op: 5341 7 | type_name: "accelerationStructureNV" 8 | struct_member_name: 9 | storage_class: -1 # NOT APPLICABLE 10 | type_flags: 0x00100000 # ??? 11 | decoration_flags: 0x00000000 # NONE 12 | traits: 13 | numeric: 14 | scalar: { width: 0, signedness: 0 } 15 | vector: { component_count: 0 } 16 | matrix: { column_count: 0, row_count: 0, stride: 0 } 17 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 18 | array: { dims_count: 0, dims: [], stride: 0 } 19 | member_count: 0 20 | members: 21 | all_block_variables: 22 | - &bv0 23 | name: 24 | offset: 0 25 | absolute_offset: 0 26 | size: 0 27 | padded_size: 0 28 | decorations: 0x00000000 # NONE 29 | numeric: 30 | scalar: { width: 0, signedness: 0 } 31 | vector: { component_count: 0 } 32 | matrix: { column_count: 0, row_count: 0, stride: 0 } 33 | array: { dims_count: 0, dims: [], stride: 0 } 34 | flags: 0x00000000 # NONE 35 | member_count: 0 36 | members: 37 | type_description: 38 | all_descriptor_bindings: 39 | - &db0 40 | spirv_id: 2 41 | name: "AccelerationStructure" 42 | binding: 0 43 | input_attachment_index: 0 44 | set: 0 45 | decoration_flags: 0x00000000 # NONE 46 | descriptor_type: 1000150000 # VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR 47 | resource_type: 4 # SRV 48 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 49 | block: *bv0 # 50 | array: { dims_count: 0, dims: [] } 51 | accessed: 1 52 | uav_counter_id: 4294967295 53 | uav_counter_binding: 54 | type_description: *td0 55 | word_offset: { binding: 80, set: 76 } 56 | all_interface_variables: 57 | module: 58 | generator: 14 # Google spiregg 59 | entry_point_name: "main" 60 | entry_point_id: 1 61 | source_language: 5 # HLSL 62 | source_language_version: 630 63 | spirv_execution_model: 5315 # AnyHitKHR 64 | shader_stage: 0x00000200 # ANY_HIT 65 | descriptor_binding_count: 1 66 | descriptor_bindings: 67 | - *db0 # "AccelerationStructure" 68 | descriptor_set_count: 1 69 | descriptor_sets: 70 | - set: 0 71 | binding_count: 1 72 | bindings: 73 | - *db0 # "AccelerationStructure" 74 | input_variable_count: 0, 75 | input_variables: 76 | output_variable_count: 0, 77 | output_variables: 78 | push_constant_count: 0, 79 | push_constants: 80 | specialization_constant_count: 0, 81 | specialization_constants: 82 | ... 83 | -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_rcall.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T lib_6_3 -fspv-target-env=vulkan1.2 2 | // CHECK: OpCapability RayTracingKHR 3 | // CHECK: OpCapability RayQueryKHR 4 | // CHECK: OpExtension "SPV_KHR_ray_tracing" 5 | // CHECK: OpExtension "SPV_KHR_ray_query" 6 | 7 | RaytracingAccelerationStructure AccelerationStructure : register(t0); 8 | RayDesc MakeRayDesc() 9 | { 10 | RayDesc desc; 11 | desc.Origin = float3(0,0,0); 12 | desc.Direction = float3(1,0,0); 13 | desc.TMin = 0.0f; 14 | desc.TMax = 9999.0; 15 | return desc; 16 | } 17 | void doInitialize(RayQuery query, RayDesc ray) 18 | { 19 | query.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_NON_OPAQUE,0xFF,ray); 20 | } 21 | 22 | struct Payload 23 | { 24 | float4 color; 25 | }; 26 | 27 | [shader("miss")] 28 | void main(inout Payload MyPayload) { 29 | Payload myPayload = { float4(0.0f,0.0f,0.0f,0.0f) }; 30 | RayQuery q; 31 | RayDesc ray = MakeRayDesc(); 32 | // CHECK: [[accel:%\d+]] = OpLoad %accelerationStructureNV %AccelerationStructure 33 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_1 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 34 | q.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_OPAQUE, 0xFF, ray); 35 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_3 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 36 | doInitialize(q, ray); 37 | } 38 | -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_rcall.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/rayquery_init_rcall.spv -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_rcall.spv.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | all_type_descriptions: 4 | - &td0 5 | id: 4 6 | op: 5341 7 | type_name: "accelerationStructureNV" 8 | struct_member_name: 9 | storage_class: -1 # NOT APPLICABLE 10 | type_flags: 0x00100000 # ??? 11 | decoration_flags: 0x00000000 # NONE 12 | traits: 13 | numeric: 14 | scalar: { width: 0, signedness: 0 } 15 | vector: { component_count: 0 } 16 | matrix: { column_count: 0, row_count: 0, stride: 0 } 17 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 18 | array: { dims_count: 0, dims: [], stride: 0 } 19 | member_count: 0 20 | members: 21 | all_block_variables: 22 | - &bv0 23 | name: 24 | offset: 0 25 | absolute_offset: 0 26 | size: 0 27 | padded_size: 0 28 | decorations: 0x00000000 # NONE 29 | numeric: 30 | scalar: { width: 0, signedness: 0 } 31 | vector: { component_count: 0 } 32 | matrix: { column_count: 0, row_count: 0, stride: 0 } 33 | array: { dims_count: 0, dims: [], stride: 0 } 34 | flags: 0x00000000 # NONE 35 | member_count: 0 36 | members: 37 | type_description: 38 | all_descriptor_bindings: 39 | - &db0 40 | spirv_id: 2 41 | name: "AccelerationStructure" 42 | binding: 0 43 | input_attachment_index: 0 44 | set: 0 45 | decoration_flags: 0x00000000 # NONE 46 | descriptor_type: 1000150000 # VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR 47 | resource_type: 4 # SRV 48 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 49 | block: *bv0 # 50 | array: { dims_count: 0, dims: [] } 51 | accessed: 1 52 | uav_counter_id: 4294967295 53 | uav_counter_binding: 54 | type_description: *td0 55 | word_offset: { binding: 80, set: 76 } 56 | all_interface_variables: 57 | module: 58 | generator: 14 # Google spiregg 59 | entry_point_name: "main" 60 | entry_point_id: 1 61 | source_language: 5 # HLSL 62 | source_language_version: 630 63 | spirv_execution_model: 5317 # MissKHR 64 | shader_stage: 0x00000800 # MISS 65 | descriptor_binding_count: 1 66 | descriptor_bindings: 67 | - *db0 # "AccelerationStructure" 68 | descriptor_set_count: 1 69 | descriptor_sets: 70 | - set: 0 71 | binding_count: 1 72 | bindings: 73 | - *db0 # "AccelerationStructure" 74 | input_variable_count: 0, 75 | input_variables: 76 | output_variable_count: 0, 77 | output_variables: 78 | push_constant_count: 0, 79 | push_constants: 80 | specialization_constant_count: 0, 81 | specialization_constants: 82 | ... 83 | -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_rchit.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T lib_6_3 -fspv-target-env=vulkan1.2 2 | // CHECK: OpCapability RayTracingKHR 3 | // CHECK: OpCapability RayQueryKHR 4 | // CHECK: OpExtension "SPV_KHR_ray_tracing" 5 | // CHECK: OpExtension "SPV_KHR_ray_query" 6 | 7 | RaytracingAccelerationStructure AccelerationStructure : register(t0); 8 | RayDesc MakeRayDesc() 9 | { 10 | RayDesc desc; 11 | desc.Origin = float3(0,0,0); 12 | desc.Direction = float3(1,0,0); 13 | desc.TMin = 0.0f; 14 | desc.TMax = 9999.0; 15 | return desc; 16 | } 17 | void doInitialize(RayQuery query, RayDesc ray) 18 | { 19 | query.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_NON_OPAQUE,0xFF,ray); 20 | } 21 | 22 | struct Payload 23 | { 24 | float4 color; 25 | }; 26 | // CHECK: OpTypePointer HitAttributeNV %Attribute 27 | struct Attribute 28 | { 29 | float2 bary; 30 | }; 31 | 32 | [shader("closesthit")] 33 | void main(inout Payload MyPayload, in Attribute MyAttr) { 34 | Payload myPayload = { float4(0.0f,0.0f,0.0f,0.0f) }; 35 | RayQuery q; 36 | RayDesc ray = MakeRayDesc(); 37 | // CHECK: [[accel:%\d+]] = OpLoad %accelerationStructureNV %AccelerationStructure 38 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_1 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 39 | q.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_OPAQUE, 0xFF, ray); 40 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_3 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 41 | doInitialize(q, ray); 42 | } 43 | -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_rchit.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/rayquery_init_rchit.spv -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_rchit.spv.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | all_type_descriptions: 4 | - &td0 5 | id: 4 6 | op: 5341 7 | type_name: "accelerationStructureNV" 8 | struct_member_name: 9 | storage_class: -1 # NOT APPLICABLE 10 | type_flags: 0x00100000 # ??? 11 | decoration_flags: 0x00000000 # NONE 12 | traits: 13 | numeric: 14 | scalar: { width: 0, signedness: 0 } 15 | vector: { component_count: 0 } 16 | matrix: { column_count: 0, row_count: 0, stride: 0 } 17 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 18 | array: { dims_count: 0, dims: [], stride: 0 } 19 | member_count: 0 20 | members: 21 | all_block_variables: 22 | - &bv0 23 | name: 24 | offset: 0 25 | absolute_offset: 0 26 | size: 0 27 | padded_size: 0 28 | decorations: 0x00000000 # NONE 29 | numeric: 30 | scalar: { width: 0, signedness: 0 } 31 | vector: { component_count: 0 } 32 | matrix: { column_count: 0, row_count: 0, stride: 0 } 33 | array: { dims_count: 0, dims: [], stride: 0 } 34 | flags: 0x00000000 # NONE 35 | member_count: 0 36 | members: 37 | type_description: 38 | all_descriptor_bindings: 39 | - &db0 40 | spirv_id: 2 41 | name: "AccelerationStructure" 42 | binding: 0 43 | input_attachment_index: 0 44 | set: 0 45 | decoration_flags: 0x00000000 # NONE 46 | descriptor_type: 1000150000 # VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR 47 | resource_type: 4 # SRV 48 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 49 | block: *bv0 # 50 | array: { dims_count: 0, dims: [] } 51 | accessed: 1 52 | uav_counter_id: 4294967295 53 | uav_counter_binding: 54 | type_description: *td0 55 | word_offset: { binding: 80, set: 76 } 56 | all_interface_variables: 57 | module: 58 | generator: 14 # Google spiregg 59 | entry_point_name: "main" 60 | entry_point_id: 1 61 | source_language: 5 # HLSL 62 | source_language_version: 630 63 | spirv_execution_model: 5316 # ClosestHitKHR 64 | shader_stage: 0x00000400 # CLOSEST_HIT 65 | descriptor_binding_count: 1 66 | descriptor_bindings: 67 | - *db0 # "AccelerationStructure" 68 | descriptor_set_count: 1 69 | descriptor_sets: 70 | - set: 0 71 | binding_count: 1 72 | bindings: 73 | - *db0 # "AccelerationStructure" 74 | input_variable_count: 0, 75 | input_variables: 76 | output_variable_count: 0, 77 | output_variables: 78 | push_constant_count: 0, 79 | push_constants: 80 | specialization_constant_count: 0, 81 | specialization_constants: 82 | ... 83 | -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_rgen.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T lib_6_3 -fspv-target-env=vulkan1.2 2 | // CHECK: OpCapability RayTracingKHR 3 | // CHECK: OpCapability RayQueryKHR 4 | // CHECK: OpExtension "SPV_KHR_ray_tracing" 5 | // CHECK: OpExtension "SPV_KHR_ray_query" 6 | 7 | // CHECK-COUNT-1: [[rs:%\d+]] = OpTypeAccelerationStructureNV 8 | RaytracingAccelerationStructure AccelerationStructure : register(t0); 9 | RayDesc MakeRayDesc() 10 | { 11 | RayDesc desc; 12 | desc.Origin = float3(0,0,0); 13 | desc.Direction = float3(1,0,0); 14 | desc.TMin = 0.0f; 15 | desc.TMax = 9999.0; 16 | return desc; 17 | } 18 | void doInitialize(RayQuery query, RayDesc ray) 19 | { 20 | query.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_NON_OPAQUE,0xFF,ray); 21 | } 22 | 23 | struct Payload 24 | { 25 | float4 color; 26 | }; 27 | 28 | 29 | [shader("raygeneration")] 30 | void main() { 31 | 32 | Payload myPayload = { float4(0.0f,0.0f,0.0f,0.0f) }; 33 | RayQuery q; 34 | RayDesc ray = MakeRayDesc(); 35 | // CHECK: [[accel:%\d+]] = OpLoad %accelerationStructureNV %AccelerationStructure 36 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_1 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 37 | q.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_OPAQUE, 0xFF, ray); 38 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_3 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 39 | doInitialize(q, ray); 40 | // CHECK: OpTraceNV {{%\d+}} %uint_0 %uint_255 %uint_0 %uint_1 %uint_0 {{%\d+}} {{%\d+}} {{%\d+}} {{%\d+}} %uint_0 41 | TraceRay(AccelerationStructure, 0x0, 0xff, 0, 1, 0, ray, myPayload); 42 | } 43 | -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_rgen.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/rayquery_init_rgen.spv -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_rgen.spv.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | all_type_descriptions: 4 | - &td0 5 | id: 4 6 | op: 5341 7 | type_name: "accelerationStructureNV" 8 | struct_member_name: 9 | storage_class: -1 # NOT APPLICABLE 10 | type_flags: 0x00100000 # ??? 11 | decoration_flags: 0x00000000 # NONE 12 | traits: 13 | numeric: 14 | scalar: { width: 0, signedness: 0 } 15 | vector: { component_count: 0 } 16 | matrix: { column_count: 0, row_count: 0, stride: 0 } 17 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 18 | array: { dims_count: 0, dims: [], stride: 0 } 19 | member_count: 0 20 | members: 21 | all_block_variables: 22 | - &bv0 23 | name: 24 | offset: 0 25 | absolute_offset: 0 26 | size: 0 27 | padded_size: 0 28 | decorations: 0x00000000 # NONE 29 | numeric: 30 | scalar: { width: 0, signedness: 0 } 31 | vector: { component_count: 0 } 32 | matrix: { column_count: 0, row_count: 0, stride: 0 } 33 | array: { dims_count: 0, dims: [], stride: 0 } 34 | flags: 0x00000000 # NONE 35 | member_count: 0 36 | members: 37 | type_description: 38 | all_descriptor_bindings: 39 | - &db0 40 | spirv_id: 2 41 | name: "AccelerationStructure" 42 | binding: 0 43 | input_attachment_index: 0 44 | set: 0 45 | decoration_flags: 0x00000000 # NONE 46 | descriptor_type: 1000150000 # VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR 47 | resource_type: 4 # SRV 48 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 49 | block: *bv0 # 50 | array: { dims_count: 0, dims: [] } 51 | accessed: 1 52 | uav_counter_id: 4294967295 53 | uav_counter_binding: 54 | type_description: *td0 55 | word_offset: { binding: 84, set: 80 } 56 | all_interface_variables: 57 | module: 58 | generator: 14 # Google spiregg 59 | entry_point_name: "main" 60 | entry_point_id: 1 61 | source_language: 5 # HLSL 62 | source_language_version: 630 63 | spirv_execution_model: 5313 # RayGenerationKHR 64 | shader_stage: 0x00000100 # RAYGEN 65 | descriptor_binding_count: 1 66 | descriptor_bindings: 67 | - *db0 # "AccelerationStructure" 68 | descriptor_set_count: 1 69 | descriptor_sets: 70 | - set: 0 71 | binding_count: 1 72 | bindings: 73 | - *db0 # "AccelerationStructure" 74 | input_variable_count: 0, 75 | input_variables: 76 | output_variable_count: 0, 77 | output_variables: 78 | push_constant_count: 0, 79 | push_constants: 80 | specialization_constant_count: 0, 81 | specialization_constants: 82 | ... 83 | -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_rint.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T lib_6_3 -fspv-target-env=vulkan1.2 2 | // CHECK: OpCapability RayTracingKHR 3 | // CHECK: OpCapability RayQueryKHR 4 | // CHECK: OpExtension "SPV_KHR_ray_tracing" 5 | // CHECK: OpExtension "SPV_KHR_ray_query" 6 | 7 | RaytracingAccelerationStructure AccelerationStructure : register(t0); 8 | RayDesc MakeRayDesc() 9 | { 10 | RayDesc desc; 11 | desc.Origin = float3(0,0,0); 12 | desc.Direction = float3(1,0,0); 13 | desc.TMin = 0.0f; 14 | desc.TMax = 9999.0; 15 | return desc; 16 | } 17 | void doInitialize(RayQuery query, RayDesc ray) 18 | { 19 | query.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_NON_OPAQUE,0xFF,ray); 20 | } 21 | 22 | struct CallData 23 | { 24 | float4 data; 25 | }; 26 | 27 | [shader("callable")] 28 | void main() { 29 | 30 | RayQuery q; 31 | RayDesc ray = MakeRayDesc(); 32 | // CHECK: [[accel:%\d+]] = OpLoad %accelerationStructureNV %AccelerationStructure 33 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_1 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 34 | q.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_OPAQUE, 0xFF, ray); 35 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_3 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 36 | doInitialize(q, ray); 37 | 38 | Attribute myHitAttribute = { float2(0.0f,0.0f) }; 39 | // CHECK: OpReportIntersectionKHR %bool %float_0 %uint_0 40 | ReportHit(0.0f, 0U, myHitAttribute); 41 | } 42 | -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_rmiss.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T lib_6_3 -fspv-target-env=vulkan1.2 2 | // CHECK: OpCapability RayTracingKHR 3 | // CHECK: OpCapability RayQueryKHR 4 | // CHECK: OpExtension "SPV_KHR_ray_tracing" 5 | // CHECK: OpExtension "SPV_KHR_ray_query" 6 | 7 | RaytracingAccelerationStructure AccelerationStructure : register(t0); 8 | RayDesc MakeRayDesc() 9 | { 10 | RayDesc desc; 11 | desc.Origin = float3(0,0,0); 12 | desc.Direction = float3(1,0,0); 13 | desc.TMin = 0.0f; 14 | desc.TMax = 9999.0; 15 | return desc; 16 | } 17 | void doInitialize(RayQuery query, RayDesc ray) 18 | { 19 | query.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_NON_OPAQUE,0xFF,ray); 20 | } 21 | 22 | struct Payload 23 | { 24 | float4 color; 25 | }; 26 | 27 | [shader("miss")] 28 | void main(inout Payload MyPayload) { 29 | Payload myPayload = { float4(0.0f,0.0f,0.0f,0.0f) }; 30 | RayQuery q; 31 | RayDesc ray = MakeRayDesc(); 32 | // CHECK: [[accel:%\d+]] = OpLoad %accelerationStructureNV %AccelerationStructure 33 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_1 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 34 | q.TraceRayInline(AccelerationStructure,RAY_FLAG_FORCE_OPAQUE, 0xFF, ray); 35 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_3 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 36 | doInitialize(q, ray); 37 | } 38 | -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_rmiss.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/rayquery_init_rmiss.spv -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_rmiss.spv.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | all_type_descriptions: 4 | - &td0 5 | id: 4 6 | op: 5341 7 | type_name: "accelerationStructureNV" 8 | struct_member_name: 9 | storage_class: -1 # NOT APPLICABLE 10 | type_flags: 0x00100000 # ??? 11 | decoration_flags: 0x00000000 # NONE 12 | traits: 13 | numeric: 14 | scalar: { width: 0, signedness: 0 } 15 | vector: { component_count: 0 } 16 | matrix: { column_count: 0, row_count: 0, stride: 0 } 17 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 18 | array: { dims_count: 0, dims: [], stride: 0 } 19 | member_count: 0 20 | members: 21 | all_block_variables: 22 | - &bv0 23 | name: 24 | offset: 0 25 | absolute_offset: 0 26 | size: 0 27 | padded_size: 0 28 | decorations: 0x00000000 # NONE 29 | numeric: 30 | scalar: { width: 0, signedness: 0 } 31 | vector: { component_count: 0 } 32 | matrix: { column_count: 0, row_count: 0, stride: 0 } 33 | array: { dims_count: 0, dims: [], stride: 0 } 34 | flags: 0x00000000 # NONE 35 | member_count: 0 36 | members: 37 | type_description: 38 | all_descriptor_bindings: 39 | - &db0 40 | spirv_id: 2 41 | name: "AccelerationStructure" 42 | binding: 0 43 | input_attachment_index: 0 44 | set: 0 45 | decoration_flags: 0x00000000 # NONE 46 | descriptor_type: 1000150000 # VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR 47 | resource_type: 4 # SRV 48 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 49 | block: *bv0 # 50 | array: { dims_count: 0, dims: [] } 51 | accessed: 1 52 | uav_counter_id: 4294967295 53 | uav_counter_binding: 54 | type_description: *td0 55 | word_offset: { binding: 80, set: 76 } 56 | all_interface_variables: 57 | module: 58 | generator: 14 # Google spiregg 59 | entry_point_name: "main" 60 | entry_point_id: 1 61 | source_language: 5 # HLSL 62 | source_language_version: 630 63 | spirv_execution_model: 5317 # MissKHR 64 | shader_stage: 0x00000800 # MISS 65 | descriptor_binding_count: 1 66 | descriptor_bindings: 67 | - *db0 # "AccelerationStructure" 68 | descriptor_set_count: 1 69 | descriptor_sets: 70 | - set: 0 71 | binding_count: 1 72 | bindings: 73 | - *db0 # "AccelerationStructure" 74 | input_variable_count: 0, 75 | input_variables: 76 | output_variable_count: 0, 77 | output_variables: 78 | push_constant_count: 0, 79 | push_constants: 80 | specialization_constant_count: 0, 81 | specialization_constants: 82 | ... 83 | -------------------------------------------------------------------------------- /tests/raytrace/rayquery_init_vs.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T vs_6_5 -E main -fspv-target-env=vulkan1.2 2 | // CHECK: OpCapability RayQueryKHR 3 | // CHECK: OpCapability RayTraversalPrimitiveCullingKHR 4 | // CHECK: OpExtension "SPV_KHR_ray_query" 5 | 6 | 7 | RaytracingAccelerationStructure AccelerationStructure : register(t0); 8 | RWByteAddressBuffer log : register(u0); 9 | 10 | RayDesc MakeRayDesc() 11 | { 12 | RayDesc desc; 13 | desc.Origin = float3(0,0,0); 14 | desc.Direction = float3(1,0,0); 15 | desc.TMin = 0.0f; 16 | desc.TMax = 9999.0; 17 | return desc; 18 | } 19 | 20 | 21 | void DoSomething() 22 | { 23 | log.Store(0,1); 24 | } 25 | 26 | void doInitialize(RayQuery query, RayDesc ray) 27 | { 28 | query.TraceRayInline(AccelerationStructure,RAY_FLAG_NONE,0xFF,ray); 29 | } 30 | 31 | 32 | void main() 33 | { 34 | // CHECK: %rayQueryKHR = OpTypeRayQueryKHR 35 | // CHECK: %_ptr_Function_rayQueryKHR = OpTypePointer Function %rayQueryKHR 36 | // CHECK: [[rayquery:%\d+]] = OpVariable %_ptr_Function_rayQueryKHR Function 37 | RayQuery q; 38 | RayDesc ray = MakeRayDesc(); 39 | // CHECK: [[accel:%\d+]] = OpLoad %accelerationStructureNV %AccelerationStructure 40 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_517 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 41 | 42 | q.TraceRayInline(AccelerationStructure,RAY_FLAG_SKIP_PROCEDURAL_PRIMITIVES, 0xFF, ray); 43 | // CHECK: OpRayQueryInitializeKHR [[rayquery]] [[accel]] %uint_5 %uint_255 {{%\d+}} %float_0 {{%\d+}} %float_9999 44 | doInitialize(q, ray); 45 | } -------------------------------------------------------------------------------- /tests/raytrace/raytracing.acceleration-structure.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -E main -T cs_6_4 -fspv-target-env=vulkan1.2 2 | 3 | // CHECK: OpCapability RayTracingKHR 4 | 5 | // CHECK: %accelerationStructureNV = OpTypeAccelerationStructureKHR 6 | 7 | RaytracingAccelerationStructure test_bvh; 8 | 9 | [numthreads(1, 1, 1)] 10 | void main() {} 11 | -------------------------------------------------------------------------------- /tests/raytrace/raytracing.acceleration-structure.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/raytracing.acceleration-structure.spv -------------------------------------------------------------------------------- /tests/raytrace/raytracing.acceleration-structure.spv.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | all_type_descriptions: 4 | all_block_variables: 5 | all_descriptor_bindings: 6 | all_interface_variables: 7 | module: 8 | generator: 14 # Google spiregg 9 | entry_point_name: "main" 10 | entry_point_id: 1 11 | source_language: 5 # HLSL 12 | source_language_version: 640 13 | spirv_execution_model: 5 # GLCompute 14 | shader_stage: 0x00000020 # CS 15 | descriptor_binding_count: 0 16 | descriptor_bindings: 17 | descriptor_set_count: 0 18 | descriptor_sets: 19 | input_variable_count: 0, 20 | input_variables: 21 | output_variable_count: 0, 22 | output_variables: 23 | push_constant_count: 0, 24 | push_constants: 25 | specialization_constant_count: 0, 26 | specialization_constants: 27 | ... 28 | -------------------------------------------------------------------------------- /tests/raytrace/raytracing.khr.closesthit.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T lib_6_3 -fspv-target-env=vulkan1.2 2 | // CHECK: OpCapability RayTracingKHR 3 | // CHECK: OpExtension "SPV_KHR_ray_tracing" 4 | // CHECK: OpDecorate [[a:%\d+]] BuiltIn LaunchIdNV 5 | // CHECK: OpDecorate [[b:%\d+]] BuiltIn LaunchSizeNV 6 | // CHECK: OpDecorate [[c:%\d+]] BuiltIn WorldRayOriginNV 7 | // CHECK: OpDecorate [[d:%\d+]] BuiltIn WorldRayDirectionNV 8 | // CHECK: OpDecorate [[e:%\d+]] BuiltIn RayTminNV 9 | // CHECK: OpDecorate [[f:%\d+]] BuiltIn IncomingRayFlagsNV 10 | // CHECK: OpDecorate %gl_InstanceID BuiltIn InstanceId 11 | // CHECK: OpDecorate [[g:%\d+]] BuiltIn InstanceCustomIndexNV 12 | // CHECK: OpDecorate %gl_PrimitiveID BuiltIn PrimitiveId 13 | // CHECK: OpDecorate [[h:%\d+]] BuiltIn ObjectRayOriginNV 14 | // CHECK: OpDecorate [[i:%\d+]] BuiltIn ObjectRayDirectionNV 15 | // CHECK: OpDecorate [[j:%\d+]] BuiltIn ObjectToWorldNV 16 | // CHECK: OpDecorate [[k:%\d+]] BuiltIn WorldToObjectNV 17 | // CHECK: OpDecorate [[l:%\d+]] BuiltIn HitKindNV 18 | // CHECK: OpDecorate [[m:%\d+]] BuiltIn RayGeometryIndexKHR 19 | 20 | // CHECK: OpTypePointer IncomingRayPayloadNV %Payload 21 | struct Payload 22 | { 23 | float4 color; 24 | }; 25 | 26 | struct CallData 27 | { 28 | float4 data; 29 | }; 30 | // CHECK: OpTypePointer HitAttributeNV %Attribute 31 | struct Attribute 32 | { 33 | float2 bary; 34 | }; 35 | 36 | // CHECK-COUNT-1: [[rstype:%\d+]] = OpTypeAccelerationStructureNV 37 | RaytracingAccelerationStructure rs; 38 | 39 | [shader("closesthit")] 40 | void main(inout Payload MyPayload, in Attribute MyAttr) { 41 | 42 | // CHECK: OpLoad %v3uint [[a]] 43 | uint3 _1 = DispatchRaysIndex(); 44 | // CHECK: OpLoad %v3uint [[b]] 45 | uint3 _2 = DispatchRaysDimensions(); 46 | // CHECK: OpLoad %v3float [[c]] 47 | float3 _3 = WorldRayOrigin(); 48 | // CHECK: OpLoad %v3float [[d]] 49 | float3 _4 = WorldRayDirection(); 50 | // CHECK: OpLoad %float [[e]] 51 | float _5 = RayTMin(); 52 | // CHECK: OpLoad %uint [[f]] 53 | uint _6 = RayFlags(); 54 | // CHECK: OpLoad %uint %gl_InstanceID 55 | uint _7 = InstanceIndex(); 56 | // CHECK: OpLoad %uint [[g]] 57 | uint _8 = InstanceID(); 58 | // CHECK: OpLoad %uint %gl_PrimitiveID 59 | uint _9 = PrimitiveIndex(); 60 | // CHECK: OpLoad %v3float [[h]] 61 | float3 _10 = ObjectRayOrigin(); 62 | // CHECK: OpLoad %v3float [[i]] 63 | float3 _11 = ObjectRayDirection(); 64 | // CHECK: [[matotw:%\d+]] = OpLoad %mat4v3float [[j]] 65 | // CHECK-NEXT: OpTranspose %mat3v4float [[matotw]] 66 | float3x4 _12 = ObjectToWorld3x4(); 67 | // CHECK: OpLoad %mat4v3float [[j]] 68 | float4x3 _13 = ObjectToWorld4x3(); 69 | // CHECK: [[matwto:%\d+]] = OpLoad %mat4v3float [[k]] 70 | // CHECK-NEXT: OpTranspose %mat3v4float [[matwto]] 71 | float3x4 _14 = WorldToObject3x4(); 72 | // CHECK: OpLoad %mat4v3float [[k]] 73 | float4x3 _15 = WorldToObject4x3(); 74 | // CHECK: OpLoad %uint [[l]] 75 | uint _16 = HitKind(); 76 | // CHECK: OpLoad %uint [[m]] 77 | uint _17 = GeometryIndex(); 78 | 79 | Payload myPayload = { float4(0.0f,0.0f,0.0f,0.0f) }; 80 | CallData myCallData = { float4(0.0f,0.0f,0.0f,0.0f) }; 81 | // CHECK: OpStore %myPayload {{%\d+}} 82 | RayDesc rayDesc; 83 | rayDesc.Origin = float3(0.0f, 0.0f, 0.0f); 84 | rayDesc.Direction = float3(0.0f, 0.0f, -1.0f); 85 | rayDesc.TMin = 0.0f; 86 | rayDesc.TMax = 1000.0f; 87 | // CHECK: OpTraceRayKHR {{%\d+}} %uint_0 %uint_255 %uint_0 %uint_1 %uint_0 {{%\d+}} {{%\d+}} {{%\d+}} {{%\d+}} %myPayload 88 | TraceRay(rs, 0x0, 0xff, 0, 1, 0, rayDesc, myPayload); 89 | // CHECK: OpExecuteCallableKHR %uint_0 %myCallData 90 | CallShader(0, myCallData); 91 | } 92 | -------------------------------------------------------------------------------- /tests/raytrace/raytracing.khr.closesthit.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/raytracing.khr.closesthit.spv -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.acceleration-structure.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -E main -T cs_6_4 -fspv-target-env=vulkan1.2 -fspv-extension=SPV_NV_ray_tracing 2 | 3 | // CHECK: OpCapability RayTracingNV 4 | // CHECK: OpExtension "SPV_NV_ray_tracing" 5 | 6 | // CHECK: %accelerationStructureNV = OpTypeAccelerationStructureKHR 7 | 8 | RaytracingAccelerationStructure test_bvh; 9 | 10 | [numthreads(1, 1, 1)] 11 | void main() {} 12 | -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.acceleration-structure.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/raytracing.nv.acceleration-structure.spv -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.acceleration-structure.spv.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | all_type_descriptions: 4 | all_block_variables: 5 | all_descriptor_bindings: 6 | all_interface_variables: 7 | module: 8 | generator: 14 # Google spiregg 9 | entry_point_name: "main" 10 | entry_point_id: 1 11 | source_language: 5 # HLSL 12 | source_language_version: 640 13 | spirv_execution_model: 5 # GLCompute 14 | shader_stage: 0x00000020 # CS 15 | descriptor_binding_count: 0 16 | descriptor_bindings: 17 | descriptor_set_count: 0 18 | descriptor_sets: 19 | input_variable_count: 0, 20 | input_variables: 21 | output_variable_count: 0, 22 | output_variables: 23 | push_constant_count: 0, 24 | push_constants: 25 | specialization_constant_count: 0, 26 | specialization_constants: 27 | ... 28 | -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.anyhit.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T lib_6_3 -fspv-extension=SPV_NV_ray_tracing 2 | // CHECK: OpCapability RayTracingNV 3 | // CHECK: OpExtension "SPV_NV_ray_tracing" 4 | // CHECK: OpDecorate [[a:%\d+]] BuiltIn LaunchIdNV 5 | // CHECK: OpDecorate [[b:%\d+]] BuiltIn LaunchSizeNV 6 | // CHECK: OpDecorate [[c:%\d+]] BuiltIn WorldRayOriginNV 7 | // CHECK: OpDecorate [[d:%\d+]] BuiltIn WorldRayDirectionNV 8 | // CHECK: OpDecorate [[e:%\d+]] BuiltIn RayTminNV 9 | // CHECK: OpDecorate [[f:%\d+]] BuiltIn IncomingRayFlagsNV 10 | // CHECK: OpDecorate %gl_InstanceID BuiltIn InstanceId 11 | // CHECK: OpDecorate [[g:%\d+]] BuiltIn InstanceCustomIndexNV 12 | // CHECK: OpDecorate %gl_PrimitiveID BuiltIn PrimitiveId 13 | // CHECK: OpDecorate [[h:%\d+]] BuiltIn ObjectRayOriginNV 14 | // CHECK: OpDecorate [[i:%\d+]] BuiltIn ObjectRayDirectionNV 15 | // CHECK: OpDecorate [[j:%\d+]] BuiltIn ObjectToWorldNV 16 | // CHECK: OpDecorate [[k:%\d+]] BuiltIn WorldToObjectNV 17 | // CHECK: OpDecorate [[l:%\d+]] BuiltIn HitKindNV 18 | 19 | // CHECK: OpTypePointer IncomingRayPayloadNV %Payload 20 | struct Payload 21 | { 22 | float4 color; 23 | }; 24 | // CHECK: OpTypePointer HitAttributeNV %Attribute 25 | struct Attribute 26 | { 27 | float2 bary; 28 | }; 29 | 30 | // CHECK-COUNT-1: [[rstype:%\d+]] = OpTypeAccelerationStructureNV 31 | RaytracingAccelerationStructure rs; 32 | 33 | [shader("anyhit")] 34 | void main(inout Payload MyPayload, in Attribute MyAttr) { 35 | 36 | // CHECK: OpLoad %v3uint [[a]] 37 | uint3 _1 = DispatchRaysIndex(); 38 | // CHECK: OpLoad %v3uint [[b]] 39 | uint3 _2 = DispatchRaysDimensions(); 40 | // CHECK: OpLoad %v3float [[c]] 41 | float3 _3 = WorldRayOrigin(); 42 | // CHECK: OpLoad %v3float [[d]] 43 | float3 _4 = WorldRayDirection(); 44 | // CHECK: OpLoad %float [[e]] 45 | float _5 = RayTMin(); 46 | // CHECK: OpLoad %uint [[f]] 47 | uint _6 = RayFlags(); 48 | // CHECK: OpLoad %uint %gl_InstanceID 49 | uint _7 = InstanceIndex(); 50 | // CHECK: OpLoad %uint [[g]] 51 | uint _8 = InstanceID(); 52 | // CHECK: OpLoad %uint %gl_PrimitiveID 53 | uint _9 = PrimitiveIndex(); 54 | // CHECK: OpLoad %v3float [[h]] 55 | float3 _10 = ObjectRayOrigin(); 56 | // CHECK: OpLoad %v3float [[i]] 57 | float3 _11 = ObjectRayDirection(); 58 | // CHECK: [[matotw:%\d+]] = OpLoad %mat4v3float [[j]] 59 | // CHECK-NEXT: OpTranspose %mat3v4float [[matotw]] 60 | float3x4 _12 = ObjectToWorld3x4(); 61 | // CHECK: OpLoad %mat4v3float [[j]] 62 | float4x3 _13 = ObjectToWorld4x3(); 63 | // CHECK: [[matwto:%\d+]] = OpLoad %mat4v3float [[k]] 64 | // CHECK-NEXT: OpTranspose %mat3v4float [[matwto]] 65 | float3x4 _14 = WorldToObject3x4(); 66 | // CHECK: OpLoad %mat4v3float [[k]] 67 | float4x3 _15 = WorldToObject4x3(); 68 | // CHECK: OpLoad %uint [[l]] 69 | uint _16 = HitKind(); 70 | 71 | if (_16 == 1U) { 72 | // CHECK: [[payloadread0:%\d+]] = OpLoad %Payload %MyPayload_0 73 | // CHECK-NEXT : OpStore %MyPayload [[payloadread0]] 74 | // CHECK-NEXT : OpIgnoreIntersectionNV 75 | IgnoreHit(); 76 | } else { 77 | // CHECK: [[payloadread1:%\d+]] = OpLoad %Payload %MyPayload_0 78 | // CHECK-NEXT : OpStore %MyPayload [[payloadread1]] 79 | // CHECK-NEXT : OpTerminateRayNV 80 | AcceptHitAndEndSearch(); 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.anyhit.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/raytracing.nv.anyhit.spv -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.callable.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T lib_6_3 -fspv-extension=SPV_NV_ray_tracing 2 | // CHECK: OpCapability RayTracingNV 3 | // CHECK: OpExtension "SPV_NV_ray_tracing" 4 | // CHECK: OpDecorate [[a:%\d+]] BuiltIn LaunchIdNV 5 | // CHECK: OpDecorate [[b:%\d+]] BuiltIn LaunchSizeNV 6 | 7 | // CHECK: OpTypePointer IncomingCallableDataNV %CallData 8 | struct CallData 9 | { 10 | float4 data; 11 | }; 12 | 13 | [shader("callable")] 14 | void main(inout CallData myCallData) { 15 | 16 | // CHECK: OpLoad %v3uint [[a]] 17 | uint3 a = DispatchRaysIndex(); 18 | // CHECK: OpLoad %v3uint [[b]] 19 | uint3 b = DispatchRaysDimensions(); 20 | } 21 | -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.callable.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/raytracing.nv.callable.spv -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.callable.spv.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | all_type_descriptions: 4 | - &td0 5 | id: 10 6 | op: 23 7 | type_name: 8 | struct_member_name: 9 | storage_class: -1 # NOT APPLICABLE 10 | type_flags: 0x00000104 # VECTOR INT 11 | decoration_flags: 0x00000000 # NONE 12 | traits: 13 | numeric: 14 | scalar: { width: 32, signedness: 0 } 15 | vector: { component_count: 3 } 16 | matrix: { column_count: 0, row_count: 0, stride: 0 } 17 | image: { dim: 0, depth: 0, arrayed: 0, ms: 0, sampled: 0, image_format: 0 } # dim=1D image_format=Unknown 18 | array: { dims_count: 0, dims: [], stride: 0 } 19 | member_count: 0 20 | members: 21 | all_block_variables: 22 | all_descriptor_bindings: 23 | all_interface_variables: 24 | - &iv0 25 | spirv_id: 3 26 | name: 27 | location: 4294967295 28 | storage_class: 1 # Input 29 | semantic: 30 | decoration_flags: 0x00000010 # BUILT_IN 31 | built_in: 5319 # InLaunchIdKHR 32 | numeric: 33 | scalar: { width: 32, signedness: 0 } 34 | vector: { component_count: 3 } 35 | matrix: { column_count: 0, row_count: 0, stride: 0 } 36 | array: { dims_count: 0, dims: [], stride: 0 } 37 | member_count: 0 38 | members: 39 | format: 104 # VK_FORMAT_R32G32B32_UINT 40 | type_description: *td0 41 | word_offset: { location: 0 } 42 | - &iv1 43 | spirv_id: 4 44 | name: 45 | location: 4294967295 46 | storage_class: 1 # Input 47 | semantic: 48 | decoration_flags: 0x00000010 # BUILT_IN 49 | built_in: 5320 # InLaunchSizeKHR 50 | numeric: 51 | scalar: { width: 32, signedness: 0 } 52 | vector: { component_count: 3 } 53 | matrix: { column_count: 0, row_count: 0, stride: 0 } 54 | array: { dims_count: 0, dims: [], stride: 0 } 55 | member_count: 0 56 | members: 57 | format: 104 # VK_FORMAT_R32G32B32_UINT 58 | type_description: *td0 59 | word_offset: { location: 0 } 60 | module: 61 | generator: 14 # Google spiregg 62 | entry_point_name: "main" 63 | entry_point_id: 1 64 | source_language: 5 # HLSL 65 | source_language_version: 630 66 | spirv_execution_model: 5318 # CallableKHR 67 | shader_stage: 0x00002000 # CALLABLE 68 | descriptor_binding_count: 0 69 | descriptor_bindings: 70 | descriptor_set_count: 0 71 | descriptor_sets: 72 | input_variable_count: 2, 73 | input_variables: 74 | - *iv0 # 75 | - *iv1 # 76 | output_variable_count: 0, 77 | output_variables: 78 | push_constant_count: 0, 79 | push_constants: 80 | specialization_constant_count: 0, 81 | specialization_constants: 82 | ... 83 | -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.closesthit.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T lib_6_3 -fspv-extension=SPV_NV_ray_tracing 2 | // CHECK: OpCapability RayTracingNV 3 | // CHECK: OpExtension "SPV_NV_ray_tracing" 4 | // CHECK: OpDecorate [[a:%\d+]] BuiltIn LaunchIdNV 5 | // CHECK: OpDecorate [[b:%\d+]] BuiltIn LaunchSizeNV 6 | // CHECK: OpDecorate [[c:%\d+]] BuiltIn WorldRayOriginNV 7 | // CHECK: OpDecorate [[d:%\d+]] BuiltIn WorldRayDirectionNV 8 | // CHECK: OpDecorate [[e:%\d+]] BuiltIn RayTminNV 9 | // CHECK: OpDecorate [[f:%\d+]] BuiltIn IncomingRayFlagsNV 10 | // CHECK: OpDecorate %gl_InstanceID BuiltIn InstanceId 11 | // CHECK: OpDecorate [[g:%\d+]] BuiltIn InstanceCustomIndexNV 12 | // CHECK: OpDecorate %gl_PrimitiveID BuiltIn PrimitiveId 13 | // CHECK: OpDecorate [[h:%\d+]] BuiltIn ObjectRayOriginNV 14 | // CHECK: OpDecorate [[i:%\d+]] BuiltIn ObjectRayDirectionNV 15 | // CHECK: OpDecorate [[j:%\d+]] BuiltIn ObjectToWorldNV 16 | // CHECK: OpDecorate [[k:%\d+]] BuiltIn WorldToObjectNV 17 | // CHECK: OpDecorate [[l:%\d+]] BuiltIn HitKindNV 18 | 19 | // CHECK: OpTypePointer IncomingRayPayloadNV %Payload 20 | struct Payload 21 | { 22 | float4 color; 23 | }; 24 | // CHECK: OpTypePointer HitAttributeNV %Attribute 25 | struct Attribute 26 | { 27 | float2 bary; 28 | }; 29 | 30 | // CHECK-COUNT-1: [[rstype:%\d+]] = OpTypeAccelerationStructureNV 31 | RaytracingAccelerationStructure rs; 32 | 33 | [shader("closesthit")] 34 | void main(inout Payload MyPayload, in Attribute MyAttr) { 35 | 36 | // CHECK: OpLoad %v3uint [[a]] 37 | uint3 _1 = DispatchRaysIndex(); 38 | // CHECK: OpLoad %v3uint [[b]] 39 | uint3 _2 = DispatchRaysDimensions(); 40 | // CHECK: OpLoad %v3float [[c]] 41 | float3 _3 = WorldRayOrigin(); 42 | // CHECK: OpLoad %v3float [[d]] 43 | float3 _4 = WorldRayDirection(); 44 | // CHECK: OpLoad %float [[e]] 45 | float _5 = RayTMin(); 46 | // CHECK: OpLoad %uint [[f]] 47 | uint _6 = RayFlags(); 48 | // CHECK: OpLoad %uint %gl_InstanceID 49 | uint _7 = InstanceIndex(); 50 | // CHECK: OpLoad %uint [[g]] 51 | uint _8 = InstanceID(); 52 | // CHECK: OpLoad %uint %gl_PrimitiveID 53 | uint _9 = PrimitiveIndex(); 54 | // CHECK: OpLoad %v3float [[h]] 55 | float3 _10 = ObjectRayOrigin(); 56 | // CHECK: OpLoad %v3float [[i]] 57 | float3 _11 = ObjectRayDirection(); 58 | // CHECK: [[matotw:%\d+]] = OpLoad %mat4v3float [[j]] 59 | // CHECK-NEXT: OpTranspose %mat3v4float [[matotw]] 60 | float3x4 _12 = ObjectToWorld3x4(); 61 | // CHECK: OpLoad %mat4v3float [[j]] 62 | float4x3 _13 = ObjectToWorld4x3(); 63 | // CHECK: [[matwto:%\d+]] = OpLoad %mat4v3float [[k]] 64 | // CHECK-NEXT: OpTranspose %mat3v4float [[matwto]] 65 | float3x4 _14 = WorldToObject3x4(); 66 | // CHECK: OpLoad %mat4v3float [[k]] 67 | float4x3 _15 = WorldToObject4x3(); 68 | // CHECK: OpLoad %uint [[l]] 69 | uint _16 = HitKind(); 70 | 71 | Payload myPayload = { float4(0.0f,0.0f,0.0f,0.0f) }; 72 | RayDesc rayDesc; 73 | rayDesc.Origin = float3(0.0f, 0.0f, 0.0f); 74 | rayDesc.Direction = float3(0.0f, 0.0f, -1.0f); 75 | rayDesc.TMin = 0.0f; 76 | rayDesc.TMax = 1000.0f; 77 | // CHECK: OpTraceNV {{%\d+}} %uint_0 %uint_255 %uint_0 %uint_1 %uint_0 {{%\d+}} {{%\d+}} {{%\d+}} {{%\d+}} %uint_0 78 | TraceRay(rs, 0x0, 0xff, 0, 1, 0, rayDesc, myPayload); 79 | } 80 | -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.closesthit.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/raytracing.nv.closesthit.spv -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.enum.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T lib_6_3 -fspv-extension=SPV_NV_ray_tracing 2 | // CHECK: OpCapability RayTracingNV 3 | // CHECK: OpExtension "SPV_NV_ray_tracing" 4 | // CHECK: OpDecorate [[a:%\d+]] BuiltIn LaunchIdNV 5 | // CHECK: OpDecorate [[b:%\d+]] BuiltIn LaunchSizeNV 6 | 7 | // CHECK-COUNT-1: [[rstype:%\d+]] = OpTypeAccelerationStructureNV 8 | RaytracingAccelerationStructure rs; 9 | 10 | struct Payload 11 | { 12 | float4 color; 13 | }; 14 | struct CallData 15 | { 16 | float4 data; 17 | }; 18 | 19 | //CHECK: %First = OpVariable %_ptr_Private_int Private %int_0 20 | //CHECK-NEXT: %Second = OpVariable %_ptr_Private_int Private %int_1 21 | enum Number { 22 | First, 23 | Second, 24 | }; 25 | 26 | //CHECK: [[first:%\d+]] = OpLoad %int %First 27 | //CHECK-NEXT: OpStore %foo [[first]] 28 | static ::Number foo = First; 29 | 30 | [shader("raygeneration")] 31 | void main() { 32 | //CHECK: [[second:%\d+]] = OpLoad %int %Second 33 | //CHECK-NEXT: OpStore %bar [[second]] 34 | static ::Number bar = Second; 35 | 36 | uint3 a = DispatchRaysIndex(); 37 | uint3 b = DispatchRaysDimensions(); 38 | 39 | Payload myPayload = { float4(0.0f,0.0f,0.0f,0.0f) }; 40 | CallData myCallData = { float4(0.0f,0.0f,0.0f,0.0f) }; 41 | RayDesc rayDesc; 42 | rayDesc.Origin = float3(0.0f, 0.0f, 0.0f); 43 | rayDesc.Direction = float3(0.0f, 0.0f, -1.0f); 44 | rayDesc.TMin = 0.0f; 45 | rayDesc.TMax = 1000.0f; 46 | TraceRay(rs, 0x0, 0xff, 0, 1, 0, rayDesc, myPayload); 47 | CallShader(0, myCallData); 48 | } 49 | -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.enum.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/raytracing.nv.enum.spv -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.intersection.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T lib_6_3 -fspv-extension=SPV_NV_ray_tracing 2 | // CHECK: OpCapability RayTracingNV 3 | // CHECK: OpExtension "SPV_NV_ray_tracing" 4 | // CHECK: OpDecorate [[a:%\d+]] BuiltIn LaunchIdNV 5 | // CHECK: OpDecorate [[b:%\d+]] BuiltIn LaunchSizeNV 6 | // CHECK: OpDecorate [[c:%\d+]] BuiltIn WorldRayOriginNV 7 | // CHECK: OpDecorate [[d:%\d+]] BuiltIn WorldRayDirectionNV 8 | // CHECK: OpDecorate [[e:%\d+]] BuiltIn RayTminNV 9 | // CHECK: OpDecorate [[f:%\d+]] BuiltIn IncomingRayFlagsNV 10 | // CHECK: OpDecorate %gl_InstanceID BuiltIn InstanceId 11 | // CHECK: OpDecorate [[g:%\d+]] BuiltIn InstanceCustomIndexNV 12 | // CHECK: OpDecorate %gl_PrimitiveID BuiltIn PrimitiveId 13 | // CHECK: OpDecorate [[h:%\d+]] BuiltIn ObjectRayOriginNV 14 | // CHECK: OpDecorate [[i:%\d+]] BuiltIn ObjectRayDirectionNV 15 | // CHECK: OpDecorate [[j:%\d+]] BuiltIn ObjectToWorldNV 16 | // CHECK: OpDecorate [[k:%\d+]] BuiltIn WorldToObjectNV 17 | 18 | struct Attribute 19 | { 20 | float2 bary; 21 | }; 22 | 23 | [shader("intersection")] 24 | void main() { 25 | 26 | // CHECK: OpLoad %v3uint [[a]] 27 | uint3 _1 = DispatchRaysIndex(); 28 | // CHECK: OpLoad %v3uint [[b]] 29 | uint3 _2 = DispatchRaysDimensions(); 30 | // CHECK: OpLoad %v3float [[c]] 31 | float3 _3 = WorldRayOrigin(); 32 | // CHECK: OpLoad %v3float [[d]] 33 | float3 _4 = WorldRayDirection(); 34 | // CHECK: OpLoad %float [[e]] 35 | float _5 = RayTMin(); 36 | // CHECK: OpLoad %uint [[f]] 37 | uint _6 = RayFlags(); 38 | // CHECK: OpLoad %uint %gl_InstanceID 39 | uint _7 = InstanceIndex(); 40 | // CHECK: OpLoad %uint [[g]] 41 | uint _8 = InstanceID(); 42 | // CHECK: OpLoad %uint %gl_PrimitiveID 43 | uint _9 = PrimitiveIndex(); 44 | // CHECK: OpLoad %v3float [[h]] 45 | float3 _10 = ObjectRayOrigin(); 46 | // CHECK: OpLoad %v3float [[i]] 47 | float3 _11 = ObjectRayDirection(); 48 | // CHECK: [[matotw:%\d+]] = OpLoad %mat4v3float [[j]] 49 | // CHECK-NEXT: OpTranspose %mat3v4float [[matotw]] 50 | float3x4 _12 = ObjectToWorld3x4(); 51 | // CHECK: OpLoad %mat4v3float [[j]] 52 | float4x3 _13 = ObjectToWorld4x3(); 53 | // CHECK: [[matwto:%\d+]] = OpLoad %mat4v3float [[k]] 54 | // CHECK-NEXT: OpTranspose %mat3v4float [[matwto]] 55 | float3x4 _14 = WorldToObject3x4(); 56 | // CHECK: OpLoad %mat4v3float [[k]] 57 | float4x3 _15 = WorldToObject4x3(); 58 | 59 | Attribute myHitAttribute = { float2(0.0f,0.0f) }; 60 | // CHECK: OpReportIntersectionKHR %bool %float_0 %uint_0 61 | ReportHit(0.0f, 0U, myHitAttribute); 62 | } 63 | -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.intersection.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/raytracing.nv.intersection.spv -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.library.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/raytracing.nv.library.spv -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.miss.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T lib_6_3 -fspv-extension=SPV_NV_ray_tracing 2 | // CHECK: OpCapability RayTracingNV 3 | // CHECK: OpExtension "SPV_NV_ray_tracing" 4 | // CHECK: OpDecorate [[a:%\d+]] BuiltIn LaunchIdNV 5 | // CHECK: OpDecorate [[b:%\d+]] BuiltIn LaunchSizeNV 6 | // CHECK: OpDecorate [[c:%\d+]] BuiltIn WorldRayOriginNV 7 | // CHECK: OpDecorate [[d:%\d+]] BuiltIn WorldRayDirectionNV 8 | // CHECK: OpDecorate [[e:%\d+]] BuiltIn RayTminNV 9 | // CHECK: OpDecorate [[f:%\d+]] BuiltIn IncomingRayFlagsNV 10 | 11 | // CHECK: OpTypePointer IncomingRayPayloadNV %Payload 12 | struct Payload 13 | { 14 | float4 color; 15 | }; 16 | 17 | [shader("miss")] 18 | void main(inout Payload MyPayload) { 19 | 20 | // CHECK: OpLoad %v3uint [[a]] 21 | uint3 _1 = DispatchRaysIndex(); 22 | // CHECK: OpLoad %v3uint [[b]] 23 | uint3 _2 = DispatchRaysDimensions(); 24 | // CHECK: OpLoad %v3float [[c]] 25 | float3 _3 = WorldRayOrigin(); 26 | // CHECK: OpLoad %v3float [[d]] 27 | float3 _4 = WorldRayDirection(); 28 | // CHECK: OpLoad %float [[e]] 29 | float _5 = RayTMin(); 30 | // CHECK: OpLoad %uint [[f]] 31 | uint _6 = RayFlags(); 32 | } 33 | -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.miss.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/raytracing.nv.miss.spv -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.raygen.hlsl: -------------------------------------------------------------------------------- 1 | // Run: %dxc -T lib_6_3 -fspv-extension=SPV_NV_ray_tracing 2 | // CHECK: OpCapability RayTracingNV 3 | // CHECK: OpExtension "SPV_NV_ray_tracing" 4 | // CHECK: OpDecorate [[a:%\d+]] BuiltIn LaunchIdNV 5 | // CHECK: OpDecorate [[b:%\d+]] BuiltIn LaunchSizeNV 6 | 7 | // CHECK-COUNT-1: [[rstype:%\d+]] = OpTypeAccelerationStructureNV 8 | RaytracingAccelerationStructure rs; 9 | 10 | struct Payload 11 | { 12 | float4 color; 13 | }; 14 | struct CallData 15 | { 16 | float4 data; 17 | }; 18 | 19 | [shader("raygeneration")] 20 | void main() { 21 | 22 | // CHECK: OpLoad %v3uint [[a]] 23 | uint3 a = DispatchRaysIndex(); 24 | // CHECK: OpLoad %v3uint [[b]] 25 | uint3 b = DispatchRaysDimensions(); 26 | 27 | Payload myPayload = { float4(0.0f,0.0f,0.0f,0.0f) }; 28 | CallData myCallData = { float4(0.0f,0.0f,0.0f,0.0f) }; 29 | RayDesc rayDesc; 30 | rayDesc.Origin = float3(0.0f, 0.0f, 0.0f); 31 | rayDesc.Direction = float3(0.0f, 0.0f, -1.0f); 32 | rayDesc.TMin = 0.0f; 33 | rayDesc.TMax = 1000.0f; 34 | // CHECK: OpTraceNV {{%\d+}} %uint_0 %uint_255 %uint_0 %uint_1 %uint_0 {{%\d+}} {{%\d+}} {{%\d+}} {{%\d+}} %uint_0 35 | TraceRay(rs, 0x0, 0xff, 0, 1, 0, rayDesc, myPayload); 36 | // CHECK: OpExecuteCallableNV %uint_0 %uint_0 37 | CallShader(0, myCallData); 38 | } 39 | -------------------------------------------------------------------------------- /tests/raytrace/raytracing.nv.raygen.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/raytrace/raytracing.nv.raygen.spv -------------------------------------------------------------------------------- /tests/spec_constants/basic.comp: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(constant_id = 3) const int SIZE = 2; 4 | 5 | layout(set = 0, binding = 0, std430) buffer SSBO { 6 | float val[SIZE]; 7 | float dummy; 8 | } ssbo; 9 | 10 | void main() { 11 | ssbo.val[0] = 0.0; 12 | } 13 | 14 | -------------------------------------------------------------------------------- /tests/spec_constants/basic.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/spec_constants/basic.spv -------------------------------------------------------------------------------- /tests/spec_constants/convert.comp: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | #extension GL_EXT_shader_explicit_arithmetic_types_int64: enable 4 | 5 | layout(local_size_x = 1) in; 6 | 7 | layout(constant_id = 0) const int64_t SONE = 1; 8 | layout(constant_id = 1) const uint64_t UONE = 1; 9 | layout(constant_id = 2) const float F_ONE = 1.0; 10 | layout(constant_id = 3) const double D_ONE = 1.0; 11 | 12 | const uint U_SONE = uint(SONE); 13 | const uint U_UONE = uint(UONE); 14 | 15 | const int S_SONE = int(SONE); 16 | const int S_UONE = int(UONE); 17 | 18 | const float F_ONE2 = float(D_ONE); 19 | const double D_ONE2 = double(F_ONE); 20 | 21 | #define DUMMY_SSBO(name, bind, size) layout(std430, set = 0, binding = bind) buffer SSBO_##name { float val[size]; float dummy; } name 22 | 23 | DUMMY_SSBO(U_Sone, 0, U_SONE); 24 | DUMMY_SSBO(U_Uone, 1, U_UONE); 25 | DUMMY_SSBO(S_Sone, 2, S_SONE); 26 | DUMMY_SSBO(S_Uone, 3, S_UONE); 27 | 28 | void main() 29 | { 30 | U_Sone.val[0] = F_ONE; 31 | U_Uone.val[0] = F_ONE; 32 | S_Sone.val[0] = F_ONE2; 33 | S_Uone.val[0] = F_ONE2; 34 | } -------------------------------------------------------------------------------- /tests/spec_constants/convert.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/spec_constants/convert.spv -------------------------------------------------------------------------------- /tests/spec_constants/local_size_id.comp: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | // note Z is not and ID 4 | // Vulkan 1.3 is needed for glslang to use LocalSizeId over LocalSize 5 | layout(local_size_x_id = 8, local_size_y_id = 4, local_size_z = 4) in; 6 | 7 | void main() { } 8 | -------------------------------------------------------------------------------- /tests/spec_constants/local_size_id_10.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/spec_constants/local_size_id_10.spv -------------------------------------------------------------------------------- /tests/spec_constants/local_size_id_10.spv.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | all_type_descriptions: 4 | all_block_variables: 5 | all_descriptor_bindings: 6 | all_interface_variables: 7 | module: 8 | generator: 8 # Khronos Glslang Reference Front End 9 | entry_point_name: "main" 10 | entry_point_id: 4 11 | source_language: 2 # GLSL 12 | source_language_version: 450 13 | spirv_execution_model: 5 # GLCompute 14 | shader_stage: 0x00000020 # CS 15 | descriptor_binding_count: 0 16 | descriptor_bindings: 17 | descriptor_set_count: 0 18 | descriptor_sets: 19 | input_variable_count: 0, 20 | input_variables: 21 | output_variable_count: 0, 22 | output_variables: 23 | push_constant_count: 0, 24 | push_constants: 25 | specialization_constant_count: 2, 26 | specialization_constants: 27 | - name: 28 | spirv_id: 7 29 | constant_id: 8 30 | - name: 31 | spirv_id: 8 32 | constant_id: 4 33 | ... 34 | -------------------------------------------------------------------------------- /tests/spec_constants/local_size_id_13.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/spec_constants/local_size_id_13.spv -------------------------------------------------------------------------------- /tests/spec_constants/local_size_id_13.spv.yaml: -------------------------------------------------------------------------------- 1 | %YAML 1.1 2 | --- 3 | all_type_descriptions: 4 | all_block_variables: 5 | all_descriptor_bindings: 6 | all_interface_variables: 7 | module: 8 | generator: 8 # Khronos Glslang Reference Front End 9 | entry_point_name: "main" 10 | entry_point_id: 4 11 | source_language: 2 # GLSL 12 | source_language_version: 450 13 | spirv_execution_model: 5 # GLCompute 14 | shader_stage: 0x00000020 # CS 15 | descriptor_binding_count: 0 16 | descriptor_bindings: 17 | descriptor_set_count: 0 18 | descriptor_sets: 19 | input_variable_count: 0, 20 | input_variables: 21 | output_variable_count: 0, 22 | output_variables: 23 | push_constant_count: 0, 24 | push_constants: 25 | specialization_constant_count: 4, 26 | specialization_constants: 27 | - name: 28 | spirv_id: 7 29 | constant_id: 8 30 | - name: 31 | spirv_id: 8 32 | constant_id: 4 33 | - name: 34 | spirv_id: 10 35 | constant_id: 8 36 | - name: 37 | spirv_id: 11 38 | constant_id: 4 39 | ... 40 | -------------------------------------------------------------------------------- /tests/spec_constants/ssbo_array.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | layout(constant_id = 8) const int SIZE_A = 4; 4 | layout(constant_id = 5) const int SIZE_B = 3; 5 | layout(set = 0, binding = 0, std430) buffer SSBO { 6 | float a[SIZE_A]; 7 | float b[SIZE_B]; 8 | } ssbo; 9 | 10 | void main() { 11 | ssbo.a[2] = ssbo.b[1]; 12 | } -------------------------------------------------------------------------------- /tests/spec_constants/ssbo_array.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/spec_constants/ssbo_array.spv -------------------------------------------------------------------------------- /tests/spec_constants/test_32bit.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/spec_constants/test_32bit.spv -------------------------------------------------------------------------------- /tests/spec_constants/test_64bit.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/spec_constants/test_64bit.spv -------------------------------------------------------------------------------- /tests/spirv15/VertexShader.hlsl: -------------------------------------------------------------------------------- 1 | Texture2D Tex0; 2 | 3 | float4 vsmain(float4 P : POSITION, uint instanceId :SV_InstanceID) : SV_Position 4 | { 5 | return P + Tex0[uint2(instanceId % 16, instanceId / 16)]; 6 | } -------------------------------------------------------------------------------- /tests/spirv15/VertexShader.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/spirv15/VertexShader.spv -------------------------------------------------------------------------------- /tests/user_type/byte_address_buffer_0.hlsl: -------------------------------------------------------------------------------- 1 | // dxc -spirv -fspv-reflect -T lib_6_4 -fspv-target-env=vulkan1.2 2 | struct MaterialData_t 3 | { 4 | float4 g_vTest; 5 | float2 g_vTest2; // accessed 6 | float3 g_vTest3; 7 | uint g_tTexture1; // accessed 8 | uint g_tTexture2; 9 | bool g_bTest1; // accessed 10 | bool g_bTest2; 11 | }; 12 | 13 | static MaterialData_t _g_MaterialData; 14 | 15 | ByteAddressBuffer g_MaterialData : register ( t4 , space1 ); 16 | 17 | struct Payload_t 18 | { 19 | float2 vTest; 20 | bool bTest; 21 | uint tTest; 22 | }; 23 | 24 | struct PayloadShadow_t 25 | { 26 | float m_flVisibility; 27 | }; 28 | 29 | [ shader ( "closesthit" ) ] 30 | void ClosestHit0 ( inout Payload_t payload , in BuiltInTriangleIntersectionAttributes attrs ) 31 | { 32 | _g_MaterialData = g_MaterialData.Load( InstanceIndex() ); 33 | 34 | payload.vTest = _g_MaterialData.g_vTest2; 35 | payload.bTest = _g_MaterialData.g_bTest1; 36 | payload.tTest = _g_MaterialData.g_tTexture1; 37 | } 38 | 39 | [ shader ( "anyhit" ) ] 40 | void AnyHit1 ( inout PayloadShadow_t payload , in BuiltInTriangleIntersectionAttributes attrs ) 41 | { 42 | _g_MaterialData = g_MaterialData.Load( InstanceIndex() ); 43 | 44 | { 45 | payload . m_flVisibility = 0.0 ; 46 | AcceptHitAndEndSearch ( ) ; 47 | } 48 | } -------------------------------------------------------------------------------- /tests/user_type/byte_address_buffer_0.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/user_type/byte_address_buffer_0.spv -------------------------------------------------------------------------------- /tests/user_type/byte_address_buffer_1.hlsl: -------------------------------------------------------------------------------- 1 | // dxc -spirv -fspv-reflect -T cs_6_0 -E csmain -fspv-target-env=vulkan1.2 2 | uint g_global; 3 | 4 | struct MaterialData_t { 5 | float4 g_vTest; 6 | float2 g_vTest2; 7 | float3 g_vTest3; 8 | uint g_tTexture1; 9 | uint g_tTexture2; 10 | bool g_bTest1; 11 | bool g_bTest2; 12 | }; 13 | 14 | static MaterialData_t _g_MaterialData; 15 | 16 | ByteAddressBuffer g_MaterialData : register (t4 , space1); 17 | RWStructuredBuffer Output : register(u1); 18 | 19 | [numthreads(1, 1, 1)] 20 | void csmain(uint3 tid : SV_DispatchThreadID) { 21 | uint2 a = g_MaterialData.Load2( tid.x + g_global ); 22 | uint b = g_MaterialData.Load( tid.x + g_global ); 23 | uint2 c = g_MaterialData.Load2(4); 24 | Output[tid.x] = a * uint2(b, b) * c; 25 | } -------------------------------------------------------------------------------- /tests/user_type/byte_address_buffer_1.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/user_type/byte_address_buffer_1.spv -------------------------------------------------------------------------------- /tests/user_type/byte_address_buffer_2.hlsl: -------------------------------------------------------------------------------- 1 | // dxc -spirv -fspv-reflect -T cs_6_0 -E csmain -fspv-target-env=vulkan1.2 2 | struct MaterialData_t { 3 | uint g_tTexture0; 4 | uint g_tTexture1; 5 | uint g_tTexture2; 6 | uint g_tTexture3; 7 | }; 8 | 9 | static MaterialData_t _g_MaterialData; 10 | 11 | ByteAddressBuffer g_MaterialData : register (t4 , space1); 12 | RWStructuredBuffer Output : register(u1); 13 | 14 | [numthreads(1, 1, 1)] 15 | void csmain(uint3 tid : SV_DispatchThreadID) { 16 | uint2 a = g_MaterialData.Load2(0); 17 | uint b = g_MaterialData.Load(1); 18 | Output[tid.x] = a * uint2(b, b); 19 | } -------------------------------------------------------------------------------- /tests/user_type/byte_address_buffer_2.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/user_type/byte_address_buffer_2.spv -------------------------------------------------------------------------------- /tests/user_type/byte_address_buffer_3.hlsl: -------------------------------------------------------------------------------- 1 | // dxc -spirv -fspv-reflect -T lib_6_4 -fspv-target-env=vulkan1.2 2 | struct MaterialData_t { 3 | float4 g_vTest0; 4 | float4 g_vTest1; // accessed 5 | float4 g_vTest2; // accessed twice, but only listed once 6 | float4 g_vTest3; // accessed 7 | float4 g_vTest4; 8 | }; 9 | 10 | static MaterialData_t _g_MaterialData; 11 | 12 | ByteAddressBuffer g_MaterialData : register ( t4 , space1 ); 13 | 14 | struct PayloadShadow_t { 15 | float m_flVisibility; 16 | }; 17 | 18 | [ shader ( "anyhit" ) ] 19 | void AnyHit1 ( inout PayloadShadow_t payload , in BuiltInTriangleIntersectionAttributes attrs ) { 20 | _g_MaterialData = g_MaterialData.Load( InstanceIndex() ); 21 | 22 | { 23 | payload . m_flVisibility = _g_MaterialData.g_vTest1.x + _g_MaterialData.g_vTest2.x; 24 | AcceptHitAndEndSearch ( ) ; 25 | } 26 | } 27 | 28 | [ shader ( "anyhit" ) ] 29 | void AnyHit0 ( inout PayloadShadow_t payload , in BuiltInTriangleIntersectionAttributes attrs ) { 30 | _g_MaterialData = g_MaterialData.Load( InstanceIndex() ); 31 | 32 | { 33 | payload . m_flVisibility = _g_MaterialData.g_vTest2.x + _g_MaterialData.g_vTest3.x; 34 | AcceptHitAndEndSearch ( ) ; 35 | } 36 | } -------------------------------------------------------------------------------- /tests/user_type/byte_address_buffer_3.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/user_type/byte_address_buffer_3.spv -------------------------------------------------------------------------------- /tests/user_type/rw_byte_address_buffer.hlsl: -------------------------------------------------------------------------------- 1 | // dxc -spirv -fspv-reflect -T lib_6_4 -fspv-target-env=vulkan1.2 2 | struct MaterialData_t 3 | { 4 | float4 g_vTest; 5 | float2 g_vTest2; // accessed 6 | float3 g_vTest3; 7 | uint g_tTexture1; // accessed 8 | uint g_tTexture2; 9 | bool g_bTest1; // accessed 10 | bool g_bTest2; 11 | }; 12 | 13 | static MaterialData_t _g_MaterialData; 14 | 15 | RWByteAddressBuffer g_MaterialData : register ( u4 , space1 ); 16 | 17 | struct Payload_t 18 | { 19 | float2 vTest; 20 | bool bTest; 21 | uint tTest; 22 | }; 23 | 24 | struct PayloadShadow_t 25 | { 26 | float m_flVisibility; 27 | }; 28 | 29 | [ shader ( "closesthit" ) ] 30 | void ClosestHit0 ( inout Payload_t payload , in BuiltInTriangleIntersectionAttributes attrs ) 31 | { 32 | _g_MaterialData = g_MaterialData.Load( InstanceIndex() ); 33 | 34 | payload.vTest = _g_MaterialData.g_vTest2; 35 | payload.bTest = _g_MaterialData.g_bTest1; 36 | payload.tTest = _g_MaterialData.g_tTexture1; 37 | } 38 | 39 | [ shader ( "anyhit" ) ] 40 | void AnyHit1 ( inout PayloadShadow_t payload , in BuiltInTriangleIntersectionAttributes attrs ) 41 | { 42 | _g_MaterialData = g_MaterialData.Load( InstanceIndex() ); 43 | 44 | { 45 | payload . m_flVisibility = 0.0 ; 46 | AcceptHitAndEndSearch ( ) ; 47 | } 48 | } -------------------------------------------------------------------------------- /tests/user_type/rw_byte_address_buffer.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/user_type/rw_byte_address_buffer.spv -------------------------------------------------------------------------------- /tests/variable_access/atomics_0.glsl: -------------------------------------------------------------------------------- 1 | #version 460 2 | #extension GL_KHR_memory_scope_semantics : enable 3 | 4 | layout(set=0, binding=0) buffer SSBO { 5 | uint a; 6 | uint b; // UNUSED 7 | uint c; 8 | uint d; 9 | uint e; // UNUSED 10 | uint f; 11 | }; 12 | 13 | void main() { 14 | uint x = atomicLoad(a, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); 15 | atomicStore(c, 0u, gl_ScopeDevice, gl_StorageSemanticsBuffer, gl_SemanticsRelaxed); 16 | atomicExchange(d, f); 17 | } -------------------------------------------------------------------------------- /tests/variable_access/atomics_0.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/variable_access/atomics_0.spv -------------------------------------------------------------------------------- /tests/variable_access/atomics_1.slang: -------------------------------------------------------------------------------- 1 | struct SSBOData { 2 | Atomic a; 3 | Atomic b; // UNUSED 4 | Atomic c; 5 | Atomic d; // UNUSED 6 | Atomic e; // UNUSED 7 | Atomic f; 8 | }; 9 | 10 | [[vk::binding(0, 0)]] 11 | RWStructuredBuffer ssbo; 12 | 13 | [shader("compute")] 14 | void main() { 15 | uint x = ssbo[0].a.load(); 16 | ssbo[0].c.exchange(0); 17 | ssbo[0].f.store(0); 18 | } -------------------------------------------------------------------------------- /tests/variable_access/atomics_1.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/variable_access/atomics_1.spv -------------------------------------------------------------------------------- /tests/variable_access/copy_array_0.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | layout(set = 0, binding = 0) buffer foo { 3 | uvec4 a; // not used 4 | uint b[4]; // used 5 | uint c; // not used 6 | }; 7 | 8 | void main() { 9 | uint d[4] = {4, 5, 6, 7}; 10 | b = d; 11 | } -------------------------------------------------------------------------------- /tests/variable_access/copy_array_0.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/variable_access/copy_array_0.spv -------------------------------------------------------------------------------- /tests/variable_access/copy_array_1.slang: -------------------------------------------------------------------------------- 1 | struct Bar { 2 | uint4 a; 3 | uint b[4]; 4 | uint c; 5 | }; 6 | 7 | [[vk::binding(0, 0)]] 8 | RWStructuredBuffer foo; 9 | 10 | [shader("compute")] 11 | void main() { 12 | uint d[4] = {4, 5, 6, 7}; 13 | foo[0].b = d; 14 | } -------------------------------------------------------------------------------- /tests/variable_access/copy_array_1.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/variable_access/copy_array_1.spv -------------------------------------------------------------------------------- /tests/variable_access/copy_array_2.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | layout(set = 0, binding = 0, std430) buffer foo1 { 3 | uvec4 a; 4 | uint b[4]; 5 | uint c; 6 | }; 7 | 8 | layout(set = 0, binding = 1, std430) buffer foo2 { 9 | uint d; 10 | uint e[4]; 11 | uvec2 f; 12 | }; 13 | 14 | void main() { 15 | b = e; 16 | } -------------------------------------------------------------------------------- /tests/variable_access/copy_array_2.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/variable_access/copy_array_2.spv -------------------------------------------------------------------------------- /tests/variable_access/copy_array_3.slang: -------------------------------------------------------------------------------- 1 | struct Bar1 { 2 | uint4 a; 3 | uint b[4]; 4 | uint c; 5 | }; 6 | 7 | struct Bar2 { 8 | uint4 d; 9 | uint e[4]; 10 | uint f; 11 | }; 12 | 13 | [[vk::binding(0, 0)]] 14 | RWStructuredBuffer foo1; 15 | 16 | [[vk::binding(0, 1)]] 17 | RWStructuredBuffer foo2; 18 | 19 | [shader("compute")] 20 | void main() { 21 | foo1[0].b = foo2[0].e; 22 | } -------------------------------------------------------------------------------- /tests/variable_access/copy_array_3.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/variable_access/copy_array_3.spv -------------------------------------------------------------------------------- /tests/variable_access/copy_memory.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/variable_access/copy_memory.spv -------------------------------------------------------------------------------- /tests/variable_access/copy_struct_0.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | 3 | struct Bar { 4 | uint x; 5 | uint y; 6 | uint z[2]; 7 | }; 8 | 9 | layout(set = 0, binding = 0, std430) buffer foo1 { 10 | uvec4 a; 11 | Bar b; 12 | uint c; 13 | }; 14 | 15 | layout(set = 0, binding = 1, std430) buffer foo2 { 16 | uvec4 d; 17 | Bar e; 18 | uint f; 19 | }; 20 | 21 | void main() { 22 | b = e; 23 | } -------------------------------------------------------------------------------- /tests/variable_access/copy_struct_0.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/variable_access/copy_struct_0.spv -------------------------------------------------------------------------------- /tests/variable_access/copy_struct_1.slang: -------------------------------------------------------------------------------- 1 | struct Bar { 2 | uint x; 3 | uint y; 4 | uint z[2]; 5 | }; 6 | 7 | struct FooBuffer1 { 8 | float4 a; 9 | Bar b; 10 | uint d; 11 | }; 12 | 13 | struct FooBuffer2 { 14 | float4 d; 15 | Bar e; 16 | uint f; 17 | }; 18 | 19 | [[vk::binding(0, 0)]] 20 | RWStructuredBuffer foo1; 21 | 22 | [[vk::binding(0, 1)]] 23 | RWStructuredBuffer foo2; 24 | 25 | [shader("compute")] 26 | void main() { 27 | foo1[0].b = foo2[0].e; 28 | } -------------------------------------------------------------------------------- /tests/variable_access/copy_struct_1.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/variable_access/copy_struct_1.spv -------------------------------------------------------------------------------- /tests/variable_access/descriptor_indexing_0.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | layout(set = 0, binding = 0) buffer foo { 3 | uint a; 4 | uint b; 5 | uint c; 6 | uint d; 7 | } bar[4]; 8 | 9 | void main() { 10 | bar[1].b = 0; 11 | bar[3].d = 0; 12 | } -------------------------------------------------------------------------------- /tests/variable_access/descriptor_indexing_0.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/variable_access/descriptor_indexing_0.spv -------------------------------------------------------------------------------- /tests/variable_access/descriptor_indexing_1.slang: -------------------------------------------------------------------------------- 1 | struct Bar { 2 | uint4 a; 3 | uint b[4]; 4 | uint c; 5 | }; 6 | 7 | [[vk::binding(0, 0)]] 8 | RWStructuredBuffer foo[8]; 9 | 10 | [shader("compute")] 11 | void main() { 12 | foo[4][0].b[3] = 0; 13 | } -------------------------------------------------------------------------------- /tests/variable_access/descriptor_indexing_1.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/variable_access/descriptor_indexing_1.spv -------------------------------------------------------------------------------- /tests/variable_access/phy_storage_buffer_used_0.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_EXT_buffer_reference : enable 3 | 4 | layout(buffer_reference, std430) buffer Node { 5 | uint payload; 6 | }; 7 | 8 | layout(buffer_reference, std430) buffer BadNode { 9 | uint bad_payload; 10 | }; 11 | 12 | layout(set = 0, binding = 0, std430) buffer SSBO { 13 | Node first_node; 14 | BadNode bad_node; // used 15 | uint placeholder; 16 | } x; 17 | 18 | void main() { 19 | x.placeholder = 0; 20 | x.first_node.payload = 3; 21 | } 22 | -------------------------------------------------------------------------------- /tests/variable_access/phy_storage_buffer_used_0.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/variable_access/phy_storage_buffer_used_0.spv -------------------------------------------------------------------------------- /tests/variable_access/phy_storage_buffer_used_1.glsl: -------------------------------------------------------------------------------- 1 | #version 450 2 | #extension GL_EXT_buffer_reference : enable 3 | 4 | layout(buffer_reference) buffer Node; 5 | 6 | layout(buffer_reference, std430) buffer Node { 7 | Node next; 8 | uint payload; 9 | }; 10 | 11 | layout(buffer_reference) buffer BadNode; 12 | layout(buffer_reference, std430) buffer BadNode { 13 | BadNode bad_next; 14 | uint bad_payload; 15 | }; 16 | 17 | layout(set = 0, binding = 0, std430) buffer SSBO { 18 | Node first_node; 19 | BadNode bad_node; // used 20 | uint placeholder; 21 | } x; 22 | 23 | void main() { 24 | x.placeholder = 0; 25 | x.first_node.next.payload = 3; 26 | } 27 | -------------------------------------------------------------------------------- /tests/variable_access/phy_storage_buffer_used_1.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/variable_access/phy_storage_buffer_used_1.spv -------------------------------------------------------------------------------- /tests/variable_access/phy_storage_buffer_used_2.slang: -------------------------------------------------------------------------------- 1 | uniform uint* data_ptr; // creates a ptr chain access 2 | uniform uint* data_ptr_usused; 3 | 4 | struct Data{ 5 | int unused_var; 6 | int used_var; 7 | } 8 | uniform Data* data_struct; 9 | 10 | [numthreads(1,1,1)] 11 | void computeMain() 12 | { 13 | data_ptr[0] = 1; 14 | data_struct->used_var = 1; 15 | } 16 | -------------------------------------------------------------------------------- /tests/variable_access/phy_storage_buffer_used_2.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/variable_access/phy_storage_buffer_used_2.spv -------------------------------------------------------------------------------- /tests/variable_access/phy_storage_buffer_used_3.slang: -------------------------------------------------------------------------------- 1 | struct DataUsed{ 2 | int unused_var_2; 3 | int used_var_2; 4 | }; 5 | 6 | struct DataUnused{ 7 | int unused_var_3; 8 | }; 9 | 10 | struct Data{ 11 | DataUnused unused_struct; 12 | DataUsed used_struct; 13 | } 14 | uniform Data* data_struct; 15 | 16 | [numthreads(1,1,1)] 17 | void computeMain() 18 | { 19 | data_struct->used_struct.used_var_2 = 1; 20 | } 21 | -------------------------------------------------------------------------------- /tests/variable_access/phy_storage_buffer_used_3.spv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/KhronosGroup/SPIRV-Reflect/c6c0f5c9796bdef40c55065d82e0df67c38a29a4/tests/variable_access/phy_storage_buffer_used_3.spv --------------------------------------------------------------------------------