From 06190d3baaf20da422b2142f460b52bff43b8f51 Mon Sep 17 00:00:00 2001 From: Eli Bogomolny Date: Thu, 17 Feb 2022 16:58:50 -0500 Subject: [PATCH] Do not set stencil buffer bit before blit --- Source/Renderer/FramebufferManager.js | 4 ++-- Source/Renderer/MultisampleFramebuffer.js | 7 +++++-- Source/Scene/GlobeDepth.js | 4 ++-- Source/Scene/InvertClassification.js | 9 ++++++--- Source/Scene/Scene.js | 4 +++- 5 files changed, 18 insertions(+), 10 deletions(-) diff --git a/Source/Renderer/FramebufferManager.js b/Source/Renderer/FramebufferManager.js index e86255792b2a..83d4a5d2b48f 100644 --- a/Source/Renderer/FramebufferManager.js +++ b/Source/Renderer/FramebufferManager.js @@ -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); } }; diff --git a/Source/Renderer/MultisampleFramebuffer.js b/Source/Renderer/MultisampleFramebuffer.js index 8eac84be5765..9327cc49cc5e 100644 --- a/Source/Renderer/MultisampleFramebuffer.js +++ b/Source/Renderer/MultisampleFramebuffer.js @@ -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; @@ -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, diff --git a/Source/Scene/GlobeDepth.js b/Source/Scene/GlobeDepth.js index 8ef6f6e3a40c..562ec8ad0ccc 100644 --- a/Source/Scene/GlobeDepth.js +++ b/Source/Scene/GlobeDepth.js @@ -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); } }; diff --git a/Source/Scene/InvertClassification.js b/Source/Scene/InvertClassification.js index 00eb0d965e3e..3fead5009c91 100644 --- a/Source/Scene/InvertClassification.js +++ b/Source/Scene/InvertClassification.js @@ -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); } }; @@ -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); diff --git a/Source/Scene/Scene.js b/Source/Scene/Scene.js index c3085805dc33..f0e85a4bfa1d 100644 --- a/Source/Scene/Scene.js +++ b/Source/Scene/Scene.js @@ -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,