Allow Blitter::fastClear to directly write to external buffer
When the external buffer is the one that is dirty, avoid a useless
copy from external to internal before fast clearing the buffer by
clearing the external buffer directly.
Change-Id: I469243ba8a2b8617f9a0f8b6e2a089f667b8ae63
Reviewed-on: https://swiftshader-review.googlesource.com/18033
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Renderer/Blitter.cpp b/src/Renderer/Blitter.cpp
index ce02ff9..c77491c 100644
--- a/src/Renderer/Blitter.cpp
+++ b/src/Renderer/Blitter.cpp
@@ -99,7 +99,8 @@
return false;
}
- uint8_t *slice = (uint8_t*)dest->lockInternal(dRect.x0, dRect.y0, dRect.slice, sw::LOCK_WRITEONLY, sw::PUBLIC);
+ bool useDestInternal = !dest->isExternalDirty();
+ uint8_t *slice = (uint8_t*)dest->lock(dRect.x0, dRect.y0, dRect.slice, sw::LOCK_WRITEONLY, sw::PUBLIC, useDestInternal);
for(int j = 0; j < dest->getSamples(); j++)
{
@@ -111,24 +112,24 @@
for(int i = dRect.y0; i < dRect.y1; i++)
{
sw::clear((uint16_t*)d, packed, dRect.x1 - dRect.x0);
- d += dest->getInternalPitchB();
+ d += dest->getPitchB(useDestInternal);
}
break;
case 4:
for(int i = dRect.y0; i < dRect.y1; i++)
{
sw::clear((uint32_t*)d, packed, dRect.x1 - dRect.x0);
- d += dest->getInternalPitchB();
+ d += dest->getPitchB(useDestInternal);
}
break;
default:
assert(false);
}
- slice += dest->getInternalSliceB();
+ slice += dest->getSliceB(useDestInternal);
}
- dest->unlockInternal();
+ dest->unlock(useDestInternal);
return true;
}