From 974a1503273543719df2a3a18a967a4a785d49f1 Mon Sep 17 00:00:00 2001 From: Jiawei Shao Date: Wed, 8 May 2019 23:59:03 +0000 Subject: [PATCH] OpenGL: Set default values for dynamic states before clear This patch fixes a bug on the OpenGL backend by setting default values for dynamic states (blend color, viewport, scissor rectangle, etc) before clearing the attachments of the render pass so that the full area of the attachments can be cleared correctly. BUG=dawn:126, dawn:137, dawn:141 TEST=dawn_end2end_tests Change-Id: I9ddf74a67413ed51f83a69a3dc2c2377a0622cac Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/7080 Commit-Queue: Jiawei Shao Reviewed-by: Austin Eng --- src/dawn_native/opengl/CommandBufferGL.cpp | 15 +++++++-------- src/tests/end2end/RenderPassLoadOpTests.cpp | 6 ------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/dawn_native/opengl/CommandBufferGL.cpp b/src/dawn_native/opengl/CommandBufferGL.cpp index 03f2e11df6..686f9dbad3 100644 --- a/src/dawn_native/opengl/CommandBufferGL.cpp +++ b/src/dawn_native/opengl/CommandBufferGL.cpp @@ -680,6 +680,13 @@ namespace dawn_native { namespace opengl { } } + // Set defaults for dynamic state before executing clears and commands. + PersistentPipelineState persistentPipelineState; + persistentPipelineState.SetDefaultState(); + glBlendColor(0, 0, 0, 0); + glViewport(0, 0, renderPass->width, renderPass->height); + glScissor(0, 0, renderPass->width, renderPass->height); + // Clear framebuffer attachments as needed { for (uint32_t i : IterateBitSet(renderPass->colorAttachmentsSet)) { @@ -725,17 +732,9 @@ namespace dawn_native { namespace opengl { RenderPipeline* lastPipeline = nullptr; uint64_t indexBufferBaseOffset = 0; - PersistentPipelineState persistentPipelineState; - PushConstantTracker pushConstants; InputBufferTracker inputBuffers; - // Set defaults for dynamic state - persistentPipelineState.SetDefaultState(); - glBlendColor(0, 0, 0, 0); - glViewport(0, 0, renderPass->width, renderPass->height); - glScissor(0, 0, renderPass->width, renderPass->height); - Command type; while (mCommands.NextCommandId(&type)) { switch (type) { diff --git a/src/tests/end2end/RenderPassLoadOpTests.cpp b/src/tests/end2end/RenderPassLoadOpTests.cpp index aadd9bc292..5915b31b9e 100644 --- a/src/tests/end2end/RenderPassLoadOpTests.cpp +++ b/src/tests/end2end/RenderPassLoadOpTests.cpp @@ -112,12 +112,6 @@ class RenderPassLoadOpTests : public DawnTest { // Tests clearing, loading, and drawing into color attachments TEST_P(RenderPassLoadOpTests, ColorClearThenLoadAndDraw) { - // TODO(jiawei.shao@intel.com): investigate why the test is flaky on Linux Intel OpenGL drivers. - // Currently we cannot collect PCI IDs from OpenGL drivers, we have to skip it on all OpenGL - // backends. - // Tracking bug: https://bugs.chromium.org/p/dawn/issues/detail?id=126 - DAWN_SKIP_TEST_IF(IsOpenGL() && IsLinux()); - // Part 1: clear once, check to make sure it's cleared utils::ComboRenderPassDescriptor renderPassClearZero({renderTargetView}); auto commandsClearZeroEncoder = device.CreateCommandEncoder();