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

RenderTarget: Add resolveDepthBuffer. #28170

Merged
merged 4 commits into from
Apr 20, 2024
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: 8 additions & 0 deletions docs/api/ar/renderers/WebGLRenderTarget.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ <h3>
[page:String internalFormat] - الافتراضي هو `null`.<br />
[page:Boolean depthBuffer] - الافتراضي هو `true`. <br />
[page:Boolean stencilBuffer] - الافتراضي هو `false`. <br />
[page:Boolean resolveDepthBuffer] - الافتراضي هو `true`. <br />
[page:Boolean resolveStencilBuffer] - الافتراضي هو `true`. <br />
[page:Number samples] - الافتراضي هو 0. <br /><br />

Expand Down Expand Up @@ -89,9 +90,16 @@ <h3>[property:Boolean depthBuffer]</h3>
<h3>[property:Boolean stencilBuffer]</h3>
<p>يعرض على مخزن القالب. الافتراضي هو false.</p>

<h3>[property:Boolean resolveDepthBuffer]</h3>
<p>
Defines whether the depth buffer should be resolved when rendering into a multisampled render target.
Default is `true`.
</p>

<h3>[property:Boolean resolveStencilBuffer]</h3>
<p>
Defines whether the stencil buffer should be resolved when rendering into a multisampled render target.
This property has no effect when [page:.resolveDepthBuffer] is set to `false`.
Default is `true`.
</p>

Expand Down
8 changes: 8 additions & 0 deletions docs/api/en/renderers/WebGLRenderTarget.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ <h3>
[page:String internalFormat] - default is `null`.<br />
[page:Boolean depthBuffer] - default is `true`. <br />
[page:Boolean stencilBuffer] - default is `false`.<br />
[page:Boolean resolveDepthBuffer] - default is `true`.<br />
[page:Boolean resolveStencilBuffer] - default is `true`.<br />
[page:Number samples] - default is `0`.<br />
[page:Number count] - default is `1`.<br /><br />
Expand Down Expand Up @@ -98,9 +99,16 @@ <h3>[property:Boolean depthBuffer]</h3>
<h3>[property:Boolean stencilBuffer]</h3>
<p>Renders to the stencil buffer. Default is false.</p>

<h3>[property:Boolean resolveDepthBuffer]</h3>
<p>
Defines whether the depth buffer should be resolved when rendering into a multisampled render target.
Default is `true`.
</p>

<h3>[property:Boolean resolveStencilBuffer]</h3>
<p>
Defines whether the stencil buffer should be resolved when rendering into a multisampled render target.
This property has no effect when [page:.resolveDepthBuffer] is set to `false`.
Default is `true`.
</p>

Expand Down
8 changes: 8 additions & 0 deletions docs/api/it/renderers/WebGLRenderTarget.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ <h3>[name]([param:Number width], [param:Number height], [param:Object options])<
[page:String internalFormat] - il valore predefinito è `null`.<br />
[page:Boolean depthBuffer] - il valore predefinito è `true`. <br />
[page:Boolean stencilBuffer] - il valore predefinito è `false`.<br />
[page:Boolean resolveDepthBuffer] - il valore predefinito è `true`.<br />
[page:Boolean resolveStencilBuffer] - il valore predefinito è `true`.<br />
[page:Number samples] - il valore predefinito è 0.<br />
[page:Number count] - default is `1`.<br /><br />
Expand Down Expand Up @@ -103,9 +104,16 @@ <h3>[property:Boolean stencilBuffer]</h3>
Effettua il rendering al buffer stencil. Il valore predefinito è `false`.
</p>

<h3>[property:Boolean resolveDepthBuffer]</h3>
<p>
Defines whether the depth buffer should be resolved when rendering into a multisampled render target.
Il valore predefinito è `true`.
</p>

<h3>[property:Boolean resolveStencilBuffer]</h3>
<p>
Defines whether the stencil buffer should be resolved when rendering into a multisampled render target.
This property has no effect when [page:.resolveDepthBuffer] is set to `false`.
Il valore predefinito è `true`.
</p>

Expand Down
8 changes: 8 additions & 0 deletions docs/api/zh/renderers/WebGLRenderTarget.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ <h3>[name]([param:Number width], [param:Number height], [param:Object options])<
[page:String internalFormat] - 默认是 `null`.<br />
[page:Boolean depthBuffer] - 默认是`true`.<br />
[page:Boolean stencilBuffer] - 默认是`false`.<br />
[page:Boolean resolveDepthBuffer] - 默认是`true`.<br />
[page:Boolean resolveStencilBuffer] - 默认是`true`.<br />
[page:Number samples] - 默认是`0`.<br />
[page:Number count] - default is `1`.<br /><br />
Expand Down Expand Up @@ -99,9 +100,16 @@ <h3>[property:Boolean stencilBuffer]</h3>
渲染到模板缓冲区。默认为false.
</p>

<h3>[property:Boolean resolveDepthBuffer]</h3>
<p>
Defines whether the depth buffer should be resolved when rendering into a multisampled render target.
默认为`true`.
</p>

<h3>[property:Boolean resolveStencilBuffer]</h3>
<p>
Defines whether the stencil buffer should be resolved when rendering into a multisampled render target.
This property has no effect when [page:.resolveDepthBuffer] is set to `false`.
默认为`true`.
</p>

Expand Down
3 changes: 3 additions & 0 deletions src/core/RenderTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class RenderTarget extends EventDispatcher {
minFilter: LinearFilter,
depthBuffer: true,
stencilBuffer: false,
resolveDepthBuffer: true,
resolveStencilBuffer: true,
depthTexture: null,
samples: 0,
Expand All @@ -59,6 +60,7 @@ class RenderTarget extends EventDispatcher {
this.depthBuffer = options.depthBuffer;
this.stencilBuffer = options.stencilBuffer;

this.resolveDepthBuffer = options.resolveDepthBuffer;
this.resolveStencilBuffer = options.resolveStencilBuffer;

this.depthTexture = options.depthTexture;
Expand Down Expand Up @@ -138,6 +140,7 @@ class RenderTarget extends EventDispatcher {
this.depthBuffer = source.depthBuffer;
this.stencilBuffer = source.stencilBuffer;

this.resolveDepthBuffer = source.resolveDepthBuffer;
this.resolveStencilBuffer = source.resolveStencilBuffer;

if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone();
Expand Down
4 changes: 1 addition & 3 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1432,12 +1432,10 @@ class WebGLRenderer {
minFilter: LinearMipmapLinearFilter,
samples: 4,
stencilBuffer: stencil,
resolveDepthBuffer: false,
resolveStencilBuffer: false
} );

const renderTargetProperties = properties.get( currentRenderState.state.transmissionRenderTarget[ camera.id ] );
renderTargetProperties.__ignoreDepthValues = true;

// debug

/*
Expand Down
11 changes: 3 additions & 8 deletions src/renderers/webgl/WebGLTextures.js
Original file line number Diff line number Diff line change
Expand Up @@ -1868,9 +1868,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

for ( let i = 0; i < textures.length; i ++ ) {

const ignoreDepthValues = ( renderTargetProperties.__ignoreDepthValues !== undefined ) ? renderTargetProperties.__ignoreDepthValues : false;

if ( ignoreDepthValues === false ) {
if ( renderTarget.resolveDepthBuffer ) {

if ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;

Expand Down Expand Up @@ -1898,7 +1896,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

invalidationArrayRead.push( _gl.COLOR_ATTACHMENT0 + i );

if ( renderTarget.depthBuffer && ignoreDepthValues === true ) {
if ( renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false ) {

invalidationArrayRead.push( depthStyle );
invalidationArrayDraw.push( depthStyle );
Expand Down Expand Up @@ -1937,10 +1935,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

} else {

const renderTargetProperties = properties.get( renderTarget );
const ignoreDepthValues = ( renderTargetProperties.__ignoreDepthValues !== undefined ) ? renderTargetProperties.__ignoreDepthValues : false;

if ( renderTarget.depthBuffer && ignoreDepthValues && supportsInvalidateFramebuffer ) {
if ( renderTarget.depthBuffer && renderTarget.resolveDepthBuffer === false && supportsInvalidateFramebuffer ) {

const depthStyle = renderTarget.stencilBuffer ? _gl.DEPTH_STENCIL_ATTACHMENT : _gl.DEPTH_ATTACHMENT;

Expand Down
6 changes: 2 additions & 4 deletions src/renderers/webxr/WebXRManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,10 @@ class WebXRManager extends EventDispatcher {
depthTexture: new DepthTexture( glProjLayer.textureWidth, glProjLayer.textureHeight, depthType, undefined, undefined, undefined, undefined, undefined, undefined, depthFormat ),
stencilBuffer: attributes.stencil,
colorSpace: renderer.outputColorSpace,
samples: attributes.antialias ? 4 : 0
samples: attributes.antialias ? 4 : 0,
resolveDepthBuffer: ( glProjLayer.ignoreDepthValues === false )
} );

const renderTargetProperties = renderer.properties.get( newRenderTarget );
renderTargetProperties.__ignoreDepthValues = glProjLayer.ignoreDepthValues;

}

newRenderTarget.isXRRenderTarget = true; // TODO Remove this when possible, see #23278
Expand Down