Make binding expose the preferred format

This commit is contained in:
Corentin Wallez
2017-09-21 12:54:53 -04:00
committed by Corentin Wallez
parent 405dcd636a
commit 2e31e8f0bf
21 changed files with 51 additions and 14 deletions

View File

@@ -142,7 +142,8 @@ void NXTTest::SetUp() {
swapchain = device.CreateSwapChainBuilder()
.SetImplementation(binding->GetSwapChainImplementation())
.GetResult();
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, 400, 400);
swapchain.Configure(static_cast<nxt::TextureFormat>(binding->GetPreferredSwapChainTextureFormat()),
nxt::TextureUsageBit::OutputAttachment, 400, 400);
device.SetErrorCallback(DeviceErrorCauseTestFailure, 0);
}

View File

@@ -38,6 +38,7 @@ namespace utils {
virtual void SetupGLFWWindowHints() = 0;
virtual void GetProcAndDevice(nxtProcTable* procs, nxtDevice* device) = 0;
virtual uint64_t GetSwapChainImplementation() = 0;
virtual nxtTextureFormat GetPreferredSwapChainTextureFormat() = 0;
void SetWindow(GLFWwindow* window);

View File

@@ -275,6 +275,10 @@ namespace utils {
return reinterpret_cast<uint64_t>(&swapchainImpl);
}
nxtTextureFormat GetPreferredSwapChainTextureFormat() override {
return NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
}
private:
nxtDevice backendDevice = nullptr;
nxtSwapChainImplementation swapchainImpl = {};

View File

@@ -136,6 +136,10 @@ namespace utils {
return reinterpret_cast<uint64_t>(&swapchainImpl);
}
nxtTextureFormat GetPreferredSwapChainTextureFormat() override {
return NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
}
private:
id<MTLDevice> metalDevice = nil;
nxtDevice backendDevice = nullptr;

View File

@@ -32,6 +32,9 @@ namespace utils {
uint64_t GetSwapChainImplementation() override {
return 0;
}
nxtTextureFormat GetPreferredSwapChainTextureFormat() override {
return NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
}
};

View File

@@ -132,6 +132,10 @@ namespace utils {
return reinterpret_cast<uint64_t>(&swapchainImpl);
}
nxtTextureFormat GetPreferredSwapChainTextureFormat() override {
return NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
}
private:
nxtDevice backendDevice = nullptr;
nxtSwapChainImplementation swapchainImpl = {};

View File

@@ -32,6 +32,9 @@ namespace utils {
uint64_t GetSwapChainImplementation() override {
return 0;
}
nxtTextureFormat GetPreferredSwapChainTextureFormat() override {
return NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM;
}
};