This commit is contained in:
Бранимир Караџић 2020-05-08 19:57:18 -07:00
parent f77154d701
commit f13e5adf4b
2 changed files with 583 additions and 586 deletions

View File

@ -377,15 +377,15 @@ namespace bgfx { namespace webgpu
#if !BX_PLATFORM_EMSCRIPTEN
DawnSwapChainImplementation(*createSwapChain)(wgpu::Device device, void* nwh);
#ifdef DAWN_ENABLE_BACKEND_D3D12
# if defined(DAWN_ENABLE_BACKEND_D3D12)
DawnSwapChainImplementation CreateSwapChainD3D12(wgpu::Device device, void* nwh)
{
HWND win32Window = (HWND)nwh;
return dawn_native::d3d12::CreateNativeSwapChainImpl(device.Get(), win32Window);
}
#endif
# endif // defined(DAWN_ENABLE_BACKEND_D3D12)
#ifdef DAWN_ENABLE_BACKEND_VULKAN
# if defined(DAWN_ENABLE_BACKEND_VULKAN)
DawnSwapChainImplementation CreateSwapChainVulkan(wgpu::Device device, void* nwh)
{
VkInstance instance = dawn_native::vulkan::GetInstance(device.Get());
@ -393,7 +393,7 @@ namespace bgfx { namespace webgpu
PFN_vkCreateWin32SurfaceKHR vkCreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR)dawn_native::vulkan::GetInstanceProcAddr(device.Get(), "vkCreateWin32SurfaceKHR");
VkSurfaceKHR surface;
#if BX_PLATFORM_WINDOWS
# if BX_PLATFORM_WINDOWS
// Copied from renderer_vk.cpp -> needs refactor
{
VkWin32SurfaceCreateInfoKHR sci;
@ -404,12 +404,12 @@ namespace bgfx { namespace webgpu
sci.hwnd = (HWND)nwh;
VkResult result = vkCreateWin32SurfaceKHR(instance, &sci, NULL, &surface);
}
#endif
# endif // BX_PLATFORM_WINDOWS
return dawn_native::vulkan::CreateNativeSwapChainImpl(device.Get(), surface);
}
#endif
# endif // defined(DAWN_ENABLE_BACKEND_VULKAN)
#endif
#endif // !BX_PLATFORM_EMSCRIPTEN
struct RendererContextWgpu : public RendererContextI
{
@ -447,17 +447,17 @@ namespace bgfx { namespace webgpu
#if !BX_PLATFORM_EMSCRIPTEN
// Default to D3D12, Metal, Vulkan, OpenGL in that order as D3D12 and Metal are the preferred on
// their respective platforms, and Vulkan is preferred to OpenGL
#if defined(DAWN_ENABLE_BACKEND_D3D12)
# if defined(DAWN_ENABLE_BACKEND_D3D12)
static dawn_native::BackendType backendType = dawn_native::BackendType::D3D12;
#elif defined(DAWN_ENABLE_BACKEND_METAL)
# elif defined(DAWN_ENABLE_BACKEND_METAL)
static dawn_native::BackendType backendType = dawn_native::BackendType::Metal;
#elif defined(DAWN_ENABLE_BACKEND_OPENGL)
# elif defined(DAWN_ENABLE_BACKEND_OPENGL)
static dawn_native::BackendType backendType = dawn_native::BackendType::OpenGL;
#elif defined(DAWN_ENABLE_BACKEND_VULKAN)
# elif defined(DAWN_ENABLE_BACKEND_VULKAN)
static dawn_native::BackendType backendType = dawn_native::BackendType::Vulkan;
#else
#error
#endif
# else
# error "Unknown platform."
# endif // defined(DAWN_ENABLE_BACKEND_*)
if (BX_ENABLED(BGFX_CONFIG_DEBUG))
{
@ -484,17 +484,17 @@ namespace bgfx { namespace webgpu
using CreateSwapChain = DawnSwapChainImplementation (*)(wgpu::Device device, void* nwh);
#if defined(DAWN_ENABLE_BACKEND_D3D12)
# if defined(DAWN_ENABLE_BACKEND_D3D12)
createSwapChain = CreateSwapChainD3D12;
#elif defined(DAWN_ENABLE_BACKEND_METAL)
# elif defined(DAWN_ENABLE_BACKEND_METAL)
createSwapChain = CreateSwapChainMetal;
#elif defined(DAWN_ENABLE_BACKEND_NULL)
# elif defined(DAWN_ENABLE_BACKEND_NULL)
createSwapChain = CreateSwapChainNull;
#elif defined(DAWN_ENABLE_BACKEND_OPENGL)
# elif defined(DAWN_ENABLE_BACKEND_OPENGL)
createSwapChain = CreateSwapChainOpenGL;
#elif defined(DAWN_ENABLE_BACKEND_VULKAN)
# elif defined(DAWN_ENABLE_BACKEND_VULKAN)
createSwapChain = CreateSwapChainVulkan;
#endif
# endif // defined(DAWN_ENABLE_BACKEND_*)
// Choose whether to use the backend procs and devices directly, or set up the wire.
WGPUDevice cDevice = backendDevice;
@ -504,7 +504,7 @@ namespace bgfx { namespace webgpu
m_device = wgpu::Device::Acquire(cDevice);
#else
m_device = wgpu::Device(emscripten_webgpu_get_device());
#endif
#endif // !BX_PLATFORM_EMSCRIPTEN
auto PrintDeviceError = [](WGPUErrorType errorType, const char* message, void*) {
BX_UNUSED(errorType);
@ -517,6 +517,7 @@ namespace bgfx { namespace webgpu
{
BX_CHECK(false, "Device error: %s", message);
}
s_ignoreError = false;
};

View File

@ -35,10 +35,8 @@
#define WEBGPU_MAX_FRAMES_IN_FLIGHT 3
#define WEBGPU_NUM_UNIFORM_BUFFERS 8
namespace bgfx
namespace bgfx { namespace webgpu
{
namespace webgpu
{
template <typename Ty>
class StateCacheT
{
@ -562,9 +560,7 @@ namespace bgfx
bx::RingBufferControl m_control;
};
} // namespace webgpu
} // namespace bgfx
} /* namespace webgpu */ } // namespace bgfx
#endif // BGFX_CONFIG_RENDERER_WEBGPU