dawn-cmake/src/dawn_native/opengl/PersistentPipelineStateGL.cpp
Corentin Wallez df69f24824 OpenGL: Don't use glad to load OpenGL entrypoints
This makes the OpenGL entry points loaded at Adapter creation from the
getProcAddress passed in the DiscoveryOptions and update all GL calls in
the backend to go through the new OpenGLFunctions object.

A code generator is added that generates the function loader and list of
GL procs from Khronos' gl.xml file but we can't get rid of glad yet
because it is used to have the PROC typedefs and enum values.

BUG=dawn:165

Change-Id: I2a583d79752f55877fa4190846f5be16cf91651a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7983
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
2019-06-13 10:22:32 +00:00

59 lines
2.3 KiB
C++

// Copyright 2017 The Dawn Authors
//
// 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.
#include "dawn_native/opengl/PersistentPipelineStateGL.h"
#include "dawn_native/opengl/OpenGLFunctions.h"
namespace dawn_native { namespace opengl {
void PersistentPipelineState::SetDefaultState(const OpenGLFunctions& gl) {
CallGLStencilFunc(gl);
}
void PersistentPipelineState::SetStencilFuncsAndMask(const OpenGLFunctions& gl,
GLenum stencilBackCompareFunction,
GLenum stencilFrontCompareFunction,
uint32_t stencilReadMask) {
if (mStencilBackCompareFunction == stencilBackCompareFunction &&
mStencilFrontCompareFunction == stencilFrontCompareFunction &&
mStencilReadMask == stencilReadMask) {
return;
}
mStencilBackCompareFunction = stencilBackCompareFunction;
mStencilFrontCompareFunction = stencilFrontCompareFunction;
mStencilReadMask = stencilReadMask;
CallGLStencilFunc(gl);
}
void PersistentPipelineState::SetStencilReference(const OpenGLFunctions& gl,
uint32_t stencilReference) {
if (mStencilReference == stencilReference) {
return;
}
mStencilReference = stencilReference;
CallGLStencilFunc(gl);
}
void PersistentPipelineState::CallGLStencilFunc(const OpenGLFunctions& gl) {
gl.StencilFuncSeparate(GL_BACK, mStencilBackCompareFunction, mStencilReference,
mStencilReadMask);
gl.StencilFuncSeparate(GL_FRONT, mStencilFrontCompareFunction, mStencilReference,
mStencilReadMask);
}
}} // namespace dawn_native::opengl