SCsub 2.1 KB

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