mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-15 08:06:19 +00:00
Unify the compare function for sampler and depth stencil
Both sampler and depth stencil include compare function, and we need to change it to appropriate functions for different backends. In order to avoid code duplication, we put it into a util file for every backend, then include that file and call the function from where we need it. We can put similar functions which can be shared among different objects into the util file in future. Shaobo's patch has already created such a util function for compare function for sampler. This patch removes the duplicated compare function in RenderPipeline for depth stencil descriptor, and call the function in util file instead. BUG=dawn:31, dawn:47 Change-Id: Ia645b48e026b5a372d1023aa7e8ecdf1e4ed7c6d Reviewed-on: https://dawn-review.googlesource.com/c/3641 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
93158ebede
commit
6e308846c2
@@ -18,6 +18,7 @@
|
||||
#include "dawn_native/opengl/Forward.h"
|
||||
#include "dawn_native/opengl/InputStateGL.h"
|
||||
#include "dawn_native/opengl/PersistentPipelineStateGL.h"
|
||||
#include "dawn_native/opengl/UtilsGL.h"
|
||||
|
||||
namespace dawn_native { namespace opengl {
|
||||
|
||||
@@ -108,29 +109,6 @@ namespace dawn_native { namespace opengl {
|
||||
descriptor->colorWriteMask & dawn::ColorWriteMask::Alpha);
|
||||
}
|
||||
|
||||
GLuint OpenGLCompareFunction(dawn::CompareFunction compareFunction) {
|
||||
switch (compareFunction) {
|
||||
case dawn::CompareFunction::Never:
|
||||
return GL_NEVER;
|
||||
case dawn::CompareFunction::Less:
|
||||
return GL_LESS;
|
||||
case dawn::CompareFunction::LessEqual:
|
||||
return GL_LEQUAL;
|
||||
case dawn::CompareFunction::Greater:
|
||||
return GL_GREATER;
|
||||
case dawn::CompareFunction::GreaterEqual:
|
||||
return GL_GEQUAL;
|
||||
case dawn::CompareFunction::NotEqual:
|
||||
return GL_NOTEQUAL;
|
||||
case dawn::CompareFunction::Equal:
|
||||
return GL_EQUAL;
|
||||
case dawn::CompareFunction::Always:
|
||||
return GL_ALWAYS;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
GLuint OpenGLStencilOperation(dawn::StencilOperation stencilOperation) {
|
||||
switch (stencilOperation) {
|
||||
case dawn::StencilOperation::Keep:
|
||||
@@ -170,7 +148,7 @@ namespace dawn_native { namespace opengl {
|
||||
glDepthMask(GL_FALSE);
|
||||
}
|
||||
|
||||
glDepthFunc(OpenGLCompareFunction(descriptor->depthCompare));
|
||||
glDepthFunc(ToOpenGLCompareFunction(descriptor->depthCompare));
|
||||
|
||||
if (StencilTestEnabled(descriptor)) {
|
||||
glEnable(GL_STENCIL_TEST);
|
||||
@@ -178,8 +156,8 @@ namespace dawn_native { namespace opengl {
|
||||
glDisable(GL_STENCIL_TEST);
|
||||
}
|
||||
|
||||
GLenum backCompareFunction = OpenGLCompareFunction(descriptor->back.compare);
|
||||
GLenum frontCompareFunction = OpenGLCompareFunction(descriptor->front.compare);
|
||||
GLenum backCompareFunction = ToOpenGLCompareFunction(descriptor->back.compare);
|
||||
GLenum frontCompareFunction = ToOpenGLCompareFunction(descriptor->front.compare);
|
||||
persistentPipelineState->SetStencilFuncsAndMask(
|
||||
backCompareFunction, frontCompareFunction, descriptor->stencilReadMask);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user