Natasha Lee 4886403b61 Clear OpenGL textures on first use if not initialized already
This prevents dirty textures to be used when memory is recycled while
destroying/creating new textures. If a texture is being used for the
first time and has not yet been initialized, it will be cleared
to zeros.

Bug: dawn:145
Change-Id: I1140ff0535241b247b855df2afefc01fbc003470
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/8380
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Natasha Lee <natlee@microsoft.com>
2019-07-02 17:38:09 +00:00

53 lines
1.8 KiB
C++

// Copyright 2019 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/UtilsGL.h"
#include "common/Assert.h"
namespace dawn_native { namespace opengl {
GLuint ToOpenGLCompareFunction(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();
}
}
GLint GetStencilMaskFromStencilFormat(dawn::TextureFormat depthStencilFormat) {
switch (depthStencilFormat) {
case dawn::TextureFormat::Depth24PlusStencil8:
return 0xFF;
default:
UNREACHABLE();
}
}
}} // namespace dawn_native::opengl