mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-16 08:27:05 +00:00
Add proper defines for backend enablement
This commit is contained in:
committed by
Corentin Wallez
parent
a7bfc9d2ac
commit
275817a93a
@@ -18,11 +18,21 @@
|
||||
|
||||
namespace utils {
|
||||
|
||||
BackendBinding* CreateD3D12Binding();
|
||||
BackendBinding* CreateMetalBinding();
|
||||
BackendBinding* CreateOpenGLBinding();
|
||||
BackendBinding* CreateNullBinding();
|
||||
BackendBinding* CreateVulkanBinding();
|
||||
#if defined(NXT_ENABLE_BACKEND_D3D12)
|
||||
BackendBinding* CreateD3D12Binding();
|
||||
#endif
|
||||
#if defined(NXT_ENABLE_BACKEND_METAL)
|
||||
BackendBinding* CreateMetalBinding();
|
||||
#endif
|
||||
#if defined(NXT_ENABLE_BACKEND_NULL)
|
||||
BackendBinding* CreateNullBinding();
|
||||
#endif
|
||||
#if defined(NXT_ENABLE_BACKEND_OPENGL)
|
||||
BackendBinding* CreateOpenGLBinding();
|
||||
#endif
|
||||
#if defined(NXT_ENABLE_BACKEND_VULKAN)
|
||||
BackendBinding* CreateVulkanBinding();
|
||||
#endif
|
||||
|
||||
void BackendBinding::SetWindow(GLFWwindow* window) {
|
||||
this->window = window;
|
||||
@@ -30,31 +40,33 @@ namespace utils {
|
||||
|
||||
BackendBinding* CreateBinding(BackendType type) {
|
||||
switch (type) {
|
||||
case BackendType::D3D12:
|
||||
#if defined(_WIN32)
|
||||
#if defined(NXT_ENABLE_BACKEND_D3D12)
|
||||
case BackendType::D3D12:
|
||||
return CreateD3D12Binding();
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
case BackendType::OpenGL:
|
||||
return CreateOpenGLBinding();
|
||||
|
||||
case BackendType::Metal:
|
||||
#if defined(__APPLE__)
|
||||
#if defined(NXT_ENABLE_BACKEND_METAL)
|
||||
case BackendType::Metal:
|
||||
return CreateMetalBinding();
|
||||
#else
|
||||
return nullptr;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
case BackendType::Null:
|
||||
return CreateNullBinding();
|
||||
#if defined(NXT_ENABLE_BACKEND_NULL)
|
||||
case BackendType::Null:
|
||||
return CreateNullBinding();
|
||||
#endif
|
||||
|
||||
case BackendType::Vulkan:
|
||||
return nullptr; // TODO(cwallez@chromium.org) change it to CreateVulkanBinding();
|
||||
#if defined(NXT_ENABLE_BACKEND_OPENGL)
|
||||
case BackendType::OpenGL:
|
||||
return CreateOpenGLBinding();
|
||||
#endif
|
||||
|
||||
#if defined(NXT_ENABLE_BACKEND_VULKAN)
|
||||
case BackendType::Vulkan:
|
||||
return CreateVulkanBinding();
|
||||
#endif
|
||||
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,21 +17,31 @@ set(UTILS_DIR ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
list(APPEND UTILS_SOURCES
|
||||
${UTILS_DIR}/BackendBinding.cpp
|
||||
${UTILS_DIR}/BackendBinding.h
|
||||
${UTILS_DIR}/NullBinding.cpp
|
||||
${UTILS_DIR}/OpenGLBinding.cpp
|
||||
${UTILS_DIR}/NXTHelpers.cpp
|
||||
${UTILS_DIR}/NXTHelpers.h
|
||||
)
|
||||
|
||||
if (APPLE)
|
||||
if (NXT_ENABLE_D3D12)
|
||||
list(APPEND UTILS_SOURCES
|
||||
${UTILS_DIR}/D3D12Binding.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NXT_ENABLE_METAL)
|
||||
list(APPEND UTILS_SOURCES
|
||||
${UTILS_DIR}/MetalBinding.mm
|
||||
)
|
||||
endif()
|
||||
|
||||
if (WIN32)
|
||||
if (NXT_ENABLE_NULL)
|
||||
list(APPEND UTILS_SOURCES
|
||||
${UTILS_DIR}/D3D12Binding.cpp
|
||||
${UTILS_DIR}/NullBinding.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
if (NXT_ENABLE_OPENGL)
|
||||
list(APPEND UTILS_SOURCES
|
||||
${UTILS_DIR}/OpenGLBinding.cpp
|
||||
)
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user