Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
34 changes: 34 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ option(SPIRV_CROSS_ENABLE_TESTS "Enable SPIRV-Cross tests." ON)
option(SPIRV_CROSS_ENABLE_GLSL "Enable GLSL support." ON)
option(SPIRV_CROSS_ENABLE_HLSL "Enable HLSL target support." ON)
option(SPIRV_CROSS_ENABLE_MSL "Enable MSL target support." ON)
option(SPIRV_CROSS_ENABLE_OPENCL "Enable OpenCL target support." ON)
option(SPIRV_CROSS_ENABLE_CPP "Enable C++ target support." ON)
option(SPIRV_CROSS_ENABLE_REFLECT "Enable JSON reflection target support." ON)
option(SPIRV_CROSS_ENABLE_C_API "Enable C API wrapper support in static library." ON)
Expand Down Expand Up @@ -242,6 +243,10 @@ set(spirv-cross-msl-sources
${CMAKE_CURRENT_SOURCE_DIR}/spirv_msl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/spirv_msl.hpp)

set(spirv-cross-opencl-sources
${CMAKE_CURRENT_SOURCE_DIR}/spirv_opencl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/spirv_opencl.hpp)

set(spirv-cross-hlsl-sources
${CMAKE_CURRENT_SOURCE_DIR}/spirv_hlsl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/spirv_hlsl.hpp)
Expand Down Expand Up @@ -306,6 +311,16 @@ if (SPIRV_CROSS_STATIC)
endif()
endif()

if (SPIRV_CROSS_ENABLE_OPENCL)
spirv_cross_add_library(spirv-cross-opencl spirv_cross_opencl STATIC
${spirv-cross-opencl-sources})
if (SPIRV_CROSS_ENABLE_GLSL)
target_link_libraries(spirv-cross-opencl PRIVATE spirv-cross-glsl)
else()
message(FATAL_ERROR "Must enable GLSL support to enable OpenCL support.")
endif()
endif()

if (SPIRV_CROSS_ENABLE_HLSL)
spirv_cross_add_library(spirv-cross-hlsl spirv_cross_hlsl STATIC
${spirv-cross-hlsl-sources})
Expand Down Expand Up @@ -343,6 +358,11 @@ if (SPIRV_CROSS_STATIC)
target_compile_definitions(spirv-cross-c PRIVATE SPIRV_CROSS_C_API_MSL=1)
endif()

if (SPIRV_CROSS_ENABLE_OPENCL)
target_link_libraries(spirv-cross-c PRIVATE spirv-cross-opencl)
target_compile_definitions(spirv-cross-c PRIVATE SPIRV_CROSS_C_API_OPENCL=1)
endif()

if (SPIRV_CROSS_ENABLE_CPP)
target_link_libraries(spirv-cross-c PRIVATE spirv-cross-cpp)
target_compile_definitions(spirv-cross-c PRIVATE SPIRV_CROSS_C_API_CPP=1)
Expand Down Expand Up @@ -393,6 +413,15 @@ if (SPIRV_CROSS_SHARED)
target_compile_definitions(spirv-cross-c-shared PRIVATE SPIRV_CROSS_C_API_MSL=1)
endif()

if (SPIRV_CROSS_ENABLE_OPENCL)
if (SPIRV_CROSS_ENABLE_GLSL)
target_sources(spirv-cross-c-shared PRIVATE ${spirv-cross-opencl-sources})
else()
message(FATAL_ERROR "Must enable GLSL support to enable OpenCL support.")
endif()
target_compile_definitions(spirv-cross-c-shared PRIVATE SPIRV_CROSS_C_API_OPENCL=1)
endif()

if (SPIRV_CROSS_ENABLE_CPP)
if (SPIRV_CROSS_ENABLE_GLSL)
target_sources(spirv-cross-c-shared PRIVATE ${spirv-cross-cpp-sources})
Expand Down Expand Up @@ -439,6 +468,10 @@ if (SPIRV_CROSS_CLI)
message(FATAL_ERROR "Must enable MSL if building CLI.")
endif()

if (NOT SPIRV_CROSS_ENABLE_OPENCL)
message(FATAL_ERROR "Must enable OpenCL if building CLI.")
endif()

if (NOT SPIRV_CROSS_ENABLE_CPP)
message(FATAL_ERROR "Must enable C++ if building CLI.")
endif()
Expand Down Expand Up @@ -468,6 +501,7 @@ if (SPIRV_CROSS_CLI)
spirv-cross-cpp
spirv-cross-reflect
spirv-cross-msl
spirv-cross-opencl
spirv-cross-util
spirv-cross-core)

Expand Down
2 changes: 2 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ let package = Package(
"shaders-msl",
"shaders-msl-no-opt",
"shaders-no-opt",
"shaders-opencl",
"shaders-opencl-no-opt",
"shaders-other",
"shaders-reflection",
"shaders-ue4",
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ SPIRV-Cross is a tool designed for parsing and converting SPIR-V to other shader
- Convert SPIR-V to readable, usable and efficient GLSL
- Convert SPIR-V to readable, usable and efficient Metal Shading Language (MSL)
- Convert SPIR-V to readable, usable and efficient HLSL
- Convert SPIR-V to readable, usable and efficient OpenCL
- Convert SPIR-V to a JSON reflection format
- Convert SPIR-V to debuggable C++ [DEPRECATED]
- Reflection API to simplify the creation of Vulkan pipeline layouts
Expand Down Expand Up @@ -546,6 +547,10 @@ To test the roundtrip path GLSL -> SPIR-V -> MSL, `--msl` can be added, e.g. `./

To test the roundtrip path GLSL -> SPIR-V -> HLSL, `--hlsl` can be added, e.g. `./test_shaders.py --hlsl shaders-hlsl`.

### OpenCL backend

To test the roundtrip path GLSL -> SPIR-V -> OpenCL, `--opencl` can be added, e.g. `./test_shaders.py --opencl shaders-opencl`.

### Updating regression tests

When legitimate changes are found, use `--update` flag to update regression files.
Expand Down
Loading