I'm trying to draw a 2d texture directly onto the screen without vertices and shaders. Based on this Stackoverflow question it seems like all I have to do is copying the texture to the swap chain texture.
CommandEncoder::copy_texture_to_texture accepts a TextureCopyView as the destination
fn copy_texture_to_texture(
&mut self,
source: TextureCopyView,
destination: TextureCopyView,
copy_size: Extent3d,
)
pub struct TextureCopyView<T> {
pub texture: T,
pub mip_level: u32,
pub origin: Origin3d,
}
where T has type &'a Texture.
However, by calling SwapChain::get_current_frame() I get this:
pub struct SwapChainTexture {
pub view: TextureView,
detail: <C as Context>::SwapChainOutputDetail,
}
which only has a TextureView available to me.
I saw that for wgpu 0.3.0 there used to be a texture field in SwapChainOutput, which presumably can be used to construct my TextureCopyView. This was deleted in 0.4.0. So what would be the correct way to copy a texture to a SwapChainTexture?
Thank you for answering my question!
Unfortunately due to compatibility, the only way to write data to the swapchain image is by rendering to it. In your case you should render a fullscreen triangle and copy from your framebuffer. This may end up being faster as there are a couple of optimizations drivers can do but only when they render.
Most helpful comment
Unfortunately due to compatibility, the only way to write data to the swapchain image is by rendering to it. In your case you should render a fullscreen triangle and copy from your framebuffer. This may end up being faster as there are a couple of optimizations drivers can do but only when they render.