CMake: Add support for the Vulkan backend

Bug: dawn:333
Change-Id: Id509e5f06862d6fee517ef47c40418077ccf4759
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/15941
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez 2020-02-18 02:12:35 +00:00 committed by Commit Bot service account
parent 215b5370bc
commit d353ca0881
3 changed files with 95 additions and 2 deletions

View File

@ -52,6 +52,7 @@ set(ENABLE_D3D12 OFF)
set(ENABLE_METAL OFF)
set(ENABLE_OPENGL OFF)
set(ENABLE_VULKAN OFF)
set(USE_X11 OFF)
if (WIN32)
set(ENABLE_D3D12 ON)
set(ENABLE_VULKAN ON)
@ -60,6 +61,7 @@ elseif(APPLE)
elseif(UNIX)
set(ENABLE_OPENGL ON)
set(ENABLE_VULKAN ON)
set(USE_X11 ON)
endif()
option(DAWN_ENABLE_D3D12 "Enable compilation of the D3D12 backend" ${ENABLE_D3D12})
@ -68,6 +70,7 @@ option(DAWN_ENABLE_NULL "Enable compilation of the Null backend" ON)
option(DAWN_ENABLE_OPENGL "Enable compilation of the OpenGL backend" ${ENABLE_OPENGL})
option(DAWN_ENABLE_VULKAN "Enable compilation of the Vulkan backend" ${ENABLE_VULKAN})
option(DAWN_ALWAYS_ASSERT "Enable assertions on all build types" OFF)
option(DAWN_USE_X11 "Enable support for X11 surface" ${USE_X11})
option(DAWN_BUILD_EXAMPLES "Enables building Dawn's exmaples" ON)
@ -118,7 +121,7 @@ endif()
if (DAWN_ENABLE_VULKAN)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_ENABLE_BACKEND_VULKAN")
endif()
if (UNIX AND NOT APPLE)
if (DAWN_USE_X11)
target_compile_definitions(dawn_internal_config INTERFACE "DAWN_USE_X11")
endif()

View File

@ -144,6 +144,11 @@ target_link_libraries(dawn_native
spirv-cross-core
)
if (DAWN_USE_X11)
find_package(X11 REQUIRED)
target_link_libraries(dawn_native PRIVATE ${X11_LIBRARIES})
endif()
if (DAWN_ENABLE_D3D12)
#TODO
endif()
@ -258,7 +263,80 @@ if (DAWN_ENABLE_OPENGL)
endif()
if (DAWN_ENABLE_VULKAN)
# TODO
target_sources(dawn_native PRIVATE
"${DAWN_INCLUDE_DIR}/dawn_native/VulkanBackend.h"
"vulkan/AdapterVk.cpp"
"vulkan/AdapterVk.h"
"vulkan/BackendVk.cpp"
"vulkan/BackendVk.h"
"vulkan/BindGroupLayoutVk.cpp"
"vulkan/BindGroupLayoutVk.h"
"vulkan/BindGroupVk.cpp"
"vulkan/BindGroupVk.h"
"vulkan/BufferVk.cpp"
"vulkan/BufferVk.h"
"vulkan/CommandBufferVk.cpp"
"vulkan/CommandBufferVk.h"
"vulkan/CommandRecordingContext.h"
"vulkan/ComputePipelineVk.cpp"
"vulkan/ComputePipelineVk.h"
"vulkan/DescriptorSetService.cpp"
"vulkan/DescriptorSetService.h"
"vulkan/DeviceVk.cpp"
"vulkan/DeviceVk.h"
"vulkan/ExternalHandle.h"
"vulkan/FencedDeleter.cpp"
"vulkan/FencedDeleter.h"
"vulkan/Forward.h"
"vulkan/NativeSwapChainImplVk.cpp"
"vulkan/NativeSwapChainImplVk.h"
"vulkan/PipelineLayoutVk.cpp"
"vulkan/PipelineLayoutVk.h"
"vulkan/QueueVk.cpp"
"vulkan/QueueVk.h"
"vulkan/RenderPassCache.cpp"
"vulkan/RenderPassCache.h"
"vulkan/RenderPipelineVk.cpp"
"vulkan/RenderPipelineVk.h"
"vulkan/ResourceHeapVk.cpp"
"vulkan/ResourceHeapVk.h"
"vulkan/ResourceMemoryAllocatorVk.cpp"
"vulkan/ResourceMemoryAllocatorVk.h"
"vulkan/SamplerVk.cpp"
"vulkan/SamplerVk.h"
"vulkan/ShaderModuleVk.cpp"
"vulkan/ShaderModuleVk.h"
"vulkan/StagingBufferVk.cpp"
"vulkan/StagingBufferVk.h"
"vulkan/SwapChainVk.cpp"
"vulkan/SwapChainVk.h"
"vulkan/TextureVk.cpp"
"vulkan/TextureVk.h"
"vulkan/UtilsVulkan.cpp"
"vulkan/UtilsVulkan.h"
"vulkan/VulkanError.cpp"
"vulkan/VulkanError.h"
"vulkan/VulkanFunctions.cpp"
"vulkan/VulkanFunctions.h"
"vulkan/VulkanInfo.cpp"
"vulkan/VulkanInfo.h"
"vulkan/external_memory/MemoryService.h"
"vulkan/external_semaphore/SemaphoreService.h"
)
target_link_libraries(dawn_native PUBLIC dawn_vulkan_headers)
if (UNIX AND NOT APPLE)
target_sources(dawn_native PRIVATE
"vulkan/external_memory/MemoryServiceOpaqueFD.cpp"
"vulkan/external_semaphore/SemaphoreServiceOpaqueFD.cpp"
)
else()
target_sources(dawn_native PRIVATE
"vulkan/external_memory/MemoryServiceNull.cpp"
"vulkan/external_semaphore/SemaphoreServiceNull.cpp"
)
endif()
endif()
# TODO how to do the component build in CMake?

View File

@ -77,3 +77,15 @@ endif()
add_library(dawn_khronos_platform INTERFACE)
target_sources(dawn_khronos_platform INTERFACE "${DAWN_THIRD_PARTY_DIR}/khronos/KHR/khrplatform.h")
target_include_directories(dawn_khronos_platform INTERFACE "${DAWN_THIRD_PARTY_DIR}/khronos")
# Header-only library for Vulkan headers
add_library(dawn_vulkan_headers INTERFACE)
target_sources(dawn_vulkan_headers INTERFACE
"${DAWN_THIRD_PARTY_DIR}/khronos/vulkan/vk_icd.h"
"${DAWN_THIRD_PARTY_DIR}/khronos/vulkan/vk_layer.h"
"${DAWN_THIRD_PARTY_DIR}/khronos/vulkan/vk_platform.h"
"${DAWN_THIRD_PARTY_DIR}/khronos/vulkan/vk_sdk_platform.h"
"${DAWN_THIRD_PARTY_DIR}/khronos/vulkan/vulkan.h"
"${DAWN_THIRD_PARTY_DIR}/khronos/vulkan/vulkan_core.h"
)
target_include_directories(dawn_vulkan_headers INTERFACE "${DAWN_THIRD_PARTY_DIR}/khronos")