Implement depth-only/stencil-only copies on Vulkan and Metal

Bug: dawn:439
Change-Id: I07ab014f4f13b73c09b2eecc48cd38b06d88166a
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/24684
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jiawei Shao <jiawei.shao@intel.com>
Commit-Queue: Austin Eng <enga@chromium.org>
This commit is contained in:
Austin Eng
2020-08-04 19:46:37 +00:00
committed by Commit Bot service account
parent e84a1b1376
commit 0a4342793e
16 changed files with 506 additions and 79 deletions

View File

@@ -926,26 +926,36 @@ std::ostringstream& DawnTestBase::AddBufferExpectation(const char* file,
return *(mDeferredExpectations.back().message.get());
}
std::ostringstream& DawnTestBase::AddTextureExpectation(const char* file,
int line,
const wgpu::Texture& texture,
uint32_t x,
uint32_t y,
uint32_t width,
uint32_t height,
uint32_t level,
uint32_t slice,
uint32_t pixelSize,
detail::Expectation* expectation) {
uint32_t bytesPerRow = Align(width * pixelSize, kTextureBytesPerRowAlignment);
uint32_t size = bytesPerRow * (height - 1) + width * pixelSize;
std::ostringstream& DawnTestBase::AddTextureExpectationImpl(const char* file,
int line,
detail::Expectation* expectation,
const wgpu::Texture& texture,
uint32_t x,
uint32_t y,
uint32_t width,
uint32_t height,
uint32_t level,
uint32_t slice,
wgpu::TextureAspect aspect,
uint32_t dataSize,
uint32_t bytesPerRow) {
if (bytesPerRow == 0) {
bytesPerRow = Align(width * dataSize, kTextureBytesPerRowAlignment);
} else {
ASSERT(bytesPerRow >= width * dataSize);
ASSERT(bytesPerRow == Align(bytesPerRow, kTextureBytesPerRowAlignment));
}
auto readback = ReserveReadback(size);
uint32_t size = bytesPerRow * (height - 1) + width * dataSize;
// TODO(enga): We should have the map async alignment in Contants.h. Also, it should change to 8
// for Float64Array.
auto readback = ReserveReadback(Align(size, 4));
// We need to enqueue the copy immediately because by the time we resolve the expectation,
// the texture might have been modified.
wgpu::TextureCopyView textureCopyView =
utils::CreateTextureCopyView(texture, level, {x, y, slice});
utils::CreateTextureCopyView(texture, level, {x, y, slice}, aspect);
wgpu::BufferCopyView bufferCopyView =
utils::CreateBufferCopyView(readback.buffer, readback.offset, bytesPerRow, 0);
wgpu::Extent3D copySize = {width, height, 1};
@@ -962,7 +972,7 @@ std::ostringstream& DawnTestBase::AddTextureExpectation(const char* file,
deferred.readbackSlot = readback.slot;
deferred.readbackOffset = readback.offset;
deferred.size = size;
deferred.rowBytes = width * pixelSize;
deferred.rowBytes = width * dataSize;
deferred.bytesPerRow = bytesPerRow;
deferred.expectation.reset(expectation);