Skip to content

Commit

Permalink
WebGLTextures: Clean up.
Browse files Browse the repository at this point in the history
  • Loading branch information
mrdoob committed Feb 6, 2021
1 parent 9663314 commit 341aa56
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions src/renderers/webgl/WebGLTextures.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,10 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

function deallocateRenderTarget( renderTarget ) {

const texture = renderTarget.texture;

const renderTargetProperties = properties.get( renderTarget );
const textureProperties = properties.get( renderTarget.texture );
const textureProperties = properties.get( texture );

if ( ! renderTarget ) return;

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

}

properties.remove( renderTarget.texture );
properties.remove( texture );
properties.remove( renderTarget );

}
Expand Down Expand Up @@ -832,9 +834,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
// Setup storage for target texture and bind it to correct framebuffer
function setupFrameBufferTexture( framebuffer, renderTarget, attachment, textureTarget ) {

const glFormat = utils.convert( renderTarget.texture.format );
const glType = utils.convert( renderTarget.texture.type );
const glInternalFormat = getInternalFormat( renderTarget.texture.internalFormat, glFormat, glType );
const texture = renderTarget.texture;

const glFormat = utils.convert( texture.format );
const glType = utils.convert( texture.type );
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );

if ( textureTarget === _gl.TEXTURE_3D || textureTarget === _gl.TEXTURE_2D_ARRAY ) {

Expand All @@ -847,7 +851,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
}

_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( renderTarget.texture ).__webglTexture, 0 );
_gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( texture ).__webglTexture, 0 );
_gl.bindFramebuffer( _gl.FRAMEBUFFER, null );

}
Expand Down Expand Up @@ -910,9 +914,11 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

} else {

const glFormat = utils.convert( renderTarget.texture.format );
const glType = utils.convert( renderTarget.texture.type );
const glInternalFormat = getInternalFormat( renderTarget.texture.internalFormat, glFormat, glType );
const texture = renderTarget.texture;

const glFormat = utils.convert( texture.format );
const glType = utils.convert( texture.type );
const glInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );

if ( isMultisample ) {

Expand Down Expand Up @@ -1171,6 +1177,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
function updateRenderTargetMipmap( renderTarget ) {

const texture = renderTarget.texture;

const supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;

if ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {
Expand Down

0 comments on commit 341aa56

Please sign in to comment.