Issue 8582 in angleproject: WebGPU: Add framebuffers with basic clear operations

2 views
Skip to first unread message

geoff… via monorail

unread,
Mar 5, 2024, 1:43:00 PM3/5/24
to angleproj...@googlegroups.com
Status: Available
Owner: mpde...@chromium.org
OS: All
Priority: Medium
Renderer: WebGPU
Type: Defect

New issue 8582 by geoff...@chromium.org: WebGPU: Add framebuffers with basic clear operations
https://bugs.chromium.org/p/angleproject/issues/detail?id=8582

Implement enough framebuffer functionality to be able to execute:

glFramebufferTexture2D(...) // Bind textures to framebuffers
glClear(GL_COLOR_BUFFER_BIT) // Clear the textures

To do this, we need a wrapper for a render target. See RenderTargetMtl as an example.
- No multisampling is required yet.
- Will likely store a webgpu::TextureView to reference the specific level of the texture being rendered to.

Store a list of current color/depth/stencil render targets in FramebufferWgpu and update their state based on the processing of dirty bits in FramebufferWgpu::syncState.



WebGPU doesn't have an explicit clear command, clears are done with LoadOp::Clear. To do this we need some renderpass infrastructure:
- Per ContextWgpu, create a wgpu::CommandEncoder at initialization.
- Add methods to ContextWpu for managing the current render pass:
- A method to start or ensure a renderpass has started. Will end the current render pass if the new one is incompatible. ex: ensureRenderpassStarted(desc)
- A method to end the current render pass (giving a reason for has been helpful for the VK backend to help eliminate redundant renderpasses [0])
- A flush method that submits all accumulated render passes to the gpu (calls commandEncoder.Finish() and queue.Submit())


At a high level, it will look like a double nested loop:

for (each flush) {
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
for (each framebuffer change) {
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(..desc..);

// Encode commands

pass.Finish();
}

wgpu::CommandBuffer commands = encoder.Finish();
queue.Submit(1, &commands);
}


To implement the clear, start a new renderpass with the load op set to clear and immediately end it. This is not the most optimal and doesn't handle a few edge cases that will be added later such as:
- If the current render pass has already started, it may be possible to clear with a draw command.
- OpenGL supports partial clears (by setting viewport, scissor and color masks), these will require draw calls to implement.


[0] https://source.chromium.org/chromium/chromium/src/+/main:third_party/angle/src/libANGLE/renderer/vulkan/vk_utils.h;l=1199;drc=f4a00cc248dd2dc8ec8759fb51620d47b5114090

--
You received this message because:
1. The project was configured to send all issue notifications to this address

You may adjust your notification preferences at:
https://bugs.chromium.org/hosting/settings

Git Watcher via monorail

unread,
Mar 22, 2024, 4:39:15 PM3/22/24
to angleproj...@googlegroups.com

Comment #1 on issue 8582 by Git Watcher: WebGPU: Add framebuffers with basic clear operations
https://bugs.chromium.org/p/angleproject/issues/detail?id=8582#c1

The following revision refers to this bug:
https://chromium.googlesource.com/angle/angle/+/1bd82319c75a570d9ade8a3cf5c1f8b38d105dac

commit 1bd82319c75a570d9ade8a3cf5c1f8b38d105dac
Author: Matthew Denton <mpde...@chromium.org>
Date: Fri Mar 22 12:00:11 2024

Add RenderTargetWgpu

Based on RenderTargetMtl without any multisampling support for now.

Bug: angleproject:8582
Change-Id: I4c77e747b341f08a0dd88f507e6d805d34a01d24
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5386899
Reviewed-by: Shahbaz Youssefi <syou...@chromium.org>
Reviewed-by: Liza Burakova <li...@chromium.org>
Commit-Queue: Matthew Denton <mpde...@chromium.org>

[add] https://crrev.com/1bd82319c75a570d9ade8a3cf5c1f8b38d105dac/src/libANGLE/renderer/wgpu/RenderTargetWgpu.cpp
[add] https://crrev.com/1bd82319c75a570d9ade8a3cf5c1f8b38d105dac/src/libANGLE/renderer/wgpu/RenderTargetWgpu.h
[modify] https://crrev.com/1bd82319c75a570d9ade8a3cf5c1f8b38d105dac/src/libANGLE/renderer/wgpu/wgpu_sources.gni
[add] https://crrev.com/1bd82319c75a570d9ade8a3cf5c1f8b38d105dac/src/libANGLE/renderer/wgpu/wgpu_utils.h
[modify] https://crrev.com/1bd82319c75a570d9ade8a3cf5c1f8b38d105dac/src/libANGLE/renderer/wgpu/wgpu_helpers.h
[modify] https://crrev.com/1bd82319c75a570d9ade8a3cf5c1f8b38d105dac/src/libANGLE/renderer/wgpu/wgpu_helpers.cpp
[add] https://crrev.com/1bd82319c75a570d9ade8a3cf5c1f8b38d105dac/src/libANGLE/renderer/wgpu/wgpu_utils.cpp

Git Watcher via monorail

unread,
Mar 25, 2024, 6:33:14 PM3/25/24
to angleproj...@googlegroups.com

Comment #2 on issue 8582 by Git Watcher: WebGPU: Add framebuffers with basic clear operations
https://bugs.chromium.org/p/angleproject/issues/detail?id=8582#c2


The following revision refers to this bug:
https://chromium.googlesource.com/angle/angle/+/eacd6acdcb008f8ee1d094c308fc4d5146526384

commit eacd6acdcb008f8ee1d094c308fc4d5146526384
Author: Matthew Denton <mpde...@chromium.org>
Date: Fri Mar 22 12:38:13 2024

Add RenderTargetCache to FramebufferWgpu

...and update it based on dirty bits.

Bug: angleproject:8582
Change-Id: If227392b24b3fc649d48cb1bce1144400cd98d70
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5386900

Reviewed-by: Shahbaz Youssefi <syou...@chromium.org>
Reviewed-by: Liza Burakova <li...@chromium.org>
Commit-Queue: Matthew Denton <mpde...@chromium.org>

geoff… via monorail

unread,
Apr 4, 2024, 9:02:04 AM4/4/24
to angleproj...@googlegroups.com
Issue 8582: WebGPU: Add framebuffers with basic clear operations
https://bugs.chromium.org/p/angleproject/issues/detail?id=8582

This issue is now blocking issue 8653.
See https://bugs.chromium.org/p/angleproject/issues/detail?id=8653

Git Watcher via monorail

unread,
Apr 4, 2024, 2:54:13 PM4/4/24
to angleproj...@googlegroups.com

Comment #4 on issue 8582 by Git Watcher: WebGPU: Add framebuffers with basic clear operations
https://bugs.chromium.org/p/angleproject/issues/detail?id=8582#c4


The following revision refers to this bug:
https://chromium.googlesource.com/angle/angle/+/5c6a531eca71fb09cf2806f97f618cb2b1cf1883

commit 5c6a531eca71fb09cf2806f97f618cb2b1cf1883
Author: Matthew Denton <mpde...@chromium.org>
Date: Wed Apr 03 09:53:13 2024

Add ContextWgpu methods for managing current render pass

For simplicity ensureRenderPassStarted() just ends the current
render pass and starts a new one.

Bug: angleproject:8582
Change-Id: I929526cf2574fa33309310e7f60191c10ab3bf7a
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5388075
Commit-Queue: Matthew Denton <mpde...@chromium.org>
Reviewed-by: Liza Burakova <li...@chromium.org>
Reviewed-by: Shahbaz Youssefi <syou...@chromium.org>

[modify] https://crrev.com/5c6a531eca71fb09cf2806f97f618cb2b1cf1883/src/libANGLE/renderer/wgpu/ContextWgpu.cpp
[modify] https://crrev.com/5c6a531eca71fb09cf2806f97f618cb2b1cf1883/src/libANGLE/renderer/wgpu/wgpu_utils.h
[modify] https://crrev.com/5c6a531eca71fb09cf2806f97f618cb2b1cf1883/src/libANGLE/renderer/wgpu/DisplayWgpu.h
[modify] https://crrev.com/5c6a531eca71fb09cf2806f97f618cb2b1cf1883/src/libANGLE/renderer/wgpu/ContextWgpu.h

Git Watcher via monorail

unread,
Apr 5, 2024, 2:26:14 PM4/5/24
to angleproj...@googlegroups.com

Comment #5 on issue 8582 by Git Watcher: WebGPU: Add framebuffers with basic clear operations
https://bugs.chromium.org/p/angleproject/issues/detail?id=8582#c5


The following revision refers to this bug:
https://chromium.googlesource.com/angle/angle/+/be42f20b70ea72acb47e32335ea142fdd3a6375a

commit be42f20b70ea72acb47e32335ea142fdd3a6375a
Author: Matthew Denton <mpde...@chromium.org>
Date: Fri Mar 22 12:45:46 2024

Start implementing glClear

Currently, because both SurfaceWgpu::getAttachmentRenderTarget() and
TextureWgpu::getAttachmentRenderTarget() are unimplemented, there is
no actual RenderTargetWgpu in the RenderTargetCache to clear.

Bug: angleproject:8582
Change-Id: I9ad33c57d533d81178d7d2a802d35b106ece5848
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5388076

Reviewed-by: Shahbaz Youssefi <syou...@chromium.org>
Reviewed-by: Liza Burakova <li...@chromium.org>
Commit-Queue: Matthew Denton <mpde...@chromium.org>

Git Watcher via monorail

unread,
Apr 15, 2024, 6:35:13 PM4/15/24
to angleproj...@googlegroups.com

Comment #6 on issue 8582 by Git Watcher: WebGPU: Add framebuffers with basic clear operations
https://bugs.chromium.org/p/angleproject/issues/detail?id=8582#c6


The following revision refers to this bug:
https://chromium.googlesource.com/angle/angle/+/6557da03c85eee30448e1fefc2d89bdc348c580d

commit 6557da03c85eee30448e1fefc2d89bdc348c580d
Author: Matthew Denton <mpde...@chromium.org>
Date: Fri Mar 22 12:49:59 2024

Implement TextureWgpu::getAttachmentRenderTarget()

Most of this is copied from TextureVk::getAttachmentRenderTarget() with
parts removed to make it simpler to start.

Need to check what happens when running a clear test.

Bug: angleproject:8582
Change-Id: Ia3b1f057add7714c7b192af1a3bf0edb41ccb649
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5388077

Reviewed-by: Liza Burakova <li...@chromium.org>
Commit-Queue: Matthew Denton <mpde...@chromium.org>

Git Watcher via monorail

unread,
May 7, 2024, 6:47:13 PM5/7/24
to angleproj...@googlegroups.com

Comment #7 on issue 8582 by Git Watcher: WebGPU: Add framebuffers with basic clear operations
https://bugs.chromium.org/p/angleproject/issues/detail?id=8582#c7


The following revision refers to this bug:
https://chromium.googlesource.com/angle/angle/+/1d0ef51841f3150aa76fb56a87fe951f1baf646a

commit 1d0ef51841f3150aa76fb56a87fe951f1baf646a
Author: Liza Burakova <li...@chromium.org>
Date: Tue May 07 20:56:43 2024

Fixing glClear tests.

This CL makes a few changes to fix up the basic glClear test
RGBA8Framebuffer, as well as adding a test that uploads a
texture before clearing a RGBA8 framebuffer.

It moves the wgpu::RenderPassDescriptor(RPD), as well as helper
methods for comparing RPDs from the context to the framebuffer.
The color attachments that are created in when FramebufferWgpu::clear
is called are also stored in the framebuffer now as well.

This CL also changes texture creation to use the RGBA8Unorm format
instead of RGBA8Uint format. It also adds the wgpu viewFormats
parameter to an ImageHelper. Future formats support is still TBD.

Bug: angleproject:8582
Change-Id: Idfc4182eb4d6de8a771f2f91d337564ee71df010
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5503549
Reviewed-by: Shahbaz Youssefi <syou...@chromium.org>
Reviewed-by: Matthew Denton <mpde...@chromium.org>
Commit-Queue: Liza Burakova <li...@chromium.org>

[modify] https://crrev.com/1d0ef51841f3150aa76fb56a87fe951f1baf646a/src/tests/gl_tests/ClearTest.cpp
[modify] https://crrev.com/1d0ef51841f3150aa76fb56a87fe951f1baf646a/src/libANGLE/renderer/wgpu/ContextWgpu.cpp
[modify] https://crrev.com/1d0ef51841f3150aa76fb56a87fe951f1baf646a/src/libANGLE/renderer/wgpu/FramebufferWgpu.cpp
[modify] https://crrev.com/1d0ef51841f3150aa76fb56a87fe951f1baf646a/src/libANGLE/renderer/wgpu/FramebufferWgpu.h
[modify] https://crrev.com/1d0ef51841f3150aa76fb56a87fe951f1baf646a/src/libANGLE/renderer/wgpu/wgpu_helpers.h
[modify] https://crrev.com/1d0ef51841f3150aa76fb56a87fe951f1baf646a/src/libANGLE/renderer/wgpu/wgpu_helpers.cpp
[modify] https://crrev.com/1d0ef51841f3150aa76fb56a87fe951f1baf646a/src/libANGLE/renderer/wgpu/TextureWgpu.cpp
[modify] https://crrev.com/1d0ef51841f3150aa76fb56a87fe951f1baf646a/src/libANGLE/renderer/wgpu/ContextWgpu.h

Git Watcher via monorail

unread,
May 9, 2024, 12:01:15 PM5/9/24
to angleproj...@googlegroups.com

Comment #8 on issue 8582 by Git Watcher: WebGPU: Add framebuffers with basic clear operations
https://bugs.chromium.org/p/angleproject/issues/detail?id=8582#c8


The following revision refers to this bug:
https://chromium.googlesource.com/angle/angle/+/394e8767c6ad535755c7c363983c4873ef641b74

commit 394e8767c6ad535755c7c363983c4873ef641b74
Author: Geoff Lang <geof...@chromium.org>
Date: Wed May 08 19:18:37 2024

WebGPU: Fix accumulating mCurrentColorAttachments.

mCurrentColorAttachments was not being cleared so multiple clear
operations would have incorrect color attachments.

Comparing against the previous RenderPassDescriptor also compared
the same color attachment memory since the same scratch buffer was
used to generate the new descriptor.

Bug: angleproject:8582
Change-Id: I9026007607941b92856728b421bc43812195ca57
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/5526978
Reviewed-by: Matthew Denton <mpde...@chromium.org>
Commit-Queue: Geoff Lang <geof...@chromium.org>
Reviewed-by: Liza Burakova <li...@chromium.org>

[modify] https://crrev.com/394e8767c6ad535755c7c363983c4873ef641b74/src/libANGLE/renderer/wgpu/FramebufferWgpu.cpp
Reply all
Reply to author
Forward
0 new messages