mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 17:05:31 +00:00
OpenGL: Unconditionally set glFrontFace
Previously glFrontFace was called only if some cull mode was set. This was incorrect because the front face also influences whether a triangle uses stencilFront or stencilBack. Because OpenGL default to GL_CCW (which with the Y-flip is the inverse of wgpu::FrontFace::CCW that's default in the descriptor), if stencilFront != stencilBack and cull mode is none, then the incorrect stencil face descriptor was used. Also adds a regression test for this issue. Bug: dawn:508 Change-Id: I00d93bda6d4f030cf9db472a9f2b0deefc72707f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/26880 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
d95180dede
commit
7268e7d36f
@@ -43,14 +43,15 @@ namespace dawn_native { namespace opengl {
|
||||
void ApplyFrontFaceAndCulling(const OpenGLFunctions& gl,
|
||||
wgpu::FrontFace face,
|
||||
wgpu::CullMode mode) {
|
||||
// Note that we invert winding direction in OpenGL. Because Y axis is up in OpenGL,
|
||||
// which is different from WebGPU and other backends (Y axis is down).
|
||||
GLenum direction = (face == wgpu::FrontFace::CCW) ? GL_CW : GL_CCW;
|
||||
gl.FrontFace(direction);
|
||||
|
||||
if (mode == wgpu::CullMode::None) {
|
||||
gl.Disable(GL_CULL_FACE);
|
||||
} else {
|
||||
gl.Enable(GL_CULL_FACE);
|
||||
// Note that we invert winding direction in OpenGL. Because Y axis is up in OpenGL,
|
||||
// which is different from WebGPU and other backends (Y axis is down).
|
||||
GLenum direction = (face == wgpu::FrontFace::CCW) ? GL_CW : GL_CCW;
|
||||
gl.FrontFace(direction);
|
||||
|
||||
GLenum cullMode = (mode == wgpu::CullMode::Front) ? GL_FRONT : GL_BACK;
|
||||
gl.CullFace(cullMode);
|
||||
|
||||
Reference in New Issue
Block a user