SCsub 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. # Use bundled Vulkan headers
  8. env.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "/include"])
  9. if env["use_volk"]:
  10. env.AppendUnique(CPPDEFINES=["USE_VOLK"])
  11. env.Prepend(CPPPATH=[thirdparty_volk_dir])
  12. if env["platform"] == "android":
  13. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_ANDROID_KHR"])
  14. elif env["platform"] == "ios":
  15. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_IOS_MVK", "VK_USE_PLATFORM_METAL_EXT"])
  16. elif env["platform"] == "linuxbsd":
  17. if env["x11"]:
  18. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_XLIB_KHR"])
  19. if env["wayland"]:
  20. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_WAYLAND_KHR"])
  21. elif env["platform"] == "macos":
  22. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_MACOS_MVK", "VK_USE_PLATFORM_METAL_EXT"])
  23. elif env["platform"] == "windows":
  24. env.AppendUnique(CPPDEFINES=["VK_USE_PLATFORM_WIN32_KHR"])
  25. # Build Vulkan memory allocator and volk
  26. env_thirdparty_vma = env.Clone()
  27. env_thirdparty_vma.disable_warnings()
  28. thirdparty_sources_vma = [thirdparty_dir + "/vk_mem_alloc.cpp"]
  29. if env["use_volk"]:
  30. env_thirdparty_vma.AppendUnique(CPPDEFINES=["VMA_STATIC_VULKAN_FUNCTIONS=1"])
  31. env_thirdparty_volk = env.Clone()
  32. env_thirdparty_volk.disable_warnings()
  33. thirdparty_sources_volk = [thirdparty_volk_dir + "/volk.c"]
  34. env_thirdparty_volk.add_source_files(thirdparty_obj, thirdparty_sources_volk)
  35. elif env["platform"] == "android":
  36. # Our current NDK version only provides old Vulkan headers,
  37. # so we have to limit VMA.
  38. env_thirdparty_vma.AppendUnique(CPPDEFINES=["VMA_VULKAN_VERSION=1000000"])
  39. elif env["platform"] == "macos" or env["platform"] == "ios":
  40. # MoltenVK supports only Vulkan 1.1 API, limit VMA to the same version.
  41. env_thirdparty_vma.AppendUnique(CPPDEFINES=["VMA_VULKAN_VERSION=1001000"])
  42. env_thirdparty_vma.add_source_files(thirdparty_obj, thirdparty_sources_vma)
  43. env.drivers_sources += thirdparty_obj
  44. # Godot source files
  45. driver_obj = []
  46. env.add_source_files(driver_obj, "*.cpp")
  47. env.drivers_sources += driver_obj
  48. # Needed to force rebuilding the driver files when the thirdparty code is updated.
  49. env.Depends(driver_obj, thirdparty_obj)