diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1429386be7..ca9bf2335e 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -24,6 +24,7 @@ function(add_dawn_sample target sources) target_link_libraries(${target} sample_utils) target_include_directories(${target} SYSTEM PRIVATE ${GLM_INCLUDE_DIR}) target_include_directories(${target} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + target_include_directories(${target} PRIVATE ${GLM_INCLUDE_DIR} ${TINYGLTFLOADER_INCLUDE_DIR}) DawnInternalTarget("examples" ${target}) # Suppress some warnings in our sample dependencies diff --git a/src/dawn_native/CMakeLists.txt b/src/dawn_native/CMakeLists.txt index aa825252d2..9ef242b4aa 100644 --- a/src/dawn_native/CMakeLists.txt +++ b/src/dawn_native/CMakeLists.txt @@ -18,6 +18,7 @@ set(METAL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/metal) set(NULL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/null) set(OPENGL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/opengl) set(VULKAN_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vulkan) +set(DAWN_NATIVE_INCLUDE_DIR ${INCLUDE_DIR}/dawn_native) Generate( LIB_NAME dawn_native_utils_autogen @@ -42,14 +43,20 @@ function(GenerateProcTable backend) target_link_libraries(${backend}_autogen dawn_native_utils_autogen) endfunction() +set(DAWN_NATIVE_SOURCES) +set(DAWN_NATIVE_DEPS dawn_common spirv_cross) +set(DAWN_NATIVE_INCLUDE_DIRS ${SPIRV_CROSS_INCLUDE_DIR}) + ################################################################################ # OpenGL Backend ################################################################################ if (DAWN_ENABLE_OPENGL) GenerateProcTable(opengl) - target_link_libraries(opengl_autogen glfw glad) + target_link_libraries(opengl_autogen glad) + list(APPEND DAWN_NATIVE_DEPS opengl_autogen glad) + list(APPEND DAWN_NATIVE_INCLUDE_DIRS ${GLAD_INCLUDE_DIR}) list(APPEND DAWN_NATIVE_SOURCES ${OPENGL_DIR}/BlendStateGL.cpp ${OPENGL_DIR}/BlendStateGL.h @@ -84,6 +91,7 @@ if (DAWN_ENABLE_OPENGL) ${OPENGL_DIR}/SwapChainGL.h ${OPENGL_DIR}/TextureGL.cpp ${OPENGL_DIR}/TextureGL.h + ${DAWN_NATIVE_INCLUDE_DIR}/OpenGLBackend.h ) endif() @@ -93,10 +101,12 @@ endif() if (DAWN_ENABLE_NULL) GenerateProcTable(null) + list(APPEND DAWN_NATIVE_DEPS null_autogen) list(APPEND DAWN_NATIVE_SOURCES ${NULL_DIR}/NullBackend.cpp ${NULL_DIR}/NullBackend.h + ${DAWN_NATIVE_INCLUDE_DIR}/NullBackend.h ) endif() @@ -106,7 +116,7 @@ endif() if (DAWN_ENABLE_METAL) GenerateProcTable(metal) - target_link_libraries(metal_autogen "-framework QuartzCore" "-framework Metal") + list(APPEND DAWN_NATIVE_DEPS metal_autogen "-framework QuartzCore" "-framework Metal" "-framework Cocoa") list(APPEND DAWN_NATIVE_SOURCES ${METAL_DIR}/BlendStateMTL.mm @@ -140,6 +150,7 @@ if (DAWN_ENABLE_METAL) ${METAL_DIR}/SwapChainMTL.h ${METAL_DIR}/TextureMTL.mm ${METAL_DIR}/TextureMTL.h + ${DAWN_NATIVE_INCLUDE_DIR}/MetalBackend.h ) endif() @@ -205,8 +216,8 @@ if (DAWN_ENABLE_D3D12) list(APPEND D3D12_LIBRARIES ${DXGUID_LIBRARY}) endif() - target_link_libraries(d3d12_autogen ${D3D12_LIBRARIES}) - target_include_directories(d3d12_autogen SYSTEM PRIVATE ${D3D12_INCLUDE_DIR} ${DXGI_INCLUDE_DIR}) + list(APPEND DAWN_NATIVE_DEPS d3d12_autogen ${D3D12_LIBRARIES}) + target_include_directories(d3d12_autogen SYSTEM PUBLIC ${D3D12_INCLUDE_DIR} ${DXGI_INCLUDE_DIR}) list(APPEND DAWN_NATIVE_SOURCES ${D3D12_DIR}/d3d12_platform.h @@ -257,6 +268,7 @@ if (DAWN_ENABLE_D3D12) ${D3D12_DIR}/TextureCopySplitter.h ${D3D12_DIR}/TextureD3D12.cpp ${D3D12_DIR}/TextureD3D12.h + ${DAWN_NATIVE_INCLUDE_DIR}/D3D12Backend.h ) endif() @@ -266,6 +278,7 @@ endif() if (DAWN_ENABLE_VULKAN) GenerateProcTable(vulkan) + list(APPEND DAWN_NATIVE_DEPS vulkan_autogen) target_include_directories(vulkan_autogen PUBLIC ${VULKAN_HEADERS_INCLUDE_DIR}) list(APPEND DAWN_NATIVE_SOURCES @@ -318,6 +331,7 @@ if (DAWN_ENABLE_VULKAN) ${VULKAN_DIR}/VulkanFunctions.h ${VULKAN_DIR}/VulkanInfo.cpp ${VULKAN_DIR}/VulkanInfo.h + ${DAWN_NATIVE_INCLUDE_DIR}/VulkanBackend.h ) endif() @@ -382,24 +396,28 @@ list(APPEND DAWN_NATIVE_SOURCES ${DAWN_NATIVE_DIR}/Texture.cpp ${DAWN_NATIVE_DIR}/Texture.h ${DAWN_NATIVE_DIR}/ToBackend.h + ${DAWN_NATIVE_INCLUDE_DIR}/dawn_native_export.h ) -add_library(libdawn_native STATIC ${DAWN_NATIVE_SOURCES}) -DawnInternalTarget("dawn_native" libdawn_native) -target_link_libraries(libdawn_native dawn_common glfw glad spirv_cross) +# We want to produce both a static and a shared libdawn_native library. The static one is for +# unittests that need access to all the symbols of the library. The shared one is for the other +# users that access libdawn_native through the regular interface. +# We use a CMake "OBJECT" library type which allows precompiling the source files and reusing +# them for both the static and the shared library. Recent CMake versions make it so if you +# depend on an OBJECT library you get its dependencies and source files, which is very similar to +# GN's source_set. However the versions of CMake on our test bots is too old and doesn't support +# this, so instead we duplicate the deps everywhere. +add_library(libdawn_native_objects OBJECT ${DAWN_NATIVE_SOURCES}) +DawnInternalTarget("dawn_native" libdawn_native_objects) +target_compile_definitions(libdawn_native_objects PRIVATE DAWN_NATIVE_IMPLEMENTATION) +target_include_directories(libdawn_native_objects PRIVATE ${DAWN_NATIVE_INCLUDE_DIRS}) +add_dependencies(libdawn_native_objects dawn_native_utils_autogen) -if (DAWN_ENABLE_D3D12) - target_link_libraries(libdawn_native d3d12_autogen) -endif() -if (DAWN_ENABLE_METAL) - target_link_libraries(libdawn_native metal_autogen) -endif() -if (DAWN_ENABLE_NULL) - target_link_libraries(libdawn_native null_autogen) -endif() -if (DAWN_ENABLE_OPENGL) - target_link_libraries(libdawn_native opengl_autogen) -endif() -if (DAWN_ENABLE_VULKAN) - target_link_libraries(libdawn_native vulkan_autogen) -endif() +add_library(libdawn_native SHARED $) +DawnInternalTarget("dawn_native" libdawn_native) +target_link_libraries(libdawn_native ${DAWN_NATIVE_DEPS}) +set_property(TARGET libdawn_native PROPERTY OUTPUT_NAME "dawn_native") + +add_library(libdawn_native_static STATIC $) +DawnInternalTarget("dawn_native" libdawn_native_static) +target_link_libraries(libdawn_native_static ${DAWN_NATIVE_DEPS}) diff --git a/src/dawn_native/d3d12/DeviceD3D12.cpp b/src/dawn_native/d3d12/DeviceD3D12.cpp index b8505525e8..e2f9f1f76d 100644 --- a/src/dawn_native/d3d12/DeviceD3D12.cpp +++ b/src/dawn_native/d3d12/DeviceD3D12.cpp @@ -16,6 +16,7 @@ #include "common/Assert.h" #include "common/SwapChainUtils.h" +#include "dawn_native/D3D12backend.h" #include "dawn_native/d3d12/BindGroupD3D12.h" #include "dawn_native/d3d12/BindGroupLayoutD3D12.h" #include "dawn_native/d3d12/BlendStateD3D12.h" diff --git a/src/dawn_native/metal/DeviceMTL.mm b/src/dawn_native/metal/DeviceMTL.mm index a2929279a8..0cd4b21f8b 100644 --- a/src/dawn_native/metal/DeviceMTL.mm +++ b/src/dawn_native/metal/DeviceMTL.mm @@ -16,6 +16,7 @@ #include "dawn_native/BindGroup.h" #include "dawn_native/BindGroupLayout.h" +#include "dawn_native/MetalBackend.h" #include "dawn_native/RenderPassDescriptor.h" #include "dawn_native/metal/BlendStateMTL.h" #include "dawn_native/metal/BufferMTL.h" diff --git a/src/dawn_native/null/NullBackend.cpp b/src/dawn_native/null/NullBackend.cpp index eb0d56107c..cb4304d39a 100644 --- a/src/dawn_native/null/NullBackend.cpp +++ b/src/dawn_native/null/NullBackend.cpp @@ -15,6 +15,7 @@ #include "dawn_native/null/NullBackend.h" #include "dawn_native/Commands.h" +#include "dawn_native/NullBackend.h" #include diff --git a/src/dawn_native/opengl/DeviceGL.cpp b/src/dawn_native/opengl/DeviceGL.cpp index 2d27e00535..62cbbe9965 100644 --- a/src/dawn_native/opengl/DeviceGL.cpp +++ b/src/dawn_native/opengl/DeviceGL.cpp @@ -16,6 +16,7 @@ #include "dawn_native/BindGroup.h" #include "dawn_native/BindGroupLayout.h" +#include "dawn_native/OpenGLBackend.h" #include "dawn_native/RenderPassDescriptor.h" #include "dawn_native/opengl/BlendStateGL.h" #include "dawn_native/opengl/BufferGL.h" diff --git a/src/dawn_native/vulkan/DeviceVk.cpp b/src/dawn_native/vulkan/DeviceVk.cpp index fcd2106e35..914a970c8a 100644 --- a/src/dawn_native/vulkan/DeviceVk.cpp +++ b/src/dawn_native/vulkan/DeviceVk.cpp @@ -17,6 +17,7 @@ #include "common/Platform.h" #include "common/SwapChainUtils.h" #include "dawn_native/Commands.h" +#include "dawn_native/VulkanBackend.h" #include "dawn_native/vulkan/BindGroupLayoutVk.h" #include "dawn_native/vulkan/BindGroupVk.h" #include "dawn_native/vulkan/BlendStateVk.h" @@ -67,7 +68,8 @@ namespace dawn_native { namespace vulkan { return backendDevice->GetInstance(); } - dawnSwapChainImplementation CreateNativeSwapChainImpl(dawnDevice device, VkSurfaceKHRNative surfaceNative) { + DAWN_NATIVE_EXPORT dawnSwapChainImplementation + CreateNativeSwapChainImpl(dawnDevice device, VkSurfaceKHRNative surfaceNative) { Device* backendDevice = reinterpret_cast(device); VkSurfaceKHR surface = VkSurfaceKHR::CreateFromHandle(surfaceNative); diff --git a/src/include/dawn_native/D3D12Backend.h b/src/include/dawn_native/D3D12Backend.h new file mode 100644 index 0000000000..a3def2a5b3 --- /dev/null +++ b/src/include/dawn_native/D3D12Backend.h @@ -0,0 +1,33 @@ +// Copyright 2018 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNNATIVE_D3D12BACKEND_H_ +#define DAWNNATIVE_D3D12BACKEND_H_ + +#include +#include +#include + +#include + +namespace dawn_native { namespace d3d12 { + DAWN_NATIVE_EXPORT void Init(dawnProcTable* procs, dawnDevice* device); + + DAWN_NATIVE_EXPORT dawnSwapChainImplementation CreateNativeSwapChainImpl(dawnDevice device, + HWND window); + DAWN_NATIVE_EXPORT dawnTextureFormat + GetNativeSwapChainPreferredFormat(const dawnSwapChainImplementation* swapChain); +}} // namespace dawn_native::d3d12 + +#endif // DAWNNATIVE_D3D12BACKEND_H_ diff --git a/src/include/dawn_native/MetalBackend.h b/src/include/dawn_native/MetalBackend.h new file mode 100644 index 0000000000..a2b6044dca --- /dev/null +++ b/src/include/dawn_native/MetalBackend.h @@ -0,0 +1,33 @@ +// Copyright 2018 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNNATIVE_METALBACKEND_H_ +#define DAWNNATIVE_METALBACKEND_H_ + +#include +#include +#include + +#import +#import + +namespace dawn_native { namespace metal { + DAWN_NATIVE_EXPORT void Init(id metalDevice, + dawnProcTable* procs, + dawnDevice* device); + DAWN_NATIVE_EXPORT void SetNextDrawable(dawnDevice device, id drawable); + DAWN_NATIVE_EXPORT void Present(dawnDevice device); +}} // namespace dawn_native::metal + +#endif // DAWNNATIVE_METALBACKEND_H_ diff --git a/src/include/dawn_native/NullBackend.h b/src/include/dawn_native/NullBackend.h new file mode 100644 index 0000000000..9a1b42adae --- /dev/null +++ b/src/include/dawn_native/NullBackend.h @@ -0,0 +1,25 @@ +// Copyright 2018 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNNATIVE_NULLBACKEND_H_ +#define DAWNNATIVE_NULLBACKEND_H_ + +#include +#include + +namespace dawn_native { namespace null { + DAWN_NATIVE_EXPORT void Init(dawnProcTable* procs, dawnDevice* device); +}} // namespace dawn_native::null + +#endif // DAWNNATIVE_NULLBACKEND_H_ diff --git a/src/include/dawn_native/OpenGLBackend.h b/src/include/dawn_native/OpenGLBackend.h new file mode 100644 index 0000000000..aa275cda5f --- /dev/null +++ b/src/include/dawn_native/OpenGLBackend.h @@ -0,0 +1,27 @@ +// Copyright 2018 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNNATIVE_OPENGLBACKEND_H_ +#define DAWNNATIVE_OPENGLBACKEND_H_ + +#include +#include + +namespace dawn_native { namespace opengl { + DAWN_NATIVE_EXPORT void Init(void* (*getProc)(const char*), + dawnProcTable* procs, + dawnDevice* device); +}} // namespace dawn_native::opengl + +#endif // DAWNNATIVE_OPENGLBACKEND_H_ diff --git a/src/include/dawn_native/VulkanBackend.h b/src/include/dawn_native/VulkanBackend.h new file mode 100644 index 0000000000..c0aef2c1e7 --- /dev/null +++ b/src/include/dawn_native/VulkanBackend.h @@ -0,0 +1,39 @@ +// Copyright 2018 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNNATIVE_VULKANBACKEND_H_ +#define DAWNNATIVE_VULKANBACKEND_H_ + +#include +#include +#include + +#include + +#include + +namespace dawn_native { namespace vulkan { + DAWN_NATIVE_EXPORT void Init(dawnProcTable* procs, + dawnDevice* device, + const std::vector& requiredInstanceExtensions); + + DAWN_NATIVE_EXPORT VkInstance GetInstance(dawnDevice device); + + DAWN_NATIVE_EXPORT dawnSwapChainImplementation CreateNativeSwapChainImpl(dawnDevice device, + VkSurfaceKHR surface); + DAWN_NATIVE_EXPORT dawnTextureFormat + GetNativeSwapChainPreferredFormat(const dawnSwapChainImplementation* swapChain); +}} // namespace dawn_native::vulkan + +#endif // DAWNNATIVE_VULKANBACKEND_H_ diff --git a/src/include/dawn_native/dawn_native_export.h b/src/include/dawn_native/dawn_native_export.h new file mode 100644 index 0000000000..f28ff85fda --- /dev/null +++ b/src/include/dawn_native/dawn_native_export.h @@ -0,0 +1,32 @@ +// Copyright 2018 The Dawn Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef DAWNNATIVE_EXPORT_H_ +#define DAWNNATIVE_EXPORT_H_ + +#if defined(WIN32) +# if defined(DAWN_NATIVE_IMPLEMENTATION) +# define DAWN_NATIVE_EXPORT __declspec(dllexport) +# else +# define DAWN_NATIVE_EXPORT __declspec(dllimport) +# endif +#else +# if defined(DAWN_NATIVE_IMPLEMENTATION) +# define DAWN_NATIVE_EXPORT __attribute__((visibility("default"))) +# else +# define DAWN_NATIVE_EXPORT +# endif +#endif + +#endif // DAWNNATIVE_EXPORT_H_ diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index c7a726ee7b..27828e20c0 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -66,7 +66,7 @@ if (DAWN_ENABLE_D3D12) endif() add_executable(dawn_unittests ${UNITTEST_SOURCES}) -target_link_libraries(dawn_unittests dawn_common gtest libdawn_native mock_dawn dawn_wire utils) +target_link_libraries(dawn_unittests dawn_common gtest libdawn_native_static mock_dawn dawn_wire utils) DawnInternalTarget("tests" dawn_unittests) add_executable(dawn_end2end_tests diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt index 06d81dd0f6..2c1f2a7876 100644 --- a/src/utils/CMakeLists.txt +++ b/src/utils/CMakeLists.txt @@ -54,8 +54,7 @@ if (DAWN_ENABLE_VULKAN) endif() add_library(utils STATIC ${UTILS_SOURCES}) -target_link_libraries(utils libdawn_native shaderc_shared libdawn) -target_include_directories(utils PUBLIC ${SRC_DIR}) +target_link_libraries(utils libdawn_native shaderc_shared libdawn glfw) DawnInternalTarget("" utils) if(NOT MSVC) # allow C-style casts -- for shaderc diff --git a/src/utils/D3D12Binding.cpp b/src/utils/D3D12Binding.cpp index cfea7ab3b0..187446b71b 100644 --- a/src/utils/D3D12Binding.cpp +++ b/src/utils/D3D12Binding.cpp @@ -15,20 +15,12 @@ #include "utils/BackendBinding.h" #include "common/Assert.h" -#include "dawn/dawn_wsi.h" +#include "dawn_native/D3D12Backend.h" #include "GLFW/glfw3.h" #define GLFW_EXPOSE_NATIVE_WIN32 #include "GLFW/glfw3native.h" -namespace dawn_native { namespace d3d12 { - void Init(dawnProcTable* procs, dawnDevice* device); - - dawnSwapChainImplementation CreateNativeSwapChainImpl(dawnDevice device, HWND window); - dawnTextureFormat GetNativeSwapChainPreferredFormat( - const dawnSwapChainImplementation* swapChain); -}} // namespace dawn_native::d3d12 - namespace utils { class D3D12Binding : public BackendBinding { diff --git a/src/utils/MetalBinding.mm b/src/utils/MetalBinding.mm index a27c9c7e44..055c1a1121 100644 --- a/src/utils/MetalBinding.mm +++ b/src/utils/MetalBinding.mm @@ -16,21 +16,12 @@ #include "common/Assert.h" #include "common/SwapChainUtils.h" -#include "dawn/dawn_wsi.h" +#include "dawn_native/MetalBackend.h" #define GLFW_EXPOSE_NATIVE_COCOA #include "GLFW/glfw3.h" #include "GLFW/glfw3native.h" -#import -#import - -namespace dawn_native { namespace metal { - void Init(id metalDevice, dawnProcTable* procs, dawnDevice* device); - void SetNextDrawable(dawnDevice device, id drawable); - void Present(dawnDevice device); -}} - namespace utils { class SwapChainImplMTL { public: diff --git a/src/utils/NullBinding.cpp b/src/utils/NullBinding.cpp index 1b428f1dc2..0327f42550 100644 --- a/src/utils/NullBinding.cpp +++ b/src/utils/NullBinding.cpp @@ -14,9 +14,7 @@ #include "utils/BackendBinding.h" -namespace dawn_native { namespace null { - void Init(dawnProcTable* procs, dawnDevice* device); -}} // namespace dawn_native::null +#include "dawn_native/NullBackend.h" namespace utils { diff --git a/src/utils/OpenGLBinding.cpp b/src/utils/OpenGLBinding.cpp index 8cc1cbc436..71002cbca7 100644 --- a/src/utils/OpenGLBinding.cpp +++ b/src/utils/OpenGLBinding.cpp @@ -18,6 +18,7 @@ #include "common/Platform.h" #include "common/SwapChainUtils.h" #include "dawn/dawn_wsi.h" +#include "dawn_native/OpenGLBackend.h" // Glad needs to be included before GLFW otherwise it complain that GL.h was already included #include "glad/glad.h" @@ -25,10 +26,6 @@ #include #include "GLFW/glfw3.h" -namespace dawn_native { namespace opengl { - void Init(void* (*getProc)(const char*), dawnProcTable* procs, dawnDevice* device); -}} // namespace dawn_native::opengl - namespace utils { class SwapChainImplGL { public: diff --git a/src/utils/VulkanBinding.cpp b/src/utils/VulkanBinding.cpp index 1aece25740..48bbce2507 100644 --- a/src/utils/VulkanBinding.cpp +++ b/src/utils/VulkanBinding.cpp @@ -15,27 +15,11 @@ #include "utils/BackendBinding.h" #include "common/Assert.h" -#include "dawn/dawn_wsi.h" +#include "dawn_native/VulkanBackend.h" -#include - -// Include GLFW after Vulkan so that it declares the Vulkan-specific functions +// Include GLFW after VulkanBackend so that it declares the Vulkan-specific functions #include "GLFW/glfw3.h" -#include - -namespace dawn_native { namespace vulkan { - void Init(dawnProcTable* procs, - dawnDevice* device, - const std::vector& requiredInstanceExtensions); - - VkInstance GetInstance(dawnDevice device); - - dawnSwapChainImplementation CreateNativeSwapChainImpl(dawnDevice device, VkSurfaceKHR surface); - dawnTextureFormat GetNativeSwapChainPreferredFormat( - const dawnSwapChainImplementation* swapChain); -}} // namespace dawn_native::vulkan - namespace utils { class SwapChainImplVulkan { diff --git a/third_party/CMakeLists.txt b/third_party/CMakeLists.txt index 1eae71562d..31cf434286 100644 --- a/third_party/CMakeLists.txt +++ b/third_party/CMakeLists.txt @@ -36,7 +36,9 @@ add_library(glad STATIC ${CMAKE_CURRENT_SOURCE_DIR}/glad/include/glad/glad.h ${CMAKE_CURRENT_SOURCE_DIR}/glad/include/KHR/khrplatform.h ) -target_include_directories(glad SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/glad/include) +set(GLAD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/glad/include) +set(GLAD_INCLUDE_DIR ${GLAD_INCLUDE_DIR} PARENT_SCOPE) +target_include_directories(glad SYSTEM PUBLIC ${GLAD_INCLUDE_DIR}) DawnExternalTarget("third_party" glad) # ShaderC @@ -129,7 +131,7 @@ if (DAWN_ENABLE_OPENGL OR NEED_SPIRV_CROSS_GLSL) endif() add_library(spirv_cross STATIC ${SPIRV_CROSS_SOURCES}) -target_include_directories(spirv_cross SYSTEM PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) +set(SPIRV_CROSS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE) DawnExternalTarget("third_party" spirv_cross) # STB, used for stb_image @@ -138,5 +140,8 @@ set(STB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/stb PARENT_SCOPE) # glm matrix math library set(GLM_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/glm PARENT_SCOPE) +# Tiny glTF loader library +set(TINYGLTFLOADER_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE) + # Vulkan headers set(VULKAN_HEADERS_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)