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

Fix order of arguments to glPolygonOffset. #3783

Merged
merged 2 commits into from
May 18, 2023

Conversation

komadori
Copy link
Contributor

@komadori komadori commented May 18, 2023

Checklist

  • Run cargo clippy.
  • Run RUSTFLAGS=--cfg=web_sys_unstable_apis cargo clippy --target wasm32-unknown-unknown if applicable.
  • Add change to CHANGELOG.md. See simple instructions inside file.

Connections
While investigating a Z-fighting issue shown in komadori/bevy_mod_outline#19 which is apparently specific to WebGL, I noticed that wgpu-hal's GL ES back-end appears to be passing the wrong arguments to glPolygonOffset. However, this bug is ultimately largely incidental to that issue.

Description
glPolygonOffset takes two arguments, factor and units. The terminology used is slightly different to wgpu, but I believe factor ("specifies a scale factor") should correspond to slope_scale and units ("create a constant depth offset") to constant. However, wgpu passes these arguments in the reverse order and this PR corrects that.

Testing
In practice, both the slope_scale and constant are often set to around 1 so wgpu swapping them would go unnoticed. I don't have a meaningful test case for this and am judging it correct by inspection of the code and OpenGL documentation.

@komadori komadori marked this pull request as ready for review May 18, 2023 20:38
Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

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

Looks great! Thank you

@cwfitzgerald cwfitzgerald enabled auto-merge (squash) May 18, 2023 22:28
@cwfitzgerald cwfitzgerald merged commit c91a660 into gfx-rs:trunk May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants