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

Expand FallbackImage to include a GpuImage for each possible TextureViewDimension #6974

Merged
merged 4 commits into from
Jun 19, 2023
Merged

Expand FallbackImage to include a GpuImage for each possible TextureViewDimension #6974

merged 4 commits into from
Jun 19, 2023

Conversation

bonsairobo
Copy link
Contributor

Objective

Fixes #6920

Solution

From the issue discussion:

From looking at the AsBindGroup derive macro implementation, the fallback image's TextureView is used when the binding's Option<Handle<Image>> is None. Because this relies on already having a view that matches the desired binding dimensions, I think the solution will require creating a separate GpuImage for each possible TextureViewDimension.


Changelog

Users can now rely on FallbackImage to work with a texture binding of any dimension.

@bonsairobo
Copy link
Contributor Author

bonsairobo commented Dec 18, 2022

Currently a draft b/c I haven't tested that this actually fixes the panic yet. I need to get my downstream crate (and it's dependencies that depend on bevy) building based on these changes first.

OK PR is ready for review.

@github-actions
Copy link
Contributor

Example alien_cake_addict failed to run, please try running it locally and check the result.

1 similar comment
@github-actions
Copy link
Contributor

Example alien_cake_addict failed to run, please try running it locally and check the result.

@bonsairobo
Copy link
Contributor Author

bonsairobo commented Mar 20, 2023

Should I be putting the integration test into an example? Is that the right pattern?

Note for reviewers: You can reproduce the error from #6920 by applying only the 1st commit and running the test example. The 2nd commit fixes the error.

@bonsairobo bonsairobo marked this pull request as ready for review March 20, 2023 02:46
@IceSentry IceSentry added the A-Rendering Drawing game state to the screen label Mar 23, 2023
@IceSentry IceSentry self-requested a review June 9, 2023 00:13
@IceSentry IceSentry added C-Usability A targeted quality-of-life change that makes Bevy easier to use C-Bug An unexpected or incorrect behavior labels Jun 11, 2023
@IceSentry IceSentry added this to the 0.11 milestone Jun 11, 2023
@IceSentry
Copy link
Contributor

Would be nice if the example was able to run as an actual test case instead of being an example, but this is out of scope of this PR since we don't have the infrastructure for this right now.

@bonsairobo
Copy link
Contributor Author

Should be good to go.

@alice-i-cecile
Copy link
Member

Much clearer, thanks :) I still don't have quite enough expertise to review this directly though, so I'm going to hold off on an approval.

@bonsairobo
Copy link
Contributor Author

bonsairobo commented Jun 13, 2023

Much clearer, thanks :) I still don't have quite enough expertise to review this directly though, so I'm going to hold off on an approval.

Ok. We have an approval from IceSentry. Is that good enough or what happens next?

@IceSentry
Copy link
Contributor

It still needs a second approval, there's been a tiny bit of pushback on discord. I wouldn't say it's a blocker, but the gist of it is that this solution doesn't scale well to support the other attributes that aren't currently supported like the texture format for example.

Also, I don't mind my real name being here, but not everyone knows that it's me.

Copy link
Contributor

@JMS55 JMS55 left a comment

Choose a reason for hiding this comment

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

Looks good to me. I'm not really concerned about combinatorial explosion due to number of parameters. Off the top of my head, I can't see why a user would care about the texture format. Binding it and using it in a shader is the same either way. The only thing that matters is: what value you get out (black/white), texture dimensions, and what format you read values in from the shader (float, uint, etc. Anything but float would be very rare though). In fact, we could use something like r32float/uint (or r8 on native) to save a very tiny amount of memory.

Tldr; I don't see a current use case for larger amounts of fallbacks beyond what we have now.

@IceSentry
Copy link
Contributor

I know that @DGriffin91 needed this for deferred shading which is why it was mentioned. It may not have been texture format, but it was definitely because of some other parameter not being handled.

@DGriffin91
Copy link
Contributor

@IceSentry yes, texture format and sample count.

@alice-i-cecile alice-i-cecile 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 Jun 14, 2023
@bonsairobo
Copy link
Contributor Author

@DGriffin91 @IceSentry If we want to support all possible TextureFormats, then we probably don't want to have a field for each combination. We could use a HashMap<(TextureViewDimension, TextureFormat), GpuImage> and lazily create the images. This could happen in a follow-up issue/PR.

Copy link
Member

@alice-i-cecile alice-i-cecile 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 the example locally and while it doesn't panic I'm just getting a grey screen. Is that intentional?

Either way, please add a description to the module comment at the top of the example explaining what "correct" behavior should look like.

@alice-i-cecile alice-i-cecile removed 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 Jun 19, 2023
@bonsairobo
Copy link
Contributor Author

I've run the example locally and while it doesn't panic I'm just getting a grey screen. Is that intentional?

Yea the shader doesn't do anything, it's just testing that it doesn't crash when attempting to bind the images.

Either way, please add a description to the module comment at the top of the example explaining what "correct" behavior should look like.

Will do.

@alice-i-cecile
Copy link
Member

Much better, thanks!

@alice-i-cecile alice-i-cecile added this pull request to the merge queue Jun 19, 2023
Merged via the queue into bevyengine:main with commit 6440546 Jun 19, 2023
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-Bug An unexpected or incorrect behavior C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FallbackImage only supports TextureDimension::D2
5 participants