Skip to content

Commit

Permalink
WebGPURenderer: copyFramebufferToTexture() Added support for multis…
Browse files Browse the repository at this point in the history
…ampling (#28054)
  • Loading branch information
sunag committed Apr 2, 2024
1 parent 75b06a1 commit b31d25c
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions examples/jsm/renderers/webgl/utils/WebGLTextureUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -576,20 +576,35 @@ class WebGLTextureUtils {
const width = texture.image.width;
const height = texture.image.height;

if ( texture.isDepthTexture ) {
const requireDrawFrameBuffer = texture.isDepthTexture === true || ( renderContext.renderTarget && renderContext.renderTarget.samples > 0 );

let mask = gl.DEPTH_BUFFER_BIT;
if ( requireDrawFrameBuffer ) {

if ( renderContext.stencil ) {
let mask;
let attachment;

mask |= gl.STENCIL_BUFFER_BIT;
if ( texture.isDepthTexture === true ) {

mask = gl.DEPTH_BUFFER_BIT;
attachment = gl.DEPTH_ATTACHMENT;

if ( renderContext.stencil ) {

mask |= gl.STENCIL_BUFFER_BIT;

}

} else {

mask = gl.COLOR_BUFFER_BIT;
attachment = gl.COLOR_ATTACHMENT0;

}

const fb = gl.createFramebuffer();
state.bindFramebuffer( gl.DRAW_FRAMEBUFFER, fb );

gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, textureGPU, 0 );
gl.framebufferTexture2D( gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, textureGPU, 0 );

gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, gl.NEAREST );

Expand Down Expand Up @@ -626,7 +641,6 @@ class WebGLTextureUtils {

if ( samples > 0 ) {


if ( depthTexture && depthTexture.isDepthTexture ) {

if ( depthTexture.type === gl.FLOAT ) {
Expand Down

0 comments on commit b31d25c

Please sign in to comment.