Fix incorrect bounds check for set_scissor_rect #167
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In
EguiNode::run
, an attempt is made to fix for bad scissor rect bounds by the width & height of the scissor rect to the physical window.However, this only works if the scissor rect starts at (0, 0); if it isn't, then the scissor rect may still go out of bounds of the window.
This can cause a panic from wgpu when
![image](https://user-images.githubusercontent.com/8049998/226864747-26301b8f-3a3e-4969-bc9b-c4da9f819051.png)
window.resolution.set(x, y)
is called from WASM with a resolution lower than the current setting, as when the window updates, but the egui draw commands haven't been updated, the scissor rect can extend outside of the render target if it has an offset top-left corner.This PR changes it so that the scissor rect bound check subtracts the upper left coordinate, ensuring that the scissor rect remains within the bounds of the window even if the draw command doesn't originate at the top left.
I have tested and confirmed this change fixes the panic and doesn't appear to have any rendering inconsistencies either from WASM or Windows.