From 799f4cd169116778c67b200839c4a30e713af2db Mon Sep 17 00:00:00 2001 From: Dan Bagnell Date: Wed, 9 Sep 2015 15:56:52 -0400 Subject: [PATCH 1/2] Always apply the scissor test on clears. --- Source/Renderer/Context.js | 8 ++++---- Source/Renderer/RenderState.js | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Source/Renderer/Context.js b/Source/Renderer/Context.js index ab65371e27c3..4e6c077708ca 100644 --- a/Source/Renderer/Context.js +++ b/Source/Renderer/Context.js @@ -697,12 +697,12 @@ define([ } } - function applyRenderState(context, renderState, passState) { + function applyRenderState(context, renderState, passState, clear) { var previousRenderState = context._currentRenderState; var previousPassState = context._currentPassState; context._currentRenderState = renderState; context._currentPassState = passState; - RenderState.partialApply(context._gl, previousRenderState, renderState, previousPassState, passState); + RenderState.partialApply(context._gl, previousRenderState, renderState, previousPassState, passState, clear); } var scratchBackBufferArray; @@ -771,7 +771,7 @@ define([ } var rs = defaultValue(clearCommand.renderState, this._defaultRenderState); - applyRenderState(this, rs, passState); + applyRenderState(this, rs, passState, true); // The command's framebuffer takes presidence over the pass' framebuffer, e.g., for off-screen rendering. var framebuffer = defaultValue(clearCommand.framebuffer, passState.framebuffer); @@ -793,7 +793,7 @@ define([ bindFramebuffer(context, framebuffer); - applyRenderState(context, rs, passState); + applyRenderState(context, rs, passState, false); var sp = defaultValue(shaderProgram, drawCommand.shaderProgram); sp._bind(); diff --git a/Source/Renderer/RenderState.js b/Source/Renderer/RenderState.js index 3d7ab0356571..4bd1f0f3c58f 100644 --- a/Source/Renderer/RenderState.js +++ b/Source/Renderer/RenderState.js @@ -661,7 +661,7 @@ define([ return funcs; } - RenderState.partialApply = function(gl, previousRenderState, renderState, previousPassState, passState) { + RenderState.partialApply = function(gl, previousRenderState, renderState, previousPassState, passState, clear) { if (previousRenderState !== renderState) { // When a new render state is applied, instead of making WebGL calls for all the states or first // comparing the states one-by-one with the previous state (basically a linear search), we take @@ -683,7 +683,10 @@ define([ var previousScissorTest = (defined(previousPassState.scissorTest)) ? previousPassState.scissorTest : previousRenderState.scissorTest; var scissorTest = (defined(passState.scissorTest)) ? passState.scissorTest : renderState.scissorTest; - if (previousScissorTest !== scissorTest) { + + // Our scissor rectangle can get out of sync with the GL scissor rectangle on clears. + // Seems to be a problem only on ANGLE. See https://github.com/AnalyticalGraphicsInc/cesium/issues/2994 + if (previousScissorTest !== scissorTest || clear) { applyScissorTest(gl, renderState, passState); } From b077d0f77c154ab75aac06c03d2ec97c98ecf9ca Mon Sep 17 00:00:00 2001 From: Patrick Cozzi Date: Wed, 9 Sep 2015 16:53:39 -0400 Subject: [PATCH 2/2] Tweak --- Source/Renderer/RenderState.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Renderer/RenderState.js b/Source/Renderer/RenderState.js index 4bd1f0f3c58f..8d659f1637b2 100644 --- a/Source/Renderer/RenderState.js +++ b/Source/Renderer/RenderState.js @@ -686,7 +686,7 @@ define([ // Our scissor rectangle can get out of sync with the GL scissor rectangle on clears. // Seems to be a problem only on ANGLE. See https://github.com/AnalyticalGraphicsInc/cesium/issues/2994 - if (previousScissorTest !== scissorTest || clear) { + if ((previousScissorTest !== scissorTest) || clear) { applyScissorTest(gl, renderState, passState); } @@ -778,4 +778,4 @@ define([ }; return RenderState; -}); \ No newline at end of file +});