Compressed textures array doesn't work with WebGPU

Hi team! Recently I’ve been working on my terrain textures. I was using Texture2DArray with compressed .dds files. However there were always console errors like:

Required size for texture data layout (851968) exceeds the linear data size (262144) with offset (0).

After digging for a while, I think I found the issue.
On line 1238 of webgpuTextureManager.ts , the “rowsPerImage” provided to webgpu is incorrect.

I believe it should be

     `rowsPerImage: Math.ceil(height / blockInformation.height)`

There is another appearance of rowsPerImage a few lines later and that might need to be changed as well.

It is said that the rowsPerImage is required “if there are multiple images to copy.” which is exactly my usecase. GPUCommandEncoder: copyBufferToTexture() method - Web APIs | MDN

This is the link for repro playground: https://playground.babylonjs.com/?BabylonToolkit#LXSKWE#2
Cheers!

Thank you for your report and for your investigation. You are correct, here is the PR:

2 Likes

Blazingly fast!:grinning_face:

1 Like