Skip to content

Commit

Permalink
Choose smaller texture sizes (#3912)
Browse files Browse the repository at this point in the history
The old code did an lcm of width vs height where for
for cubemaps because cubemaps must be square and
textures must be a multiple of block sizes.

With a format with a blockSize of 5x8 and a minSize
of 32 that would end up doing lcm of 35x32 which is 1120.
Then for a cube array it would end up allocating
1120x1120x24 and if the format is rgba32float that's 418meg.

The new code just gets the lcm of the blockWidth vs blockHeight
and then aligning to that which will be much much smaller.
  • Loading branch information
greggman authored Aug 21, 2024
1 parent f8472c9 commit 6632746
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -2197,7 +2197,9 @@ export function chooseTextureSize({
const width = align(Math.max(minSize, blockWidth * minBlocks), blockWidth);
const height = align(Math.max(minSize, blockHeight * minBlocks), blockHeight);
if (viewDimension === 'cube' || viewDimension === 'cube-array') {
const size = lcm(width, height);
const blockLCM = lcm(blockWidth, blockHeight);
const largest = Math.max(width, height);
const size = align(largest, blockLCM);
return [size, size, viewDimension === 'cube-array' ? 24 : 6];
}
const depthOrArrayLayers = getDepthOrArrayLayersForViewDimension(viewDimension);
Expand Down

0 comments on commit 6632746

Please sign in to comment.