Triforce v0.9.0

Character tab, faster renderer defaults, HD rumble shipped, and the 11-30 bug pass: ending softlock below 60 fps, adult first-night lock, Intel Arc robust buffers, adult map, randomizer load order.
This commit is contained in:
ruckus7382sfgsgdf
2026-11-30 20:55:14 -06:00
parent 8cb23131f9
commit 822ee913bc
86 changed files with 8128 additions and 438 deletions

View File

@@ -69,4 +69,41 @@ public static class BlockLinear
}
return output;
}
/// <summary>((Triforce, 11-29) The other way: a linear image written into block-linear order, into output (at least
/// Size bytes; bytes the image does not cover are left as they are). For the Character page's recoloured textures.</summary>
public static void Swizzle(ReadOnlySpan<byte> linear, Span<byte> output, int width, int height, int bytesPerElement, int blockHeightLog2)
{
if (bytesPerElement is not (1 or 2 or 4 or 8 or 16))
throw new NotSupportedException(bytesPerElement + " bytes per element");
if (Size(width, height, bytesPerElement, blockHeightLog2) > output.Length)
throw new InvalidDataException("the texture's data is shorter than its size calls for");
var pitch = width * bytesPerElement;
var gobsInX = (pitch + 63) >> GobSizeXShift;
var blockSize = gobsInX << (GobSizeShift + blockHeightLog2);
var blockHeightMask = (1 << blockHeightLog2) - 1;
var xShift = GobSizeShift + blockHeightLog2;
for (var y = 0; y < height; y++)
{
var swizzledY = SwizzleY(y);
var blockY = y >> GobSizeYShift;
var offsetY = (blockY >> blockHeightLog2) * blockSize + ((blockY & blockHeightMask) << GobSizeShift);
var row = linear.Slice(y * pitch, pitch);
for (var x = 0; x < pitch; x += bytesPerElement)
{
var offsetX = (x >> GobSizeXShift) << xShift;
var at = offsetY + offsetX + (SwizzleX(x & 63) | swizzledY);
row.Slice(x, bytesPerElement).CopyTo(output.Slice(at, bytesPerElement));
}
}
}
/// <summary>The block height (log2, in GOBs) a smaller mip level uses: the texture's, halved while half of it still
/// covers the level's height (the GPU's rule).</summary>
public static int MipBlockHeight(int heightInElements, int blockHeightLog2)
{
var bh = blockHeightLog2;
while (bh > 0 && (8 << (bh - 1)) >= heightInElements) bh--;
return bh;
}
}