2018-07-18 09:40:26 +00:00
|
|
|
// Copyright 2017 The Dawn Authors
|
2017-06-01 15:30:03 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
|
2018-07-24 11:53:51 +00:00
|
|
|
#include "dawn_native/opengl/PersistentPipelineStateGL.h"
|
2017-06-01 15:30:03 +00:00
|
|
|
|
2017-11-24 19:16:15 +00:00
|
|
|
namespace backend { namespace opengl {
|
2017-06-01 15:30:03 +00:00
|
|
|
|
2017-06-02 18:31:53 +00:00
|
|
|
void PersistentPipelineState::SetDefaultState() {
|
2017-06-05 17:12:16 +00:00
|
|
|
CallGLStencilFunc();
|
2017-06-01 15:30:03 +00:00
|
|
|
}
|
|
|
|
|
2017-11-24 19:16:15 +00:00
|
|
|
void PersistentPipelineState::SetStencilFuncsAndMask(GLenum stencilBackCompareFunction,
|
|
|
|
GLenum stencilFrontCompareFunction,
|
|
|
|
uint32_t stencilReadMask) {
|
2017-11-23 19:24:20 +00:00
|
|
|
if (mStencilBackCompareFunction == stencilBackCompareFunction &&
|
|
|
|
mStencilFrontCompareFunction == stencilFrontCompareFunction &&
|
|
|
|
mStencilReadMask == stencilReadMask) {
|
2017-06-05 17:12:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-11-23 19:24:20 +00:00
|
|
|
mStencilBackCompareFunction = stencilBackCompareFunction;
|
|
|
|
mStencilFrontCompareFunction = stencilFrontCompareFunction;
|
|
|
|
mStencilReadMask = stencilReadMask;
|
2017-06-05 17:12:16 +00:00
|
|
|
CallGLStencilFunc();
|
2017-06-01 15:30:03 +00:00
|
|
|
}
|
|
|
|
|
2017-06-02 18:31:53 +00:00
|
|
|
void PersistentPipelineState::SetStencilReference(uint32_t stencilReference) {
|
2017-11-23 19:24:20 +00:00
|
|
|
if (mStencilReference == stencilReference) {
|
2017-06-05 17:12:16 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-11-23 19:24:20 +00:00
|
|
|
mStencilReference = stencilReference;
|
2017-06-05 17:12:16 +00:00
|
|
|
CallGLStencilFunc();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PersistentPipelineState::CallGLStencilFunc() {
|
2017-11-24 19:16:15 +00:00
|
|
|
glStencilFuncSeparate(GL_BACK, mStencilBackCompareFunction, mStencilReference,
|
|
|
|
mStencilReadMask);
|
|
|
|
glStencilFuncSeparate(GL_FRONT, mStencilFrontCompareFunction, mStencilReference,
|
|
|
|
mStencilReadMask);
|
2017-06-01 15:30:03 +00:00
|
|
|
}
|
|
|
|
|
2017-11-24 19:16:15 +00:00
|
|
|
}} // namespace backend::opengl
|