Fix issues in end2end tests for enabling buffer lazy clear by default

This patch cleans up some issues in the end2end tests that will cause
test failures when we enable buffer lazy initialization by default.

This patch also skips a test that always fails with Vulkan validation
layer.

BUG=dawn:414
TEST=dawn_end2end_tests

Change-Id: I40f643615b3fec4e52c90d576285534a99950915
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/26960
Reviewed-by: Austin Eng <enga@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Jiawei Shao <jiawei.shao@intel.com>
This commit is contained in:
Jiawei Shao
2020-08-23 06:08:05 +00:00
committed by Commit Bot service account
parent ce78ce2e28
commit ef74473347
6 changed files with 56 additions and 12 deletions

View File

@@ -21,6 +21,18 @@ namespace dawn_native { namespace opengl {
// Buffer
// static
ResultOrError<Ref<Buffer>> Buffer::CreateInternalBuffer(Device* device,
const BufferDescriptor* descriptor,
bool shouldLazyClear) {
Ref<Buffer> buffer = AcquireRef(new Buffer(device, descriptor, shouldLazyClear));
if (descriptor->mappedAtCreation) {
DAWN_TRY(buffer->MapAtCreation());
}
return std::move(buffer);
}
Buffer::Buffer(Device* device, const BufferDescriptor* descriptor)
: BufferBase(device, descriptor) {
// TODO(cwallez@chromium.org): Have a global "zero" buffer instead of creating a new 4-byte
@@ -38,6 +50,13 @@ namespace dawn_native { namespace opengl {
}
}
Buffer::Buffer(Device* device, const BufferDescriptor* descriptor, bool shouldLazyClear)
: Buffer(device, descriptor) {
if (!shouldLazyClear) {
SetIsDataInitialized();
}
}
Buffer::~Buffer() {
DestroyInternal();
}

View File

@@ -25,6 +25,10 @@ namespace dawn_native { namespace opengl {
class Buffer final : public BufferBase {
public:
static ResultOrError<Ref<Buffer>> CreateInternalBuffer(Device* device,
const BufferDescriptor* descriptor,
bool shouldLazyClear);
Buffer(Device* device, const BufferDescriptor* descriptor);
GLuint GetHandle() const;
@@ -34,6 +38,7 @@ namespace dawn_native { namespace opengl {
void EnsureDataInitializedAsDestination(const CopyTextureToBufferCmd* copy);
private:
Buffer(Device* device, const BufferDescriptor* descriptor, bool shouldLazyClear);
~Buffer() override;
MaybeError MapAsyncImpl(wgpu::MapMode mode, size_t offset, size_t size) override;
void UnmapImpl() override;

View File

@@ -334,8 +334,10 @@ namespace dawn_native { namespace opengl {
return DAWN_OUT_OF_MEMORY_ERROR("Unable to allocate buffer.");
}
// TODO(natlee@microsoft.com): use Dynamic Uplaoder here for temp buffer
Ref<Buffer> srcBuffer = AcquireRef(ToBackend(device->CreateBuffer(&descriptor)));
// We don't count the lazy clear of srcBuffer because it is an internal buffer.
// TODO(natlee@microsoft.com): use Dynamic Uploader here for temp buffer
Ref<Buffer> srcBuffer;
DAWN_TRY_ASSIGN(srcBuffer, Buffer::CreateInternalBuffer(device, &descriptor, false));
// Fill the buffer with clear color
memset(srcBuffer->GetMappedRange(0, descriptor.size), clearColor, descriptor.size);