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);
|
||||
}
|
||||
|
||||
const nxtSwapChainImplementation& SwapChainBase::GetImplementation() {
|
||||
const dawnSwapChainImplementation& SwapChainBase::GetImplementation() {
|
||||
return mImplementation;
|
||||
}
|
||||
|
||||
|
@ -106,8 +106,8 @@ namespace backend {
|
|||
return;
|
||||
}
|
||||
|
||||
nxtSwapChainImplementation& impl =
|
||||
*reinterpret_cast<nxtSwapChainImplementation*>(implementation);
|
||||
dawnSwapChainImplementation& impl =
|
||||
*reinterpret_cast<dawnSwapChainImplementation*>(implementation);
|
||||
|
||||
if (!impl.Init || !impl.Destroy || !impl.Configure || !impl.GetNextTexture ||
|
||||
!impl.Present) {
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
#include "backend/Forward.h"
|
||||
#include "backend/RefCounted.h"
|
||||
|
||||
#include "dawn/dawncpp.h"
|
||||
#include "dawn/dawn_wsi.h"
|
||||
#include "dawn/dawncpp.h"
|
||||
|
||||
namespace backend {
|
||||
|
||||
|
@ -40,13 +40,13 @@ namespace backend {
|
|||
void Present(TextureBase* texture);
|
||||
|
||||
protected:
|
||||
const nxtSwapChainImplementation& GetImplementation();
|
||||
const dawnSwapChainImplementation& GetImplementation();
|
||||
virtual TextureBase* GetNextTextureImpl(TextureBuilder* builder) = 0;
|
||||
virtual void OnBeforePresent(TextureBase* texture) = 0;
|
||||
|
||||
private:
|
||||
DeviceBase* mDevice = nullptr;
|
||||
nxtSwapChainImplementation mImplementation = {};
|
||||
dawnSwapChainImplementation mImplementation = {};
|
||||
dawn::TextureFormat mFormat = {};
|
||||
dawn::TextureUsageBit mAllowedUsage;
|
||||
uint32_t mWidth = 0;
|
||||
|
@ -65,7 +65,7 @@ namespace backend {
|
|||
private:
|
||||
friend class SwapChainBase;
|
||||
|
||||
nxtSwapChainImplementation mImplementation = {};
|
||||
dawnSwapChainImplementation mImplementation = {};
|
||||
};
|
||||
|
||||
} // namespace backend
|
||||
|
|
|
@ -49,10 +49,10 @@ namespace backend { namespace d3d12 {
|
|||
*device = reinterpret_cast<nxtDevice>(new Device());
|
||||
}
|
||||
|
||||
nxtSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, HWND window) {
|
||||
dawnSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, HWND window) {
|
||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||
|
||||
nxtSwapChainImplementation impl;
|
||||
dawnSwapChainImplementation impl;
|
||||
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, window));
|
||||
impl.textureUsage = NXT_TEXTURE_USAGE_BIT_PRESENT;
|
||||
|
||||
|
@ -60,7 +60,7 @@ namespace backend { namespace d3d12 {
|
|||
}
|
||||
|
||||
nxtTextureFormat GetNativeSwapChainPreferredFormat(
|
||||
const nxtSwapChainImplementation* swapChain) {
|
||||
const dawnSwapChainImplementation* swapChain) {
|
||||
NativeSwapChainImpl* impl = reinterpret_cast<NativeSwapChainImpl*>(swapChain->userData);
|
||||
return static_cast<nxtTextureFormat>(impl->GetPreferredFormat());
|
||||
}
|
||||
|
|
|
@ -45,10 +45,10 @@ namespace backend { namespace d3d12 {
|
|||
NativeSwapChainImpl::~NativeSwapChainImpl() {
|
||||
}
|
||||
|
||||
void NativeSwapChainImpl::Init(nxtWSIContextD3D12* /*context*/) {
|
||||
void NativeSwapChainImpl::Init(dawnWSIContextD3D12* /*context*/) {
|
||||
}
|
||||
|
||||
nxtSwapChainError NativeSwapChainImpl::Configure(nxtTextureFormat format,
|
||||
dawnSwapChainError NativeSwapChainImpl::Configure(nxtTextureFormat format,
|
||||
nxtTextureUsageBit usage,
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
|
@ -86,10 +86,10 @@ namespace backend { namespace d3d12 {
|
|||
// used
|
||||
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();
|
||||
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.
|
||||
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.
|
||||
|
||||
ASSERT_SUCCESS(mSwapChain->Present(1, 0));
|
||||
|
@ -108,7 +108,7 @@ namespace backend { namespace d3d12 {
|
|||
mDevice->NextSerial();
|
||||
|
||||
mBufferSerials[mCurrentBuffer] = mDevice->GetSerial();
|
||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
dawn::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
#include "backend/d3d12/d3d12_platform.h"
|
||||
|
||||
#include "dawn/dawncpp.h"
|
||||
#include "dawn/dawn_wsi.h"
|
||||
#include "dawn/dawncpp.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
@ -28,18 +28,18 @@ namespace backend { namespace d3d12 {
|
|||
|
||||
class NativeSwapChainImpl {
|
||||
public:
|
||||
using WSIContext = nxtWSIContextD3D12;
|
||||
using WSIContext = dawnWSIContextD3D12;
|
||||
|
||||
NativeSwapChainImpl(Device* device, HWND window);
|
||||
~NativeSwapChainImpl();
|
||||
|
||||
void Init(nxtWSIContextD3D12* context);
|
||||
nxtSwapChainError Configure(nxtTextureFormat format,
|
||||
void Init(dawnWSIContextD3D12* context);
|
||||
dawnSwapChainError Configure(nxtTextureFormat format,
|
||||
nxtTextureUsageBit,
|
||||
uint32_t width,
|
||||
uint32_t height);
|
||||
nxtSwapChainError GetNextTexture(nxtSwapChainNextTexture* nextTexture);
|
||||
nxtSwapChainError Present();
|
||||
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture);
|
||||
dawnSwapChainError Present();
|
||||
|
||||
dawn::TextureFormat GetPreferredFormat() const;
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace backend { namespace d3d12 {
|
|||
|
||||
SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
|
||||
const auto& im = GetImplementation();
|
||||
nxtWSIContextD3D12 wsiContext = {};
|
||||
dawnWSIContextD3D12 wsiContext = {};
|
||||
wsiContext.device = reinterpret_cast<nxtDevice>(GetDevice());
|
||||
im.Init(im.userData, &wsiContext);
|
||||
|
||||
|
@ -36,8 +36,8 @@ namespace backend { namespace d3d12 {
|
|||
|
||||
TextureBase* SwapChain::GetNextTextureImpl(TextureBuilder* builder) {
|
||||
const auto& im = GetImplementation();
|
||||
nxtSwapChainNextTexture next = {};
|
||||
nxtSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
dawnSwapChainNextTexture next = {};
|
||||
dawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
if (error) {
|
||||
GetDevice()->HandleError(error);
|
||||
return nullptr;
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace backend { namespace metal {
|
|||
|
||||
SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
|
||||
const auto& im = GetImplementation();
|
||||
nxtWSIContextMetal wsiContext = {};
|
||||
dawnWSIContextMetal wsiContext = {};
|
||||
wsiContext.device = ToBackend(GetDevice())->GetMTLDevice();
|
||||
im.Init(im.userData, &wsiContext);
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ namespace backend { namespace metal {
|
|||
|
||||
TextureBase* SwapChain::GetNextTextureImpl(TextureBuilder* builder) {
|
||||
const auto& im = GetImplementation();
|
||||
nxtSwapChainNextTexture next = {};
|
||||
nxtSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
dawnSwapChainNextTexture next = {};
|
||||
dawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
if (error) {
|
||||
GetDevice()->HandleError(error);
|
||||
return nullptr;
|
||||
|
|
|
@ -31,8 +31,8 @@ namespace backend { namespace opengl {
|
|||
|
||||
TextureBase* SwapChain::GetNextTextureImpl(TextureBuilder* builder) {
|
||||
const auto& im = GetImplementation();
|
||||
nxtSwapChainNextTexture next = {};
|
||||
nxtSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
dawnSwapChainNextTexture next = {};
|
||||
dawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
if (error) {
|
||||
GetDevice()->HandleError(error);
|
||||
return nullptr;
|
||||
|
|
|
@ -67,10 +67,10 @@ namespace backend { namespace vulkan {
|
|||
return backendDevice->GetInstance();
|
||||
}
|
||||
|
||||
nxtSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, VkSurfaceKHR surface) {
|
||||
dawnSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, VkSurfaceKHR surface) {
|
||||
Device* backendDevice = reinterpret_cast<Device*>(device);
|
||||
|
||||
nxtSwapChainImplementation impl;
|
||||
dawnSwapChainImplementation impl;
|
||||
impl = CreateSwapChainImplementation(new NativeSwapChainImpl(backendDevice, surface));
|
||||
impl.textureUsage = NXT_TEXTURE_USAGE_BIT_PRESENT;
|
||||
|
||||
|
@ -78,7 +78,7 @@ namespace backend { namespace vulkan {
|
|||
}
|
||||
|
||||
nxtTextureFormat GetNativeSwapChainPreferredFormat(
|
||||
const nxtSwapChainImplementation* swapChain) {
|
||||
const dawnSwapChainImplementation* swapChain) {
|
||||
NativeSwapChainImpl* impl = reinterpret_cast<NativeSwapChainImpl*>(swapChain->userData);
|
||||
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)) {
|
||||
ASSERT(false);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ namespace backend { namespace vulkan {
|
|||
}
|
||||
}
|
||||
|
||||
nxtSwapChainError NativeSwapChainImpl::Configure(nxtTextureFormat format,
|
||||
dawnSwapChainError NativeSwapChainImpl::Configure(nxtTextureFormat format,
|
||||
nxtTextureUsageBit usage,
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
|
@ -147,10 +147,10 @@ namespace backend { namespace vulkan {
|
|||
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
|
||||
// with the swapchain image. Further operations on the image will wait for this semaphore.
|
||||
VkSemaphore semaphore = VK_NULL_HANDLE;
|
||||
|
@ -174,10 +174,10 @@ namespace backend { namespace vulkan {
|
|||
nextTexture->texture.u64 = mSwapChainImages[mLastImageIndex].GetHandle();
|
||||
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
|
||||
// writes were made available to the stage.
|
||||
|
||||
|
@ -199,7 +199,7 @@ namespace backend { namespace vulkan {
|
|||
ASSERT(false);
|
||||
}
|
||||
|
||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
dawn::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
|
||||
#include "backend/vulkan/VulkanInfo.h"
|
||||
|
||||
#include "dawn/dawncpp.h"
|
||||
#include "dawn/dawn_wsi.h"
|
||||
#include "dawn/dawncpp.h"
|
||||
|
||||
namespace backend { namespace vulkan {
|
||||
|
||||
|
@ -26,18 +26,18 @@ namespace backend { namespace vulkan {
|
|||
|
||||
class NativeSwapChainImpl {
|
||||
public:
|
||||
using WSIContext = nxtWSIContextVulkan;
|
||||
using WSIContext = dawnWSIContextVulkan;
|
||||
|
||||
NativeSwapChainImpl(Device* device, VkSurfaceKHR surface);
|
||||
~NativeSwapChainImpl();
|
||||
|
||||
void Init(nxtWSIContextVulkan* context);
|
||||
nxtSwapChainError Configure(nxtTextureFormat format,
|
||||
void Init(dawnWSIContextVulkan* context);
|
||||
dawnSwapChainError Configure(nxtTextureFormat format,
|
||||
nxtTextureUsageBit,
|
||||
uint32_t width,
|
||||
uint32_t height);
|
||||
nxtSwapChainError GetNextTexture(nxtSwapChainNextTexture* nextTexture);
|
||||
nxtSwapChainError Present();
|
||||
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture* nextTexture);
|
||||
dawnSwapChainError Present();
|
||||
|
||||
dawn::TextureFormat GetPreferredFormat() const;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ namespace backend { namespace vulkan {
|
|||
|
||||
SwapChain::SwapChain(SwapChainBuilder* builder) : SwapChainBase(builder) {
|
||||
const auto& im = GetImplementation();
|
||||
nxtWSIContextVulkan wsiContext = {};
|
||||
dawnWSIContextVulkan wsiContext = {};
|
||||
im.Init(im.userData, &wsiContext);
|
||||
|
||||
ASSERT(im.textureUsage != NXT_TEXTURE_USAGE_BIT_NONE);
|
||||
|
@ -33,8 +33,8 @@ namespace backend { namespace vulkan {
|
|||
|
||||
TextureBase* SwapChain::GetNextTextureImpl(TextureBuilder* builder) {
|
||||
const auto& im = GetImplementation();
|
||||
nxtSwapChainNextTexture next = {};
|
||||
nxtSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
dawnSwapChainNextTexture next = {};
|
||||
dawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
|
||||
if (error) {
|
||||
GetDevice()->HandleError(error);
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
#define COMMON_SWAPCHAINUTILS_H_
|
||||
|
||||
template <typename T>
|
||||
nxtSwapChainImplementation CreateSwapChainImplementation(T* swapChain) {
|
||||
nxtSwapChainImplementation impl = {};
|
||||
dawnSwapChainImplementation CreateSwapChainImplementation(T* swapChain) {
|
||||
dawnSwapChainImplementation impl = {};
|
||||
impl.userData = swapChain;
|
||||
impl.Init = [](void* userData, void* wsiContext) {
|
||||
auto* ctx = reinterpret_cast<typename T::WSIContext*>(wsiContext);
|
||||
|
@ -28,7 +28,7 @@ nxtSwapChainImplementation CreateSwapChainImplementation(T* swapChain) {
|
|||
uint32_t width, uint32_t 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);
|
||||
};
|
||||
impl.Present = [](void* userData) { return reinterpret_cast<T*>(userData)->Present(); };
|
||||
|
|
|
@ -23,8 +23,7 @@ namespace nxt {
|
|||
#define CR_GLIBCXX_4_7_0 20120322
|
||||
#define CR_GLIBCXX_4_5_4 20120702
|
||||
#define CR_GLIBCXX_4_6_4 20121127
|
||||
#if defined(__GLIBCXX__) && \
|
||||
(__GLIBCXX__ < CR_GLIBCXX_4_7_0 || __GLIBCXX__ == CR_GLIBCXX_4_5_4 || \
|
||||
#if defined(__GLIBCXX__) && (__GLIBCXX__ < CR_GLIBCXX_4_7_0 || __GLIBCXX__ == CR_GLIBCXX_4_5_4 || \
|
||||
__GLIBCXX__ == CR_GLIBCXX_4_6_4)
|
||||
# define CR_USE_FALLBACKS_FOR_OLD_GLIBCXX
|
||||
#endif
|
||||
|
@ -89,9 +88,10 @@ namespace nxt {
|
|||
return (static_cast<Integral>(value) & (static_cast<Integral>(value) - 1)) == 0;
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, typename = typename std::enable_if<
|
||||
LowerBitmask<T1>::enable && LowerBitmask<T2>::enable
|
||||
>::type>
|
||||
template <typename T1,
|
||||
typename T2,
|
||||
typename = typename std::enable_if<LowerBitmask<T1>::enable &&
|
||||
LowerBitmask<T2>::enable>::type>
|
||||
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator|(T1 left, T2 right) {
|
||||
using T = typename LowerBitmask<T1>::type;
|
||||
using Integral = typename UnderlyingType<T>::type;
|
||||
|
@ -99,9 +99,10 @@ namespace nxt {
|
|||
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, typename = typename std::enable_if<
|
||||
LowerBitmask<T1>::enable && LowerBitmask<T2>::enable
|
||||
>::type>
|
||||
template <typename T1,
|
||||
typename T2,
|
||||
typename = typename std::enable_if<LowerBitmask<T1>::enable &&
|
||||
LowerBitmask<T2>::enable>::type>
|
||||
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator&(T1 left, T2 right) {
|
||||
using T = typename LowerBitmask<T1>::type;
|
||||
using Integral = typename UnderlyingType<T>::type;
|
||||
|
@ -109,9 +110,10 @@ namespace nxt {
|
|||
static_cast<Integral>(LowerBitmask<T2>::Lower(right));
|
||||
}
|
||||
|
||||
template<typename T1, typename T2, typename = typename std::enable_if<
|
||||
LowerBitmask<T1>::enable && LowerBitmask<T2>::enable
|
||||
>::type>
|
||||
template <typename T1,
|
||||
typename T2,
|
||||
typename = typename std::enable_if<LowerBitmask<T1>::enable &&
|
||||
LowerBitmask<T2>::enable>::type>
|
||||
constexpr BoolConvertible<typename LowerBitmask<T1>::type> operator^(T1 left, T2 right) {
|
||||
using T = typename LowerBitmask<T1>::type;
|
||||
using Integral = typename UnderlyingType<T>::type;
|
||||
|
@ -155,6 +157,6 @@ namespace nxt {
|
|||
l = l ^ r;
|
||||
return l;
|
||||
}
|
||||
}
|
||||
} // namespace nxt
|
||||
|
||||
#endif // NXT_ENUM_CLASS_BITMASKS_H_
|
||||
|
|
|
@ -12,14 +12,14 @@
|
|||
//* See the License for the specific language governing permissions and
|
||||
//* limitations under the License.
|
||||
|
||||
#ifndef NXT_WSI_H
|
||||
#define NXT_WSI_H
|
||||
#ifndef DAWN_WSI_H
|
||||
#define DAWN_WSI_H
|
||||
|
||||
#include <dawn/dawn.h>
|
||||
|
||||
// Error message (or nullptr if there was no error)
|
||||
typedef const char* nxtSwapChainError;
|
||||
constexpr nxtSwapChainError NXT_SWAP_CHAIN_NO_ERROR = nullptr;
|
||||
typedef const char* dawnSwapChainError;
|
||||
constexpr dawnSwapChainError DAWN_SWAP_CHAIN_NO_ERROR = nullptr;
|
||||
|
||||
typedef struct {
|
||||
/// Backend-specific texture id/name/pointer
|
||||
|
@ -28,36 +28,40 @@ typedef struct {
|
|||
uint64_t u64;
|
||||
uint32_t u32;
|
||||
} texture;
|
||||
} nxtSwapChainNextTexture;
|
||||
} dawnSwapChainNextTexture;
|
||||
|
||||
typedef struct {
|
||||
/// 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);
|
||||
|
||||
/// Destroy the swap chain implementation.
|
||||
void (*Destroy)(void* userData);
|
||||
|
||||
/// 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.
|
||||
nxtSwapChainError (*GetNextTexture)(void* userData, nxtSwapChainNextTexture* nextTexture);
|
||||
dawnSwapChainError (*GetNextTexture)(void* userData, dawnSwapChainNextTexture* nextTexture);
|
||||
|
||||
/// 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.
|
||||
void* userData;
|
||||
|
||||
/// For use by the D3D12 and Vulkan backends: how the swapchain will use the texture.
|
||||
nxtTextureUsageBit textureUsage;
|
||||
} nxtSwapChainImplementation;
|
||||
} dawnSwapChainImplementation;
|
||||
|
||||
#if defined(DAWN_ENABLE_BACKEND_D3D12) && defined(__cplusplus)
|
||||
typedef struct {
|
||||
nxtDevice device = nullptr;
|
||||
} nxtWSIContextD3D12;
|
||||
} dawnWSIContextD3D12;
|
||||
#endif
|
||||
|
||||
#if defined(DAWN_ENABLE_BACKEND_METAL) && defined(__OBJC__)
|
||||
|
@ -65,17 +69,17 @@ typedef struct {
|
|||
|
||||
typedef struct {
|
||||
id<MTLDevice> device = nil;
|
||||
} nxtWSIContextMetal;
|
||||
} dawnWSIContextMetal;
|
||||
#endif
|
||||
|
||||
#ifdef DAWN_ENABLE_BACKEND_OPENGL
|
||||
typedef struct {
|
||||
} nxtWSIContextGL;
|
||||
} dawnWSIContextGL;
|
||||
#endif
|
||||
|
||||
#ifdef DAWN_ENABLE_BACKEND_VULKAN
|
||||
typedef struct {
|
||||
} nxtWSIContextVulkan;
|
||||
} dawnWSIContextVulkan;
|
||||
#endif
|
||||
|
||||
#endif // NXT_WSI_H
|
||||
#endif // DAWN_WSI_H
|
||||
|
|
|
@ -24,8 +24,9 @@
|
|||
namespace backend { namespace d3d12 {
|
||||
void Init(nxtProcTable* procs, nxtDevice* device);
|
||||
|
||||
nxtSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, HWND window);
|
||||
nxtTextureFormat GetNativeSwapChainPreferredFormat(const nxtSwapChainImplementation* swapChain);
|
||||
dawnSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, HWND window);
|
||||
nxtTextureFormat GetNativeSwapChainPreferredFormat(
|
||||
const dawnSwapChainImplementation* swapChain);
|
||||
}} // namespace backend::d3d12
|
||||
|
||||
namespace utils {
|
||||
|
@ -57,7 +58,7 @@ namespace utils {
|
|||
|
||||
private:
|
||||
nxtDevice mBackendDevice = nullptr;
|
||||
nxtSwapChainImplementation mSwapchainImpl = {};
|
||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||
};
|
||||
|
||||
BackendBinding* CreateD3D12Binding() {
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace backend { namespace metal {
|
|||
namespace utils {
|
||||
class SwapChainImplMTL {
|
||||
public:
|
||||
using WSIContext = nxtWSIContextMetal;
|
||||
using WSIContext = dawnWSIContextMetal;
|
||||
|
||||
SwapChainImplMTL(id nsWindow) : mNsWindow(nsWindow) {
|
||||
}
|
||||
|
@ -44,12 +44,12 @@ namespace utils {
|
|||
[mCurrentDrawable release];
|
||||
}
|
||||
|
||||
void Init(nxtWSIContextMetal* ctx) {
|
||||
void Init(dawnWSIContextMetal* ctx) {
|
||||
mMtlDevice = ctx->device;
|
||||
mCommandQueue = [mMtlDevice newCommandQueue];
|
||||
}
|
||||
|
||||
nxtSwapChainError Configure(nxtTextureFormat format,
|
||||
dawnSwapChainError Configure(nxtTextureFormat format,
|
||||
nxtTextureUsageBit,
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
|
@ -74,10 +74,10 @@ namespace utils {
|
|||
|
||||
[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 = [mLayer nextDrawable];
|
||||
[mCurrentDrawable retain];
|
||||
|
@ -88,15 +88,15 @@ namespace utils {
|
|||
|
||||
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];
|
||||
[commandBuffer presentDrawable:mCurrentDrawable];
|
||||
[commandBuffer commit];
|
||||
|
||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -136,7 +136,7 @@ namespace utils {
|
|||
private:
|
||||
id<MTLDevice> mMetalDevice = nil;
|
||||
nxtDevice mBackendDevice = nullptr;
|
||||
nxtSwapChainImplementation mSwapchainImpl = {};
|
||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||
};
|
||||
|
||||
BackendBinding* CreateMetalBinding() {
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace backend { namespace opengl {
|
|||
namespace utils {
|
||||
class SwapChainImplGL {
|
||||
public:
|
||||
using WSIContext = nxtWSIContextGL;
|
||||
using WSIContext = dawnWSIContextGL;
|
||||
|
||||
SwapChainImplGL(GLFWwindow* window) : mWindow(window) {
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ namespace utils {
|
|||
glDeleteFramebuffers(1, &mBackFBO);
|
||||
}
|
||||
|
||||
void Init(nxtWSIContextGL*) {
|
||||
void Init(dawnWSIContextGL*) {
|
||||
glGenTextures(1, &mBackTexture);
|
||||
glBindTexture(GL_TEXTURE_2D, mBackTexture);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, 0, 0, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
|
||||
|
@ -53,7 +53,7 @@ namespace utils {
|
|||
mBackTexture, 0);
|
||||
}
|
||||
|
||||
nxtSwapChainError Configure(nxtTextureFormat format,
|
||||
dawnSwapChainError Configure(nxtTextureFormat format,
|
||||
nxtTextureUsageBit,
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
|
@ -70,22 +70,22 @@ namespace utils {
|
|||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE,
|
||||
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;
|
||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
nxtSwapChainError Present() {
|
||||
dawnSwapChainError Present() {
|
||||
glBindFramebuffer(GL_READ_FRAMEBUFFER, mBackFBO);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
glBlitFramebuffer(0, 0, mWidth, mHeight, 0, mHeight, mWidth, 0, GL_COLOR_BUFFER_BIT,
|
||||
GL_NEAREST);
|
||||
glfwSwapBuffers(mWindow);
|
||||
|
||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -132,7 +132,7 @@ namespace utils {
|
|||
|
||||
private:
|
||||
nxtDevice mBackendDevice = nullptr;
|
||||
nxtSwapChainImplementation mSwapchainImpl = {};
|
||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||
};
|
||||
|
||||
BackendBinding* CreateOpenGLBinding() {
|
||||
|
|
|
@ -29,15 +29,16 @@ namespace backend { namespace vulkan {
|
|||
|
||||
VkInstance GetInstance(nxtDevice device);
|
||||
|
||||
nxtSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, VkSurfaceKHR surface);
|
||||
nxtTextureFormat GetNativeSwapChainPreferredFormat(const nxtSwapChainImplementation* swapChain);
|
||||
dawnSwapChainImplementation CreateNativeSwapChainImpl(nxtDevice device, VkSurfaceKHR surface);
|
||||
nxtTextureFormat GetNativeSwapChainPreferredFormat(
|
||||
const dawnSwapChainImplementation* swapChain);
|
||||
}} // namespace backend::vulkan
|
||||
|
||||
namespace utils {
|
||||
|
||||
class SwapChainImplVulkan {
|
||||
public:
|
||||
using WSIContext = nxtWSIContextVulkan;
|
||||
using WSIContext = dawnWSIContextVulkan;
|
||||
|
||||
SwapChainImplVulkan(GLFWwindow* /*window*/) {
|
||||
}
|
||||
|
@ -45,19 +46,19 @@ namespace utils {
|
|||
~SwapChainImplVulkan() {
|
||||
}
|
||||
|
||||
void Init(nxtWSIContextVulkan*) {
|
||||
void Init(dawnWSIContextVulkan*) {
|
||||
}
|
||||
|
||||
nxtSwapChainError Configure(nxtTextureFormat, nxtTextureUsageBit, uint32_t, uint32_t) {
|
||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
||||
dawnSwapChainError Configure(nxtTextureFormat, nxtTextureUsageBit, uint32_t, uint32_t) {
|
||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
nxtSwapChainError GetNextTexture(nxtSwapChainNextTexture*) {
|
||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
||||
dawnSwapChainError GetNextTexture(dawnSwapChainNextTexture*) {
|
||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
nxtSwapChainError Present() {
|
||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
||||
dawnSwapChainError Present() {
|
||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -95,7 +96,7 @@ namespace utils {
|
|||
|
||||
private:
|
||||
nxtDevice mDevice;
|
||||
nxtSwapChainImplementation mSwapchainImpl = {};
|
||||
dawnSwapChainImplementation mSwapchainImpl = {};
|
||||
};
|
||||
|
||||
BackendBinding* CreateVulkanBinding() {
|
||||
|
|
Loading…
Reference in New Issue