فهرست منبع

WebGLTextures: Fix DepthTexture's allocation (#23868)

* WebGLTextures: Fix DepthTexture's allocation

* WebGLTextures: Rearrange if clauses
chubei-oppen 3 سال پیش
والد
کامیت
3b08a8fc32
1فایلهای تغییر یافته به همراه20 افزوده شده و 12 حذف شده
  1. 20 12
      src/renderers/webgl/WebGLTextures.js

+ 20 - 12
src/renderers/webgl/WebGLTextures.js

@@ -776,13 +776,17 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 				//
 
-				if ( useTexStorage && allocateMemory ) {
+				if ( allocateMemory ) {
 
-					state.texStorage2D( _gl.TEXTURE_2D, 1, glInternalFormat, image.width, image.height );
+					if ( useTexStorage ) {
 
-				} else {
+						state.texStorage2D( _gl.TEXTURE_2D, 1, glInternalFormat, image.width, image.height );
 
-					state.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );
+					} else {
+
+						state.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );
+
+					}
 
 				}
 
@@ -924,20 +928,24 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
 
 			} else if ( texture.isFramebufferTexture ) {
 
-				if ( useTexStorage && allocateMemory ) {
+				if ( allocateMemory ) {
+
+					if ( useTexStorage ) {
 
-					state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height );
+						state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height );
 
-				} else if ( allocateMemory ) {
+					} else {
+
+						let width = image.width, height = image.height;
 
-					let width = image.width, height = image.height;
+						for ( let i = 0; i < levels; i ++ ) {
 
-					for ( let i = 0; i < levels; i ++ ) {
+							state.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, width, height, 0, glFormat, glType, null );
 
-						state.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, width, height, 0, glFormat, glType, null );
+							width >>= 1;
+							height >>= 1;
 
-						width >>= 1;
-						height >>= 1;
+						}
 
 					}