Skip to content

Commit 32707cc

Browse files
committed
vulkan: fix coopmat shader generation when cross-compiling
Previously the status of coopmat{,2} support isn't passed to the vulkan-shaders-gen project building on the host, which leads to build failure because of the cross-compiling code expecting coopmat{,2} shaders that didn't get generated. Fix this by passing the coopmat{,2} support status to vulkan-shaders subproject. Signed-off-by: Icenowy Zheng <[email protected]>
1 parent 2099a9d commit 32707cc

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

ggml/src/ggml-vulkan/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ if (Vulkan_FOUND)
3232

3333
if (${glslc_error} MATCHES ".*extension not supported: GL_KHR_cooperative_matrix.*")
3434
message(STATUS "GL_KHR_cooperative_matrix not supported by glslc")
35+
set(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT OFF CACHE INTERNAL "Whether coopmat is supported by glslc")
3536
else()
3637
message(STATUS "GL_KHR_cooperative_matrix supported by glslc")
3738
add_compile_definitions(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
39+
set(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT ON CACHE INTERNAL "Whether coopmat is supported by glslc")
3840
endif()
3941

4042
# Compile a test shader to determine whether GL_NV_cooperative_matrix2 is supported.
@@ -46,9 +48,11 @@ if (Vulkan_FOUND)
4648

4749
if (${glslc_error} MATCHES ".*extension not supported: GL_NV_cooperative_matrix2.*")
4850
message(STATUS "GL_NV_cooperative_matrix2 not supported by glslc")
51+
set(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT OFF CACHE INTERNAL "Whether coopmat2 is supported by glslc")
4952
else()
5053
message(STATUS "GL_NV_cooperative_matrix2 supported by glslc")
5154
add_compile_definitions(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
55+
set(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT ON CACHE INTERNAL "Whether coopmat2 is supported by glslc")
5256
endif()
5357

5458
target_link_libraries(ggml-vulkan PRIVATE Vulkan::Vulkan)
@@ -119,6 +123,8 @@ if (Vulkan_FOUND)
119123
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders
120124
CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${HOST_CMAKE_TOOLCHAIN_FILE}
121125
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
126+
-DGGML_VULKAN_COOPMAT_GLSLC_SUPPORT=${GGML_VULKAN_COOPMAT_GLSLC_SUPPORT}
127+
-DGGML_VULKAN_COOPMAT2_GLSLC_SUPPORT=${GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT}
122128
BUILD_COMMAND ${CMAKE_COMMAND} --build .
123129
INSTALL_COMMAND ${CMAKE_COMMAND} --install .
124130
INSTALL_DIR ${CMAKE_BINARY_DIR}

ggml/src/ggml-vulkan/vulkan-shaders/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
find_package (Threads REQUIRED)
22

3+
if (GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
4+
add_compile_definitions(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
5+
endif()
6+
if (GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
7+
add_compile_definitions(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
8+
endif()
39
set(TARGET vulkan-shaders-gen)
410
add_executable(${TARGET} vulkan-shaders-gen.cpp)
511
install(TARGETS ${TARGET} RUNTIME)

0 commit comments

Comments
 (0)