diff --git a/examples/Animometer.cpp b/examples/Animometer.cpp index 86802a08ed..1511192664 100644 --- a/examples/Animometer.cpp +++ b/examples/Animometer.cpp @@ -49,7 +49,7 @@ void init() { queue = device.CreateQueueBuilder().GetResult(); 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"( #version 450 diff --git a/examples/CHelloTriangle.cpp b/examples/CHelloTriangle.cpp index 9b68052ce1..19f727ee2b 100644 --- a/examples/CHelloTriangle.cpp +++ b/examples/CHelloTriangle.cpp @@ -39,7 +39,7 @@ void init() { swapchain = nxtSwapChainBuilderGetResult(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 = "#version 450\n" diff --git a/examples/ComputeBoids.cpp b/examples/ComputeBoids.cpp index 52ad72100f..5434c68a1e 100644 --- a/examples/ComputeBoids.cpp +++ b/examples/ComputeBoids.cpp @@ -291,7 +291,7 @@ void init() { queue = device.CreateQueueBuilder().GetResult(); 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(); initRender(); diff --git a/examples/HelloCompute.cpp b/examples/HelloCompute.cpp index 5db366bc24..7b6a5937fb 100644 --- a/examples/HelloCompute.cpp +++ b/examples/HelloCompute.cpp @@ -35,7 +35,7 @@ void init() { queue = device.CreateQueueBuilder().GetResult(); 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; memset(&s, 0, sizeof(s)); diff --git a/examples/HelloDepthStencil.cpp b/examples/HelloDepthStencil.cpp index 97d8d69db3..97439a2beb 100644 --- a/examples/HelloDepthStencil.cpp +++ b/examples/HelloDepthStencil.cpp @@ -116,7 +116,7 @@ void init() { queue = device.CreateQueueBuilder().GetResult(); 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(); diff --git a/examples/HelloIndices.cpp b/examples/HelloIndices.cpp index 93092f7e32..5c94277c72 100644 --- a/examples/HelloIndices.cpp +++ b/examples/HelloIndices.cpp @@ -49,7 +49,7 @@ void init() { queue = device.CreateQueueBuilder().GetResult(); 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(); diff --git a/examples/HelloInstancing.cpp b/examples/HelloInstancing.cpp index a5c11f88d9..c26e7ef36f 100644 --- a/examples/HelloInstancing.cpp +++ b/examples/HelloInstancing.cpp @@ -52,7 +52,7 @@ void init() { queue = device.CreateQueueBuilder().GetResult(); 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(); diff --git a/examples/HelloTriangle.cpp b/examples/HelloTriangle.cpp index b9c9334738..90aec10653 100644 --- a/examples/HelloTriangle.cpp +++ b/examples/HelloTriangle.cpp @@ -83,7 +83,7 @@ void init() { queue = device.CreateQueueBuilder().GetResult(); 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(); initTextures(); diff --git a/examples/HelloUBO.cpp b/examples/HelloUBO.cpp index a01b1306dc..edd92d65e6 100644 --- a/examples/HelloUBO.cpp +++ b/examples/HelloUBO.cpp @@ -33,7 +33,7 @@ void init() { queue = device.CreateQueueBuilder().GetResult(); 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"( #version 450 diff --git a/examples/HelloVertices.cpp b/examples/HelloVertices.cpp index 8b93742c5b..6e4adabb27 100644 --- a/examples/HelloVertices.cpp +++ b/examples/HelloVertices.cpp @@ -43,7 +43,7 @@ void init() { queue = device.CreateQueueBuilder().GetResult(); 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(); diff --git a/examples/RenderToTexture.cpp b/examples/RenderToTexture.cpp index de9df40ea9..7e75b36565 100644 --- a/examples/RenderToTexture.cpp +++ b/examples/RenderToTexture.cpp @@ -167,7 +167,7 @@ void init() { queue = device.CreateQueueBuilder().GetResult(); 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(); initTextures(); diff --git a/examples/glTFViewer/glTFViewer.cpp b/examples/glTFViewer/glTFViewer.cpp index cbf343986b..2273f87ba4 100644 --- a/examples/glTFViewer/glTFViewer.cpp +++ b/examples/glTFViewer/glTFViewer.cpp @@ -464,7 +464,7 @@ namespace { queue = device.CreateQueueBuilder().GetResult(); 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); depthStencilView = CreateDefaultDepthStencilView(device); diff --git a/next.json b/next.json index 002b2f1c5c..9671852caa 100644 --- a/next.json +++ b/next.json @@ -1051,7 +1051,6 @@ "args": [ {"name": "format", "type": "texture format"}, {"name": "allowedUsage", "type": "texture usage bit"}, - {"name": "initialUsage", "type": "texture usage bit"}, {"name": "width", "type": "uint32_t"}, {"name": "height", "type": "uint32_t"} ] diff --git a/src/backend/SwapChain.cpp b/src/backend/SwapChain.cpp index 4224ffb13d..a09f8e2eed 100644 --- a/src/backend/SwapChain.cpp +++ b/src/backend/SwapChain.cpp @@ -34,24 +34,19 @@ namespace backend { 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) { device->HandleError("Swap chain cannot be configured to zero size"); return; } allowedUsage |= nxt::TextureUsageBit::Present; - if (!(HasZeroOrOneBits(initialUsage) && (initialUsage & allowedUsage))) { - device->HandleError("Swap chain configured with invalid texture usage"); - return; - } this->format = format; this->allowedUsage = allowedUsage; - this->initialUsage = initialUsage; this->width = width; this->height = height; implementation.Configure(implementation.userData, - static_cast(format), static_cast(allowedUsage), static_cast(initialUsage), width, height); + static_cast(format), static_cast(allowedUsage), width, height); } TextureBase* SwapChainBase::GetNextTexture() { @@ -67,7 +62,6 @@ namespace backend { builder->SetFormat(format); builder->SetMipLevels(1); builder->SetAllowedUsage(allowedUsage); - builder->SetInitialUsage(initialUsage); auto* texture = GetNextTextureImpl(builder); lastNextTexture = texture; diff --git a/src/backend/SwapChain.h b/src/backend/SwapChain.h index 77006a6047..3e931340fa 100644 --- a/src/backend/SwapChain.h +++ b/src/backend/SwapChain.h @@ -32,7 +32,7 @@ namespace backend { DeviceBase* GetDevice(); // 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(); void Present(TextureBase* texture); @@ -45,7 +45,6 @@ namespace backend { nxtSwapChainImplementation implementation = {}; nxt::TextureFormat format = {}; nxt::TextureUsageBit allowedUsage; - nxt::TextureUsageBit initialUsage; uint32_t width = 0; uint32_t height = 0; TextureBase* lastNextTexture = nullptr; diff --git a/src/include/nxt/nxt_wsi.h b/src/include/nxt/nxt_wsi.h index 85902813f6..76828ca741 100644 --- a/src/include/nxt/nxt_wsi.h +++ b/src/include/nxt/nxt_wsi.h @@ -35,7 +35,7 @@ typedef struct { void (*Destroy)(void* userData); /// 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. nxtSwapChainError (*GetNextTexture)(void* userData, nxtSwapChainNextTexture* nextTexture); diff --git a/src/tests/NXTTest.cpp b/src/tests/NXTTest.cpp index 4f9d89398c..61851a0143 100644 --- a/src/tests/NXTTest.cpp +++ b/src/tests/NXTTest.cpp @@ -142,7 +142,7 @@ void NXTTest::SetUp() { swapchain = device.CreateSwapChainBuilder() .SetImplementation(binding->GetSwapChainImplementation()) .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); } diff --git a/src/utils/D3D12Binding.cpp b/src/utils/D3D12Binding.cpp index fe90d70312..3e99eac52e 100644 --- a/src/utils/D3D12Binding.cpp +++ b/src/utils/D3D12Binding.cpp @@ -156,7 +156,7 @@ namespace utils { 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) { if (format != NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM) { return "unsupported format"; @@ -199,25 +199,6 @@ namespace utils { lastSerialRenderTargetWasUsed[n] = initialSerial; } - renderTargetResourceState = D3D12ResourceState(initialUsage); - - // Transition the first frame. Resources are initially created in PRESENT state - if (renderTargetResourceState != D3D12_RESOURCE_STATE_PRESENT) { - ComPtr 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; } diff --git a/src/utils/MetalBinding.mm b/src/utils/MetalBinding.mm index 89e0bce47c..e5953b1af3 100644 --- a/src/utils/MetalBinding.mm +++ b/src/utils/MetalBinding.mm @@ -68,7 +68,7 @@ namespace utils { commandQueue = [mtlDevice newCommandQueue]; } - nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit, nxtTextureUsageBit, + nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit, uint32_t width, uint32_t height) { if (format != NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM) { return "unsupported format"; diff --git a/src/utils/OpenGLBinding.cpp b/src/utils/OpenGLBinding.cpp index 4aabe4db2f..62e8bbb101 100644 --- a/src/utils/OpenGLBinding.cpp +++ b/src/utils/OpenGLBinding.cpp @@ -69,7 +69,7 @@ namespace utils { GL_TEXTURE_2D, backTexture, 0); } - nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit, nxtTextureUsageBit, + nxtSwapChainError Configure(nxtTextureFormat format, nxtTextureUsageBit, uint32_t width, uint32_t height) { if (format != NXT_TEXTURE_FORMAT_R8_G8_B8_A8_UNORM) { return "unsupported format"; diff --git a/src/utils/SwapChainImpl.h b/src/utils/SwapChainImpl.h index 057044189a..1bef573f28 100644 --- a/src/utils/SwapChainImpl.h +++ b/src/utils/SwapChainImpl.h @@ -28,9 +28,8 @@ namespace utils { impl.Destroy = [](void* userData) { delete reinterpret_cast(userData); }; - impl.Configure = [](void* userData, nxtTextureFormat format, nxtTextureUsageBit allowedUsage, nxtTextureUsageBit initialUsage, uint32_t width, uint32_t height) { - return reinterpret_cast(userData)->Configure( - format, allowedUsage, initialUsage, width, height); + impl.Configure = [](void* userData, nxtTextureFormat format, nxtTextureUsageBit allowedUsage, uint32_t width, uint32_t height) { + return reinterpret_cast(userData)->Configure(format, allowedUsage, width, height); }; impl.GetNextTexture = [](void* userData, nxtSwapChainNextTexture* nextTexture) { return reinterpret_cast(userData)->GetNextTexture(