-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
[Merged by Bors] - Avoid windows with a physical size of zero #4098
Conversation
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.
Can confirm this fixes #4097 on Win11. Changes look like a nice improvement. 👍
Marking as ready for review because this is a bugfix with a tiny footprint.
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.
The changes that are in the PR look good. I don't know if they address all possible cases across the entire codebase, but I think that is probably difficult to know and I'm too tired to sensibly go through and check right now.
28d2b34
to
fe4e608
Compare
I had to make quite a few changes to rebase this PR. In addition to avoiding the zero size cases, I removed an unnecessary clear of The last commit (d1d4027) is optional - it's a small change to avoid the unconditional allocation of the I ran the |
@HackerFoo instead of handling this special case throughout the code, what if we squash it at the source to prevent this from popping up yet again? Changing the pub fn update_actual_size_from_backend(&mut self, physical_width: u32, physical_height: u32) {
self.physical_width = physical_width.max(1);
self.physical_height = physical_height.max(1);
} It feels a little bit hacky, but maybe it's a more robust way to handle this edge case by effectively ensuring window dims are nonzero? |
Using A render target with a dimension of 0 is invalid, and so that is why More generally, I've found it a good practice to use It's useful to change the problem to avoid edge cases (here's a really cool example), but it should never be done in a way that could give an incorrect answer. |
d1d4027
to
b67dcfd
Compare
For what it's worth, I agree with the returning None approach and that for me is a centralised solution. When I've said "is there a way to solve this in one place and avoid problems everywhere else?" what I mean is that having things have to check for 0s on usizes or so is easy to miss and then have random panics or unexpected visual artifacts far from the root problem. Making it an Option or Result, in my opinion, forces you to have to handle it when using it. It strongly indicates that this can 'fail' or give an 'invalid' result and so you need to handle that. Makes sense to me. |
You are both entirely correct, using an
Oof, I'm an idiot. I just realized you are doing this with So, uh, long story short, this PR is perfect, please ignore me. 🙂 |
We've got conflicts now that #4345 is merged :) |
- clear clusters on ClusterConfig::None or missing render target - don't clear cluster.lights otherwise so it can be reused
b67dcfd
to
60729c5
Compare
bors r+ |
# Objective Fix #4097 ## Solution Return `None` from `RenderTarget::get_physical_size` if either dimension is zero.
# Objective - #4098 still hasn't fixed minimisation on Windows. - `Clusters.lights` is assumed to have the number of items given by the product of `Clusters.dimensions`'s axes. ## Solution - Make that true in `clear`.
# Objective Fix bevyengine#4097 ## Solution Return `None` from `RenderTarget::get_physical_size` if either dimension is zero.
# Objective - bevyengine#4098 still hasn't fixed minimisation on Windows. - `Clusters.lights` is assumed to have the number of items given by the product of `Clusters.dimensions`'s axes. ## Solution - Make that true in `clear`.
# Objective Fix bevyengine#4097 ## Solution Return `None` from `RenderTarget::get_physical_size` if either dimension is zero.
# Objective - bevyengine#4098 still hasn't fixed minimisation on Windows. - `Clusters.lights` is assumed to have the number of items given by the product of `Clusters.dimensions`'s axes. ## Solution - Make that true in `clear`.
Objective
Fix #4097
Solution
Return
None
fromRenderTarget::get_physical_size
if either dimension is zero.