Add CMake target for Vulkan shaders
This commit is contained in:
parent
29ba5a83d7
commit
1b4759f9cf
2 changed files with 34 additions and 144961 deletions
|
@ -509,13 +509,15 @@ if (LLAMA_RPC)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if (LLAMA_VULKAN)
|
if (LLAMA_VULKAN)
|
||||||
|
find_package(Python COMPONENTS Interpreter)
|
||||||
|
if (NOT Python_FOUND)
|
||||||
|
message(FATAL_ERROR "python is required to compile Vulkan shaders")
|
||||||
|
endif()
|
||||||
|
|
||||||
find_package(Vulkan)
|
find_package(Vulkan)
|
||||||
if (Vulkan_FOUND)
|
if (Vulkan_FOUND)
|
||||||
message(STATUS "Vulkan found")
|
message(STATUS "Vulkan found")
|
||||||
|
|
||||||
set(GGML_HEADERS_VULKAN ggml-vulkan.h)
|
|
||||||
set(GGML_SOURCES_VULKAN ggml-vulkan.cpp)
|
|
||||||
|
|
||||||
add_compile_definitions(GGML_USE_VULKAN)
|
add_compile_definitions(GGML_USE_VULKAN)
|
||||||
|
|
||||||
# Workaround to the "can't dereference invalidated vector iterator" bug in clang-cl debug build
|
# Workaround to the "can't dereference invalidated vector iterator" bug in clang-cl debug build
|
||||||
|
@ -544,7 +546,35 @@ if (LLAMA_VULKAN)
|
||||||
add_compile_definitions(GGML_VULKAN_RUN_TESTS)
|
add_compile_definitions(GGML_VULKAN_RUN_TESTS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set (_llama_vk_genshaders_cmd ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/ggml_vk_generate_shaders.py)
|
||||||
|
set (_llama_vk_header ${CMAKE_CURRENT_BINARY_DIR}/ggml-vulkan-shaders.hpp)
|
||||||
|
set (_llama_vk_source ${CMAKE_CURRENT_BINARY_DIR}/ggml-vulkan-shaders.cpp)
|
||||||
|
set (_llama_vk_input_dir ${CMAKE_CURRENT_SOURCE_DIR}/vulkan-shaders)
|
||||||
|
set (_llama_vk_output_dir ${CMAKE_CURRENT_BINARY_DIR}/vulkan-shaders.spv)
|
||||||
|
|
||||||
|
file(GLOB _llama_vk_shader_deps "${_llama_vk_input_dir}/*.comp")
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${_llama_vk_header}
|
||||||
|
${_llama_vk_source}
|
||||||
|
|
||||||
|
COMMAND ${_llama_vk_genshaders_cmd}
|
||||||
|
--glslc ${Vulkan_GLSLC_EXECUTABLE}
|
||||||
|
--input-dir ${_llama_vk_input_dir}
|
||||||
|
--output-dir ${_llama_vk_output_dir}
|
||||||
|
--target-hpp ${_llama_vk_header}
|
||||||
|
--target-cpp ${_llama_vk_source}
|
||||||
|
--no-clean
|
||||||
|
|
||||||
|
DEPENDS ${_llama_vk_shader_deps}
|
||||||
|
COMMENT "Generate vulkan shaders"
|
||||||
|
)
|
||||||
|
|
||||||
|
set(GGML_HEADERS_VULKAN ggml-vulkan.h ${_llama_vk_header})
|
||||||
|
set(GGML_SOURCES_VULKAN ggml-vulkan.cpp ${_llama_vk_source})
|
||||||
|
|
||||||
set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} Vulkan::Vulkan)
|
set(LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} Vulkan::Vulkan)
|
||||||
|
set(LLAMA_EXTRA_INCLUDES ${LLAMA_EXTRA_INCLUDES} ${CMAKE_BINARY_DIR})
|
||||||
else()
|
else()
|
||||||
message(WARNING "Vulkan not found")
|
message(WARNING "Vulkan not found")
|
||||||
endif()
|
endif()
|
||||||
|
|
144957
ggml-vulkan-shaders.hpp
144957
ggml-vulkan-shaders.hpp
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue