Metal: Implement lazy texture clears

Bug: dawn:145
Change-Id: I73d161002cb09498e41838a10e9ac1db996c955d
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/14781
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng
2020-01-16 00:12:10 +00:00
committed by Commit Bot service account
parent 0ecc48ecb7
commit 0d6619848d
13 changed files with 813 additions and 61 deletions

View File

@@ -193,12 +193,15 @@ namespace dawn_native { namespace opengl {
Device* device = ToBackend(GetDevice());
const OpenGLFunctions& gl = device->gl;
uint8_t clearColor = (clearValue == TextureBase::ClearValue::Zero) ? 0 : 1;
float fClearColor = (clearValue == TextureBase::ClearValue::Zero) ? 0.f : 1.f;
if (GetFormat().isRenderable) {
if (GetFormat().HasDepthOrStencil()) {
bool doDepthClear = GetFormat().HasDepth();
bool doStencilClear = GetFormat().HasStencil();
GLfloat depth = clearColor;
GLfloat depth = fClearColor;
GLint stencil = clearColor;
if (doDepthClear) {
gl.DepthMask(GL_TRUE);
@@ -265,8 +268,7 @@ namespace dawn_native { namespace opengl {
// Fill the buffer with clear color
uint8_t* clearBuffer = nullptr;
DAWN_TRY(srcBuffer->MapAtCreation(&clearBuffer));
std::fill(reinterpret_cast<uint32_t*>(clearBuffer),
reinterpret_cast<uint32_t*>(clearBuffer + descriptor.size), clearColor);
memset(clearBuffer, clearColor, descriptor.size);
srcBuffer->Unmap();
// Bind buffer and texture, and make the buffer to texture copy