diff --git a/src/dawn_native/opengl/BufferGL.cpp b/src/dawn_native/opengl/BufferGL.cpp index dc9beef7de..7e91a4940c 100644 --- a/src/dawn_native/opengl/BufferGL.cpp +++ b/src/dawn_native/opengl/BufferGL.cpp @@ -28,7 +28,13 @@ namespace dawn_native { namespace opengl { device->gl.GenBuffers(1, &mBuffer); device->gl.BindBuffer(GL_ARRAY_BUFFER, mBuffer); - device->gl.BufferData(GL_ARRAY_BUFFER, size, nullptr, GL_STATIC_DRAW); + + if (device->IsToggleEnabled(Toggle::NonzeroClearResourcesOnCreationForTesting)) { + std::vector clearValues(size, 1u); + device->gl.BufferData(GL_ARRAY_BUFFER, size, clearValues.data(), GL_STATIC_DRAW); + } else { + device->gl.BufferData(GL_ARRAY_BUFFER, size, nullptr, GL_STATIC_DRAW); + } } Buffer::~Buffer() { diff --git a/src/tests/end2end/NonzeroBufferCreationTests.cpp b/src/tests/end2end/NonzeroBufferCreationTests.cpp index e3fefa7b62..46f136606e 100644 --- a/src/tests/end2end/NonzeroBufferCreationTests.cpp +++ b/src/tests/end2end/NonzeroBufferCreationTests.cpp @@ -53,4 +53,5 @@ TEST_P(NonzeroBufferCreationTests, BufferCreationWithMapWriteWithoutCopyDstUsage DAWN_INSTANTIATE_TEST(NonzeroBufferCreationTests, D3D12Backend({"nonzero_clear_resources_on_creation_for_testing"}), MetalBackend({"nonzero_clear_resources_on_creation_for_testing"}), + OpenGLBackend({"nonzero_clear_resources_on_creation_for_testing"}), VulkanBackend({"nonzero_clear_resources_on_creation_for_testing"}));