From c9552d5c9a4053f9ab117e883f6f395df5dea2b0 Mon Sep 17 00:00:00 2001 From: yoki0805 Date: Tue, 22 Oct 2024 17:32:44 +0800 Subject: [PATCH] fix other texture types --- cocos/gfx/webgl/webgl-commands.ts | 51 ++++---- cocos/gfx/webgl2/webgl2-commands.ts | 196 +++++++++++++++------------- 2 files changed, 133 insertions(+), 114 deletions(-) diff --git a/cocos/gfx/webgl/webgl-commands.ts b/cocos/gfx/webgl/webgl-commands.ts index e812a3d15ed..ffc9d88a400 100644 --- a/cocos/gfx/webgl/webgl-commands.ts +++ b/cocos/gfx/webgl/webgl-commands.ts @@ -2727,7 +2727,8 @@ export function WebGLCmdFuncCopyBuffersToTexture ( gpuTexture.width$ === destWidth && gpuTexture.height$ === destHeight && offset.x === 0 && offset.y === 0 ); - if (!isFullCopy && gpuTexture.glInternalFmt$ !== (WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL as number) && !device.extensions.noCompressedTexSubImage2D$) { + if (!isFullCopy && gpuTexture.glInternalFmt$ !== (WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL as number) + && !device.extensions.noCompressedTexSubImage2D$) { gl.compressedTexSubImage2D( WebGLConstants.TEXTURE_2D, mipLevel, @@ -2793,28 +2794,34 @@ export function WebGLCmdFuncCopyBuffersToTexture ( gpuTexture.glType$, pixels, ); - } else if (gpuTexture.glInternalFmt$ !== (WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL as number) - && !device.extensions.noCompressedTexSubImage2D$) { - gl.compressedTexSubImage2D( - WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, - mipLevel, - offset.x, - offset.y, - destWidth, - destHeight, - gpuTexture.glFormat$, - pixels, - ); - } else { // WEBGL_compressed_texture_etc1 - gl.compressedTexImage2D( - WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, - mipLevel, - gpuTexture.glInternalFmt$, - destWidth, - destHeight, - 0, - pixels, + } else { + const isFullCopy = ( + gpuTexture.width$ === destWidth && gpuTexture.height$ === destHeight + && offset.x === 0 && offset.y === 0 ); + if (!isFullCopy && gpuTexture.glInternalFmt$ !== (WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL as number) + && !device.extensions.noCompressedTexSubImage2D$) { + gl.compressedTexSubImage2D( + WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, + mipLevel, + offset.x, + offset.y, + destWidth, + destHeight, + gpuTexture.glFormat$, + pixels, + ); + } else { // WEBGL_compressed_texture_etc1 + gl.compressedTexImage2D( + WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, + mipLevel, + gpuTexture.glInternalFmt$, + destWidth, + destHeight, + 0, + pixels, + ); + } } } } diff --git a/cocos/gfx/webgl2/webgl2-commands.ts b/cocos/gfx/webgl2/webgl2-commands.ts index afc1f305e7f..1d1330661cc 100644 --- a/cocos/gfx/webgl2/webgl2-commands.ts +++ b/cocos/gfx/webgl2/webgl2-commands.ts @@ -2829,27 +2829,33 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( gpuTexture.glType$, pixels, ); - } else if (gpuTexture.glInternalFmt$ !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL as number) { - gl.compressedTexSubImage2D( - WebGLConstants.TEXTURE_2D, - mipLevel, - offset.x, - offset.y, - destWidth, - destHeight, - gpuTexture.glFormat$, - pixels, - ); - } else { // WEBGL_compressed_texture_etc1 - gl.compressedTexImage2D( - WebGLConstants.TEXTURE_2D, - mipLevel, - gpuTexture.glInternalFmt$, - destWidth, - destHeight, - 0, - pixels, + } else { + const isFullCopy = ( + gpuTexture.width$ === destWidth && gpuTexture.height$ === destHeight + && offset.x === 0 && offset.y === 0 ); + if (!isFullCopy && gpuTexture.glInternalFmt$ !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL as number) { + gl.compressedTexSubImage2D( + WebGLConstants.TEXTURE_2D, + mipLevel, + offset.x, + offset.y, + destWidth, + destHeight, + gpuTexture.glFormat$, + pixels, + ); + } else { // WEBGL_compressed_texture_etc1 + gl.compressedTexImage2D( + WebGLConstants.TEXTURE_2D, + mipLevel, + gpuTexture.glInternalFmt$, + destWidth, + destHeight, + 0, + pixels, + ); + } } } break; @@ -2899,30 +2905,36 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( gpuTexture.glType$, pixels, ); - } else if (gpuTexture.glInternalFmt$ !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL as number) { - gl.compressedTexSubImage3D( - WebGLConstants.TEXTURE_2D_ARRAY, - mipLevel, - offset.x, - offset.y, - offset.z, - destWidth, - destHeight, - extent.depth, - gpuTexture.glFormat$, - pixels, - ); - } else { // WEBGL_compressed_texture_etc1 - gl.compressedTexImage3D( - WebGLConstants.TEXTURE_2D_ARRAY, - mipLevel, - gpuTexture.glInternalFmt$, - destWidth, - destHeight, - extent.depth, - 0, - pixels, + } else { + const isFullCopy = ( + gpuTexture.width$ === destWidth && gpuTexture.height$ === destHeight + && offset.x === 0 && offset.y === 0 ); + if (!isFullCopy && gpuTexture.glInternalFmt$ !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL as number) { + gl.compressedTexSubImage3D( + WebGLConstants.TEXTURE_2D_ARRAY, + mipLevel, + offset.x, + offset.y, + offset.z, + destWidth, + destHeight, + extent.depth, + gpuTexture.glFormat$, + pixels, + ); + } else { // WEBGL_compressed_texture_etc1 + gl.compressedTexImage3D( + WebGLConstants.TEXTURE_2D_ARRAY, + mipLevel, + gpuTexture.glInternalFmt$, + destWidth, + destHeight, + extent.depth, + 0, + pixels, + ); + } } } } @@ -2970,36 +2982,30 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( gpuTexture.glType$, pixels, ); - } else { - const isFullCopy = ( - gpuTexture.width$ === destWidth && gpuTexture.height$ === destHeight - && offset.x === 0 && offset.y === 0 + } else if (gpuTexture.glInternalFmt$ !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL as number) { + gl.compressedTexSubImage3D( + WebGLConstants.TEXTURE_2D_ARRAY, + mipLevel, + offset.x, + offset.y, + offset.z, + destWidth, + destHeight, + extent.depth, + gpuTexture.glFormat$, + pixels, + ); + } else { // WEBGL_compressed_texture_etc1 + gl.compressedTexImage3D( + WebGLConstants.TEXTURE_2D_ARRAY, + mipLevel, + gpuTexture.glInternalFmt$, + destWidth, + destHeight, + extent.depth, + 0, + pixels, ); - if (!isFullCopy && gpuTexture.glInternalFmt$ !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL as number) { - gl.compressedTexSubImage3D( - WebGLConstants.TEXTURE_2D_ARRAY, - mipLevel, - offset.x, - offset.y, - offset.z, - destWidth, - destHeight, - extent.depth, - gpuTexture.glFormat$, - pixels, - ); - } else { // WEBGL_compressed_texture_etc1 - gl.compressedTexImage3D( - WebGLConstants.TEXTURE_2D_ARRAY, - mipLevel, - gpuTexture.glInternalFmt$, - destWidth, - destHeight, - extent.depth, - 0, - pixels, - ); - } } } break; @@ -3044,27 +3050,33 @@ export function WebGL2CmdFuncCopyBuffersToTexture ( gpuTexture.glType$, pixels, ); - } else if (gpuTexture.glInternalFmt$ !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL as number) { - gl.compressedTexSubImage2D( - WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, - mipLevel, - offset.x, - offset.y, - destWidth, - destHeight, - gpuTexture.glFormat$, - pixels, - ); - } else { // WEBGL_compressed_texture_etc1 - gl.compressedTexImage2D( - WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, - mipLevel, - gpuTexture.glInternalFmt$, - destWidth, - destHeight, - 0, - pixels, + } else { + const isFullCopy = ( + gpuTexture.width$ === destWidth && gpuTexture.height$ === destHeight + && offset.x === 0 && offset.y === 0 ); + if (!isFullCopy && gpuTexture.glInternalFmt$ !== WebGL2EXT.COMPRESSED_RGB_ETC1_WEBGL as number) { + gl.compressedTexSubImage2D( + WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, + mipLevel, + offset.x, + offset.y, + destWidth, + destHeight, + gpuTexture.glFormat$, + pixels, + ); + } else { // WEBGL_compressed_texture_etc1 + gl.compressedTexImage2D( + WebGLConstants.TEXTURE_CUBE_MAP_POSITIVE_X + f, + mipLevel, + gpuTexture.glInternalFmt$, + destWidth, + destHeight, + 0, + pixels, + ); + } } } }