Skip to content

Commit 74159e1

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 bd40678 commit 74159e1

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

ggml/src/ggml-vulkan/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ if (Vulkan_FOUND)
2323
../../include/ggml-vulkan.h
2424
)
2525

26+
set(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT OFF)
27+
2628
# Compile a test shader to determine whether GL_KHR_cooperative_matrix is supported.
2729
# If it's not, there will be an error to stderr.
2830
# If it's supported, set a define to indicate that we should compile those shaders
@@ -35,8 +37,11 @@ if (Vulkan_FOUND)
3537
else()
3638
message(STATUS "GL_KHR_cooperative_matrix supported by glslc")
3739
add_compile_definitions(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
40+
set(GGML_VULKAN_COOPMAT_GLSLC_SUPPORT ON)
3841
endif()
3942

43+
set(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT OFF)
44+
4045
# Compile a test shader to determine whether GL_NV_cooperative_matrix2 is supported.
4146
# If it's not, there will be an error to stderr.
4247
# If it's supported, set a define to indicate that we should compile those shaders
@@ -49,6 +54,7 @@ if (Vulkan_FOUND)
4954
else()
5055
message(STATUS "GL_NV_cooperative_matrix2 supported by glslc")
5156
add_compile_definitions(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
57+
set(GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT ON)
5258
endif()
5359

5460
target_link_libraries(ggml-vulkan PRIVATE Vulkan::Vulkan)
@@ -119,6 +125,8 @@ if (Vulkan_FOUND)
119125
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders
120126
CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${HOST_CMAKE_TOOLCHAIN_FILE}
121127
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}
128+
-DGGML_VULKAN_COOPMAT_GLSLC_SUPPORT=${GGML_VULKAN_COOPMAT_GLSLC_SUPPORT}
129+
-DGGML_VULKAN_COOPMAT2_GLSLC_SUPPORT=${GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT}
122130
BUILD_COMMAND ${CMAKE_COMMAND} --build .
123131
INSTALL_COMMAND ${CMAKE_COMMAND} --install .
124132
INSTALL_DIR ${CMAKE_BINARY_DIR}

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

Lines changed: 6 additions & 0 deletions
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)