remove initialUsage from SwapChain::Configure
This commit is contained in:
parent
8e587e8b42
commit
921fb5e1ce
|
@ -49,7 +49,7 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
||||||
|
|
||||||
nxt::ShaderModule vsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, R"(
|
nxt::ShaderModule vsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, R"(
|
||||||
#version 450
|
#version 450
|
||||||
|
|
|
@ -39,7 +39,7 @@ void init() {
|
||||||
swapchain = nxtSwapChainBuilderGetResult(builder);
|
swapchain = nxtSwapChainBuilderGetResult(builder);
|
||||||
nxtSwapChainBuilderRelease(builder);
|
nxtSwapChainBuilderRelease(builder);
|
||||||
}
|
}
|
||||||
nxtSwapChainConfigure(swapchain, NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM, NXT_TEXTURE_USAGE_BIT_OUTPUT_ATTACHMENT, NXT_TEXTURE_USAGE_BIT_OUTPUT_ATTACHMENT, 640, 480);
|
nxtSwapChainConfigure(swapchain, NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM, NXT_TEXTURE_USAGE_BIT_OUTPUT_ATTACHMENT, 640, 480);
|
||||||
|
|
||||||
const char* vs =
|
const char* vs =
|
||||||
"#version 450\n"
|
"#version 450\n"
|
||||||
|
|
|
@ -291,7 +291,7 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
||||||
|
|
||||||
initBuffers();
|
initBuffers();
|
||||||
initRender();
|
initRender();
|
||||||
|
|
|
@ -35,7 +35,7 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
||||||
|
|
||||||
struct {uint32_t a; float b;} s;
|
struct {uint32_t a; float b;} s;
|
||||||
memset(&s, 0, sizeof(s));
|
memset(&s, 0, sizeof(s));
|
||||||
|
|
|
@ -116,7 +116,7 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
||||||
|
|
||||||
initBuffers();
|
initBuffers();
|
||||||
|
|
||||||
|
|
|
@ -49,7 +49,7 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
||||||
|
|
||||||
initBuffers();
|
initBuffers();
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
||||||
|
|
||||||
initBuffers();
|
initBuffers();
|
||||||
|
|
||||||
|
|
|
@ -83,7 +83,7 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
||||||
|
|
||||||
initBuffers();
|
initBuffers();
|
||||||
initTextures();
|
initTextures();
|
||||||
|
|
|
@ -33,7 +33,7 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
||||||
|
|
||||||
nxt::ShaderModule vsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, R"(
|
nxt::ShaderModule vsModule = utils::CreateShaderModule(device, nxt::ShaderStage::Vertex, R"(
|
||||||
#version 450
|
#version 450
|
||||||
|
|
|
@ -43,7 +43,7 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
||||||
|
|
||||||
initBuffers();
|
initBuffers();
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,7 @@ void init() {
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
||||||
|
|
||||||
initBuffers();
|
initBuffers();
|
||||||
initTextures();
|
initTextures();
|
||||||
|
|
|
@ -464,7 +464,7 @@ namespace {
|
||||||
|
|
||||||
queue = device.CreateQueueBuilder().GetResult();
|
queue = device.CreateQueueBuilder().GetResult();
|
||||||
swapchain = GetSwapChain(device);
|
swapchain = GetSwapChain(device);
|
||||||
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, 640, 480);
|
||||||
|
|
||||||
renderpass = CreateDefaultRenderPass(device);
|
renderpass = CreateDefaultRenderPass(device);
|
||||||
depthStencilView = CreateDefaultDepthStencilView(device);
|
depthStencilView = CreateDefaultDepthStencilView(device);
|
||||||
|
|
|
@ -1051,7 +1051,6 @@
|
||||||
"args": [
|
"args": [
|
||||||
{"name": "format", "type": "texture format"},
|
{"name": "format", "type": "texture format"},
|
||||||
{"name": "allowedUsage", "type": "texture usage bit"},
|
{"name": "allowedUsage", "type": "texture usage bit"},
|
||||||
{"name": "initialUsage", "type": "texture usage bit"},
|
|
||||||
{"name": "width", "type": "uint32_t"},
|
{"name": "width", "type": "uint32_t"},
|
||||||
{"name": "height", "type": "uint32_t"}
|
{"name": "height", "type": "uint32_t"}
|
||||||
]
|
]
|
||||||
|
|
|
@ -34,24 +34,19 @@ namespace backend {
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SwapChainBase::Configure(nxt::TextureFormat format, nxt::TextureUsageBit allowedUsage, nxt::TextureUsageBit initialUsage, uint32_t width, uint32_t height) {
|
void SwapChainBase::Configure(nxt::TextureFormat format, nxt::TextureUsageBit allowedUsage, uint32_t width, uint32_t height) {
|
||||||
if (width == 0 || height == 0) {
|
if (width == 0 || height == 0) {
|
||||||
device->HandleError("Swap chain cannot be configured to zero size");
|
device->HandleError("Swap chain cannot be configured to zero size");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
allowedUsage |= nxt::TextureUsageBit::Present;
|
allowedUsage |= nxt::TextureUsageBit::Present;
|
||||||
if (!(HasZeroOrOneBits(initialUsage) && (initialUsage & allowedUsage))) {
|
|
||||||
device->HandleError("Swap chain configured with invalid texture usage");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this->format = format;
|
this->format = format;
|
||||||
this->allowedUsage = allowedUsage;
|
this->allowedUsage = allowedUsage;
|
||||||
this->initialUsage = initialUsage;
|
|
||||||
this->width = width;
|
this->width = width;
|
||||||
this->height = height;
|
this->height = height;
|
||||||
implementation.Configure(implementation.userData,
|
implementation.Configure(implementation.userData,
|
||||||
static_cast<nxtTextureFormat>(format), static_cast<nxtTextureUsageBit>(allowedUsage), static_cast<nxtTextureUsageBit>(initialUsage), width, height);
|
static_cast<nxtTextureFormat>(format), static_cast<nxtTextureUsageBit>(allowedUsage), width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureBase* SwapChainBase::GetNextTexture() {
|
TextureBase* SwapChainBase::GetNextTexture() {
|
||||||
|
@ -67,7 +62,6 @@ namespace backend {
|
||||||
builder->SetFormat(format);
|
builder->SetFormat(format);
|
||||||
builder->SetMipLevels(1);
|
builder->SetMipLevels(1);
|
||||||
builder->SetAllowedUsage(allowedUsage);
|
builder->SetAllowedUsage(allowedUsage);
|
||||||
builder->SetInitialUsage(initialUsage);
|
|
||||||
|
|
||||||
auto* texture = GetNextTextureImpl(builder);
|
auto* texture = GetNextTextureImpl(builder);
|
||||||
lastNextTexture = texture;
|
lastNextTexture = texture;
|
||||||
|
|
|
@ -32,7 +32,7 @@ namespace backend {
|
||||||
DeviceBase* GetDevice();
|
DeviceBase* GetDevice();
|
||||||
|
|
||||||
// NXT API
|
// NXT API
|
||||||
void Configure(nxt::TextureFormat format, nxt::TextureUsageBit allowedUsage, nxt::TextureUsageBit initialUsage, uint32_t width, uint32_t height);
|
void Configure(nxt::TextureFormat format, nxt::TextureUsageBit allowedUsage, uint32_t width, uint32_t height);
|
||||||
TextureBase* GetNextTexture();
|
TextureBase* GetNextTexture();
|
||||||
void Present(TextureBase* texture);
|
void Present(TextureBase* texture);
|
||||||
|
|
||||||
|
@ -45,7 +45,6 @@ namespace backend {
|
||||||
nxtSwapChainImplementation implementation = {};
|
nxtSwapChainImplementation implementation = {};
|
||||||
nxt::TextureFormat format = {};
|
nxt::TextureFormat format = {};
|
||||||
nxt::TextureUsageBit allowedUsage;
|
nxt::TextureUsageBit allowedUsage;
|
||||||
nxt::TextureUsageBit initialUsage;
|
|
||||||
uint32_t width = 0;
|
uint32_t width = 0;
|
||||||
uint32_t height = 0;
|
uint32_t height = 0;
|
||||||
TextureBase* lastNextTexture = nullptr;
|
TextureBase* lastNextTexture = nullptr;
|
||||||
|
|
|
@ -35,7 +35,7 @@ typedef struct {
|
||||||
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, nxtTextureUsageBit initialUsage, uint32_t width, uint32_t height);
|
nxtSwapChainError (*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);
|
nxtSwapChainError (*GetNextTexture)(void* userData, nxtSwapChainNextTexture* nextTexture);
|
||||||
|
|
|
@ -142,7 +142,7 @@ void NXTTest::SetUp() {
|
||||||
swapchain = device.CreateSwapChainBuilder()
|
swapchain = device.CreateSwapChainBuilder()
|
||||||
.SetImplementation(binding->GetSwapChainImplementation())
|
.SetImplementation(binding->GetSwapChainImplementation())
|
||||||
.GetResult();
|
.GetResult();
|
||||||
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, nxt::TextureUsageBit::OutputAttachment, 400, 400);
|
swapchain.Configure(nxt::TextureFormat::R8G8B8A8Unorm, nxt::TextureUsageBit::OutputAttachment, 400, 400);
|
||||||
|
|
||||||
device.SetErrorCallback(DeviceErrorCauseTestFailure, 0);
|
device.SetErrorCallback(DeviceErrorCauseTestFailure, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,7 @@ namespace utils {
|
||||||
commandQueue = backend::d3d12::GetCommandQueue(backendDevice);
|
commandQueue = backend::d3d12::GetCommandQueue(backendDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit allowedUsage, nxtTextureUsageBit initialUsage,
|
nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit allowedUsage,
|
||||||
uint32_t width, uint32_t height) {
|
uint32_t width, 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";
|
||||||
|
@ -199,25 +199,6 @@ namespace utils {
|
||||||
lastSerialRenderTargetWasUsed[n] = initialSerial;
|
lastSerialRenderTargetWasUsed[n] = initialSerial;
|
||||||
}
|
}
|
||||||
|
|
||||||
renderTargetResourceState = D3D12ResourceState(initialUsage);
|
|
||||||
|
|
||||||
// Transition the first frame. Resources are initially created in PRESENT state
|
|
||||||
if (renderTargetResourceState != D3D12_RESOURCE_STATE_PRESENT) {
|
|
||||||
ComPtr<ID3D12GraphicsCommandList> commandList = {};
|
|
||||||
backend::d3d12::OpenCommandList(backendDevice, &commandList);
|
|
||||||
|
|
||||||
D3D12_RESOURCE_BARRIER resourceBarrier;
|
|
||||||
resourceBarrier.Transition.pResource = renderTargetResources[renderTargetIndex].Get();
|
|
||||||
resourceBarrier.Transition.StateBefore = D3D12_RESOURCE_STATE_PRESENT;
|
|
||||||
resourceBarrier.Transition.StateAfter = renderTargetResourceState;
|
|
||||||
resourceBarrier.Transition.Subresource = D3D12_RESOURCE_BARRIER_ALL_SUBRESOURCES;
|
|
||||||
resourceBarrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;
|
|
||||||
resourceBarrier.Flags = D3D12_RESOURCE_BARRIER_FLAG_NONE;
|
|
||||||
commandList->ResourceBarrier(1, &resourceBarrier);
|
|
||||||
ASSERT_SUCCESS(commandList->Close());
|
|
||||||
backend::d3d12::ExecuteCommandLists(backendDevice, { commandList.Get() });
|
|
||||||
}
|
|
||||||
|
|
||||||
return NXT_SWAP_CHAIN_NO_ERROR;
|
return NXT_SWAP_CHAIN_NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,7 @@ namespace utils {
|
||||||
commandQueue = [mtlDevice newCommandQueue];
|
commandQueue = [mtlDevice newCommandQueue];
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit, nxtTextureUsageBit,
|
nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit,
|
||||||
uint32_t width, uint32_t height) {
|
uint32_t width, 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";
|
||||||
|
|
|
@ -69,7 +69,7 @@ namespace utils {
|
||||||
GL_TEXTURE_2D, backTexture, 0);
|
GL_TEXTURE_2D, backTexture, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit, nxtTextureUsageBit,
|
nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit,
|
||||||
uint32_t width, uint32_t height) {
|
uint32_t width, 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";
|
||||||
|
|
|
@ -28,9 +28,8 @@ namespace utils {
|
||||||
impl.Destroy = [](void* userData) {
|
impl.Destroy = [](void* userData) {
|
||||||
delete reinterpret_cast<TImpl*>(userData);
|
delete reinterpret_cast<TImpl*>(userData);
|
||||||
};
|
};
|
||||||
impl.Configure = [](void* userData, nxtTextureFormat format, nxtTextureUsageBit allowedUsage, nxtTextureUsageBit initialUsage, uint32_t width, uint32_t height) {
|
impl.Configure = [](void* userData, nxtTextureFormat format, nxtTextureUsageBit allowedUsage, uint32_t width, uint32_t height) {
|
||||||
return reinterpret_cast<TImpl*>(userData)->Configure(
|
return reinterpret_cast<TImpl*>(userData)->Configure(format, allowedUsage, width, height);
|
||||||
format, allowedUsage, initialUsage, width, height);
|
|
||||||
};
|
};
|
||||||
impl.GetNextTexture = [](void* userData, nxtSwapChainNextTexture* nextTexture) {
|
impl.GetNextTexture = [](void* userData, nxtSwapChainNextTexture* nextTexture) {
|
||||||
return reinterpret_cast<TImpl*>(userData)->GetNextTexture(
|
return reinterpret_cast<TImpl*>(userData)->GetNextTexture(
|
||||||
|
|
Loading…
Reference in New Issue