Status: Available
Owner:
mpde...@chromium.orgOS: 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=8582Implement 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