From 77755b9f55a4f475ca7a545fe1455624af744e4b Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Tue, 14 Sep 2021 16:02:00 +0000 Subject: [PATCH] Remove deprecated wgpu::StoreOp::Clear Bug: dawn:937 Change-Id: I80cdb3b6b3caecc83a6e8cc009bb494179808cd9 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/63742 Commit-Queue: Corentin Wallez Reviewed-by: Brandon Jones Reviewed-by: Austin Eng --- dawn.json | 3 +- src/dawn_native/CommandBuffer.cpp | 1 - src/dawn_native/CommandEncoder.cpp | 14 ++----- .../d3d12/RenderPassBuilderD3D12.cpp | 3 +- src/dawn_native/metal/CommandBufferMTL.mm | 4 -- src/dawn_native/opengl/CommandBufferGL.cpp | 3 +- src/tests/end2end/DeprecatedAPITests.cpp | 40 ------------------- 7 files changed, 6 insertions(+), 62 deletions(-) diff --git a/dawn.json b/dawn.json index 86326c869c..6ee48d8bd8 100644 --- a/dawn.json +++ b/dawn.json @@ -1094,8 +1094,7 @@ "category": "enum", "values": [ {"value": 0, "name": "store"}, - {"value": 1, "name": "discard"}, - {"value": 2, "name": "clear"} + {"value": 1, "name": "discard"} ] }, "origin 3D": { diff --git a/src/dawn_native/CommandBuffer.cpp b/src/dawn_native/CommandBuffer.cpp index 748cc31d37..43455c2178 100644 --- a/src/dawn_native/CommandBuffer.cpp +++ b/src/dawn_native/CommandBuffer.cpp @@ -127,7 +127,6 @@ namespace dawn_native { break; case wgpu::StoreOp::Discard: - case wgpu::StoreOp::Clear: view->GetTexture()->SetIsSubresourceContentInitialized(false, range); break; } diff --git a/src/dawn_native/CommandEncoder.cpp b/src/dawn_native/CommandEncoder.cpp index eb38cf45e7..74a931446a 100644 --- a/src/dawn_native/CommandEncoder.cpp +++ b/src/dawn_native/CommandEncoder.cpp @@ -41,14 +41,6 @@ namespace dawn_native { namespace { - MaybeError ValidateDeprecatedStoreOp(DeviceBase* device, wgpu::StoreOp value) { - if (value == wgpu::StoreOp::Clear) { - device->EmitDeprecationWarning( - "The 'clear' storeOp is deprecated. Use 'discard' instead."); - } - return ValidateStoreOp(value); - } - MaybeError ValidateB2BCopyAlignment(uint64_t dataSize, uint64_t srcOffset, uint64_t dstOffset) { @@ -232,7 +224,7 @@ namespace dawn_native { } DAWN_TRY(ValidateLoadOp(colorAttachment.loadOp)); - DAWN_TRY(ValidateDeprecatedStoreOp(device, colorAttachment.storeOp)); + DAWN_TRY(ValidateStoreOp(colorAttachment.storeOp)); if (colorAttachment.loadOp == wgpu::LoadOp::Clear) { if (std::isnan(colorAttachment.clearColor.r) || @@ -286,8 +278,8 @@ namespace dawn_native { DAWN_TRY(ValidateLoadOp(depthStencilAttachment->depthLoadOp)); DAWN_TRY(ValidateLoadOp(depthStencilAttachment->stencilLoadOp)); - DAWN_TRY(ValidateDeprecatedStoreOp(device, depthStencilAttachment->depthStoreOp)); - DAWN_TRY(ValidateDeprecatedStoreOp(device, depthStencilAttachment->stencilStoreOp)); + DAWN_TRY(ValidateStoreOp(depthStencilAttachment->depthStoreOp)); + DAWN_TRY(ValidateStoreOp(depthStencilAttachment->stencilStoreOp)); if (attachment->GetAspects() == (Aspect::Depth | Aspect::Stencil) && depthStencilAttachment->depthReadOnly != depthStencilAttachment->stencilReadOnly) { diff --git a/src/dawn_native/d3d12/RenderPassBuilderD3D12.cpp b/src/dawn_native/d3d12/RenderPassBuilderD3D12.cpp index 147531190a..47da954c22 100644 --- a/src/dawn_native/d3d12/RenderPassBuilderD3D12.cpp +++ b/src/dawn_native/d3d12/RenderPassBuilderD3D12.cpp @@ -36,7 +36,6 @@ namespace dawn_native { namespace d3d12 { D3D12_RENDER_PASS_ENDING_ACCESS_TYPE D3D12EndingAccessType(wgpu::StoreOp storeOp) { switch (storeOp) { case wgpu::StoreOp::Discard: - case wgpu::StoreOp::Clear: return D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_DISCARD; case wgpu::StoreOp::Store: return D3D12_RENDER_PASS_ENDING_ACCESS_TYPE_PRESERVE; @@ -56,7 +55,7 @@ namespace dawn_native { namespace d3d12 { ToBackend(resolveDestination->GetTexture())->GetD3D12Resource(); // Clear or preserve the resolve source. - if (storeOp == wgpu::StoreOp::Discard || storeOp == wgpu::StoreOp::Clear) { + if (storeOp == wgpu::StoreOp::Discard) { resolveParameters.PreserveResolveSource = false; } else if (storeOp == wgpu::StoreOp::Store) { resolveParameters.PreserveResolveSource = true; diff --git a/src/dawn_native/metal/CommandBufferMTL.mm b/src/dawn_native/metal/CommandBufferMTL.mm index f41cff71ee..45d1ed1fc4 100644 --- a/src/dawn_native/metal/CommandBufferMTL.mm +++ b/src/dawn_native/metal/CommandBufferMTL.mm @@ -101,7 +101,6 @@ namespace dawn_native { namespace metal { kMTLStoreActionStoreAndMultisampleResolve; break; case wgpu::StoreOp::Discard: - case wgpu::StoreOp::Clear: descriptor.colorAttachments[i].storeAction = MTLStoreActionMultisampleResolve; break; @@ -112,7 +111,6 @@ namespace dawn_native { namespace metal { descriptor.colorAttachments[i].storeAction = MTLStoreActionStore; break; case wgpu::StoreOp::Discard: - case wgpu::StoreOp::Clear: descriptor.colorAttachments[i].storeAction = MTLStoreActionDontCare; break; } @@ -137,7 +135,6 @@ namespace dawn_native { namespace metal { break; case wgpu::StoreOp::Discard: - case wgpu::StoreOp::Clear: descriptor.depthAttachment.storeAction = MTLStoreActionDontCare; break; } @@ -165,7 +162,6 @@ namespace dawn_native { namespace metal { break; case wgpu::StoreOp::Discard: - case wgpu::StoreOp::Clear: descriptor.stencilAttachment.storeAction = MTLStoreActionDontCare; break; } diff --git a/src/dawn_native/opengl/CommandBufferGL.cpp b/src/dawn_native/opengl/CommandBufferGL.cpp index 1534e090d6..fdb1eba51a 100644 --- a/src/dawn_native/opengl/CommandBufferGL.cpp +++ b/src/dawn_native/opengl/CommandBufferGL.cpp @@ -1055,8 +1055,7 @@ namespace dawn_native { namespace opengl { } } - if (attachmentInfo->storeOp == wgpu::StoreOp::Discard || - attachmentInfo->storeOp == wgpu::StoreOp::Clear) { + if (attachmentInfo->storeOp == wgpu::StoreOp::Discard) { // TODO(natlee@microsoft.com): call glDiscard to do optimization } } diff --git a/src/tests/end2end/DeprecatedAPITests.cpp b/src/tests/end2end/DeprecatedAPITests.cpp index e604ce883e..3248c99ab5 100644 --- a/src/tests/end2end/DeprecatedAPITests.cpp +++ b/src/tests/end2end/DeprecatedAPITests.cpp @@ -34,46 +34,6 @@ class DeprecationTests : public DawnTest { } }; -// Test that StoreOp::Clear is deprecated. -TEST_P(DeprecationTests, StoreOpClear) { - utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1); - wgpu::CommandEncoder encoder = device.CreateCommandEncoder(); - wgpu::RenderPassEncoder pass; - - // Check that a storeOp of Clear for color attachments raises a validation warning. - renderPass.renderPassInfo.cColorAttachments[0].storeOp = wgpu::StoreOp::Clear; - - EXPECT_DEPRECATION_WARNING(pass = encoder.BeginRenderPass(&renderPass.renderPassInfo)); - pass.EndPass(); - - // Check that a storeOp of Clear for depth/stencil attachments raises a validation warning. - wgpu::TextureDescriptor descriptor; - descriptor.dimension = wgpu::TextureDimension::e2D; - descriptor.size = {1, 1, 1}; - descriptor.sampleCount = 1; - descriptor.format = wgpu::TextureFormat::Depth24PlusStencil8; - descriptor.mipLevelCount = 1; - descriptor.usage = wgpu::TextureUsage::RenderAttachment; - wgpu::Texture depthStencil = device.CreateTexture(&descriptor); - - wgpu::RenderPassDepthStencilAttachment* depthAttachment = - &renderPass.renderPassInfo.cDepthStencilAttachmentInfo; - renderPass.renderPassInfo.depthStencilAttachment = depthAttachment; - depthAttachment->view = depthStencil.CreateView(); - - renderPass.renderPassInfo.cColorAttachments[0].storeOp = wgpu::StoreOp::Discard; - depthAttachment->depthStoreOp = wgpu::StoreOp::Clear; - - EXPECT_DEPRECATION_WARNING(pass = encoder.BeginRenderPass(&renderPass.renderPassInfo)); - pass.EndPass(); - - depthAttachment->depthStoreOp = wgpu::StoreOp::Discard; - depthAttachment->stencilStoreOp = wgpu::StoreOp::Clear; - - EXPECT_DEPRECATION_WARNING(pass = encoder.BeginRenderPass(&renderPass.renderPassInfo)); - pass.EndPass(); -} - // Test that readonly storage textures are deprecated TEST_P(DeprecationTests, ReadOnlyStorageTextures) { // Control case: WriteOnly storage textures are allowed.