Use as_image_copy where possible (#10733)

# Objective

`wgpu` has a helper method `texture.as_image_copy()` for a common
pattern when making a default-like `ImageCopyTexture` from a texture.

This is used in various places in Bevy for texture copy operations, but
it was not used where `write_texture` is called.

## Solution

- Replace struct `ImageCopyTexture` initialization with
`texture.as_image_copy()` where appropriate

Signed-off-by: Torstein Grindvik <torstein.grindvik@muybridge.com>
Co-authored-by: Torstein Grindvik <torstein.grindvik@muybridge.com>
This commit is contained in:
Torstein Grindvik 2023-11-26 20:24:32 +01:00 committed by GitHub
parent 89d652ba3a
commit 4788315fd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 18 deletions

View file

@ -377,12 +377,7 @@ impl FromWorld for MeshPipeline {
let format_size = image.texture_descriptor.format.pixel_size();
render_queue.write_texture(
ImageCopyTexture {
texture: &texture,
mip_level: 0,
origin: Origin3d::ZERO,
aspect: TextureAspect::All,
},
texture.as_image_copy(),
&image.data,
ImageDataLayout {
offset: 0,

View file

@ -304,12 +304,7 @@ impl FromWorld for Mesh2dPipeline {
let format_size = image.texture_descriptor.format.pixel_size();
render_queue.write_texture(
ImageCopyTexture {
texture: &texture,
mip_level: 0,
origin: Origin3d::ZERO,
aspect: TextureAspect::All,
},
texture.as_image_copy(),
&image.data,
ImageDataLayout {
offset: 0,

View file

@ -100,12 +100,7 @@ impl FromWorld for SpritePipeline {
let format_size = image.texture_descriptor.format.pixel_size();
render_queue.write_texture(
ImageCopyTexture {
texture: &texture,
mip_level: 0,
origin: Origin3d::ZERO,
aspect: TextureAspect::All,
},
texture.as_image_copy(),
&image.data,
ImageDataLayout {
offset: 0,