gfx-rs/wgpu

Blit Utility

Opened this issue · 3 comments

We don't offer a blit_texture utility in wgpu right now due to a number of platforms needing to emulate it with standard pipelines.

While this shouldn't be something done implicitly, we can easily provide a user-space utility in utils to make blitting easier.

Is this the sort of api you are looking for?

use wgpu::util::BlitTexture;
encoder.blit_texture(source, dest, extent);

Should it be a standard pipeline or platform dependant (vkCmdBlitImage if supported else vkCmdCopyImage for example)?

it should be a utility that is implemented using wgpu exposed methods.

@cwfitzgerald can you add a bit more detail what this should do? I imagine what you're trying to get at is to have a copy_texture_to_texture that works on formats that aren't otherwise copyable?
Imho this shouldn't be called blit since that's a quite antique term at this point and technically 🤓 not correct

Should it be a standard pipeline

Yeah.

Can you add a bit more detail what this should do? I imagine what you're trying to get at is to have a copy_texture_to_texture that works on formats that aren't otherwise copyable?

To satisify all of the "I just need to render-copy A to B" be it incompatible formats, differing sizes, or whatever.

Is this the sort of api you are looking for?

I was thinking something on the lines of this. I want to make each pipeline explicit objects so we don't need an internal pipeline cache.

struct TextureBlitter { ... }

impl TextureBlitter {
    fn new(format: TextureFormat, sample_type: FilterMode) -> Self;
    
    fn copy(encoder: &mut CommandEncoder, target: &TextureView, source: &TextureView);
}

Or something like that.