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

[Gles] Fix clearing depth and stencil at the same time #2675

Merged
merged 2 commits into from
May 19, 2022

Conversation

expenses
Copy link
Contributor

Description

Currently in the gles backend, if a depth+stencil buffer with a format like TextureFormat::Depth24FloatPlusStencil8 is attached to a render pass with both the depth and stencil set to clear, only the depth is cleared. I'm not sure if this happens with native gl, but it certainly does with webgl.

Testing

This fixed a problem I had in my project. Here's a before and after of using a stencil buffer for a mirror:

mirror_before_and_after

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 good, kinda weird we need it, but this is also an optimization, so totally fine with me

wgpu-hal/src/gles/mod.rs Show resolved Hide resolved
@expenses
Copy link
Contributor Author

kinda weird we need it

Wait.... Could it be that the problem is actually that the depth buffer doesn't get cleared in the area under the stencil, because we're still stencil testing or something? I need to test what happens if we clear the stencil buffer first. Regardless though, this PR is still good because we shouldn't have to think about this stuff

@cwfitzgerald
Copy link
Member

That's very plausible, not sure how stencil interacts with clears on GL

@expenses
Copy link
Contributor Author

Wait.... Could it be that the problem is actually that the depth buffer doesn't get cleared in the area under the stencil, because we're still stencil testing or something? I need to test what happens if we clear the stencil buffer first. Regardless though, this PR is still good because we shouldn't have to think about this stuff

Nope, switching the two around doesn't seem to make a difference. Odd. Oh well, I've added some documentation

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.

Thanks!

@cwfitzgerald cwfitzgerald merged commit 1ec2678 into gfx-rs:master May 19, 2022
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