Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always apply the scissor test on clears. #3010

Merged
merged 2 commits into from
Sep 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
});
});