use correct size of pixel instead of 4 (#2977)

# Objective

- Fixes #2919 
- Initial pixel was hard coded and not dependent on texture format
- Replace #2920 as I noticed this needed to be done also on pipeline rendering branch

## Solution

- Replace the hard coded pixel with one using the texture pixel size
This commit is contained in:
François 2021-10-28 23:10:45 +00:00
parent dacc9d03a7
commit a2ea9279b2
2 changed files with 9 additions and 5 deletions

View file

@ -168,10 +168,11 @@ impl TextureAtlasBuilder {
&contains_smallest_box,
) {
Ok(rect_placements) => {
atlas_texture = Texture::new_fill(
Extent3d::new(current_width, current_height, 1),
let size = Extent3d::new(current_width, current_height, 1);
atlas_texture = Texture::new(
size,
TextureDimension::D2,
&[0, 0, 0, 0],
vec![0; self.format.pixel_size() * size.volume()],
self.format,
);
Some(rect_placements)

View file

@ -176,14 +176,17 @@ impl TextureAtlasBuilder {
&contains_smallest_box,
) {
Ok(rect_placements) => {
atlas_texture = Image::new_fill(
atlas_texture = Image::new(
Extent3d {
width: current_width,
height: current_height,
depth_or_array_layers: 1,
},
TextureDimension::D2,
&[0, 0, 0, 0],
vec![
0;
self.format.pixel_size() * (current_width * current_height) as usize
],
self.format,
);
Some(rect_placements)