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:
parent
ce78ce2e28
commit
ef74473347
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1011,13 +1011,15 @@ void DawnTestBase::FlushWire() {
|
|||
DawnTestBase::ReadbackReservation DawnTestBase::ReserveReadback(uint64_t readbackSize) {
|
||||
// For now create a new MapRead buffer for each readback
|
||||
// TODO(cwallez@chromium.org): eventually make bigger buffers and allocate linearly?
|
||||
wgpu::BufferDescriptor descriptor;
|
||||
descriptor.size = readbackSize;
|
||||
descriptor.usage = wgpu::BufferUsage::MapRead | wgpu::BufferUsage::CopyDst;
|
||||
|
||||
ReadbackSlot slot;
|
||||
slot.bufferSize = readbackSize;
|
||||
slot.buffer = device.CreateBuffer(&descriptor);
|
||||
|
||||
// Create and initialize the slot buffer so that it won't unexpectedly affect the count of
|
||||
// resource lazy clear in the tests.
|
||||
const std::vector<uint8_t> initialBufferData(readbackSize, 0u);
|
||||
slot.buffer =
|
||||
utils::CreateBufferFromData(device, initialBufferData.data(), readbackSize,
|
||||
wgpu::BufferUsage::MapRead | wgpu::BufferUsage::CopyDst);
|
||||
|
||||
ReadbackReservation reservation;
|
||||
reservation.buffer = slot.buffer;
|
||||
|
|
|
@ -167,6 +167,10 @@ TEST_P(TextureSubresourceTest, MipmapLevelsTest) {
|
|||
|
||||
// Test different array layers
|
||||
TEST_P(TextureSubresourceTest, ArrayLayersTest) {
|
||||
// TODO(crbug.com/dawn/517): The Vulkan backend hits this validation rule.
|
||||
// https://www.khronos.org/registry/vulkan/specs/1.2-extensions/html/vkspec.html#VUID-vkCmdDraw-None-02687
|
||||
DAWN_SKIP_TEST_IF(IsBackendValidationEnabled() && IsVulkan());
|
||||
|
||||
// Create a texture with 1 mipmap level and 2 layers
|
||||
wgpu::Texture texture =
|
||||
CreateTexture(1, 2,
|
||||
|
|
|
@ -1365,10 +1365,12 @@ TEST_P(TextureZeroInitTest, CopyTextureToBufferNonRenderableUnaligned) {
|
|||
{
|
||||
uint32_t bytesPerRow = Align(kUnalignedSize, kTextureBytesPerRowAlignment);
|
||||
|
||||
wgpu::BufferDescriptor bufferDesc;
|
||||
bufferDesc.size = kUnalignedSize * bytesPerRow;
|
||||
bufferDesc.usage = wgpu::BufferUsage::CopyDst;
|
||||
wgpu::Buffer buffer = device.CreateBuffer(&bufferDesc);
|
||||
// Create and initialize the destination buffer to ensure we only count the times of
|
||||
// texture lazy initialization in this test.
|
||||
const uint64_t bufferSize = kUnalignedSize * bytesPerRow;
|
||||
const std::vector<uint8_t> initialBufferData(bufferSize, 0u);
|
||||
wgpu::Buffer buffer = utils::CreateBufferFromData(device, initialBufferData.data(),
|
||||
bufferSize, wgpu::BufferUsage::CopyDst);
|
||||
|
||||
wgpu::TextureCopyView textureCopyView = utils::CreateTextureCopyView(texture, 0, {0, 0, 0});
|
||||
wgpu::BufferCopyView bufferCopyView =
|
||||
|
@ -1635,10 +1637,20 @@ TEST_P(TextureZeroInitTest, WriteTextureHalfAtMipLevel) {
|
|||
kMipLevel, 0);
|
||||
}
|
||||
|
||||
// TODO(jiawei.shao@intel.com): remove "lazy_clear_buffer_on_first_use" when we complete the
|
||||
// support of buffer lazy initialization.
|
||||
DAWN_INSTANTIATE_TEST(TextureZeroInitTest,
|
||||
D3D12Backend({"nonzero_clear_resources_on_creation_for_testing"}),
|
||||
D3D12Backend({"nonzero_clear_resources_on_creation_for_testing"},
|
||||
{"use_d3d12_render_pass"}),
|
||||
D3D12Backend({"nonzero_clear_resources_on_creation_for_testing",
|
||||
"lazy_clear_buffer_on_first_use"}),
|
||||
OpenGLBackend({"nonzero_clear_resources_on_creation_for_testing"}),
|
||||
OpenGLBackend({"nonzero_clear_resources_on_creation_for_testing",
|
||||
"lazy_clear_buffer_on_first_use"}),
|
||||
MetalBackend({"nonzero_clear_resources_on_creation_for_testing"}),
|
||||
VulkanBackend({"nonzero_clear_resources_on_creation_for_testing"}));
|
||||
MetalBackend({"nonzero_clear_resources_on_creation_for_testing",
|
||||
"lazy_clear_buffer_on_first_use"}),
|
||||
VulkanBackend({"nonzero_clear_resources_on_creation_for_testing"}),
|
||||
VulkanBackend({"nonzero_clear_resources_on_creation_for_testing",
|
||||
"lazy_clear_buffer_on_first_use"}));
|
||||
|
|
Loading…
Reference in New Issue