mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-13 16:45:56 +00:00
Rename nxt -> dawn for dawn_wsi.h declarations
Also does the initial complete formatting of files in src/include
This commit is contained in:
parent
3e371b146d
commit
05c90ee4cb
@ -83,7 +83,7 @@ namespace backend {
|
|||||||
mImplementation.Present(mImplementation.userData);
|
mImplementation.Present(mImplementation.userData);
|
||||||
}
|
}
|
||||||
|
|
||||||
const nxtSwapChainImplementation& SwapChainBase::GetImplementation() {
|
const dawnSwapChainImplementation& SwapChainBase::GetImplementation() {
|
||||||
return mImplementation;
|
return mImplementation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,8 +106,8 @@ namespace backend {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainImplementation& impl =
|
dawnSwapChainImplementation& impl =
|
||||||
*reinterpret_cast<nxtSwapChainImplementation*>(implementation);
|
*reinterpret_cast<dawnSwapChainImplementation*>(implementation);
|
||||||
|
|
||||||
if (!impl.Init || !impl.Destroy || !impl.Configure || !impl.GetNextTexture ||
|
if (!impl.Init || !impl.Destroy || !impl.Configure || !impl.GetNextTexture ||
|
||||||
!impl.Present) {
|
!impl.Present) {
|
||||||
|
@ -19,8 +19,8 @@
|
|||||||
#include "backend/Forward.h"
|
#include "backend/Forward.h"
|
||||||
#include "backend/RefCounted.h"
|
#include "backend/RefCounted.h"
|
||||||
|
|
||||||
#include "dawn/dawncpp.h"
|
|
||||||
#include "dawn/dawn_wsi.h"
|
#include "dawn/dawn_wsi.h"
|
||||||
|
#include "dawn/dawncpp.h"
|
||||||
|
|
||||||
namespace backend {
|
namespace backend {
|
||||||
|
|
||||||
@ -40,13 +40,13 @@ namespace backend {
|
|||||||
void Present(TextureBase* texture);
|
void Present(TextureBase* texture);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const nxtSwapChainImplementation& GetImplementation();
|
const dawnSwapChainImplementation& GetImplementation();
|
||||||
virtual TextureBase* GetNextTextureImpl(TextureBuilder* builder) = 0;
|
virtual TextureBase* GetNextTextureImpl(TextureBuilder* builder) = 0;
|
||||||
virtual void OnBeforePresent(TextureBase* texture) = 0;
|
virtual void OnBeforePresent(TextureBase* texture) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DeviceBase* mDevice = nullptr;
|
DeviceBase* mDevice = nullptr;
|
||||||
nxtSwapChainImplementation mImplementation = {};
|
dawnSwapChainImplementation mImplementation = {};
|
||||||
dawn::TextureFormat mFormat = {};
|
dawn::TextureFormat mFormat = {};
|
||||||
dawn::TextureUsageBit mAllowedUsage;
|
dawn::TextureUsageBit mAllowedUsage;
|
||||||
uint32_t mWidth = 0;
|
uint32_t mWidth = 0;
|
||||||
@ -65,7 +65,7 @@ namespace backend {
|
|||||||
private:
|
private:
|
||||||
friend class SwapChainBase;
|
friend class SwapChainBase;
|
||||||
|
|
||||||
nxtSwapChainImplementation mImplementation = {};
|
dawnSwapChainImplementation mImplementation = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace backend
|
} // namespace backend
|
||||||
|
@ -49,10 +49,10 @@ namespace backend { namespace d3d12 {
|
|||||||
*device = reinterpret_cast<nxtDevice>(new Device());
|
*device = reinterpret_cast<nxtDevice>(new Device());
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, HWND window) {
|
dawnSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, HWND window) {
|
||||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||||
|
|
||||||
nxtSwapChainImplementation impl;
|
dawnSwapChainImplementation impl;
|
||||||
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, window));
|
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, window));
|
||||||
impl.textureUsage = NXT_TEXTURE_USAGE_BIT_PRESENT;
|
impl.textureUsage = NXT_TEXTURE_USAGE_BIT_PRESENT;
|
||||||
|
|
||||||
@ -60,7 +60,7 @@ namespace backend { namespace d3d12 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nxtTextureFormat GetNativeSwapChainPreferredFormat(
|
nxtTextureFormat GetNativeSwapChainPreferredFormat(
|
||||||
const nxtSwapChainImplementation* swapChain) {
|
const dawnSwapChainImplementation* swapChain) {
|
||||||
NativeSwapChainImpl* impl = reinterpret_cast<NativeSwapChainImpl*>(swapChain->userData);
|
NativeSwapChainImpl* impl = reinterpret_cast<NativeSwapChainImpl*>(swapChain->userData);
|
||||||
return static_cast<nxtTextureFormat>(impl->GetPreferredFormat());
|
return static_cast<nxtTextureFormat>(impl->GetPreferredFormat());
|
||||||
}
|
}
|
||||||
|
@ -45,13 +45,13 @@ namespace backend { namespace d3d12 {
|
|||||||
NativeSwapChainImpl::~NativeSwapChainImpl() {
|
NativeSwapChainImpl::~NativeSwapChainImpl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeSwapChainImpl::Init(nxtWSIContextD3D12* /*context*/) {
|
void NativeSwapChainImpl::Init(dawnWSIContextD3D12* /*context*/) {
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError NativeSwapChainImpl::Configure(nxtTextureFormat format,
|
dawnSwapChainError NativeSwapChainImpl::Configure(nxtTextureFormat format,
|
||||||
nxtTextureUsageBit usage,
|
nxtTextureUsageBit usage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
ASSERT(width > 0);
|
ASSERT(width > 0);
|
||||||
ASSERT(height > 0);
|
ASSERT(height > 0);
|
||||||
ASSERT(format == static_cast<nxtTextureFormat>(GetPreferredFormat()));
|
ASSERT(format == static_cast<nxtTextureFormat>(GetPreferredFormat()));
|
||||||
@ -86,10 +86,10 @@ namespace backend { namespace d3d12 {
|
|||||||
// used
|
// used
|
||||||
mBufferSerials.resize(kFrameCount, 0);
|
mBufferSerials.resize(kFrameCount, 0);
|
||||||
|
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError NativeSwapChainImpl::GetNextTexture(nxtSwapChainNextTexture* nextTexture) {
|
dawnSwapChainError NativeSwapChainImpl::GetNextTexture(dawnSwapChainNextTexture* nextTexture) {
|
||||||
mCurrentBuffer = mSwapChain->GetCurrentBackBufferIndex();
|
mCurrentBuffer = mSwapChain->GetCurrentBackBufferIndex();
|
||||||
nextTexture->texture.ptr = mBuffers[mCurrentBuffer].Get();
|
nextTexture->texture.ptr = mBuffers[mCurrentBuffer].Get();
|
||||||
|
|
||||||
@ -97,10 +97,10 @@ namespace backend { namespace d3d12 {
|
|||||||
// with the buffer. Ideally the synchronization should be all done on the GPU.
|
// with the buffer. Ideally the synchronization should be all done on the GPU.
|
||||||
mDevice->WaitForSerial(mBufferSerials[mCurrentBuffer]);
|
mDevice->WaitForSerial(mBufferSerials[mCurrentBuffer]);
|
||||||
|
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError NativeSwapChainImpl::Present() {
|
dawnSwapChainError NativeSwapChainImpl::Present() {
|
||||||
// This assumes the texture has already been transition to the PRESENT state.
|
// This assumes the texture has already been transition to the PRESENT state.
|
||||||
|
|
||||||
ASSERT_SUCCESS(mSwapChain->Present(1, 0));
|
ASSERT_SUCCESS(mSwapChain->Present(1, 0));
|
||||||
@ -108,7 +108,7 @@ namespace backend { namespace d3d12 {
|
|||||||
mDevice->NextSerial();
|
mDevice->NextSerial();
|
||||||
|
|
||||||
mBufferSerials[mCurrentBuffer] = mDevice->GetSerial();
|
mBufferSerials[mCurrentBuffer] = mDevice->GetSerial();
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
|
dawn::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
#include "backend/d3d12/d3d12_platform.h"
|
#include "backend/d3d12/d3d12_platform.h"
|
||||||
|
|
||||||
#include "dawn/dawncpp.h"
|
|
||||||
#include "dawn/dawn_wsi.h"
|
#include "dawn/dawn_wsi.h"
|
||||||
|
#include "dawn/dawncpp.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@ -28,18 +28,18 @@ namespace backend { namespace d3d12 {
|
|||||||
|
|
||||||
class NativeSwapChainImpl {
|
class NativeSwapChainImpl {
|
||||||
public:
|
public:
|
||||||
using WSIContext = nxtWSIContextD3D12;
|
using WSIContext = dawnWSIContextD3D12;
|
||||||
|
|
||||||
NativeSwapChainImpl(Device* device, HWND window);
|
NativeSwapChainImpl(Device* device, HWND window);
|
||||||
~NativeSwapChainImpl();
|
~NativeSwapChainImpl();
|
||||||
|
|
||||||
void Init(nxtWSIContextD3D12* context);
|
void Init(dawnWSIContextD3D12* context);
|
||||||
nxtSwapChainError Configure(nxtTextureFormat format,
|
dawnSwapChainError Configure(nxtTextureFormat format,
|
||||||
nxtTextureUsageBit,
|
nxtTextureUsageBit,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height);
|
uint32_t height);
|
||||||
nxtSwapChainError GetNextTexture(nxtSwapChainNextTexture* nextTexture);
|
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture);
|
||||||
nxtSwapChainError Present();
|
dawnSwapChainError Present();
|
||||||
|
|
||||||
dawn::TextureFormat GetPreferredFormat() const;
|
dawn::TextureFormat GetPreferredFormat() const;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace backend { namespace d3d12 {
|
|||||||
|
|
||||||
SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
|
SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
|
||||||
const auto& im = GetImplementation();
|
const auto& im = GetImplementation();
|
||||||
nxtWSIContextD3D12 wsiContext = {};
|
dawnWSIContextD3D12 wsiContext = {};
|
||||||
wsiContext.device = reinterpret_cast<nxtDevice>(GetDevice());
|
wsiContext.device = reinterpret_cast<nxtDevice>(GetDevice());
|
||||||
im.Init(im.userData, &wsiContext);
|
im.Init(im.userData, &wsiContext);
|
||||||
|
|
||||||
@ -36,8 +36,8 @@ namespace backend { namespace d3d12 {
|
|||||||
|
|
||||||
TextureBase* SwapChain::GetNextTextureImpl(TextureBuilder* builder) {
|
TextureBase* SwapChain::GetNextTextureImpl(TextureBuilder* builder) {
|
||||||
const auto& im = GetImplementation();
|
const auto& im = GetImplementation();
|
||||||
nxtSwapChainNextTexture next = {};
|
dawnSwapChainNextTexture next = {};
|
||||||
nxtSwapChainError error = im.GetNextTexture(im.userData, &next);
|
dawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||||
if (error) {
|
if (error) {
|
||||||
GetDevice()->HandleError(error);
|
GetDevice()->HandleError(error);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -23,7 +23,7 @@ namespace backend { namespace metal {
|
|||||||
|
|
||||||
SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
|
SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
|
||||||
const auto& im = GetImplementation();
|
const auto& im = GetImplementation();
|
||||||
nxtWSIContextMetal wsiContext = {};
|
dawnWSIContextMetal wsiContext = {};
|
||||||
wsiContext.device = ToBackend(GetDevice())->GetMTLDevice();
|
wsiContext.device = ToBackend(GetDevice())->GetMTLDevice();
|
||||||
im.Init(im.userData, &wsiContext);
|
im.Init(im.userData, &wsiContext);
|
||||||
}
|
}
|
||||||
@ -33,8 +33,8 @@ namespace backend { namespace metal {
|
|||||||
|
|
||||||
TextureBase* SwapChain::GetNextTextureImpl(TextureBuilder* builder) {
|
TextureBase* SwapChain::GetNextTextureImpl(TextureBuilder* builder) {
|
||||||
const auto& im = GetImplementation();
|
const auto& im = GetImplementation();
|
||||||
nxtSwapChainNextTexture next = {};
|
dawnSwapChainNextTexture next = {};
|
||||||
nxtSwapChainError error = im.GetNextTexture(im.userData, &next);
|
dawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||||
if (error) {
|
if (error) {
|
||||||
GetDevice()->HandleError(error);
|
GetDevice()->HandleError(error);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -31,8 +31,8 @@ namespace backend { namespace opengl {
|
|||||||
|
|
||||||
TextureBase* SwapChain::GetNextTextureImpl(TextureBuilder* builder) {
|
TextureBase* SwapChain::GetNextTextureImpl(TextureBuilder* builder) {
|
||||||
const auto& im = GetImplementation();
|
const auto& im = GetImplementation();
|
||||||
nxtSwapChainNextTexture next = {};
|
dawnSwapChainNextTexture next = {};
|
||||||
nxtSwapChainError error = im.GetNextTexture(im.userData, &next);
|
dawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||||
if (error) {
|
if (error) {
|
||||||
GetDevice()->HandleError(error);
|
GetDevice()->HandleError(error);
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -67,10 +67,10 @@ namespace backend { namespace vulkan {
|
|||||||
return backendDevice->GetInstance();
|
return backendDevice->GetInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, VkSurfaceKHR surface) {
|
dawnSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, VkSurfaceKHR surface) {
|
||||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||||
|
|
||||||
nxtSwapChainImplementation impl;
|
dawnSwapChainImplementation impl;
|
||||||
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, surface));
|
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, surface));
|
||||||
impl.textureUsage = NXT_TEXTURE_USAGE_BIT_PRESENT;
|
impl.textureUsage = NXT_TEXTURE_USAGE_BIT_PRESENT;
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ namespace backend { namespace vulkan {
|
|||||||
}
|
}
|
||||||
|
|
||||||
nxtTextureFormat GetNativeSwapChainPreferredFormat(
|
nxtTextureFormat GetNativeSwapChainPreferredFormat(
|
||||||
const nxtSwapChainImplementation* swapChain) {
|
const dawnSwapChainImplementation* swapChain) {
|
||||||
NativeSwapChainImpl* impl = reinterpret_cast<NativeSwapChainImpl*>(swapChain->userData);
|
NativeSwapChainImpl* impl = reinterpret_cast<NativeSwapChainImpl*>(swapChain->userData);
|
||||||
return static_cast<nxtTextureFormat>(impl->GetPreferredFormat());
|
return static_cast<nxtTextureFormat>(impl->GetPreferredFormat());
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ namespace backend { namespace vulkan {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeSwapChainImpl::Init(nxtWSIContextVulkan* /*context*/) {
|
void NativeSwapChainImpl::Init(dawnWSIContextVulkan* /*context*/) {
|
||||||
if (!GatherSurfaceInfo(*mDevice, mSurface, &mInfo)) {
|
if (!GatherSurfaceInfo(*mDevice, mSurface, &mInfo)) {
|
||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
}
|
}
|
||||||
@ -67,10 +67,10 @@ namespace backend { namespace vulkan {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError NativeSwapChainImpl::Configure(nxtTextureFormat format,
|
dawnSwapChainError NativeSwapChainImpl::Configure(nxtTextureFormat format,
|
||||||
nxtTextureUsageBit usage,
|
nxtTextureUsageBit usage,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
ASSERT(mInfo.capabilities.minImageExtent.width <= width);
|
ASSERT(mInfo.capabilities.minImageExtent.width <= width);
|
||||||
ASSERT(mInfo.capabilities.maxImageExtent.width >= width);
|
ASSERT(mInfo.capabilities.maxImageExtent.width >= width);
|
||||||
ASSERT(mInfo.capabilities.minImageExtent.height <= height);
|
ASSERT(mInfo.capabilities.minImageExtent.height <= height);
|
||||||
@ -147,10 +147,10 @@ namespace backend { namespace vulkan {
|
|||||||
nullptr, 1, &barrier);
|
nullptr, 1, &barrier);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError NativeSwapChainImpl::GetNextTexture(nxtSwapChainNextTexture* nextTexture) {
|
dawnSwapChainError NativeSwapChainImpl::GetNextTexture(dawnSwapChainNextTexture* nextTexture) {
|
||||||
// Transiently create a semaphore that will be signaled when the presentation engine is done
|
// Transiently create a semaphore that will be signaled when the presentation engine is done
|
||||||
// with the swapchain image. Further operations on the image will wait for this semaphore.
|
// with the swapchain image. Further operations on the image will wait for this semaphore.
|
||||||
VkSemaphore semaphore = VK_NULL_HANDLE;
|
VkSemaphore semaphore = VK_NULL_HANDLE;
|
||||||
@ -174,10 +174,10 @@ namespace backend { namespace vulkan {
|
|||||||
nextTexture->texture.u64 = mSwapChainImages[mLastImageIndex].GetHandle();
|
nextTexture->texture.u64 = mSwapChainImages[mLastImageIndex].GetHandle();
|
||||||
mDevice->AddWaitSemaphore(semaphore);
|
mDevice->AddWaitSemaphore(semaphore);
|
||||||
|
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError NativeSwapChainImpl::Present() {
|
dawnSwapChainError NativeSwapChainImpl::Present() {
|
||||||
// This assumes that the image has already been transitioned to the PRESENT layout and
|
// This assumes that the image has already been transitioned to the PRESENT layout and
|
||||||
// writes were made available to the stage.
|
// writes were made available to the stage.
|
||||||
|
|
||||||
@ -199,7 +199,7 @@ namespace backend { namespace vulkan {
|
|||||||
ASSERT(false);
|
ASSERT(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
dawn::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
|
dawn::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
#include "backend/vulkan/VulkanInfo.h"
|
#include "backend/vulkan/VulkanInfo.h"
|
||||||
|
|
||||||
#include "dawn/dawncpp.h"
|
|
||||||
#include "dawn/dawn_wsi.h"
|
#include "dawn/dawn_wsi.h"
|
||||||
|
#include "dawn/dawncpp.h"
|
||||||
|
|
||||||
namespace backend { namespace vulkan {
|
namespace backend { namespace vulkan {
|
||||||
|
|
||||||
@ -26,18 +26,18 @@ namespace backend { namespace vulkan {
|
|||||||
|
|
||||||
class NativeSwapChainImpl {
|
class NativeSwapChainImpl {
|
||||||
public:
|
public:
|
||||||
using WSIContext = nxtWSIContextVulkan;
|
using WSIContext = dawnWSIContextVulkan;
|
||||||
|
|
||||||
NativeSwapChainImpl(Device* device, VkSurfaceKHR surface);
|
NativeSwapChainImpl(Device* device, VkSurfaceKHR surface);
|
||||||
~NativeSwapChainImpl();
|
~NativeSwapChainImpl();
|
||||||
|
|
||||||
void Init(nxtWSIContextVulkan* context);
|
void Init(dawnWSIContextVulkan* context);
|
||||||
nxtSwapChainError Configure(nxtTextureFormat format,
|
dawnSwapChainError Configure(nxtTextureFormat format,
|
||||||
nxtTextureUsageBit,
|
nxtTextureUsageBit,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height);
|
uint32_t height);
|
||||||
nxtSwapChainError GetNextTexture(nxtSwapChainNextTexture* nextTexture);
|
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture);
|
||||||
nxtSwapChainError Present();
|
dawnSwapChainError Present();
|
||||||
|
|
||||||
dawn::TextureFormat GetPreferredFormat() const;
|
dawn::TextureFormat GetPreferredFormat() const;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ namespace backend { namespace vulkan {
|
|||||||
|
|
||||||
SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
|
SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
|
||||||
const auto& im = GetImplementation();
|
const auto& im = GetImplementation();
|
||||||
nxtWSIContextVulkan wsiContext = {};
|
dawnWSIContextVulkan wsiContext = {};
|
||||||
im.Init(im.userData, &wsiContext);
|
im.Init(im.userData, &wsiContext);
|
||||||
|
|
||||||
ASSERT(im.textureUsage != NXT_TEXTURE_USAGE_BIT_NONE);
|
ASSERT(im.textureUsage != NXT_TEXTURE_USAGE_BIT_NONE);
|
||||||
@ -33,8 +33,8 @@ namespace backend { namespace vulkan {
|
|||||||
|
|
||||||
TextureBase* SwapChain::GetNextTextureImpl(TextureBuilder* builder) {
|
TextureBase* SwapChain::GetNextTextureImpl(TextureBuilder* builder) {
|
||||||
const auto& im = GetImplementation();
|
const auto& im = GetImplementation();
|
||||||
nxtSwapChainNextTexture next = {};
|
dawnSwapChainNextTexture next = {};
|
||||||
nxtSwapChainError error = im.GetNextTexture(im.userData, &next);
|
dawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
GetDevice()->HandleError(error);
|
GetDevice()->HandleError(error);
|
||||||
|
@ -16,8 +16,8 @@
|
|||||||
#define COMMON_SWAPCHAINUTILS_H_
|
#define COMMON_SWAPCHAINUTILS_H_
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
nxtSwapChainImplementation CreateSwapChainImplementation(T* swapChain) {
|
dawnSwapChainImplementation CreateSwapChainImplementation(T* swapChain) {
|
||||||
nxtSwapChainImplementation impl = {};
|
dawnSwapChainImplementation impl = {};
|
||||||
impl.userData = swapChain;
|
impl.userData = swapChain;
|
||||||
impl.Init = [](void* userData, void* wsiContext) {
|
impl.Init = [](void* userData, void* wsiContext) {
|
||||||
auto* ctx = reinterpret_cast<typename T::WSIContext*>(wsiContext);
|
auto* ctx = reinterpret_cast<typename T::WSIContext*>(wsiContext);
|
||||||
@ -28,7 +28,7 @@ nxtSwapChainImplementation CreateSwapChainImplementation(T* swapChain) {
|
|||||||
uint32_t width, uint32_t height) {
|
uint32_t width, uint32_t height) {
|
||||||
return reinterpret_cast<T*>(userData)->Configure(format, allowedUsage, width, height);
|
return reinterpret_cast<T*>(userData)->Configure(format, allowedUsage, width, height);
|
||||||
};
|
};
|
||||||
impl.GetNextTexture = [](void* userData, nxtSwapChainNextTexture* nextTexture) {
|
impl.GetNextTexture = [](void* userData, dawnSwapChainNextTexture* nextTexture) {
|
||||||
return reinterpret_cast<T*>(userData)->GetNextTexture(nextTexture);
|
return reinterpret_cast<T*>(userData)->GetNextTexture(nextTexture);
|
||||||
};
|
};
|
||||||
impl.Present = [](void* userData) { return reinterpret_cast<T*>(userData)->Present(); };
|
impl.Present = [](void* userData) { return reinterpret_cast<T*>(userData)->Present(); };
|
||||||
|
@ -23,33 +23,32 @@ namespace nxt {
|
|||||||
#define CR_GLIBCXX_4_7_0 20120322
|
#define CR_GLIBCXX_4_7_0 20120322
|
||||||
#define CR_GLIBCXX_4_5_4 20120702
|
#define CR_GLIBCXX_4_5_4 20120702
|
||||||
#define CR_GLIBCXX_4_6_4 20121127
|
#define CR_GLIBCXX_4_6_4 20121127
|
||||||
#if defined(__GLIBCXX__) && \
|
#if defined(__GLIBCXX__) && (__GLIBCXX__ < CR_GLIBCXX_4_7_0 || __GLIBCXX__ == CR_GLIBCXX_4_5_4 || \
|
||||||
(__GLIBCXX__ < CR_GLIBCXX_4_7_0 || __GLIBCXX__ == CR_GLIBCXX_4_5_4 || \
|
__GLIBCXX__ == CR_GLIBCXX_4_6_4)
|
||||||
__GLIBCXX__ == CR_GLIBCXX_4_6_4)
|
# define CR_USE_FALLBACKS_FOR_OLD_GLIBCXX
|
||||||
#define CR_USE_FALLBACKS_FOR_OLD_GLIBCXX
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CR_USE_FALLBACKS_FOR_OLD_GLIBCXX)
|
#if defined(CR_USE_FALLBACKS_FOR_OLD_GLIBCXX)
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct UnderlyingType {
|
struct UnderlyingType {
|
||||||
using type = __underlying_type(T);
|
using type = __underlying_type(T);
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
template <typename T>
|
template <typename T>
|
||||||
using UnderlyingType = std::underlying_type<T>;
|
using UnderlyingType = std::underlying_type<T>;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
struct IsNXTBitmask {
|
struct IsNXTBitmask {
|
||||||
static constexpr bool enable = false;
|
static constexpr bool enable = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T, typename Enable = void>
|
template <typename T, typename Enable = void>
|
||||||
struct LowerBitmask {
|
struct LowerBitmask {
|
||||||
static constexpr bool enable = false;
|
static constexpr bool enable = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
struct LowerBitmask<T, typename std::enable_if<IsNXTBitmask<T>::enable>::type> {
|
struct LowerBitmask<T, typename std::enable_if<IsNXTBitmask<T>::enable>::type> {
|
||||||
static constexpr bool enable = true;
|
static constexpr bool enable = true;
|
||||||
using type = T;
|
using type = T;
|
||||||
@ -58,7 +57,7 @@ namespace nxt {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
struct BoolConvertible {
|
struct BoolConvertible {
|
||||||
using Integral = typename UnderlyingType<T>::type;
|
using Integral = typename UnderlyingType<T>::type;
|
||||||
|
|
||||||
@ -74,7 +73,7 @@ namespace nxt {
|
|||||||
Integral value;
|
Integral value;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
struct LowerBitmask<BoolConvertible<T>> {
|
struct LowerBitmask<BoolConvertible<T>> {
|
||||||
static constexpr bool enable = true;
|
static constexpr bool enable = true;
|
||||||
using type = T;
|
using type = T;
|
||||||
@ -83,44 +82,47 @@ namespace nxt {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename T>
|
template <typename T>
|
||||||
constexpr bool HasZeroOrOneBits(T value) {
|
constexpr bool HasZeroOrOneBits(T value) {
|
||||||
using Integral = typename UnderlyingType<T>::type;
|
using Integral = typename UnderlyingType<T>::type;
|
||||||
return (static_cast<Integral>(value) & (static_cast<Integral>(value) - 1)) == 0;
|
return (static_cast<Integral>(value) & (static_cast<Integral>(value) - 1)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T1, typename T2, typename = typename std::enable_if<
|
template <typename T1,
|
||||||
LowerBitmask<T1>::enable && LowerBitmask<T2>::enable
|
typename T2,
|
||||||
>::type>
|
typename = typename std::enable_if<LowerBitmask<T1>::enable &&
|
||||||
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator | (T1 left, T2 right) {
|
LowerBitmask<T2>::enable>::type>
|
||||||
|
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator|(T1 left, T2 right) {
|
||||||
using T = typename LowerBitmask<T1>::type;
|
using T = typename LowerBitmask<T1>::type;
|
||||||
using Integral = typename UnderlyingType<T>::type;
|
using Integral = typename UnderlyingType<T>::type;
|
||||||
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) |
|
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) |
|
||||||
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
|
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T1, typename T2, typename = typename std::enable_if<
|
template <typename T1,
|
||||||
LowerBitmask<T1>::enable && LowerBitmask<T2>::enable
|
typename T2,
|
||||||
>::type>
|
typename = typename std::enable_if<LowerBitmask<T1>::enable &&
|
||||||
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator & (T1 left, T2 right) {
|
LowerBitmask<T2>::enable>::type>
|
||||||
|
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator&(T1 left, T2 right) {
|
||||||
using T = typename LowerBitmask<T1>::type;
|
using T = typename LowerBitmask<T1>::type;
|
||||||
using Integral = typename UnderlyingType<T>::type;
|
using Integral = typename UnderlyingType<T>::type;
|
||||||
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) &
|
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) &
|
||||||
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
|
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T1, typename T2, typename = typename std::enable_if<
|
template <typename T1,
|
||||||
LowerBitmask<T1>::enable && LowerBitmask<T2>::enable
|
typename T2,
|
||||||
>::type>
|
typename = typename std::enable_if<LowerBitmask<T1>::enable &&
|
||||||
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator ^ (T1 left, T2 right) {
|
LowerBitmask<T2>::enable>::type>
|
||||||
|
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator^(T1 left, T2 right) {
|
||||||
using T = typename LowerBitmask<T1>::type;
|
using T = typename LowerBitmask<T1>::type;
|
||||||
using Integral = typename UnderlyingType<T>::type;
|
using Integral = typename UnderlyingType<T>::type;
|
||||||
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) ^
|
return static_cast<Integral>(LowerBitmask<T1>::Lower(left)) ^
|
||||||
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
|
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T1>
|
template <typename T1>
|
||||||
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator ~ (T1 t) {
|
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator~(T1 t) {
|
||||||
using T = typename LowerBitmask<T1>::type;
|
using T = typename LowerBitmask<T1>::type;
|
||||||
using Integral = typename UnderlyingType<T>::type;
|
using Integral = typename UnderlyingType<T>::type;
|
||||||
return ~static_cast<Integral>(LowerBitmask<T1>::Lower(t));
|
return ~static_cast<Integral>(LowerBitmask<T1>::Lower(t));
|
||||||
@ -155,6 +157,6 @@ namespace nxt {
|
|||||||
l = l ^ r;
|
l = l ^ r;
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
}
|
} // namespace nxt
|
||||||
|
|
||||||
#endif // NXT_ENUM_CLASS_BITMASKS_H_
|
#endif // NXT_ENUM_CLASS_BITMASKS_H_
|
||||||
|
@ -12,14 +12,14 @@
|
|||||||
//* See the License for the specific language governing permissions and
|
//* See the License for the specific language governing permissions and
|
||||||
//* limitations under the License.
|
//* limitations under the License.
|
||||||
|
|
||||||
#ifndef NXT_WSI_H
|
#ifndef DAWN_WSI_H
|
||||||
#define NXT_WSI_H
|
#define DAWN_WSI_H
|
||||||
|
|
||||||
#include <dawn/dawn.h>
|
#include <dawn/dawn.h>
|
||||||
|
|
||||||
// Error message (or nullptr if there was no error)
|
// Error message (or nullptr if there was no error)
|
||||||
typedef const char* nxtSwapChainError;
|
typedef const char* dawnSwapChainError;
|
||||||
constexpr nxtSwapChainError NXT_SWAP_CHAIN_NO_ERROR = nullptr;
|
constexpr dawnSwapChainError DAWN_SWAP_CHAIN_NO_ERROR = nullptr;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/// Backend-specific texture id/name/pointer
|
/// Backend-specific texture id/name/pointer
|
||||||
@ -28,54 +28,58 @@ typedef struct {
|
|||||||
uint64_t u64;
|
uint64_t u64;
|
||||||
uint32_t u32;
|
uint32_t u32;
|
||||||
} texture;
|
} texture;
|
||||||
} nxtSwapChainNextTexture;
|
} dawnSwapChainNextTexture;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/// Initialize the swap chain implementation.
|
/// Initialize the swap chain implementation.
|
||||||
/// (*wsiContext) is one of nxtWSIContext{D3D12,Metal,GL}
|
/// (*wsiContext) is one of dawnWSIContext{D3D12,Metal,GL}
|
||||||
void (*Init)(void* userData, void* wsiContext);
|
void (*Init)(void* userData, void* wsiContext);
|
||||||
|
|
||||||
/// Destroy the swap chain implementation.
|
/// Destroy the swap chain implementation.
|
||||||
void (*Destroy)(void* userData);
|
void (*Destroy)(void* userData);
|
||||||
|
|
||||||
/// Configure/reconfigure the swap chain.
|
/// Configure/reconfigure the swap chain.
|
||||||
nxtSwapChainError (*Configure)(void* userData, nxtTextureFormat format, nxtTextureUsageBit allowedUsage, uint32_t width, uint32_t height);
|
dawnSwapChainError (*Configure)(void* userData,
|
||||||
|
nxtTextureFormat format,
|
||||||
|
nxtTextureUsageBit allowedUsage,
|
||||||
|
uint32_t width,
|
||||||
|
uint32_t height);
|
||||||
|
|
||||||
/// Acquire the next texture from the swap chain.
|
/// Acquire the next texture from the swap chain.
|
||||||
nxtSwapChainError (*GetNextTexture)(void* userData, nxtSwapChainNextTexture* nextTexture);
|
dawnSwapChainError (*GetNextTexture)(void* userData, dawnSwapChainNextTexture* nextTexture);
|
||||||
|
|
||||||
/// Present the last acquired texture to the screen.
|
/// Present the last acquired texture to the screen.
|
||||||
nxtSwapChainError (*Present)(void* userData);
|
dawnSwapChainError (*Present)(void* userData);
|
||||||
|
|
||||||
/// Each function is called with userData as its first argument.
|
/// Each function is called with userData as its first argument.
|
||||||
void* userData;
|
void* userData;
|
||||||
|
|
||||||
/// For use by the D3D12 and Vulkan backends: how the swapchain will use the texture.
|
/// For use by the D3D12 and Vulkan backends: how the swapchain will use the texture.
|
||||||
nxtTextureUsageBit textureUsage;
|
nxtTextureUsageBit textureUsage;
|
||||||
} nxtSwapChainImplementation;
|
} dawnSwapChainImplementation;
|
||||||
|
|
||||||
#if defined(DAWN_ENABLE_BACKEND_D3D12) && defined(__cplusplus)
|
#if defined(DAWN_ENABLE_BACKEND_D3D12) && defined(__cplusplus)
|
||||||
typedef struct {
|
typedef struct {
|
||||||
nxtDevice device = nullptr;
|
nxtDevice device = nullptr;
|
||||||
} nxtWSIContextD3D12;
|
} dawnWSIContextD3D12;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(DAWN_ENABLE_BACKEND_METAL) && defined(__OBJC__)
|
#if defined(DAWN_ENABLE_BACKEND_METAL) && defined(__OBJC__)
|
||||||
#import <Metal/Metal.h>
|
# import <Metal/Metal.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
id<MTLDevice> device = nil;
|
id<MTLDevice> device = nil;
|
||||||
} nxtWSIContextMetal;
|
} dawnWSIContextMetal;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_BACKEND_OPENGL
|
#ifdef DAWN_ENABLE_BACKEND_OPENGL
|
||||||
typedef struct {
|
typedef struct {
|
||||||
} nxtWSIContextGL;
|
} dawnWSIContextGL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef DAWN_ENABLE_BACKEND_VULKAN
|
#ifdef DAWN_ENABLE_BACKEND_VULKAN
|
||||||
typedef struct {
|
typedef struct {
|
||||||
} nxtWSIContextVulkan;
|
} dawnWSIContextVulkan;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // NXT_WSI_H
|
#endif // DAWN_WSI_H
|
||||||
|
@ -24,8 +24,9 @@
|
|||||||
namespace backend { namespace d3d12 {
|
namespace backend { namespace d3d12 {
|
||||||
void Init(nxtProcTable* procs, nxtDevice* device);
|
void Init(nxtProcTable* procs, nxtDevice* device);
|
||||||
|
|
||||||
nxtSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, HWND window);
|
dawnSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, HWND window);
|
||||||
nxtTextureFormat GetNativeSwapChainPreferredFormat(const nxtSwapChainImplementation* swapChain);
|
nxtTextureFormat GetNativeSwapChainPreferredFormat(
|
||||||
|
const dawnSwapChainImplementation* swapChain);
|
||||||
}} // namespace backend::d3d12
|
}} // namespace backend::d3d12
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
@ -57,7 +58,7 @@ namespace utils {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
nxtDevice mBackendDevice = nullptr;
|
nxtDevice mBackendDevice = nullptr;
|
||||||
nxtSwapChainImplementation mSwapchainImpl = {};
|
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
BackendBinding* CreateD3D12Binding() {
|
BackendBinding* CreateD3D12Binding() {
|
||||||
|
@ -34,7 +34,7 @@ namespace backend { namespace metal {
|
|||||||
namespace utils {
|
namespace utils {
|
||||||
class SwapChainImplMTL {
|
class SwapChainImplMTL {
|
||||||
public:
|
public:
|
||||||
using WSIContext = nxtWSIContextMetal;
|
using WSIContext = dawnWSIContextMetal;
|
||||||
|
|
||||||
SwapChainImplMTL(id nsWindow) : mNsWindow(nsWindow) {
|
SwapChainImplMTL(id nsWindow) : mNsWindow(nsWindow) {
|
||||||
}
|
}
|
||||||
@ -44,15 +44,15 @@ namespace utils {
|
|||||||
[mCurrentDrawable release];
|
[mCurrentDrawable release];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init(nxtWSIContextMetal* ctx) {
|
void Init(dawnWSIContextMetal* ctx) {
|
||||||
mMtlDevice = ctx->device;
|
mMtlDevice = ctx->device;
|
||||||
mCommandQueue = [mMtlDevice newCommandQueue];
|
mCommandQueue = [mMtlDevice newCommandQueue];
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError Configure(nxtTextureFormat format,
|
dawnSwapChainError Configure(nxtTextureFormat format,
|
||||||
nxtTextureUsageBit,
|
nxtTextureUsageBit,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
if (format != NXT_TEXTURE_FORMAT_B8_G8_R8_A8_UNORM) {
|
if (format != NXT_TEXTURE_FORMAT_B8_G8_R8_A8_UNORM) {
|
||||||
return "unsupported format";
|
return "unsupported format";
|
||||||
}
|
}
|
||||||
@ -74,10 +74,10 @@ namespace utils {
|
|||||||
|
|
||||||
[contentView setLayer:mLayer];
|
[contentView setLayer:mLayer];
|
||||||
|
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError GetNextTexture(nxtSwapChainNextTexture* nextTexture) {
|
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture) {
|
||||||
[mCurrentDrawable release];
|
[mCurrentDrawable release];
|
||||||
mCurrentDrawable = [mLayer nextDrawable];
|
mCurrentDrawable = [mLayer nextDrawable];
|
||||||
[mCurrentDrawable retain];
|
[mCurrentDrawable retain];
|
||||||
@ -88,15 +88,15 @@ namespace utils {
|
|||||||
|
|
||||||
nextTexture->texture.ptr = reinterpret_cast<void*>(mCurrentTexture);
|
nextTexture->texture.ptr = reinterpret_cast<void*>(mCurrentTexture);
|
||||||
|
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError Present() {
|
dawnSwapChainError Present() {
|
||||||
id<MTLCommandBuffer> commandBuffer = [mCommandQueue commandBuffer];
|
id<MTLCommandBuffer> commandBuffer = [mCommandQueue commandBuffer];
|
||||||
[commandBuffer presentDrawable:mCurrentDrawable];
|
[commandBuffer presentDrawable:mCurrentDrawable];
|
||||||
[commandBuffer commit];
|
[commandBuffer commit];
|
||||||
|
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -136,7 +136,7 @@ namespace utils {
|
|||||||
private:
|
private:
|
||||||
id<MTLDevice> mMetalDevice = nil;
|
id<MTLDevice> mMetalDevice = nil;
|
||||||
nxtDevice mBackendDevice = nullptr;
|
nxtDevice mBackendDevice = nullptr;
|
||||||
nxtSwapChainImplementation mSwapchainImpl = {};
|
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
BackendBinding* CreateMetalBinding() {
|
BackendBinding* CreateMetalBinding() {
|
||||||
|
@ -32,7 +32,7 @@ namespace backend { namespace opengl {
|
|||||||
namespace utils {
|
namespace utils {
|
||||||
class SwapChainImplGL {
|
class SwapChainImplGL {
|
||||||
public:
|
public:
|
||||||
using WSIContext = nxtWSIContextGL;
|
using WSIContext = dawnWSIContextGL;
|
||||||
|
|
||||||
SwapChainImplGL(GLFWwindow* window) : mWindow(window) {
|
SwapChainImplGL(GLFWwindow* window) : mWindow(window) {
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ namespace utils {
|
|||||||
glDeleteFramebuffers(1, &mBackFBO);
|
glDeleteFramebuffers(1, &mBackFBO);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init(nxtWSIContextGL*) {
|
void Init(dawnWSIContextGL*) {
|
||||||
glGenTextures(1, &mBackTexture);
|
glGenTextures(1, &mBackTexture);
|
||||||
glBindTexture(GL_TEXTURE_2D, mBackTexture);
|
glBindTexture(GL_TEXTURE_2D, mBackTexture);
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
||||||
@ -53,10 +53,10 @@ namespace utils {
|
|||||||
mBackTexture, 0);
|
mBackTexture, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError Configure(nxtTextureFormat format,
|
dawnSwapChainError Configure(nxtTextureFormat format,
|
||||||
nxtTextureUsageBit,
|
nxtTextureUsageBit,
|
||||||
uint32_t width,
|
uint32_t width,
|
||||||
uint32_t height) {
|
uint32_t height) {
|
||||||
if (format != NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM) {
|
if (format != NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM) {
|
||||||
return "unsupported format";
|
return "unsupported format";
|
||||||
}
|
}
|
||||||
@ -70,22 +70,22 @@ namespace utils {
|
|||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||||
nullptr);
|
nullptr);
|
||||||
|
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError GetNextTexture(nxtSwapChainNextTexture* nextTexture) {
|
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture) {
|
||||||
nextTexture->texture.u32 = mBackTexture;
|
nextTexture->texture.u32 = mBackTexture;
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError Present() {
|
dawnSwapChainError Present() {
|
||||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, mBackFBO);
|
glBindFramebuffer(GL_READ_FRAMEBUFFER, mBackFBO);
|
||||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||||
glBlitFramebuffer(0, 0, mWidth, mHeight, 0, mHeight, mWidth, 0, GL_COLOR_BUFFER_BIT,
|
glBlitFramebuffer(0, 0, mWidth, mHeight, 0, mHeight, mWidth, 0, GL_COLOR_BUFFER_BIT,
|
||||||
GL_NEAREST);
|
GL_NEAREST);
|
||||||
glfwSwapBuffers(mWindow);
|
glfwSwapBuffers(mWindow);
|
||||||
|
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -132,7 +132,7 @@ namespace utils {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
nxtDevice mBackendDevice = nullptr;
|
nxtDevice mBackendDevice = nullptr;
|
||||||
nxtSwapChainImplementation mSwapchainImpl = {};
|
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
BackendBinding* CreateOpenGLBinding() {
|
BackendBinding* CreateOpenGLBinding() {
|
||||||
|
@ -29,15 +29,16 @@ namespace backend { namespace vulkan {
|
|||||||
|
|
||||||
VkInstance GetInstance(nxtDevice device);
|
VkInstance GetInstance(nxtDevice device);
|
||||||
|
|
||||||
nxtSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, VkSurfaceKHR surface);
|
dawnSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, VkSurfaceKHR surface);
|
||||||
nxtTextureFormat GetNativeSwapChainPreferredFormat(const nxtSwapChainImplementation* swapChain);
|
nxtTextureFormat GetNativeSwapChainPreferredFormat(
|
||||||
|
const dawnSwapChainImplementation* swapChain);
|
||||||
}} // namespace backend::vulkan
|
}} // namespace backend::vulkan
|
||||||
|
|
||||||
namespace utils {
|
namespace utils {
|
||||||
|
|
||||||
class SwapChainImplVulkan {
|
class SwapChainImplVulkan {
|
||||||
public:
|
public:
|
||||||
using WSIContext = nxtWSIContextVulkan;
|
using WSIContext = dawnWSIContextVulkan;
|
||||||
|
|
||||||
SwapChainImplVulkan(GLFWwindow* /*window*/) {
|
SwapChainImplVulkan(GLFWwindow* /*window*/) {
|
||||||
}
|
}
|
||||||
@ -45,19 +46,19 @@ namespace utils {
|
|||||||
~SwapChainImplVulkan() {
|
~SwapChainImplVulkan() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Init(nxtWSIContextVulkan*) {
|
void Init(dawnWSIContextVulkan*) {
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError Configure(nxtTextureFormat, nxtTextureUsageBit, uint32_t, uint32_t) {
|
dawnSwapChainError Configure(nxtTextureFormat, nxtTextureUsageBit, uint32_t, uint32_t) {
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError GetNextTexture(nxtSwapChainNextTexture*) {
|
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture*) {
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError Present() {
|
dawnSwapChainError Present() {
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -95,7 +96,7 @@ namespace utils {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
nxtDevice mDevice;
|
nxtDevice mDevice;
|
||||||
nxtSwapChainImplementation mSwapchainImpl = {};
|
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
BackendBinding* CreateVulkanBinding() {
|
BackendBinding* CreateVulkanBinding() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user