Skip to content
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

check sampler type in as_bind_group derives #12637

Merged
merged 5 commits into from
Aug 21, 2024

Conversation

robtfm
Copy link
Contributor

@robtfm robtfm commented Mar 21, 2024

Objective

currently if we use an image with the wrong sampler type in a material, wgpu panics with an invalid texture format. turn this into a warning and fail more gracefully.

Solution

the expected sampler type is specified in the AsBindGroup derive, so we can just check the image sampler is what it should be.

i am not totally sure about the mapping of image sampler type to #[sampler(type)], i assumed:

    "filtering" => [ TextureSampleType::Float { filterable: true } ],
    "non_filtering" => [
        TextureSampleType::Float { filterable: false },
        TextureSampleType::Sint,
        TextureSampleType::Uint,
    ],
    "comparison" => [ TextureSampleType::Depth ],

@robtfm robtfm added A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change labels Mar 21, 2024
Copy link
Contributor

@afonsolage afonsolage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've run into this issue and I agree this shouldn't be a hard error, since it's totally recoverable, by just changing the sample or data format.

crates/bevy_render/src/render_resource/bind_group.rs Outdated Show resolved Hide resolved
@rparrett rparrett added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Aug 13, 2024
@alice-i-cecile alice-i-cecile added the C-Usability A targeted quality-of-life change that makes Bevy easier to use label Aug 19, 2024
@alice-i-cecile
Copy link
Member

@robtfm I'll merge this once the merge conflicts are resolved :)

@robtfm robtfm reopened this Aug 20, 2024
@robtfm
Copy link
Contributor Author

robtfm commented Aug 20, 2024

apologies, i destroyed the history trying to rebase...

@alice-i-cecile
Copy link
Member

That's git for you ;) No worries, it gets squashed to the PR level anyways.

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Aug 21, 2024
Merged via the queue into bevyengine:main with commit 6e2f96f Aug 21, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen C-Code-Quality A section of code that is hard to understand or change C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants