|
@@ -661,10 +661,25 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
if ( mipmaps.length > 0 && supportsMips ) {
|
|
if ( mipmaps.length > 0 && supportsMips ) {
|
|
|
|
|
|
|
|
+ if ( useTexStorage && allocateMemory ) {
|
|
|
|
+
|
|
|
|
+ state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, mipmaps[ 0 ].width, mipmaps[ 0 ].height );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
for ( let i = 0, il = mipmaps.length; i < il; i ++ ) {
|
|
|
|
|
|
mipmap = mipmaps[ i ];
|
|
mipmap = mipmaps[ i ];
|
|
- state.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
|
|
|
|
|
|
+
|
|
|
|
+ if ( useTexStorage ) {
|
|
|
|
+
|
|
|
|
+ state.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, mipmap.width, mipmap.height, glFormat, glType, mipmap.data );
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ state.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -672,7 +687,21 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
} else {
|
|
} else {
|
|
|
|
|
|
- state.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data );
|
|
|
|
|
|
+ if ( useTexStorage ) {
|
|
|
|
+
|
|
|
|
+ if ( allocateMemory ) {
|
|
|
|
+
|
|
|
|
+ state.texStorage2D( _gl.TEXTURE_2D, levels, glInternalFormat, image.width, image.height );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ state.texSubImage2D( _gl.TEXTURE_2D, 0, 0, 0, image.width, image.height, glFormat, glType, image.data );
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ state.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -726,11 +755,39 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,
|
|
|
|
|
|
} else if ( texture.isDataTexture2DArray ) {
|
|
} else if ( texture.isDataTexture2DArray ) {
|
|
|
|
|
|
- state.texImage3D( _gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
|
|
|
|
|
|
+ if ( useTexStorage ) {
|
|
|
|
+
|
|
|
|
+ if ( allocateMemory ) {
|
|
|
|
+
|
|
|
|
+ state.texStorage3D( _gl.TEXTURE_2D_ARRAY, levels, glInternalFormat, image.width, image.height, image.depth );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ state.texSubImage3D( _gl.TEXTURE_2D_ARRAY, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ state.texImage3D( _gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
} else if ( texture.isDataTexture3D ) {
|
|
} else if ( texture.isDataTexture3D ) {
|
|
|
|
|
|
- state.texImage3D( _gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
|
|
|
|
|
|
+ if ( useTexStorage ) {
|
|
|
|
+
|
|
|
|
+ if ( allocateMemory ) {
|
|
|
|
+
|
|
|
|
+ state.texStorage3D( _gl.TEXTURE_3D, levels, glInternalFormat, image.width, image.height, image.depth );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ state.texSubImage3D( _gl.TEXTURE_3D, 0, 0, 0, 0, image.width, image.height, image.depth, glFormat, glType, image.data );
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ state.texImage3D( _gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
|
|
} else if ( texture.isFramebufferTexture ) {
|
|
} else if ( texture.isFramebufferTexture ) {
|
|
|
|
|