[Bf-blender-cvs] [72b395a7e63] temp-vulkan-shader: Find includes and libs for shaderc.

Jeroen Bakker noreply at git.blender.org
Fri Nov 18 15:51:16 CET 2022


Commit: 72b395a7e638771917f5b5e3003b2d888eac4f71
Author: Jeroen Bakker
Date:   Fri Nov 18 15:49:42 2022 +0100
Branches: temp-vulkan-shader
https://developer.blender.org/rB72b395a7e638771917f5b5e3003b2d888eac4f71

Find includes and libs for shaderc.

Don't use the default find_pavkage(vulkan) as that won't find the SDK.
ShaderC is only part of the SDK, not of the distributed driver part.

===================================================================

M	build_files/cmake/platform/platform_apple.cmake
M	source/blender/gpu/CMakeLists.txt
M	source/blender/gpu/vulkan/vk_backend.hh
M	source/blender/gpu/vulkan/vk_shader.cc

===================================================================

diff --git a/build_files/cmake/platform/platform_apple.cmake b/build_files/cmake/platform/platform_apple.cmake
index b923a076792..403d131cbfa 100644
--- a/build_files/cmake/platform/platform_apple.cmake
+++ b/build_files/cmake/platform/platform_apple.cmake
@@ -101,7 +101,19 @@ if(WITH_USD)
 endif()
 
 if(WITH_VULKAN_BACKEND)
-  find_package(Vulkan REQUIRED)
+  if(EXISTS ${LIBDIR}/vulkan)
+    set(VULKAN_FOUND On)
+    set(VULKAN_ROOT_DIR ${LIBDIR}/vulkan/macOS)
+    set(VULKAN_INCLUDE_DIR ${VULKAN_ROOT_DIR}/include)
+    set(VULKAN_INCLUDE_DIRS ${VULKAN_INCLUDE_DIR})
+    set(VULKAN_LIBRARY ${VULKAN_ROOT_DIR}/lib/libvulkan.1.dylib)
+    set(SHADERC_LIBRARY ${VULKAN_ROOT_DIR}/lib/libshaderc.a)
+    set(VULKAN_LIBRARIES ${VULKAN_LIBRARY} ${SHADERC_LIBRARY})
+  else()
+    message(WARNING "Vulkan was not found, disabling WITH_VULKAN_BACKEND")
+    set(WITH_VULKAN_BACKEND OFF)
+  endif()
+
   find_package(MoltenVK REQUIRED)
 endif()
 
diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt
index 03b819c7172..23e196397b8 100644
--- a/source/blender/gpu/CMakeLists.txt
+++ b/source/blender/gpu/CMakeLists.txt
@@ -43,6 +43,8 @@ set(INC
 
 set(INC_SYS
   ${Epoxy_INCLUDE_DIRS}
+  ${VULKAN_INCLUDE_DIRS}
+  ${MOLTENVK_INCLUDE_DIRS}
 )
 
 set(SRC
@@ -277,6 +279,8 @@ endif()
 
 set(LIB
   ${Epoxy_LIBRARIES}
+  ${VULKAN_LIBRARIES}
+  ${MOLTENVK_LIBRARIES}
 )
 
 set(MSL_SRC
diff --git a/source/blender/gpu/vulkan/vk_backend.hh b/source/blender/gpu/vulkan/vk_backend.hh
index 55b528bfa00..b52f17ae40c 100644
--- a/source/blender/gpu/vulkan/vk_backend.hh
+++ b/source/blender/gpu/vulkan/vk_backend.hh
@@ -9,6 +9,7 @@
 
 #include "gpu_backend.hh"
 
+
 namespace blender::gpu {
 
 class VKBackend : public GPUBackend {
diff --git a/source/blender/gpu/vulkan/vk_shader.cc b/source/blender/gpu/vulkan/vk_shader.cc
index d628f3eb851..6ebca5d5904 100644
--- a/source/blender/gpu/vulkan/vk_shader.cc
+++ b/source/blender/gpu/vulkan/vk_shader.cc
@@ -7,6 +7,13 @@
 
 #include "vk_shader.hh"
 
+#ifdef __APPLE__
+#  include <MoltenVK/vk_mvk_moltenvk.h>
+#else
+#  include <vulkan/vulkan.h>
+#endif
+#include "shaderc/shaderc.hpp"
+
 namespace blender::gpu {
 void VKShader::vertex_shader_from_glsl(MutableSpan<const char *> /*sources*/)
 {



More information about the Bf-blender-cvs mailing list