-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
remove pixel size and try to calculate texture sizes more correctly #6788
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. |
@@ -16,16 +16,12 @@ impl AssetLoader for HdrTextureLoader { | |||
) -> BoxedFuture<'a, Result<()>> { | |||
Box::pin(async move { | |||
let format = TextureFormat::Rgba32Float; | |||
debug_assert_eq!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
wgpu
already maintains a list of this info https://docs.rs/wgpu-types/0.14.0/src/wgpu_types/lib.rs.html#2359Solution
format.describe().block_size
directly in situations where it is obvious that the format is uncompressed or where surrounding code assumes the texture is uncompressed.TextureFormatPixelInfo
were 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
TextureFormatPixelInfo
has been removed.PixelInfo::components
can be gotten fromtexture_format.describe().components
.PixelInfo::type_size
can 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_descriptor
instead. These includebytes_per_row
,total_bytes
androws_per_image
.