I've got a 3D texture that is only accessible to the GPU, which I'm trying to clear at the start of a frame. I've tried setting each element to zero using a computer shader, but that's taking nearly 3ms for a 64x64x64 texture, and I'd like to use something bigger than that.
It would be great if I could do something like the clear-on-load action for color attachments, but I'm don't think that's possible in this situation.
What's the fastest way to clear the texture?
The easiest way to do this is by using the renderPassDesciptor's loadActions, like so:
MTLRenderPassDescriptor *rpdesc = [MTLRenderPassDescriptor renderPassDescriptor];
rpdesc.colorAttachments[0].clearColor = MTLClearColorMake(0,0,0,0);
rpdesc.colorAttachments[0].loadAction = MTLLoadActionClear;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With