Skip to content

Commit

Permalink
Add SpirV-reflection to detect usage of buffer-references (#1577)
Browse files Browse the repository at this point in the history
Add SpirV-reflection to detect usage of buffer-references

- Add a SpirV-parser to detect dereferencing of buffer-references
- track back to their definition and extract descriptor-set/binding/push-constant-block
- from there using spirv_reflect: extract buffer-offsets and potential array-strides
- issue a warning in case buffer-references are used, currently unsupported
- remove multiple copies of spirv.h in external/precompiled
- Add SPIRV-Headers as submodule
- Add SPIRV-Reflect as submodule
  • Loading branch information
fabian-lunarg authored Jul 4, 2024
1 parent 1c20857 commit d570c3b
Show file tree
Hide file tree
Showing 34 changed files with 2,345 additions and 36,503 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
[submodule "external/Vulkan-Headers"]
path = external/Vulkan-Headers
url = https://github.com/KhronosGroup/Vulkan-Headers.git
[submodule "external/SPIRV-Headers"]
path = external/SPIRV-Headers
url = https://github.com/KhronosGroup/SPIRV-Headers.git
[submodule "external/SPIRV-Reflect"]
path = external/SPIRV-Reflect
url = https://github.com/KhronosGroup/SPIRV-Reflect.git
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -334,13 +334,23 @@ add_library(vulkan_registry INTERFACE)
target_include_directories(vulkan_registry INTERFACE ${CMAKE_SOURCE_DIR}/external/Vulkan-Headers/include)
target_compile_definitions(vulkan_registry INTERFACE VK_NO_PROTOTYPES VK_ENABLE_BETA_EXTENSIONS)

add_library(spirv_registry INTERFACE)
target_include_directories(spirv_registry INTERFACE ${CMAKE_SOURCE_DIR}/external/SPIRV-Headers/include)

add_library(vulkan_memory_allocator INTERFACE)
target_compile_options(vulkan_memory_allocator INTERFACE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
-Wno-nullability-completeness>
)
target_include_directories(vulkan_memory_allocator INTERFACE ${CMAKE_SOURCE_DIR}/external/VulkanMemoryAllocator/include)

# SPIRV-Reflect included as submodule -> libspirv-reflect-static.a
set(SPIRV_REFLECT_EXAMPLES OFF)
set(SPIRV_REFLECT_EXECUTABLE OFF)
set(SPIRV_REFLECT_STATIC_LIB ON)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
add_subdirectory(external/SPIRV-Reflect EXCLUDE_FROM_ALL)

if (${RUN_TESTS})
add_library(catch2 INTERFACE)
target_include_directories(catch2 INTERFACE external)
Expand Down
11 changes: 11 additions & 0 deletions android/framework/cmake-config/PlatformConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,19 @@ add_library(vulkan_registry INTERFACE)
target_include_directories(vulkan_registry INTERFACE ${GFXRECON_SOURCE_DIR}/external/Vulkan-Headers/include)
target_compile_definitions(vulkan_registry INTERFACE VK_NO_PROTOTYPES VK_ENABLE_BETA_EXTENSIONS)

add_library(spirv_registry INTERFACE)
target_include_directories(spirv_registry INTERFACE ${GFXRECON_SOURCE_DIR}/external/SPIRV-Headers/include)

add_library(nlohmann_json INTERFACE)
target_include_directories(nlohmann_json INTERFACE ${GFXRECON_SOURCE_DIR}/external/nlohmann)

add_library(vulkan_memory_allocator INTERFACE)
target_include_directories(vulkan_memory_allocator INTERFACE ${GFXRECON_SOURCE_DIR}/external/VulkanMemoryAllocator/include)

# SPIRV-Reflect included as submodule -> libspirv-reflect-static.a
set(SPIRV_REFLECT_EXAMPLES OFF CACHE INTERNAL "no spirv_reflect samples" FORCE)
set(SPIRV_REFLECT_EXECUTABLE OFF CACHE INTERNAL "no spirv_reflect executables" FORCE)
set(SPIRV_REFLECT_STATIC_LIB ON CACHE INTERNAL "create spirv-reflect-static library" FORCE)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW CACHE INTERNAL "set a cmake policy for spirv_reflect" FORCE)
add_subdirectory("${GFXRECON_SOURCE_DIR}/external/SPIRV-Reflect" EXCLUDE_FROM_ALL "${CMAKE_BINARY_DIR}/external/SPIRV-Reflect")
include_directories("${GFXRECON_SOURCE_DIR}/external/SPIRV-Reflect")
2 changes: 1 addition & 1 deletion android/framework/decode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ target_link_libraries(gfxrecon_decode
vulkan_memory_allocator
platform_specific
nlohmann_json
${GFXRECON_SOURCE_DIR}/external/precompiled/android/lib/${ANDROID_ABI}/libspirv-reflect-static.a)
spirv-reflect-static)
5 changes: 5 additions & 0 deletions android/framework/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ target_sources(gfxrecon_util
${GFXRECON_SOURCE_DIR}/framework/util/platform.h
${GFXRECON_SOURCE_DIR}/framework/util/settings_loader.h
${GFXRECON_SOURCE_DIR}/framework/util/settings_loader.cpp
${GFXRECON_SOURCE_DIR}/framework/util/spirv_helper.h
${GFXRECON_SOURCE_DIR}/framework/util/spirv_parsing_util.h
${GFXRECON_SOURCE_DIR}/framework/util/spirv_parsing_util.cpp
${GFXRECON_SOURCE_DIR}/framework/util/strings.h
${GFXRECON_SOURCE_DIR}/framework/util/strings.cpp
${GFXRECON_SOURCE_DIR}/framework/util/to_string.h
Expand Down Expand Up @@ -68,6 +71,8 @@ target_include_directories(gfxrecon_util
target_link_libraries(gfxrecon_util
platform_specific
vulkan_registry
spirv_registry
spirv-reflect-static
${GFXRECON_SOURCE_DIR}/external/precompiled/android/lib/${ANDROID_ABI}/liblz4_static.a
${GFXRECON_SOURCE_DIR}/external/precompiled/android/lib/${ANDROID_ABI}/libzstd.a
z)
1 change: 1 addition & 0 deletions external/SPIRV-Headers
Submodule SPIRV-Headers added at eb49bb
1 change: 1 addition & 0 deletions external/SPIRV-Reflect
Submodule SPIRV-Reflect added at fa71fe
Loading

0 comments on commit d570c3b

Please sign in to comment.