Skip to content

Commit

Permalink
Do not set stencil buffer bit before blit
Browse files Browse the repository at this point in the history
  • Loading branch information
ebogo1 committed Feb 17, 2022
1 parent a2fa0e4 commit 06190d3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Source/Renderer/FramebufferManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,9 +402,9 @@ FramebufferManager.prototype.setDepthStencilTexture = function (texture) {
this._depthStencilTexture = texture;
};

FramebufferManager.prototype.prepareTextures = function (context) {
FramebufferManager.prototype.prepareTextures = function (context, blitStencil) {
if (this._numSamples > 1) {
this._multisampleFramebuffer.blitFramebuffers(context);
this._multisampleFramebuffer.blitFramebuffers(context, blitStencil);
}
};

Expand Down
7 changes: 5 additions & 2 deletions Source/Renderer/MultisampleFramebuffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ MultisampleFramebuffer.prototype.getColorFramebuffer = function () {
return this._colorFramebuffer;
};

MultisampleFramebuffer.prototype.blitFramebuffers = function (context) {
MultisampleFramebuffer.prototype.blitFramebuffers = function (
context,
blitStencil
) {
this._renderFramebuffer.bindRead();
this._colorFramebuffer.bindDraw();
const gl = context._gl;
Expand All @@ -81,7 +84,7 @@ MultisampleFramebuffer.prototype.blitFramebuffers = function (context) {
mask |= gl.COLOR_BUFFER_BIT;
}
if (defined(this._colorFramebuffer.depthStencilTexture)) {
mask |= gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT;
mask |= gl.DEPTH_BUFFER_BIT | (blitStencil ? gl.STENCIL_BUFFER_BIT : 0);
}
gl.blitFramebuffer(
0,
Expand Down
4 changes: 2 additions & 2 deletions Source/Scene/GlobeDepth.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,9 @@ GlobeDepth.prototype.update = function (
this._clearGlobeDepth = clearGlobeDepth;
};

GlobeDepth.prototype.prepareColorTextures = function (context) {
GlobeDepth.prototype.prepareColorTextures = function (context, blitStencil) {
if (!this.picking && this._numSamples > 1) {
this._outputFramebuffer.prepareTextures(context);
this._outputFramebuffer.prepareTextures(context, blitStencil);
}
};

Expand Down
9 changes: 6 additions & 3 deletions Source/Scene/InvertClassification.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,12 @@ InvertClassification.prototype.update = function (
}
};

InvertClassification.prototype.prepareTextures = function (context) {
InvertClassification.prototype.prepareTextures = function (
context,
blitStencil
) {
if (this._fbo._numSamples > 1) {
this._fbo._multisampleFramebuffer.blitFramebuffers(context);
this._fbo.prepareTextures(context, blitStencil);
}
};

Expand All @@ -337,7 +340,7 @@ InvertClassification.prototype.executeClassified = function (
if (!defined(this._previousFramebuffer)) {
const framebuffer = passState.framebuffer;

this.prepareTextures(context);
this.prepareTextures(context, true);
passState.framebuffer = this._fboClassified.framebuffer;
this._translucentCommand.execute(context, passState);

Expand Down
4 changes: 3 additions & 1 deletion Source/Scene/Scene.js
Original file line number Diff line number Diff line change
Expand Up @@ -2484,7 +2484,9 @@ function executeCommands(scene, passState) {

if (length > 0) {
if (defined(globeDepth) && environmentState.useGlobeDepthFramebuffer) {
globeDepth.prepareColorTextures(context);
// When clearGlobeDepth is true, executeUpdateDepth needs
// a globe depth texture with resolved stencil bits.
globeDepth.prepareColorTextures(context, clearGlobeDepth);
globeDepth.executeUpdateDepth(
context,
passState,
Expand Down

0 comments on commit 06190d3

Please sign in to comment.