@@ -23,36 +23,40 @@ if (Vulkan_FOUND)
2323 ../../include /ggml-vulkan.h
2424 )
2525
26- # Compile a test shader to determine whether GL_KHR_cooperative_matrix is supported.
27- # If it's not, there will be an error to stderr.
28- # If it's supported, set a define to indicate that we should compile those shaders
29- execute_process (COMMAND ${Vulkan_GLSLC_EXECUTABLE} -o - -fshader-stage=compute --target -env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR} /vulkan-shaders/test_coopmat_support.comp"
30- OUTPUT_VARIABLE glslc_output
31- ERROR_VARIABLE glslc_error)
32-
33- if (${glslc_error} MATCHES ".*extension not supported: GL_KHR_cooperative_matrix.*" )
34- 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" )
36- else ()
37- message (STATUS "GL_KHR_cooperative_matrix supported by glslc" )
38- add_compile_definitions (GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
39- set (GGML_VULKAN_COOPMAT_GLSLC_SUPPORT ON CACHE INTERNAL "Whether coopmat is supported by glslc" )
26+ if (NOT DEFINED GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
27+ # Compile a test shader to determine whether GL_KHR_cooperative_matrix is supported.
28+ # If it's not, there will be an error to stderr.
29+ # If it's supported, set a define to indicate that we should compile those shaders
30+ execute_process (COMMAND ${Vulkan_GLSLC_EXECUTABLE} -o - -fshader-stage=compute --target -env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR} /vulkan-shaders/test_coopmat_support.comp"
31+ OUTPUT_VARIABLE glslc_output
32+ ERROR_VARIABLE glslc_error)
33+
34+ if (${glslc_error} MATCHES ".*extension not supported: GL_KHR_cooperative_matrix.*" )
35+ message (STATUS "GL_KHR_cooperative_matrix not supported by glslc" )
36+ set (GGML_VULKAN_COOPMAT_GLSLC_SUPPORT OFF CACHE INTERNAL "Whether coopmat is supported by glslc" )
37+ else ()
38+ message (STATUS "GL_KHR_cooperative_matrix supported by glslc" )
39+ add_compile_definitions (GGML_VULKAN_COOPMAT_GLSLC_SUPPORT)
40+ set (GGML_VULKAN_COOPMAT_GLSLC_SUPPORT ON CACHE INTERNAL "Whether coopmat is supported by glslc" )
41+ endif ()
4042 endif ()
4143
42- # Compile a test shader to determine whether GL_NV_cooperative_matrix2 is supported.
43- # If it's not, there will be an error to stderr.
44- # If it's supported, set a define to indicate that we should compile those shaders
45- execute_process (COMMAND ${Vulkan_GLSLC_EXECUTABLE} -o - -fshader-stage=compute --target -env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR} /vulkan-shaders/test_coopmat2_support.comp"
46- OUTPUT_VARIABLE glslc_output
47- ERROR_VARIABLE glslc_error)
48-
49- if (${glslc_error} MATCHES ".*extension not supported: GL_NV_cooperative_matrix2.*" )
50- 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" )
52- else ()
53- message (STATUS "GL_NV_cooperative_matrix2 supported by glslc" )
54- add_compile_definitions (GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
55- set (GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT ON CACHE INTERNAL "Whether coopmat2 is supported by glslc" )
44+ if (NOT DEFINED GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
45+ # Compile a test shader to determine whether GL_NV_cooperative_matrix2 is supported.
46+ # If it's not, there will be an error to stderr.
47+ # If it's supported, set a define to indicate that we should compile those shaders
48+ execute_process (COMMAND ${Vulkan_GLSLC_EXECUTABLE} -o - -fshader-stage=compute --target -env=vulkan1.3 "${CMAKE_CURRENT_SOURCE_DIR} /vulkan-shaders/test_coopmat2_support.comp"
49+ OUTPUT_VARIABLE glslc_output
50+ ERROR_VARIABLE glslc_error)
51+
52+ if (${glslc_error} MATCHES ".*extension not supported: GL_NV_cooperative_matrix2.*" )
53+ message (STATUS "GL_NV_cooperative_matrix2 not supported by glslc" )
54+ set (GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT OFF CACHE INTERNAL "Whether coopmat2 is supported by glslc" )
55+ else ()
56+ message (STATUS "GL_NV_cooperative_matrix2 supported by glslc" )
57+ add_compile_definitions (GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT)
58+ set (GGML_VULKAN_COOPMAT2_GLSLC_SUPPORT ON CACHE INTERNAL "Whether coopmat2 is supported by glslc" )
59+ endif ()
5660 endif ()
5761
5862 target_link_libraries (ggml-vulkan PRIVATE Vulkan::Vulkan)
0 commit comments