Skip to content

Commit 653c3ab

Browse files
slimbuckMartin Valigursky
authored andcommitted
Open Fix WebGL readTextureAsync allocating too much memory for outputData (#8472)
1 parent 772763e commit 653c3ab

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/platform/graphics/webgl/webgl-graphics-device.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2139,8 +2139,9 @@ class WebglGraphicsDevice extends GraphicsDevice {
21392139
const needsRgbaReadback = rgbaChannels > 0;
21402140

21412141
// Use caller's buffer or allocate output buffer in the user's expected format
2142-
const outputData = options.data ?? new (getPixelFormatArrayType(texture._format))(
2143-
TextureUtils.calcLevelGpuSize(width, height, 1, texture._format)
2142+
const ArrayType = getPixelFormatArrayType(texture._format);
2143+
const outputData = options.data ?? new ArrayType(
2144+
TextureUtils.calcLevelGpuSize(width, height, 1, texture._format) / ArrayType.BYTES_PER_ELEMENT
21442145
);
21452146

21462147
// For formats requiring RGBA readback, allocate a larger RGBA buffer

0 commit comments

Comments
 (0)