Skip to content

Commit

Permalink
fix other texture types
Browse files Browse the repository at this point in the history
  • Loading branch information
yoki0805 committed Oct 22, 2024
1 parent 76df15d commit c9552d5
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 114 deletions.
51 changes: 29 additions & 22 deletions cocos/gfx/webgl/webgl-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
);
}
}
}
}
Expand Down
196 changes: 104 additions & 92 deletions cocos/gfx/webgl2/webgl2-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
);
}
}
}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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,
);
}
}
}
}
Expand Down

0 comments on commit c9552d5

Please sign in to comment.