Skip to content

Commit

Permalink
Merge pull request #5225 from AnalyticalGraphicsInc/viewports-increme…
Browse files Browse the repository at this point in the history
…ntal

Incremental renderer updates for multiple viewports
  • Loading branch information
lilleyse authored Apr 27, 2017
2 parents 9cc847e + b91d88b commit e0db2a9
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 71 deletions.
22 changes: 19 additions & 3 deletions Source/Scene/FXAA.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ define([
this._viewport = new BoundingRectangle();
this._rs = undefined;

this._useScissorTest = false;
this._scissorRectangle = undefined;

var clearCommand = new ClearCommand({
color : new Color(0.0, 0.0, 0.0, 0.0),
depth : 1.0,
Expand Down Expand Up @@ -81,7 +84,7 @@ define([
}
}

FXAA.prototype.update = function(context) {
FXAA.prototype.update = function(context, passState) {
var width = context.drawingBufferWidth;
var height = context.drawingBufferHeight;

Expand Down Expand Up @@ -150,9 +153,22 @@ define([
this._viewport.width = width;
this._viewport.height = height;

if (!defined(this._rs) || !BoundingRectangle.equals(this._rs.viewport, this._viewport)) {
var useScissorTest = !BoundingRectangle.equals(this._viewport, passState.viewport);
var updateScissor = useScissorTest !== this._useScissorTest;
this._useScissorTest = useScissorTest;

if (!BoundingRectangle.equals(this._scissorRectangle, passState.viewport)) {
this._scissorRectangle = BoundingRectangle.clone(passState.viewport, this._scissorRectangle);
updateScissor = true;
}

if (!defined(this._rs) || !BoundingRectangle.equals(this._rs.viewport, this._viewport) || updateScissor) {
this._rs = RenderState.fromCache({
viewport : this._viewport
viewport : this._viewport,
scissorTest : {
enabled : this._useScissorTest,
rectangle : this._scissorRectangle
}
});
}

Expand Down
30 changes: 23 additions & 7 deletions Source/Scene/GlobeDepth.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ define([
this._viewport = new BoundingRectangle();
this._rs = undefined;

this._useScissorTest = false;
this._scissorRectangle = undefined;

this._debugGlobeDepthViewportCommand = undefined;
}

Expand Down Expand Up @@ -111,7 +114,7 @@ define([
});
}

function createFramebuffers(globeDepth, context, width, height) {
function createFramebuffers(globeDepth, context) {
globeDepth.framebuffer = new Framebuffer({
context : context,
colorTextures : [globeDepth._colorTexture],
Expand All @@ -133,17 +136,30 @@ define([
destroyTextures(globeDepth);
destroyFramebuffers(globeDepth);
createTextures(globeDepth, context, width, height);
createFramebuffers(globeDepth, context, width, height);
createFramebuffers(globeDepth, context);
}
}

function updateCopyCommands(globeDepth, context, width, height) {
function updateCopyCommands(globeDepth, context, width, height, passState) {
globeDepth._viewport.width = width;
globeDepth._viewport.height = height;

if (!defined(globeDepth._rs) || !BoundingRectangle.equals(globeDepth._viewport, globeDepth._rs.viewport)) {
var useScissorTest = !BoundingRectangle.equals(globeDepth._viewport, passState.viewport);
var updateScissor = useScissorTest !== globeDepth._useScissorTest;
globeDepth._useScissorTest = useScissorTest;

if (!BoundingRectangle.equals(globeDepth._scissorRectangle, passState.viewport)) {
globeDepth._scissorRectangle = BoundingRectangle.clone(passState.viewport, globeDepth._scissorRectangle);
updateScissor = true;
}

if (!defined(globeDepth._rs) || !BoundingRectangle.equals(globeDepth._viewport, globeDepth._rs.viewport) || updateScissor) {
globeDepth._rs = RenderState.fromCache({
viewport : globeDepth._viewport
viewport : globeDepth._viewport,
scissorTest : {
enabled : globeDepth._useScissorTest,
rectangle : globeDepth._scissorRectangle
}
});
}

Expand Down Expand Up @@ -196,12 +212,12 @@ define([
executeDebugGlobeDepth(this, context, passState);
};

GlobeDepth.prototype.update = function(context) {
GlobeDepth.prototype.update = function(context, passState) {
var width = context.drawingBufferWidth;
var height = context.drawingBufferHeight;

updateFramebuffers(this, context, width, height);
updateCopyCommands(this, context, width, height);
updateCopyCommands(this, context, width, height, passState);
context.uniformState.globeDepthTexture = undefined;
};

Expand Down
22 changes: 19 additions & 3 deletions Source/Scene/OIT.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ define([

this._viewport = new BoundingRectangle();
this._rs = undefined;

this._useScissorTest = false;
this._scissorRectangle = undefined;
}

function destroyTextures(oit) {
Expand Down Expand Up @@ -200,7 +203,7 @@ define([
return supported;
}

OIT.prototype.update = function(context, framebuffer) {
OIT.prototype.update = function(context, passState, framebuffer) {
if (!this.isSupported()) {
return;
}
Expand Down Expand Up @@ -312,9 +315,22 @@ define([
this._viewport.width = width;
this._viewport.height = height;

if (!defined(this._rs) || !BoundingRectangle.equals(this._viewport, this._rs.viewport)) {
var useScissorTest = !BoundingRectangle.equals(this._viewport, passState.viewport);
var updateScissor = useScissorTest !== this._useScissorTest;
this._useScissorTest = useScissorTest;

if (!BoundingRectangle.equals(this._scissorRectangle, passState.viewport)) {
this._scissorRectangle = BoundingRectangle.clone(passState.viewport, this._scissorRectangle);
updateScissor = true;
}

if (!defined(this._rs) || !BoundingRectangle.equals(this._viewport, this._rs.viewport) || updateScissor) {
this._rs = RenderState.fromCache({
viewport : this._viewport
viewport : this._viewport,
scissorTest : {
enabled : this._useScissorTest,
rectangle : this._scissorRectangle
}
});
}

Expand Down
Loading

0 comments on commit e0db2a9

Please sign in to comment.