SCsub 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/env python
  2. from misc.utility.scons_hints import *
  3. Import("env")
  4. thirdparty_obj = []
  5. thirdparty_dir = "#thirdparty/vulkan"
  6. thirdparty_volk_dir = "#thirdparty/volk"
  7. thirdparty_spirv_headers_dir = "#thirdparty/spirv-headers"
  8. thirdparty_respirv_dir = "#thirdparty/re-spirv"
  9. # Use bundled Vulkan headers
  10. env.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "/include"])
  11. if env["use_volk"]:
  12. env.AppendUnique(CPPDEFINES=["USE_VOLK"])
  13. env.Prepend(CPPPATH=[thirdparty_volk_dir])
  14. if env["platform"] == "android":
  15. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_ANDROID_KHR"])
  16. elif env["platform"] == "ios":
  17. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_IOS_MVK", "VK_USE_PLATFORM_METAL_EXT"])
  18. elif env["platform"] == "linuxbsd":
  19. if env["x11"]:
  20. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_XLIB_KHR"])
  21. if env["wayland"]:
  22. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_WAYLAND_KHR"])
  23. elif env["platform"] == "macos":
  24. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_MACOS_MVK", "VK_USE_PLATFORM_METAL_EXT"])
  25. elif env["platform"] == "windows":
  26. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_WIN32_KHR"])
  27. # Build Vulkan memory allocator and volk
  28. env_thirdparty_vma = env.Clone()
  29. env_thirdparty_vma.disable_warnings()
  30. thirdparty_sources_vma = [thirdparty_dir + "/vk_mem_alloc.cpp"]
  31. if env["use_volk"]:
  32. env_thirdparty_vma.AppendUnique(CPPDEFINES=[("VMA_STATIC_VULKAN_FUNCTIONS", 1)])
  33. env_thirdparty_volk = env.Clone()
  34. env_thirdparty_volk.disable_warnings()
  35. thirdparty_sources_volk = [thirdparty_volk_dir + "/volk.c"]
  36. env_thirdparty_volk.add_source_files(thirdparty_obj, thirdparty_sources_volk)
  37. elif env["platform"] == "android":
  38. # Our current NDK version only provides old Vulkan headers,
  39. # so we have to limit VMA.
  40. env_thirdparty_vma.AppendUnique(CPPDEFINES=[("VMA_VULKAN_VERSION", 1000000)])
  41. elif env["platform"] == "macos" or env["platform"] == "ios":
  42. # MoltenVK supports only Vulkan 1.1 API, limit VMA to the same version.
  43. env_thirdparty_vma.AppendUnique(CPPDEFINES=[("VMA_VULKAN_VERSION", 1001000)])
  44. env_thirdparty_vma.add_source_files(thirdparty_obj, thirdparty_sources_vma)
  45. # Build re-spirv
  46. env_thirdparty_respirv = env.Clone()
  47. env_thirdparty_respirv.Prepend(CPPPATH=[thirdparty_spirv_headers_dir + "/include"])
  48. env_thirdparty_respirv.disable_warnings()
  49. thirdparty_sources_respirv = [thirdparty_respirv_dir + "/re-spirv.cpp"]
  50. env_thirdparty_respirv.add_source_files(thirdparty_obj, thirdparty_sources_respirv)
  51. env.drivers_sources += thirdparty_obj
  52. # Godot source files
  53. driver_obj = []
  54. env.add_source_files(driver_obj, "*.cpp")
  55. env.drivers_sources += driver_obj
  56. # Needed to force rebuilding the driver files when the thirdparty code is updated.
  57. env.Depends(driver_obj, thirdparty_obj)