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 <jiawei.shao@intel.com>
Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
Jiawei Shao 2019-05-08 23:59:03 +00:00 committed by Commit Bot service account
parent f112ceca34
commit 974a150327
2 changed files with 7 additions and 14 deletions

View File

@ -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 // Clear framebuffer attachments as needed
{ {
for (uint32_t i : IterateBitSet(renderPass->colorAttachmentsSet)) { for (uint32_t i : IterateBitSet(renderPass->colorAttachmentsSet)) {
@ -725,17 +732,9 @@ namespace dawn_native { namespace opengl {
RenderPipeline* lastPipeline = nullptr; RenderPipeline* lastPipeline = nullptr;
uint64_t indexBufferBaseOffset = 0; uint64_t indexBufferBaseOffset = 0;
PersistentPipelineState persistentPipelineState;
PushConstantTracker pushConstants; PushConstantTracker pushConstants;
InputBufferTracker inputBuffers; 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; Command type;
while (mCommands.NextCommandId(&type)) { while (mCommands.NextCommandId(&type)) {
switch (type) { switch (type) {

View File

@ -112,12 +112,6 @@ class RenderPassLoadOpTests : public DawnTest {
// Tests clearing, loading, and drawing into color attachments // Tests clearing, loading, and drawing into color attachments
TEST_P(RenderPassLoadOpTests, ColorClearThenLoadAndDraw) { 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 // Part 1: clear once, check to make sure it's cleared
utils::ComboRenderPassDescriptor renderPassClearZero({renderTargetView}); utils::ComboRenderPassDescriptor renderPassClearZero({renderTargetView});
auto commandsClearZeroEncoder = device.CreateCommandEncoder(); auto commandsClearZeroEncoder = device.CreateCommandEncoder();