Skip to content

Commit 8ebe8dd

Browse files
authored
Improve Vulkan shader build system (#9239)
* Improve Vulkan shader builds system - Add dependency to vulkan-shaders-gen to rebuild shaders when changing the shader compilation utility. - Add option to generate debug info for Vulkan shaders to provide shader source to Vulkan shader profiling tools * remove not required self dependency
1 parent 9bc6db2 commit 8ebe8dd

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

ggml/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ option(GGML_VULKAN "ggml: use Vulkan"
135135
option(GGML_VULKAN_CHECK_RESULTS "ggml: run Vulkan op checks" OFF)
136136
option(GGML_VULKAN_DEBUG "ggml: enable Vulkan debug output" OFF)
137137
option(GGML_VULKAN_MEMORY_DEBUG "ggml: enable Vulkan memory debug output" OFF)
138+
option(GGML_VULKAN_SHADER_DEBUG_INFO "ggml: enable Vulkan shader debug info" OFF)
138139
option(GGML_VULKAN_PERF "ggml: enable Vulkan perf output" OFF)
139140
option(GGML_VULKAN_VALIDATE "ggml: enable Vulkan validation" OFF)
140141
option(GGML_VULKAN_RUN_TESTS "ggml: run Vulkan tests" OFF)

ggml/src/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -612,6 +612,10 @@ if (GGML_VULKAN)
612612
add_compile_definitions(GGML_VULKAN_MEMORY_DEBUG)
613613
endif()
614614

615+
if (GGML_VULKAN_SHADER_DEBUG_INFO)
616+
add_compile_definitions(GGML_VULKAN_SHADER_DEBUG_INFO)
617+
endif()
618+
615619
if (GGML_VULKAN_PERF)
616620
add_compile_definitions(GGML_VULKAN_PERF)
617621
endif()

ggml/src/vulkan-shaders/vulkan-shaders-gen.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,11 @@ void string_to_spv(const std::string& _name, const std::string& in_fname, const
200200
#else
201201
std::vector<std::string> cmd = {GLSLC, "-fshader-stage=compute", "--target-env=vulkan1.2", "-O", in_path, "-o", out_fname};
202202
#endif
203+
204+
#ifdef GGML_VULKAN_SHADER_DEBUG_INFO
205+
cmd.push_back("-g");
206+
#endif
207+
203208
for (const auto& define : defines) {
204209
cmd.push_back("-D" + define.first + "=" + define.second);
205210
}

0 commit comments

Comments
 (0)