remove pixel size and try to calculate texture sizes more correctly#6788
remove pixel size and try to calculate texture sizes more correctly#6788hymm wants to merge 6 commits intobevyengine:mainfrom
Conversation
|
I think block_size =! type_size, so need to investigate more on what the equivalence is. edit: I think it's block_size = type_size * components, but will go through the whole table and check |
2846343 to
9781f12
Compare
|
So there's one mismatch and that is on |
|
I now see there's an old PR that tried to do something similar. #4124. It seems like there's some issues around compressed textures that this PR might not be dealing with correctly. |
Co-authored-by: Kurt Kühnert <kurt@kuhnert.dev>
I knew I’d seen a PR for this before. |
| ) -> BoxedFuture<'a, Result<()>> { | ||
| Box::pin(async move { | ||
| let format = TextureFormat::Rgba32Float; | ||
| debug_assert_eq!( |
There was a problem hiding this comment.
this debug assert is sort of meaningless since we're hard coded to Rgba32Float
5d9b8dd to
fe17713
Compare
|
Closing now that #6820 is getting merged. We can add the extra step in a new PR. |
# Objective - Get rid of giant match statement to get PixelInfo. - This will allow for supporting any texture that is uncompressed, instead of people needing to PR in any textures that are supported in wgpu, but not bevy. ## Solution - More conservative alternative to #6788, where we don't try to make some of the calculations correct for compressed types. - Delete `PixelInfo` and get the pixel_size directly from wgpu. Data from wgpu is here: https://docs.rs/wgpu-types/0.14.0/src/wgpu_types/lib.rs.html#2359 - Panic if the texture is a compressed type. An integer byte size of a pixel is no longer a valid concept when talking about compressed textures. - All internal usages use `pixel_size` and not `pixel_info` and are on uncompressed formats. Most of these usages are on either explicit texture formats or slightly indirectly through `TextureFormat::bevy_default()`. The other uses are in `TextureAtlas` and have other calculations that assumes the texture is uncompressed. ## Changelog - remove `PixelInfo` and get `pixel_size` from wgpu ## Migration Guide `PixelInfo` has been removed. `PixelInfo::components` is equivalent to `texture_format.describe().components`. `PixelInfo::type_size` can be gotten from `texture_format.describe().block_size/ texture_format.describe().components`. But note this can yield incorrect results for some texture types like Rg11b10Float.
# Objective - Get rid of giant match statement to get PixelInfo. - This will allow for supporting any texture that is uncompressed, instead of people needing to PR in any textures that are supported in wgpu, but not bevy. ## Solution - More conservative alternative to bevyengine#6788, where we don't try to make some of the calculations correct for compressed types. - Delete `PixelInfo` and get the pixel_size directly from wgpu. Data from wgpu is here: https://docs.rs/wgpu-types/0.14.0/src/wgpu_types/lib.rs.html#2359 - Panic if the texture is a compressed type. An integer byte size of a pixel is no longer a valid concept when talking about compressed textures. - All internal usages use `pixel_size` and not `pixel_info` and are on uncompressed formats. Most of these usages are on either explicit texture formats or slightly indirectly through `TextureFormat::bevy_default()`. The other uses are in `TextureAtlas` and have other calculations that assumes the texture is uncompressed. ## Changelog - remove `PixelInfo` and get `pixel_size` from wgpu ## Migration Guide `PixelInfo` has been removed. `PixelInfo::components` is equivalent to `texture_format.describe().components`. `PixelInfo::type_size` can be gotten from `texture_format.describe().block_size/ texture_format.describe().components`. But note this can yield incorrect results for some texture types like Rg11b10Float.
# Objective - Get rid of giant match statement to get PixelInfo. - This will allow for supporting any texture that is uncompressed, instead of people needing to PR in any textures that are supported in wgpu, but not bevy. ## Solution - More conservative alternative to bevyengine#6788, where we don't try to make some of the calculations correct for compressed types. - Delete `PixelInfo` and get the pixel_size directly from wgpu. Data from wgpu is here: https://docs.rs/wgpu-types/0.14.0/src/wgpu_types/lib.rs.html#2359 - Panic if the texture is a compressed type. An integer byte size of a pixel is no longer a valid concept when talking about compressed textures. - All internal usages use `pixel_size` and not `pixel_info` and are on uncompressed formats. Most of these usages are on either explicit texture formats or slightly indirectly through `TextureFormat::bevy_default()`. The other uses are in `TextureAtlas` and have other calculations that assumes the texture is uncompressed. ## Changelog - remove `PixelInfo` and get `pixel_size` from wgpu ## Migration Guide `PixelInfo` has been removed. `PixelInfo::components` is equivalent to `texture_format.describe().components`. `PixelInfo::type_size` can be gotten from `texture_format.describe().block_size/ texture_format.describe().components`. But note this can yield incorrect results for some texture types like Rg11b10Float.
Objective
wgpualready maintains a list of this info https://docs.rs/wgpu-types/0.14.0/src/wgpu_types/lib.rs.html#2359Solution
format.describe().block_sizedirectly in situations where it is obvious that the format is uncompressed or where surrounding code assumes the texture is uncompressed.TextureFormatPixelInfowere on uncompressed textures. A smaller change would be to panic if in the pixel_info function if the texture is compressed and return block_size for type_size otherwise.Breaking Changes
TextureFormatPixelInfohas been removed.PixelInfo::componentscan be gotten fromtexture_format.describe().components.PixelInfo::type_sizecan be gotten fromtexture_format.describe().block_size/ texture_format.describe().components. But note this can yield incorrect results for some texture types likeRg11b10Float. You might prefer to use the new functions ontexture_descriptorinstead. These includebytes_per_row,total_bytesandrows_per_image.