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

Incremental renderer updates for multiple viewports #5225

Merged
merged 5 commits into from
Apr 27, 2017
Merged
Show file tree
Hide file tree
Changes from 2 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
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 = undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throughout, _useScissorTest is a boolean, right? Initialize it as such, e.g., = false, unless this creates an issue.

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 = undefined;
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 = undefined;
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