Skip to content

Commit

Permalink
fix astc texture
Browse files Browse the repository at this point in the history
  • Loading branch information
yoki0805 committed Oct 22, 2024
1 parent b6e8c8c commit ee8e6bc
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 43 deletions.
46 changes: 26 additions & 20 deletions cocos/gfx/webgl/webgl-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2722,27 +2722,33 @@ export function WebGLCmdFuncCopyBuffersToTexture (
gpuTexture.glType$,
pixels,
);
} else if (gpuTexture.glInternalFmt$ !== (WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL as number) && !device.extensions.noCompressedTexSubImage2D$) {
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$ !== (WebGLEXT.COMPRESSED_RGB_ETC1_WEBGL as number) && !device.extensions.noCompressedTexSubImage2D$) {
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
52 changes: 29 additions & 23 deletions cocos/gfx/webgl2/webgl2-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2970,30 +2970,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,
);
}
}
}
break;
Expand Down

0 comments on commit ee8e6bc

Please sign in to comment.