Reintroduce clear_texture Metal/Vulkan/DX12#1905
Conversation
and remove unused clear-buffer.ron test
…exture in the future
kvark
left a comment
There was a problem hiding this comment.
What is the semantics of CLEAR_COMMANDS now? Is it purely for textures? If so, we may need to indicate that in the name.
|
By renaming & simplifying Arguably now that I explicitly state for the |
Fix incorrect use of texture.size in clear_texture for metal/dx12 Fix incorrect mip/layer ranges in clear_texture for metal/dx12
Ok, that's the actual concern. |
|
Ah okay this is a bit messed up right now, but already was before I reckon. wgpu-hal still is required to implement both clear_buffer and clear_texture because otherwise wgpu won't be able to implement zero-init which it is required to do. However, wgpu won't expose clear_buffer/texture unless asked so because it is not a feature of WebGPU. Allowing that would lead to non-portable applications. So what I should do in this pr is that it's not wgpu-hal advertising the availability of the feature (it's always there), but wgpu itself? |
kvark
left a comment
There was a problem hiding this comment.
Discussed this on matrix. The short story is: clearing textures is a prerequisite for zero-initialization in wgpu-core, so separating it out from buffers wouldn't make much sense.
|
It seems that on macos, all the examples now hang on waiting a mutex in |
Connections
Major puzzle piece for getting texture zero init in, see #1688
The idea is to implement the lazy texture inits with render target clears wherever possible, but for everything else we need to be able to perform clears using merely the COPY_DST usage, wgpu_hal's
clear_textureis the answer for that.Description
Main piece here is the reintroduction & implementation of clear_texture, but a few related things made it was well in here:
Note that clear_texture is more restricted than originally:
For implementing zero init we will internally need to enforce either COPY_DST or RENDER_ATTACHMENT. Conveniently, the formats that clear_texture is not supported almost always come with RENDER_ATTACHMENT anyways.
Did not implemented
clear_texturefor GLES, I simply ran out of energy to do the tricky row copying again. Left as an exercise for the reader.Testing
Only tested using the rather simplistic player test. We'll need to set up tests that iterate through more texture types/sizes/formats in the future (not only for clearing, but for all sort of things).
Ran it with Vulkan/DX12 (@ Win10, Nvidia) and Metal (@ MacOS, Intel)