From 8c74520586085635cad5005a3ac6a1b55a6d9344 Mon Sep 17 00:00:00 2001 From: Concedo <39025047+LostRuins@users.noreply.github.com> Date: Thu, 3 Apr 2025 20:51:17 +0800 Subject: [PATCH] added NO_VULKAN_EXTENSIONS flag to disable dp4a and coopmat if needed --- Makefile | 9 +++++++-- ggml/src/ggml-vulkan/ggml-vulkan.cpp | 2 ++ .../ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index a4999030c..d8be64457 100644 --- a/Makefile +++ b/Makefile @@ -392,6 +392,9 @@ endif endif endif +ifdef NO_VULKAN_EXTENSIONS + VKGEN_ADD = -DNO_VULKAN_EXTENSIONS +endif # # Print build information @@ -585,7 +588,7 @@ ggml_v3-opencl.o: otherarch/ggml_v3-opencl.cpp otherarch/ggml_v3-opencl.h #vulkan ggml-vulkan.o: ggml/src/ggml-vulkan/ggml-vulkan.cpp ggml/include/ggml-vulkan.h ggml/src/ggml-vulkan-shaders.cpp - $(CXX) $(CXXFLAGS) $(VULKAN_FLAGS) -c $< -o $@ + $(CXX) $(CXXFLAGS) $(VKGEN_ADD) $(VULKAN_FLAGS) -c $< -o $@ # intermediate objects llama.o: src/llama.cpp ggml/include/ggml.h ggml/include/ggml-alloc.h ggml/include/ggml-backend.h ggml/include/ggml-cuda.h ggml/include/ggml-metal.h include/llama.h otherarch/llama-util.h @@ -666,15 +669,17 @@ endif vulkan-shaders-gen: ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp @echo 'Vulkan shaders need to be regenerated. This can only be done on Windows or Linux. Please stand by...' - $(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS) + $(CXX) $(CXXFLAGS) $(VKGEN_ADD) $(filter-out %.h,$^) -o $@ $(LDFLAGS) ifeq ($(OS),Windows_NT) @echo 'Now rebuilding vulkan shaders for Windows...' $(shell) vulkan-shaders-gen --glslc glslc --input-dir ggml/src/ggml-vulkan/vulkan-shaders --target-hpp ggml/src/ggml-vulkan-shaders.hpp --target-cpp ggml/src/ggml-vulkan-shaders.cpp + @echo 'Vulkan Shaders Rebuilt for Windows...' else @echo 'Now rebuilding vulkan shaders for Linux...' ${shell} chmod +x vulkan-shaders-gen ${shell} chmod +x glslc-linux $(shell) ./vulkan-shaders-gen --glslc ./glslc-linux --input-dir ggml/src/ggml-vulkan/vulkan-shaders --target-hpp ggml/src/ggml-vulkan-shaders.hpp --target-cpp ggml/src/ggml-vulkan-shaders.cpp + @echo 'Vulkan Shaders Rebuilt for Linux...' endif #generated libraries diff --git a/ggml/src/ggml-vulkan/ggml-vulkan.cpp b/ggml/src/ggml-vulkan/ggml-vulkan.cpp index a7e9510ec..7a03788f6 100644 --- a/ggml/src/ggml-vulkan/ggml-vulkan.cpp +++ b/ggml/src/ggml-vulkan/ggml-vulkan.cpp @@ -1,9 +1,11 @@ +#ifndef NO_VULKAN_EXTENSIONS #ifndef GGML_VULKAN_COOPMAT_GLSLC_SUPPORT #define GGML_VULKAN_COOPMAT_GLSLC_SUPPORT #endif #ifndef GGML_VULKAN_INTEGER_DOT_GLSLC_SUPPORT #define GGML_VULKAN_INTEGER_DOT_GLSLC_SUPPORT #endif +#endif #include "ggml-vulkan.h" #include diff --git a/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp b/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp index a83844334..ae8810205 100644 --- a/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp +++ b/ggml/src/ggml-vulkan/vulkan-shaders/vulkan-shaders-gen.cpp @@ -32,12 +32,14 @@ #endif #define ASYNCIO_CONCURRENCY 64 +#ifndef NO_VULKAN_EXTENSIONS #ifndef GGML_VULKAN_COOPMAT_GLSLC_SUPPORT #define GGML_VULKAN_COOPMAT_GLSLC_SUPPORT #endif #ifndef GGML_VULKAN_INTEGER_DOT_GLSLC_SUPPORT #define GGML_VULKAN_INTEGER_DOT_GLSLC_SUPPORT #endif +#endif std::mutex lock; std::vector> shader_fnames;