mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-16 09:37:03 +00:00
aurora: Working movie player (again)
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
#include <dawn/native/OpenGLBackend.h>
|
||||
#endif
|
||||
|
||||
namespace aurora::utils {
|
||||
namespace aurora::gpu::utils {
|
||||
|
||||
#if defined(DAWN_ENABLE_BACKEND_D3D12)
|
||||
BackendBinding* CreateD3D12Binding(SDL_Window* window, WGPUDevice device);
|
||||
@@ -76,4 +76,4 @@ BackendBinding* CreateBinding(wgpu::BackendType type, SDL_Window* window, WGPUDe
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace aurora::utils
|
||||
} // namespace aurora::gpu::utils
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
struct SDL_Window;
|
||||
|
||||
namespace aurora::utils {
|
||||
namespace aurora::gpu::utils {
|
||||
|
||||
class BackendBinding {
|
||||
public:
|
||||
@@ -24,4 +24,4 @@ protected:
|
||||
void DiscoverAdapter(dawn::native::Instance* instance, SDL_Window* window, wgpu::BackendType type);
|
||||
BackendBinding* CreateBinding(wgpu::BackendType type, SDL_Window* window, WGPUDevice device);
|
||||
|
||||
} // namespace aurora::utils
|
||||
} // namespace aurora::gpu::utils
|
||||
|
||||
@@ -24,7 +24,7 @@ template <typename T> DawnSwapChainImplementation CreateSwapChainImplementation(
|
||||
return impl;
|
||||
}
|
||||
|
||||
namespace aurora::utils {
|
||||
namespace aurora::gpu::utils {
|
||||
class SwapChainImplMTL {
|
||||
public:
|
||||
using WSIContext = DawnWSIContextMetal;
|
||||
@@ -105,4 +105,4 @@ private:
|
||||
};
|
||||
|
||||
BackendBinding *CreateMetalBinding(SDL_Window *window, WGPUDevice device) { return new MetalBinding(window, device); }
|
||||
} // namespace aurora::utils
|
||||
} // namespace aurora::gpu::utils
|
||||
|
||||
@@ -3,26 +3,33 @@
|
||||
#include <SDL_video.h>
|
||||
#include <dawn/native/OpenGLBackend.h>
|
||||
|
||||
namespace aurora::utils {
|
||||
namespace aurora::gpu::utils {
|
||||
class OpenGLBinding : public BackendBinding {
|
||||
public:
|
||||
OpenGLBinding(SDL_Window* window, WGPUDevice device) : BackendBinding(window, device) {}
|
||||
|
||||
uint64_t GetSwapChainImplementation() override {
|
||||
if (m_swapChainImpl.userData == nullptr) {
|
||||
m_swapChainImpl = dawn::native::opengl::CreateNativeSwapChainImpl(
|
||||
m_device, [](void* userdata) { SDL_GL_SwapWindow(static_cast<SDL_Window*>(userdata)); }, m_window);
|
||||
CreateSwapChainImpl();
|
||||
}
|
||||
return reinterpret_cast<uint64_t>(&m_swapChainImpl);
|
||||
}
|
||||
|
||||
WGPUTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||
if (m_swapChainImpl.userData == nullptr) {
|
||||
CreateSwapChainImpl();
|
||||
}
|
||||
return dawn::native::opengl::GetNativeSwapChainPreferredFormat(&m_swapChainImpl);
|
||||
}
|
||||
|
||||
private:
|
||||
DawnSwapChainImplementation m_swapChainImpl{};
|
||||
|
||||
void CreateSwapChainImpl() {
|
||||
m_swapChainImpl = dawn::native::opengl::CreateNativeSwapChainImpl(
|
||||
m_device, [](void* userdata) { SDL_GL_SwapWindow(static_cast<SDL_Window*>(userdata)); }, m_window);
|
||||
}
|
||||
};
|
||||
|
||||
BackendBinding* CreateOpenGLBinding(SDL_Window* window, WGPUDevice device) { return new OpenGLBinding(window, device); }
|
||||
} // namespace aurora::utils
|
||||
} // namespace aurora::gpu::utils
|
||||
|
||||
@@ -4,30 +4,36 @@
|
||||
#include <cassert>
|
||||
#include <dawn/native/VulkanBackend.h>
|
||||
|
||||
namespace aurora::utils {
|
||||
namespace aurora::gpu::utils {
|
||||
class VulkanBinding : public BackendBinding {
|
||||
public:
|
||||
VulkanBinding(SDL_Window* window, WGPUDevice device) : BackendBinding(window, device) {}
|
||||
|
||||
uint64_t GetSwapChainImplementation() override {
|
||||
if (m_swapChainImpl.userData == nullptr) {
|
||||
VkSurfaceKHR surface = VK_NULL_HANDLE;
|
||||
if (SDL_Vulkan_CreateSurface(m_window, dawn::native::vulkan::GetInstance(m_device), &surface) != SDL_TRUE) {
|
||||
assert(false);
|
||||
}
|
||||
m_swapChainImpl = dawn::native::vulkan::CreateNativeSwapChainImpl(m_device, surface);
|
||||
CreateSwapChainImpl();
|
||||
}
|
||||
return reinterpret_cast<uint64_t>(&m_swapChainImpl);
|
||||
}
|
||||
|
||||
WGPUTextureFormat GetPreferredSwapChainTextureFormat() override {
|
||||
assert(m_swapChainImpl.userData != nullptr);
|
||||
if (m_swapChainImpl.userData == nullptr) {
|
||||
CreateSwapChainImpl();
|
||||
}
|
||||
return dawn::native::vulkan::GetNativeSwapChainPreferredFormat(&m_swapChainImpl);
|
||||
}
|
||||
|
||||
private:
|
||||
DawnSwapChainImplementation m_swapChainImpl{};
|
||||
|
||||
void CreateSwapChainImpl() {
|
||||
VkSurfaceKHR surface = VK_NULL_HANDLE;
|
||||
if (SDL_Vulkan_CreateSurface(m_window, dawn::native::vulkan::GetInstance(m_device), &surface) != SDL_TRUE) {
|
||||
assert(false);
|
||||
}
|
||||
m_swapChainImpl = dawn::native::vulkan::CreateNativeSwapChainImpl(m_device, surface);
|
||||
}
|
||||
};
|
||||
|
||||
BackendBinding* CreateVulkanBinding(SDL_Window* window, WGPUDevice device) { return new VulkanBinding(window, device); }
|
||||
} // namespace aurora::utils
|
||||
} // namespace aurora::gpu::utils
|
||||
|
||||
Reference in New Issue
Block a user