Skip to content

Commit

Permalink
Merge pull request #3010 from AnalyticalGraphicsInc/scissor-clear
Browse files Browse the repository at this point in the history
Always apply the scissor test on clears.
  • Loading branch information
pjcozzi committed Sep 9, 2015
2 parents a6bc070 + b077d0f commit 3c0a524
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 4 additions & 4 deletions Source/Renderer/Context.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand Down
9 changes: 6 additions & 3 deletions Source/Renderer/RenderState.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

Expand Down Expand Up @@ -775,4 +778,4 @@ define([
};

return RenderState;
});
});

0 comments on commit 3c0a524

Please sign in to comment.