diff --git a/Assets/ASTC Encoder/CHANGELOG.md b/Assets/ASTC Encoder/CHANGELOG.md index 26ea0bf..bd4220c 100644 --- a/Assets/ASTC Encoder/CHANGELOG.md +++ b/Assets/ASTC Encoder/CHANGELOG.md @@ -2,6 +2,15 @@ All notable changes to `com.aperture.astcenc` (Runtime ASTC Encoder for Unity) are documented in this file. +## [2.3.1] - 2026-11-29 + +### Changed & Optimized +- **GPU Compute Encoder Throughput (P0 / P1 / Medium)**: + - **Single-Pass Pixel Cache & LDR/HDR Shader Split**: Replaced multi-pass texture loads with a single-pass compact `uint` RGBA8 LDR pixel cache and split `ASTC_HDR_VARIANT` via `LocalKeyword` to reduce register pressure on LDR paths. + - **O(1) BISE Quantization & Direct Weight Packing**: Added division-free `AstcLinearToCode`, 56-entry O(1) `kAstcWeightLut`, Gather tent-kernel weight decimation, direct MSB-descending power-of-2 weight packing (skipping 128-bit reversal), and `6x6` exact-grid Fast mode (`0x108`). + - **ComputeBuffer Pooling**: Pooled intermediate GPU block buffers (`AcquireBlockBuffer` / `ReturnBlockBuffer`) with exact-byte async readbacks in `AstcGpuBackend`. + - **Dedicated Medium Kernels (`ASTC_NO_2P`)**: Added 12 `EncodeTex*Med` / `EncodeBuf*Med` kernels stripping 2-Partition code and registers at compile time, paired with pruned Stage 0/1 candidates, 1-pass endpoint refinement, and a conservative ~50 dB PSNR early-out (cutting 1024px Medium GPU latency by 28%–35% on Apple Silicon Metal with negligible quality impact). + ## [2.3.0] - 2026-11-28 ### Added diff --git a/Assets/ASTC Encoder/Runtime/Gpu/AstcGpuBackend.cs b/Assets/ASTC Encoder/Runtime/Gpu/AstcGpuBackend.cs index 33c24bc..c064711 100644 --- a/Assets/ASTC Encoder/Runtime/Gpu/AstcGpuBackend.cs +++ b/Assets/ASTC Encoder/Runtime/Gpu/AstcGpuBackend.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; @@ -49,8 +50,11 @@ internal static class AstcGpuBackend private static ComputeShader s_Shader; private static bool s_ShaderLoadAttempted; + private static LocalKeyword s_KwHdrVariant; private static int[] s_TexKernels; private static int[] s_BufKernels; + private static int[] s_TexMedKernels; + private static int[] s_BufMedKernels; private static int[] s_TexFastKernels; private static int[] s_BufFastKernels; @@ -293,12 +297,16 @@ private static int GetDispatchGroupsY(int blockCountY, BlockSize blockSize) private static int GetTexKernel(int slot, uint qualityTier) { - return qualityTier == 0u ? s_TexFastKernels[slot] : s_TexKernels[slot]; + if (qualityTier == 0u) return s_TexFastKernels[slot]; + if (qualityTier == 1u) return s_TexMedKernels[slot]; + return s_TexKernels[slot]; } private static int GetBufKernel(int slot, uint qualityTier) { - return qualityTier == 0u ? s_BufFastKernels[slot] : s_BufKernels[slot]; + if (qualityTier == 0u) return s_BufFastKernels[slot]; + if (qualityTier == 1u) return s_BufMedKernels[slot]; + return s_BufKernels[slot]; } private static uint ResolveShaderMode(GraphicsFormat sourceFormat, TextureType textureType, out bool isSRGB, out bool isHdr) @@ -337,6 +345,8 @@ private static bool EnsureShaderLoaded() return false; } + s_KwHdrVariant = new LocalKeyword(s_Shader, "ASTC_HDR_VARIANT"); + s_TexKernels = new int[6] { s_Shader.FindKernel("EncodeTex4x4"), @@ -357,6 +367,26 @@ private static bool EnsureShaderLoaded() s_Shader.FindKernel("EncodeBuf12x12"), }; + s_TexMedKernels = new int[6] + { + s_Shader.FindKernel("EncodeTex4x4Med"), + s_Shader.FindKernel("EncodeTex5x5Med"), + s_Shader.FindKernel("EncodeTex6x6Med"), + s_Shader.FindKernel("EncodeTex8x8Med"), + s_Shader.FindKernel("EncodeTex10x10Med"), + s_Shader.FindKernel("EncodeTex12x12Med"), + }; + + s_BufMedKernels = new int[6] + { + s_Shader.FindKernel("EncodeBuf4x4Med"), + s_Shader.FindKernel("EncodeBuf5x5Med"), + s_Shader.FindKernel("EncodeBuf6x6Med"), + s_Shader.FindKernel("EncodeBuf8x8Med"), + s_Shader.FindKernel("EncodeBuf10x10Med"), + s_Shader.FindKernel("EncodeBuf12x12Med"), + }; + s_TexFastKernels = new int[6] { s_Shader.FindKernel("EncodeTex4x4Fast"), @@ -409,30 +439,24 @@ internal static void Preload(BlockSize blockSize) rt.Create(); buf = new ComputeBuffer(1, k_BytesPerBlock, ComputeBufferType.Structured); - // Warm up both Fast and Full kernels for Texture and Buffer outputs to prevent first-use PSO stalls. - int texFastKernel = s_TexFastKernels[slot]; - s_Shader.SetTexture(texFastKernel, s_PropSourceTex, dummySrc); - s_Shader.SetTexture(texFastKernel, s_PropDestTex, rt); - SetCommonUniforms(s_Shader, 4, 4, 0, 1, 1, 0, k_ModeLdrRgb, false, false, 0u); - s_Shader.Dispatch(texFastKernel, 1, 1, 1); - - int bufFastKernel = s_BufFastKernels[slot]; - s_Shader.SetTexture(bufFastKernel, s_PropSourceTex, dummySrc); - s_Shader.SetBuffer(bufFastKernel, s_PropDestBuffer, buf); - SetCommonUniforms(s_Shader, 4, 4, 0, 1, 1, 0, k_ModeLdrRgb, false, false, 0u); - s_Shader.Dispatch(bufFastKernel, 1, 1, 1); - - int texKernel = s_TexKernels[slot]; - s_Shader.SetTexture(texKernel, s_PropSourceTex, dummySrc); - s_Shader.SetTexture(texKernel, s_PropDestTex, rt); - SetCommonUniforms(s_Shader, 4, 4, 0, 1, 1, 0, k_ModeLdrRgb, false, false, 1u); - s_Shader.Dispatch(texKernel, 1, 1, 1); - - int bufKernel = s_BufKernels[slot]; - s_Shader.SetTexture(bufKernel, s_PropSourceTex, dummySrc); - s_Shader.SetBuffer(bufKernel, s_PropDestBuffer, buf); - SetCommonUniforms(s_Shader, 4, 4, 0, 1, 1, 0, k_ModeLdrRgb, false, false, 1u); - s_Shader.Dispatch(bufKernel, 1, 1, 1); + for (int variant = 0; variant < 2; variant++) + { + uint mode = variant == 0 ? k_ModeHdrRgb : k_ModeLdrRgb; + for (uint tier = 0u; tier <= 2u; tier++) + { + SetCommonUniforms(s_Shader, 4, 4, 0, 1, 1, 0, mode, false, false, tier); + + int texKernel = GetTexKernel(slot, tier); + s_Shader.SetTexture(texKernel, s_PropSourceTex, dummySrc); + s_Shader.SetTexture(texKernel, s_PropDestTex, rt); + s_Shader.Dispatch(texKernel, 1, 1, 1); + + int bufKernel = GetBufKernel(slot, tier); + s_Shader.SetTexture(bufKernel, s_PropSourceTex, dummySrc); + s_Shader.SetBuffer(bufKernel, s_PropDestBuffer, buf); + s_Shader.Dispatch(bufKernel, 1, 1, 1); + } + } if (EnsureMipShaderLoaded()) { @@ -551,12 +575,115 @@ private static RenderTextureDescriptor CreateMipRTDescriptor(int width, int heig }; } + private const int k_MaxPooledBuffers = 4; + private const int k_MinPooledBufferBlocks = 1024; + private const int k_MaxPooledBufferBlocks = (8 * 1024 * 1024) / k_BytesPerBlock; + private const int k_PooledBlockBudget = (16 * 1024 * 1024) / k_BytesPerBlock; + private static readonly List s_BufferPool = new List(k_MaxPooledBuffers); + private static uint s_BufferPoolGeneration; + + private static void PruneInvalidBlockBuffers() + { + for (int i = s_BufferPool.Count - 1; i >= 0; i--) + { + ComputeBuffer buffer = s_BufferPool[i]; + if (buffer != null && buffer.IsValid()) + continue; + + buffer?.Release(); + s_BufferPool.RemoveAt(i); + } + } + + private static ComputeBuffer AcquireBlockBuffer(int requiredBlocks) + { + if (requiredBlocks > k_MaxPooledBufferBlocks) + return new ComputeBuffer(requiredBlocks, k_BytesPerBlock, ComputeBufferType.Structured); + + PruneInvalidBlockBuffers(); + int bestIdx = -1; + int bestCount = int.MaxValue; + for (int i = s_BufferPool.Count - 1; i >= 0; i--) + { + ComputeBuffer candidate = s_BufferPool[i]; + if (candidate.count >= requiredBlocks && candidate.count < bestCount) + { + bestCount = candidate.count; + bestIdx = i; + } + } + + if (bestIdx >= 0) + { + ComputeBuffer reused = s_BufferPool[bestIdx]; + s_BufferPool.RemoveAt(bestIdx); + return reused; + } + + int allocBlocks = k_MinPooledBufferBlocks; + while (allocBlocks < requiredBlocks) + allocBlocks <<= 1; + return new ComputeBuffer(allocBlocks, k_BytesPerBlock, ComputeBufferType.Structured); + } + + private static void ReturnBlockBuffer(ComputeBuffer buffer, uint generation) + { + if (buffer == null) + return; + + if (generation != s_BufferPoolGeneration || !buffer.IsValid() || buffer.count > k_MaxPooledBufferBlocks) + { + buffer.Release(); + return; + } + + PruneInvalidBlockBuffers(); + int totalBlocks = buffer.count; + int smallestIdx = -1; + int smallestCount = int.MaxValue; + for (int i = 0; i < s_BufferPool.Count; i++) + { + int count = s_BufferPool[i].count; + totalBlocks += count; + if (count < smallestCount) + { + smallestIdx = i; + smallestCount = count; + } + } + + if (s_BufferPool.Count < k_MaxPooledBuffers && totalBlocks <= k_PooledBlockBudget) + { + s_BufferPool.Add(buffer); + } + else if (smallestIdx >= 0 && buffer.count > smallestCount && totalBlocks - smallestCount <= k_PooledBlockBudget) + { + s_BufferPool[smallestIdx].Release(); + s_BufferPool[smallestIdx] = buffer; + } + else + { + buffer.Release(); + } + } + internal static void ReleaseCache() { + unchecked { s_BufferPoolGeneration++; } + for (int i = 0; i < s_BufferPool.Count; i++) + { + if (s_BufferPool[i] != null) + s_BufferPool[i].Release(); + } + s_BufferPool.Clear(); + s_Shader = null; s_ShaderLoadAttempted = false; + s_KwHdrVariant = default; s_TexKernels = null; s_BufKernels = null; + s_TexMedKernels = null; + s_BufMedKernels = null; s_TexFastKernels = null; s_BufFastKernels = null; s_MipShader = null; @@ -569,6 +696,8 @@ private static void SetCommonUniforms( int blockCountX, int blockCountY, int bufferBlockOffset, uint mode, bool isSRGB, bool useAlphaWeight, uint qualityTier) { + bool isHdrMode = mode == k_ModeHdrRgb || mode == k_ModeHdrRgba; + shader.SetKeyword(s_KwHdrVariant, isHdrMode); shader.SetInt(s_PropSrcWidth, srcWidth); shader.SetInt(s_PropSrcHeight, srcHeight); shader.SetInt(s_PropMipLevel, mipLevel); @@ -588,6 +717,8 @@ private static void SetCommonUniforms( int blockCountX, int blockCountY, int bufferBlockOffset, uint mode, bool isSRGB, bool useAlphaWeight, uint qualityTier) { + bool isHdrMode = mode == k_ModeHdrRgb || mode == k_ModeHdrRgba; + cmd.SetKeyword(shader, s_KwHdrVariant, isHdrMode); cmd.SetComputeIntParam(shader, s_PropSrcWidth, srcWidth); cmd.SetComputeIntParam(shader, s_PropSrcHeight, srcHeight); cmd.SetComputeIntParam(shader, s_PropMipLevel, mipLevel); @@ -622,9 +753,11 @@ private static ComputeBuffer DispatchAllMipsToBuffer( int mipCount, bool useAlphaWeight, bool generateMipmaps, - out int totalBytes) + out int totalBytes, + out uint bufferGeneration) { totalBytes = 0; + bufferGeneration = s_BufferPoolGeneration; if (!IsSupported || !IsInputSupported(source)) return null; @@ -633,7 +766,7 @@ private static ComputeBuffer DispatchAllMipsToBuffer( return null; int totalBlocks = CalculateTotalBlocks(source.width, source.height, mipCount, bx, by); - if (totalBlocks <= 0) + if (totalBlocks <= 0 || totalBlocks > int.MaxValue / k_BytesPerBlock) return null; uint mode = ResolveShaderMode(source.graphicsFormat, textureType, out bool isSRGB, out bool isHdr); @@ -643,7 +776,7 @@ private static ComputeBuffer DispatchAllMipsToBuffer( bool useFloat16Mip = (isHdr || isSRGB) && textureType != TextureType.Normal; int mipKernel = textureType == TextureType.Normal ? s_MipKernelNormal : s_MipKernelColor; - var buffer = new ComputeBuffer(totalBlocks, k_BytesPerBlock, ComputeBufferType.Structured); + ComputeBuffer buffer = AcquireBlockBuffer(totalBlocks); RenderTexture prevMipRT = null; RenderTexture currMipRT = null; try @@ -711,7 +844,7 @@ private static ComputeBuffer DispatchAllMipsToBuffer( } catch { - buffer.Release(); + ReturnBlockBuffer(buffer, bufferGeneration); throw; } finally @@ -754,8 +887,8 @@ internal static AstcRaw CompressTextureSync( } int mipCount = ResolveEffectiveMipCount(source, includeMipmaps, generateMipmaps, out bool willGenMips); - ComputeBuffer buffer = DispatchAllMipsToBuffer(source, textureType, blockSize, quality, mipCount, useAlphaWeight, willGenMips, out int totalBytes); - if (buffer == null || totalBytes <= 0) + ComputeBuffer buffer = DispatchAllMipsToBuffer(source, textureType, blockSize, quality, mipCount, useAlphaWeight, willGenMips, out int totalBytes, out uint bufferGeneration); + if (buffer == null) return null; try @@ -763,7 +896,7 @@ internal static AstcRaw CompressTextureSync( // Avoid LOH managed array allocation when AsyncGPUReadback is available. if (SystemInfo.supportsAsyncGPUReadback) { - AsyncGPUReadbackRequest req = AsyncGPUReadback.Request(buffer); + AsyncGPUReadbackRequest req = AsyncGPUReadback.Request(buffer, totalBytes, 0); req.WaitForCompletion(); if (req.hasError) { @@ -791,7 +924,7 @@ internal static AstcRaw CompressTextureSync( int totalBlocks = totalBytes / k_BytesPerBlock; var blocks = new AstcBlock128[totalBlocks]; - buffer.GetData(blocks); + buffer.GetData(blocks, 0, 0, totalBlocks); IntPtr fallbackUnmanaged = Marshal.AllocHGlobal(totalBytes); try @@ -813,7 +946,7 @@ internal static AstcRaw CompressTextureSync( } finally { - buffer.Release(); + ReturnBlockBuffer(buffer, bufferGeneration); } } @@ -848,8 +981,8 @@ internal static Task CompressTextureAsync( } int mipCount = ResolveEffectiveMipCount(source, includeMipmaps, generateMipmaps, out bool willGenMips); - ComputeBuffer buffer = DispatchAllMipsToBuffer(source, textureType, blockSize, quality, mipCount, useAlphaWeight, willGenMips, out int totalBytes); - if (buffer == null || totalBytes <= 0) + ComputeBuffer buffer = DispatchAllMipsToBuffer(source, textureType, blockSize, quality, mipCount, useAlphaWeight, willGenMips, out int totalBytes, out uint bufferGeneration); + if (buffer == null) return Task.FromResult(null); var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); @@ -861,7 +994,7 @@ internal static Task CompressTextureAsync( try { - AsyncGPUReadback.Request(buffer, request => + AsyncGPUReadback.Request(buffer, totalBytes, 0, request => { cancelReg.Dispose(); try @@ -908,14 +1041,14 @@ internal static Task CompressTextureAsync( } finally { - buffer.Release(); + ReturnBlockBuffer(buffer, bufferGeneration); } }); } catch { cancelReg.Dispose(); - buffer.Release(); + ReturnBlockBuffer(buffer, bufferGeneration); throw; } diff --git a/Assets/ASTC Encoder/Runtime/Gpu/Shaders/AstcGpuBise.hlsl b/Assets/ASTC Encoder/Runtime/Gpu/Shaders/AstcGpuBise.hlsl index cdf4227..71be3b7 100644 --- a/Assets/ASTC Encoder/Runtime/Gpu/Shaders/AstcGpuBise.hlsl +++ b/Assets/ASTC Encoder/Runtime/Gpu/Shaders/AstcGpuBise.hlsl @@ -132,6 +132,7 @@ uint AstcPack3Quints(uint q0, uint q1, uint q2) } // Maps a monotonically ordered quantized level k in [0, range-1] to the ASTC BISE code. +// Uses exact reciprocal multiplies for /3 and /5 (valid for all k < 256) to avoid GPU integer div/mod. uint AstcLinearToCode(uint k, uint q) { uint rangeVal, b, t, qu; @@ -142,20 +143,21 @@ uint AstcLinearToCode(uint k, uint q) } uint halfR = rangeVal >> 1u; - uint baseVal = (t != 0u) ? 3u : 5u; - if (k < halfR) + uint val = (k < halfR) ? k : ((rangeVal - 1u) - k); + uint oddBit = (k < halfR) ? 0u : 1u; + + uint m, d; + if (t != 0u) { - uint d = k % baseVal; - uint m = k / baseVal; - return (d << b) | (m << 1u); + m = (val * 0xAAABu) >> 17u; + d = val - m * 3u; } else { - uint rk = (rangeVal - 1u) - k; - uint d = rk % baseVal; - uint m = rk / baseVal; - return (d << b) | (m << 1u) | 1u; + m = (val * 0xCCCDu) >> 18u; + d = val - m * 5u; } + return (d << b) | (m << 1u) | oddBit; } // Exact Khronos ASTC color unquantization: BISE code v -> [0, 255]. @@ -209,6 +211,17 @@ uint AstcUnquantizeColor(uint v, uint q) return (A & 0x80u) | (T >> 2u); } +uint AstcUnquantizePow2Weight(uint v, uint b) +{ + uint t; + if (b == 1u) t = (v != 0u) ? 63u : 0u; + else if (b == 2u) t = v * 21u; + else if (b == 3u) t = (v << 3u) | v; + else if (b == 4u) t = (v << 2u) | (v >> 2u); + else t = (v << 1u) | (v >> 4u); + return t + (t > 32u ? 1u : 0u); +} + // Exact Khronos ASTC weight unquantization: BISE code v -> [0, 64]. uint AstcUnquantizeWeight(uint v, uint q) { @@ -218,11 +231,7 @@ uint AstcUnquantizeWeight(uint v, uint q) if (t == 0u && qu == 0u) { - if (b == 1u) T = (v != 0u) ? 63u : 0u; - else if (b == 2u) T = v * 21u; - else if (b == 3u) T = (v << 3u) | v; - else if (b == 4u) T = (v << 2u) | (v >> 2u); - else T = (v << 1u) | (v >> 4u); + return AstcUnquantizePow2Weight(v, b); } else if (t != 0u) { @@ -289,6 +298,20 @@ uint AstcQuantizeColorRange(uint c8, uint q, bool min128, out uint unquantOut) int maxK = (int)rangeVal - 1; int kEst = clamp((int)floor((float)c8 * (float)maxK / 255.0 + 0.5), minK, maxK); + // O(1) fast path for pure power-of-2 quantization ranges (no trit/quint search loop or integer div/mod). + if (t == 0u && qu == 0u) + { + uint v = (uint)kEst; + uint r = v << (8u - b); + if (b < 8u) r |= v >> max((int)b * 2 - 8, 0); + if (b <= 3u) + { + r = (b == 3u) ? ((v << 5u) | (v << 2u) | (v >> 1u)) : ((b == 2u) ? (v * 85u) : (v * 255u)); + } + unquantOut = r & 0xFFu; + return v; + } + uint bestCode = 0u; uint bestUq = 0u; int bestErr = 10000; @@ -318,33 +341,91 @@ uint AstcQuantizeColorMin128(uint c8, uint q, out uint unquantOut) return AstcQuantizeColorRange(c8, q, true, unquantOut); } +// Reverses the lowest b bits (b in 1..4) of a power-of-2 weight code for direct MSB-descending packing. +uint AstcReverseSmallBits(uint v, uint b) +{ + if (b == 2u) return ((v & 1u) << 1u) | (v >> 1u); + if (b == 3u) return ((v & 1u) << 2u) | (v & 2u) | (v >> 2u); + if (b == 4u) return ((v & 1u) << 3u) | ((v & 2u) << 1u) | ((v & 4u) >> 1u) | (v >> 3u); + return v & 1u; +} + +// Compact 56-entry packed LUT for all non-power-of-2 ASTC weight quant modes (QUANT_3/5/6/10/12/20). +// Each entry packs (code | (unquantizedWeight64 << 8)) in monotonic order of unquantized weight. +static const uint kAstcWeightLut[56] = +{ + // QUANT_3 (offset 0, range 3) + 0x0000u, 0x2001u, 0x4002u, + // QUANT_5 (offset 3, range 5) + 0x0000u, 0x1001u, 0x2002u, 0x3003u, 0x4004u, + // QUANT_6 (offset 8, range 6) + 0x0000u, 0x0C02u, 0x1904u, 0x2705u, 0x3403u, 0x4001u, + // QUANT_10 (offset 14, range 10) + 0x0000u, 0x0702u, 0x0E04u, 0x1506u, 0x1C08u, 0x2409u, 0x2B07u, 0x3205u, 0x3903u, 0x4001u, + // QUANT_12 (offset 24, range 12) + 0x0000u, 0x0504u, 0x0B08u, 0x1102u, 0x1706u, 0x1C0Au, 0x240Bu, 0x2907u, 0x2F03u, 0x3509u, 0x3B05u, 0x4001u, + // QUANT_20 (offset 36, range 20) + 0x0000u, 0x0304u, 0x0608u, 0x090Cu, 0x0D10u, 0x1002u, 0x1306u, 0x170Au, 0x1A0Eu, 0x1D12u, + 0x2313u, 0x260Fu, 0x290Bu, 0x2D07u, 0x3003u, 0x3311u, 0x370Du, 0x3A09u, 0x3D05u, 0x4001u +}; + +uint AstcWeightNeighbor(uint k, uint maxK, float error) +{ + return (error > 0.0) ? min(k + 1u, maxK) : max(k, 1u) - 1u; +} + +uint AstcQuantizePow2Weight(float w01, uint maxK, uint b, out uint unquantOut) +{ + float sw = saturate(w01); + uint k = min((uint)floor(sw * (float)maxK + 0.5), maxK); + uint uq = AstcUnquantizePow2Weight(k, b); + float target = sw * 64.0; + float error = target - (float)uq; + + // Uniform rounding locates the candidates, but decoded weights are not uniformly spaced. + uint kNbr = AstcWeightNeighbor(k, maxK, error); + uint uqNbr = AstcUnquantizePow2Weight(kNbr, b); + bool useNeighbor = abs(target - (float)uqNbr) < abs(error); + unquantOut = useNeighbor ? uqNbr : uq; + return useNeighbor ? kNbr : k; +} + // Quantizes a normalized weight w01 in [0, 1] to the exact nearest BISE code and returns unquantized [0, 64]. uint AstcQuantizeWeight(float w01, uint q, out uint unquantOut) { uint rangeVal, b, t, qu; AstcGetQuantParams(q, rangeVal, b, t, qu); - float w64 = saturate(w01) * 64.0; - int maxK = (int)rangeVal - 1; - int kEst = clamp((int)floor(saturate(w01) * (float)maxK + 0.5), 0, maxK); - - uint bestCode = 0u; - uint bestUq = 0u; - float bestErr = 1e30; - - [loop] for (int step = 0; step < 3; ++step) + uint maxK = rangeVal - 1u; + if (t == 0u && qu == 0u) { - int dk = (step == 0) ? 0 : ((step == 1) ? -1 : 1); - int k = kEst + dk; - if (k < 0 || k > maxK) continue; - uint code = AstcLinearToCode((uint)k, q); - uint uq = AstcUnquantizeWeight(code, q); - float err = abs((float)uq - w64); - if (err < bestErr) { bestErr = err; bestCode = code; bestUq = uq; } + return AstcQuantizePow2Weight(w01, maxK, b, unquantOut); } - - unquantOut = bestUq; - return bestCode; + float sw = saturate(w01); + uint kEst = min((uint)floor(sw * (float)maxK + 0.5), maxK); + + // O(1) exact LUT path for all trit/quint weight ranges (QUANT_3/5/6/10/12/20): + // because unquantized weights are strictly monotonic, checking kEst and 1 neighbor in the + // direction of (w64 - uqEst) guarantees the exact nearest BISE code with zero loops. + uint lutBase = (q == ASTC_QUANT_3) ? 0u + : (q == ASTC_QUANT_5) ? 3u + : (q == ASTC_QUANT_6) ? 8u + : (q == ASTC_QUANT_10) ? 14u + : (q == ASTC_QUANT_12) ? 24u + : 36u; + + uint e0 = kAstcWeightLut[lutBase + kEst]; + uint uq0 = e0 >> 8u; + float w64 = sw * 64.0; + float diff0 = w64 - (float)uq0; + + uint kNbr = AstcWeightNeighbor(kEst, maxK, diff0); + uint e1 = kAstcWeightLut[lutBase + kNbr]; + uint uq1 = e1 >> 8u; + + uint bestEntry = (abs(w64 - (float)uq1) < abs(diff0)) ? e1 : e0; + unquantOut = bestEntry >> 8u; + return bestEntry & 0xFFu; } // Writes up to 24 bits into a 128-bit block (little-endian uint4), branchless. diff --git a/Assets/ASTC Encoder/Runtime/Gpu/Shaders/AstcGpuColor.hlsl b/Assets/ASTC Encoder/Runtime/Gpu/Shaders/AstcGpuColor.hlsl index 0e3ff79..19f5f44 100644 --- a/Assets/ASTC Encoder/Runtime/Gpu/Shaders/AstcGpuColor.hlsl +++ b/Assets/ASTC Encoder/Runtime/Gpu/Shaders/AstcGpuColor.hlsl @@ -27,6 +27,8 @@ float3 AstcLinearToSRGB(float3 rgb) return lerp(hi, c * 12.92, float3(c <= 0.0031308)); } +#if defined(ASTC_HDR_VARIANT) + // Exact Khronos ASTC float4 -> 16-bit LNS [0, 65535] conversion (branchless vectorized). // Negative values and NaNs clamp to 0; values >= 65536 clamp to 65535. float4 AstcFloatToLns4(float4 c) @@ -375,6 +377,10 @@ void AstcQuantizeHdrAlphaEndpoints( uqA1Lns = (float)((uq1 & 0x7Fu) << 9u); } +#endif // ASTC_HDR_VARIANT + +#if !defined(ASTC_FAST_ONLY) && !defined(ASTC_NO_2P) + // ============================================================================ // ASTC 2-Partition Procedural Hash (Khronos Spec Section 22.21) // ============================================================================ @@ -462,10 +468,49 @@ uint AstcSelectPartition2(uint seed, uint x, uint y, bool smallBlock) return AstcEvalPartition2(AstcPreparePartition2(seed, smallBlock), x, y); } +#endif // !ASTC_FAST_ONLY + // ============================================================================ // ASTC Hardware Bilinear Weight Grid Infill (Khronos Spec Section 22.17) // ============================================================================ +uint AstcInfillScale(uint blockSize, uint gridSize) +{ + return ((1024u + (blockSize >> 1u)) / (blockSize - 1u)) * (gridSize - 1u); +} + +uint AstcInfillCoord(uint texel, uint scale) +{ + return (texel * scale + 32u) >> 6u; +} + +uint4 AstcInfillWeights(uint s, uint t) +{ + uint fs = s & 15u; + uint ft = t & 15u; + uint w11 = (fs * ft + 8u) >> 4u; + return uint4(16u - fs - ft + w11, fs - w11, ft - w11, w11); +} + +// Invert the rounded infill coordinate for the two cells adjacent to this grid node. +uint2 AstcGatherSpan(uint node, uint scale, uint blockSize) +{ + uint lo = ((max(node, 1u) - 1u) << 10u) + 32u; + uint hi = ((node + 1u) << 10u) - 33u; + return uint2(node == 0u ? 0u : (lo + scale - 1u) / scale, + min(blockSize - 1u, hi / scale)); +} + +uint AstcGatherTap(uint s, uint t, uint gx, uint gy) +{ + uint4 w = AstcInfillWeights(s, t); + bool right = (gx != (s >> 4u)); + bool bottom = (gy != (t >> 4u)); + uint row0 = right ? w.y : w.x; + uint row1 = right ? w.w : w.z; + return bottom ? row1 : row0; +} + // Computes bilinear grid coordinates (js, jt) and 4 integer weights (w00, w10, w01, w11) // summing to 16 for texel (x, y) in a (blockX, blockY) block using a (gridW, gridH) weight grid. void AstcComputeInfillTap( @@ -475,25 +520,12 @@ void AstcComputeInfillTap( out uint js, out uint jt, out uint4 tapWeights) { - uint ds = (1024u + (blockX >> 1u)) / (blockX - 1u); - uint dt = (1024u + (blockY >> 1u)) / (blockY - 1u); - uint cs = ds * x; - uint ct = dt * y; - - uint gs = (cs * (gridW - 1u) + 32u) >> 6u; - uint gt = (ct * (gridH - 1u) + 32u) >> 6u; + uint gs = AstcInfillCoord(x, AstcInfillScale(blockX, gridW)); + uint gt = AstcInfillCoord(y, AstcInfillScale(blockY, gridH)); js = gs >> 4u; jt = gt >> 4u; - uint fs = gs & 15u; - uint ft = gt & 15u; - - uint w11 = (fs * ft + 8u) >> 4u; - uint w10 = fs - w11; - uint w01 = ft - w11; - uint w00 = 16u - fs - ft + w11; - - tapWeights = uint4(w00, w10, w01, w11); + tapWeights = AstcInfillWeights(gs, gt); } // Evaluates the exact ASTC hardware interpolated weight [0, 64] at texel (x, y) diff --git a/Assets/ASTC Encoder/Runtime/Gpu/Shaders/AstcGpuCore.hlsl b/Assets/ASTC Encoder/Runtime/Gpu/Shaders/AstcGpuCore.hlsl index 3ac11d8..3dc00fc 100644 --- a/Assets/ASTC Encoder/Runtime/Gpu/Shaders/AstcGpuCore.hlsl +++ b/Assets/ASTC Encoder/Runtime/Gpu/Shaders/AstcGpuCore.hlsl @@ -17,6 +17,12 @@ #define ASTC_EFF_HDR_RGB_LDR_ALPHA 4u // CEM 14 (8 ep: HDR RGB + LDR A) #define ASTC_EFF_HDR_RGBA 5u // CEM 15 (8 ep: HDR RGB + HDR A) +#if !defined(ASTC_FAST_ONLY) && !defined(ASTC_NO_2P) +#define ASTC_ENABLE_2P 1 +#else +#define ASTC_ENABLE_2P 0 +#endif + struct AstcCandidate { uint blockMode; @@ -26,13 +32,17 @@ struct AstcCandidate uint epQuant; uint isDualPlane; uint dualPlaneChannel; +#if ASTC_ENABLE_2P uint isTwoPart; uint partSeed; +#endif float error; float4 e0; float4 e1; +#if ASTC_ENABLE_2P float4 e0_p1; float4 e1_p1; +#endif }; #if BLOCK_X <= 4 @@ -46,24 +56,31 @@ struct AstcCandidate #define ASTC_MAX_GRID_U 36u #endif +#if ASTC_ENABLE_2P +#define ASTC_MAX_EP_CODES 16 +#else +#define ASTC_MAX_EP_CODES 8 +#endif + // Shared per-thread scratch arrays: eliminates per-call-site local indexableTemp arrays // and array-by-value copies across functions (prevents FXC/HLSLcc/DXC compile timeouts). static float g_AstcGrid0[ASTC_MAX_GRID]; static float g_AstcGrid1[ASTC_MAX_GRID]; -static float g_AstcDecimNum[ASTC_MAX_GRID]; -static float g_AstcDecimDen[ASTC_MAX_GRID]; +#if !defined(ASTC_FAST_ONLY) static uint g_AstcGridUq0[ASTC_MAX_GRID]; static uint g_AstcGridUq1[ASTC_MAX_GRID]; -static uint g_AstcEpCodes[16]; -static uint g_AstcCandEpCodes[16]; +static uint g_AstcCandEpCodes[ASTC_MAX_EP_CODES]; +#endif +static uint g_AstcEpCodes[ASTC_MAX_EP_CODES]; static uint g_AstcEpVals[8]; static uint g_AstcEpCArr[8]; static uint g_AstcEpUqArr[8]; -// On-chip per-thread packed 4x16-bit working-pixel cache (16..144 uint2s = 128..1152 bytes per thread). -// Eliminates redundant texture loads, sRGB, and HDR LNS conversions across all 18+ fetch call sites -// and keeps FXC/HLSLcc/Metal shader compilation fast for >=8x8 kernels. +// On-chip per-thread working-pixel cache: +// - LDR variants pack RGBA8 into a single uint (64..576 bytes per thread, 50% smaller than uint2). +// - HDR variants pack 4x16-bit LNS into uint2 (128..1152 bytes per thread). #define ASTC_ENABLE_PIXEL_CACHE 1 +#if defined(ASTC_HDR_VARIANT) static uint2 g_AstcPackedBlock[BLOCK_X * BLOCK_Y]; uint2 AstcPackRgba16(float4 v) @@ -71,65 +88,38 @@ uint2 AstcPackRgba16(float4 v) uint4 u = (uint4)clamp(floor(v + 0.5), 0.0, 65535.0); return uint2(u.x | (u.y << 16u), u.z | (u.w << 16u)); } +#else +static uint g_AstcPackedBlock[BLOCK_X * BLOCK_Y]; -// Loads and converts one texel from _AstcSourceTex into working space (single shared sRGB + LNS path). -float4 AstcLoadWorkingPixel(uint baseX, uint baseY, uint x, uint y, uint effMode, out float impWeight) +uint AstcPackRgba8(uint4 u) { - impWeight = 1.0; - - uint px = min(baseX + x, _AstcSrcWidth - 1u); - uint py = min(baseY + y, _AstcSrcHeight - 1u); - float4 raw = _AstcSourceTex.Load(int3(px, py, _AstcMipLevel)); - - if (effMode <= ASTC_EFF_LDR_NORMAL) - { - float3 rgb = (_AstcIsSRGB != 0u) ? AstcLinearToSRGB(raw.rgb) : saturate(raw.rgb); - if (effMode == ASTC_EFF_LDR_NORMAL) - { - return float4(rgb.g * 255.0, 0.0, 0.0, rgb.r * 255.0); - } - float a = (effMode == ASTC_EFF_LDR_RGB) ? 1.0 : saturate(raw.a); - if (effMode == ASTC_EFF_LDR_RGBA && _AstcUseAlphaWeight != 0u) - { - impWeight = max(a, 0.02); - } - return float4(rgb * 255.0, a * 255.0); - } - - // HDR modes: share a single branchless vectorized LNS conversion - float4 lns = AstcFloatToLns4(raw); - if (effMode == ASTC_EFF_HDR_RGB) - { - return float4(lns.rgb, 65535.0); - } - if (effMode == ASTC_EFF_HDR_RGB_LDR_ALPHA) - { - // Scale LDR alpha [0,1] into [0, 65535] to balance vector norm with LNS RGB. - return float4(lns.rgb, saturate(raw.a) * 65535.0); - } - - // ASTC_EFF_HDR_RGBA - return lns; + return (u.x & 0xFFu) | ((u.y & 0xFFu) << 8u) | ((u.z & 0xFFu) << 16u) | ((u.w & 0xFFu) << 24u); } +#endif -// Fetches one texel in the encoder's working space for the current effective mode. +// Fetches one texel in the encoder's working space for the current effective mode from the pre-populated block cache. float4 AstcFetchWorkingPixel(uint baseX, uint baseY, uint x, uint y, uint effMode, out float impWeight) { -#if ASTC_ENABLE_PIXEL_CACHE impWeight = 1.0; +#if defined(ASTC_HDR_VARIANT) uint2 packed = g_AstcPackedBlock[y * BLOCK_X + x]; - float4 cached = float4( + return float4( (float)(packed.x & 0xFFFFu), (float)(packed.x >> 16u), (float)(packed.y & 0xFFFFu), (float)(packed.y >> 16u)); +#else + uint packed = g_AstcPackedBlock[y * BLOCK_X + x]; + float4 cached = float4( + (float)(packed & 0xFFu), + (float)((packed >> 8u) & 0xFFu), + (float)((packed >> 16u) & 0xFFu), + (float)(packed >> 24u)); if (effMode == ASTC_EFF_LDR_RGBA && _AstcUseAlphaWeight != 0u) { impWeight = max(cached.a * (1.0 / 255.0), 0.02); } return cached; -#else - return AstcLoadWorkingPixel(baseX, baseY, x, y, effMode, impWeight); #endif } @@ -137,32 +127,46 @@ float4 AstcFetchWorkingPixel(uint baseX, uint baseY, uint x, uint y, uint effMod // while always keeping Alpha at full 1.0 weight so transparent edges stay accurate. float4 AstcGetChannelImp(uint effMode, float imp) { +#if defined(ASTC_HDR_VARIANT) + return float4(1.0, 1.0, 1.0, 1.0); +#else return (effMode == ASTC_EFF_LDR_RGBA && _AstcUseAlphaWeight != 0u) ? float4(imp, imp, imp, 1.0) : float4(1.0, 1.0, 1.0, 1.0); +#endif } float4 AstcClampWorkingColor(float4 c, uint effMode) { - float maxVal = (effMode >= ASTC_EFF_HDR_RGB) ? 65535.0 : 255.0; - return clamp(c, 0.0, maxVal); +#if defined(ASTC_HDR_VARIANT) + return clamp(c, 0.0, 65535.0); +#else + return clamp(c, 0.0, 255.0); +#endif } uint AstcGetCemForEffMode(uint effMode) { - if (effMode == ASTC_EFF_LDR_NORMAL) return ASTC_CEM_LDR_LUM_ALPHA_DIRECT; - if (effMode == ASTC_EFF_LDR_RGB) return ASTC_CEM_LDR_RGB_DIRECT; - if (effMode == ASTC_EFF_LDR_RGBA) return ASTC_CEM_LDR_RGBA_DIRECT; +#if defined(ASTC_HDR_VARIANT) if (effMode == ASTC_EFF_HDR_RGB) return ASTC_CEM_HDR_RGB_DIRECT; if (effMode == ASTC_EFF_HDR_RGB_LDR_ALPHA) return ASTC_CEM_HDR_RGB_LDR_ALPHA; return ASTC_CEM_HDR_RGBA_DIRECT; +#else + if (effMode == ASTC_EFF_LDR_NORMAL) return ASTC_CEM_LDR_LUM_ALPHA_DIRECT; + if (effMode == ASTC_EFF_LDR_RGB) return ASTC_CEM_LDR_RGB_DIRECT; + return ASTC_CEM_LDR_RGBA_DIRECT; +#endif } uint AstcGetEpCountForEffMode(uint effMode) { +#if defined(ASTC_HDR_VARIANT) + return (effMode == ASTC_EFF_HDR_RGB) ? 6u : 8u; +#else if (effMode == ASTC_EFF_LDR_NORMAL) return 4u; - if (effMode == ASTC_EFF_LDR_RGB || effMode == ASTC_EFF_HDR_RGB) return 6u; + if (effMode == ASTC_EFF_LDR_RGB) return 6u; return 8u; +#endif } float AstcGetChannel(float4 v, uint ch) @@ -187,11 +191,21 @@ float4 AstcSetChannel(float4 v, uint ch, float val) float4 AstcChannelMaskEx(uint effMode, uint excludedChannel) { float4 m; +#if defined(ASTC_HDR_VARIANT) + if (effMode == ASTC_EFF_HDR_RGB) + { + m = float4(1.0, 1.0, 1.0, 0.0); + } + else + { + m = float4(1.0, 1.0, 1.0, 1.0); + } +#else if (effMode == ASTC_EFF_LDR_NORMAL) { m = float4(1.0, 0.0, 0.0, 1.0); } - else if (effMode == ASTC_EFF_LDR_RGB || effMode == ASTC_EFF_HDR_RGB) + else if (effMode == ASTC_EFF_LDR_RGB) { m = float4(1.0, 1.0, 1.0, 0.0); } @@ -199,6 +213,7 @@ float4 AstcChannelMaskEx(uint effMode, uint excludedChannel) { m = float4(1.0, 1.0, 1.0, 1.0); } +#endif if (excludedChannel < 4u) { @@ -212,22 +227,22 @@ float4 AstcChannelMaskEx(uint effMode, uint excludedChannel) // that were projected prior to endpoint quantization. void AstcCanonicalizeEndpoints(uint effMode, inout float4 e0, inout float4 e1) { - if (effMode == ASTC_EFF_LDR_RGB || effMode == ASTC_EFF_LDR_RGBA) +#if defined(ASTC_HDR_VARIANT) + float maxRgb0 = max(e0.r, max(e0.g, e0.b)); + float maxRgb1 = max(e1.r, max(e1.g, e1.b)); + if (maxRgb0 > maxRgb1) { - if ((e0.r + e0.g + e0.b) > (e1.r + e1.g + e1.b)) - { - float4 tmp = e0; e0 = e1; e1 = tmp; - } + float4 tmp = e0; e0 = e1; e1 = tmp; } - else if (effMode >= ASTC_EFF_HDR_RGB) +#else + if (effMode == ASTC_EFF_LDR_RGB || effMode == ASTC_EFF_LDR_RGBA) { - float maxRgb0 = max(e0.r, max(e0.g, e0.b)); - float maxRgb1 = max(e1.r, max(e1.g, e1.b)); - if (maxRgb0 > maxRgb1) + if ((e0.r + e0.g + e0.b) > (e1.r + e1.g + e1.b)) { float4 tmp = e0; e0 = e1; e1 = tmp; } } +#endif } // Quantizes one partition's endpoints (e0, e1) according to effMode and epQuant. @@ -246,6 +261,7 @@ void AstcQuantizeEndpoints( uqE1 = float4(0.0, 0.0, 0.0, 255.0); swapped = false; +#if !defined(ASTC_HDR_VARIANT) if (effMode == ASTC_EFF_LDR_NORMAL) { g_AstcEpVals[0] = (uint)clamp(floor(e0.x + 0.5), 0.0, 255.0); @@ -265,49 +281,45 @@ void AstcQuantizeEndpoints( return; } - if (effMode == ASTC_EFF_LDR_RGB || effMode == ASTC_EFF_LDR_RGBA) - { - g_AstcEpVals[0] = (uint)clamp(floor(e0.r + 0.5), 0.0, 255.0); - g_AstcEpVals[1] = (uint)clamp(floor(e1.r + 0.5), 0.0, 255.0); - g_AstcEpVals[2] = (uint)clamp(floor(e0.g + 0.5), 0.0, 255.0); - g_AstcEpVals[3] = (uint)clamp(floor(e1.g + 0.5), 0.0, 255.0); - g_AstcEpVals[4] = (uint)clamp(floor(e0.b + 0.5), 0.0, 255.0); - g_AstcEpVals[5] = (uint)clamp(floor(e1.b + 0.5), 0.0, 255.0); - g_AstcEpVals[6] = (uint)clamp(floor(e0.a + 0.5), 0.0, 255.0); - g_AstcEpVals[7] = (uint)clamp(floor(e1.a + 0.5), 0.0, 255.0); - - [loop] for (uint z = 0u; z < 8u; ++z) { g_AstcEpCArr[z] = 0u; g_AstcEpUqArr[z] = 255u; } + g_AstcEpVals[0] = (uint)clamp(floor(e0.r + 0.5), 0.0, 255.0); + g_AstcEpVals[1] = (uint)clamp(floor(e1.r + 0.5), 0.0, 255.0); + g_AstcEpVals[2] = (uint)clamp(floor(e0.g + 0.5), 0.0, 255.0); + g_AstcEpVals[3] = (uint)clamp(floor(e1.g + 0.5), 0.0, 255.0); + g_AstcEpVals[4] = (uint)clamp(floor(e0.b + 0.5), 0.0, 255.0); + g_AstcEpVals[5] = (uint)clamp(floor(e1.b + 0.5), 0.0, 255.0); + g_AstcEpVals[6] = (uint)clamp(floor(e0.a + 0.5), 0.0, 255.0); + g_AstcEpVals[7] = (uint)clamp(floor(e1.a + 0.5), 0.0, 255.0); - uint cnt = (effMode == ASTC_EFF_LDR_RGBA) ? 8u : 6u; - [loop] for (uint i = 0u; i < cnt; ++i) - { - uint uqTmp; - g_AstcEpCArr[i] = AstcQuantizeColor(g_AstcEpVals[i], epQuant, uqTmp); - g_AstcEpUqArr[i] = uqTmp; - } + [loop] for (uint z = 0u; z < 8u; ++z) { g_AstcEpCArr[z] = 0u; g_AstcEpUqArr[z] = 255u; } - // Khronos ASTC spec: CEM 8/12 triggers blue-contraction & endpoint swap whenever (r1+g1+b1) < (r0+g0+b0). - // Guarantee s1 >= s0 so hardware always decodes direct endpoints without unexpected contraction/inversion. - if ((g_AstcEpUqArr[0] + g_AstcEpUqArr[2] + g_AstcEpUqArr[4]) > (g_AstcEpUqArr[1] + g_AstcEpUqArr[3] + g_AstcEpUqArr[5])) - { - swapped = true; - [loop] for (uint s = 0u; s < 8u; s += 2u) - { - uint tc = g_AstcEpCArr[s]; g_AstcEpCArr[s] = g_AstcEpCArr[s + 1u]; g_AstcEpCArr[s + 1u] = tc; - uint tu = g_AstcEpUqArr[s]; g_AstcEpUqArr[s] = g_AstcEpUqArr[s + 1u]; g_AstcEpUqArr[s + 1u] = tu; - } - } + uint cnt = (effMode == ASTC_EFF_LDR_RGBA) ? 8u : 6u; + [loop] for (uint i = 0u; i < cnt; ++i) + { + uint uqTmp; + g_AstcEpCArr[i] = AstcQuantizeColor(g_AstcEpVals[i], epQuant, uqTmp); + g_AstcEpUqArr[i] = uqTmp; + } - [loop] for (uint k = 0u; k < cnt; ++k) + // Khronos ASTC spec: CEM 8/12 triggers blue-contraction & endpoint swap whenever (r1+g1+b1) < (r0+g0+b0). + // Guarantee s1 >= s0 so hardware always decodes direct endpoints without unexpected contraction/inversion. + if ((g_AstcEpUqArr[0] + g_AstcEpUqArr[2] + g_AstcEpUqArr[4]) > (g_AstcEpUqArr[1] + g_AstcEpUqArr[3] + g_AstcEpUqArr[5])) + { + swapped = true; + [loop] for (uint s = 0u; s < 8u; s += 2u) { - g_AstcEpCodes[codeOffset + k] = g_AstcEpCArr[k]; + uint tc = g_AstcEpCArr[s]; g_AstcEpCArr[s] = g_AstcEpCArr[s + 1u]; g_AstcEpCArr[s + 1u] = tc; + uint tu = g_AstcEpUqArr[s]; g_AstcEpUqArr[s] = g_AstcEpUqArr[s + 1u]; g_AstcEpUqArr[s + 1u] = tu; } + } - uqE0 = float4((float)g_AstcEpUqArr[0], (float)g_AstcEpUqArr[2], (float)g_AstcEpUqArr[4], (float)g_AstcEpUqArr[6]); - uqE1 = float4((float)g_AstcEpUqArr[1], (float)g_AstcEpUqArr[3], (float)g_AstcEpUqArr[5], (float)g_AstcEpUqArr[7]); - return; + [loop] for (uint k = 0u; k < cnt; ++k) + { + g_AstcEpCodes[codeOffset + k] = g_AstcEpCArr[k]; } + uqE0 = float4((float)g_AstcEpUqArr[0], (float)g_AstcEpUqArr[2], (float)g_AstcEpUqArr[4], (float)g_AstcEpUqArr[6]); + uqE1 = float4((float)g_AstcEpUqArr[1], (float)g_AstcEpUqArr[3], (float)g_AstcEpUqArr[5], (float)g_AstcEpUqArr[7]); +#else // HDR RGB / HDR RGB + LDR Alpha / HDR RGBA // Orient endpoints so e1 holds the major RGB component, enabling CEM 11 high-precision delta modes. float maxRgb0 = max(e0.r, max(e0.g, e0.b)); @@ -347,6 +359,7 @@ void AstcQuantizeEndpoints( uqE0.a = isHdrA ? (float)((uqA0 & 0x7Fu) << 9u) : (float)(uqA0 * 257u); uqE1.a = isHdrA ? (float)((uqA1 & 0x7Fu) << 9u) : (float)(uqA1 * 257u); } +#endif } // Fits principal-axis endpoints for a single subset (partFilter == 2 means all texels). @@ -358,44 +371,60 @@ void AstcFitSubsetEndpoints( uint partSeed, uint partFilter, uint refineIters, + bool hasPreStats, + float4 preMeanP, + float4 preMinC, + float4 preMaxC, out float4 outE0, out float4 outE1) { float4 mask = AstcChannelMaskEx(effMode, excludedChannel); +#if ASTC_ENABLE_2P bool smallBlock = (BLOCK_X * BLOCK_Y) < 32u; +#endif - // Pass 1: per-channel weighted mean & bounds - float4 sumP = 0.0; - float4 sumW = 0.0; - float4 minC = float4(1e9, 1e9, 1e9, 1e9); - float4 maxC = float4(-1e9, -1e9, -1e9, -1e9); + // Pass 1: per-channel weighted mean & bounds (skipped when Step 1 already computed full-block stats) + float4 meanP = preMeanP; + float4 minC = preMinC; + float4 maxC = preMaxC; - [loop] for (uint y = 0u; y < BLOCK_Y; ++y) + if (!hasPreStats) { - [loop] for (uint x = 0u; x < BLOCK_X; ++x) + float4 sumP = 0.0; + float4 sumW = 0.0; + minC = float4(1e9, 1e9, 1e9, 1e9); + maxC = float4(-1e9, -1e9, -1e9, -1e9); + + [loop] for (uint y = 0u; y < BLOCK_Y; ++y) { - if (partFilter < 2u && AstcSelectPartition2(partSeed, x, y, smallBlock) != partFilter) - continue; + [loop] for (uint x = 0u; x < BLOCK_X; ++x) + { +#if ASTC_ENABLE_2P + if (partFilter < 2u && AstcSelectPartition2(partSeed, x, y, smallBlock) != partFilter) + continue; +#endif - float imp; - float4 p = AstcFetchWorkingPixel(baseX, baseY, x, y, effMode, imp); - float4 chImp = AstcGetChannelImp(effMode, imp); - sumP += p * chImp; - sumW += chImp; - minC = min(minC, p); - maxC = max(maxC, p); + float imp; + float4 p = AstcFetchWorkingPixel(baseX, baseY, x, y, effMode, imp); + float4 chImp = AstcGetChannelImp(effMode, imp); + sumP += p * chImp; + sumW += chImp; + minC = min(minC, p); + maxC = max(maxC, p); + } } - } - if (sumW.a <= 1e-6) - { - outE0 = 0.0; - outE1 = 0.0; - return; - } + if (sumW.a <= 1e-6) + { + outE0 = 0.0; + outE1 = 0.0; + return; + } - float4 meanP = sumP / max(sumW, 1e-6); + meanP = sumP / max(sumW, 1e-6); + } +#if !defined(ASTC_HDR_VARIANT) // Special fast exact path for 1D channels (Normal plane0 = L only) if (effMode == ASTC_EFF_LDR_NORMAL && excludedChannel == 3u) { @@ -403,6 +432,7 @@ void AstcFitSubsetEndpoints( outE1 = float4(maxC.x, 0.0, 0.0, maxC.w); return; } +#endif // Pass 2: MaxAccum principal axis (ARM astcenc style) float4 acc0 = 0.0, acc1 = 0.0, acc2 = 0.0, acc3 = 0.0; @@ -410,8 +440,10 @@ void AstcFitSubsetEndpoints( { [loop] for (uint x2 = 0u; x2 < BLOCK_X; ++x2) { +#if ASTC_ENABLE_2P if (partFilter < 2u && AstcSelectPartition2(partSeed, x2, y2, smallBlock) != partFilter) continue; +#endif float imp; float4 p = AstcFetchWorkingPixel(baseX, baseY, x2, y2, effMode, imp); @@ -443,6 +475,8 @@ void AstcFitSubsetEndpoints( } axis *= rsqrt(bestL); + float4 maskedAxis = axis * mask; + float meanProj = dot(meanP, maskedAxis); // Pass 3: Project onto principal axis for initial [minT, maxT] endpoints float minT = 1e9; @@ -451,12 +485,14 @@ void AstcFitSubsetEndpoints( { [loop] for (uint x3 = 0u; x3 < BLOCK_X; ++x3) { +#if ASTC_ENABLE_2P if (partFilter < 2u && AstcSelectPartition2(partSeed, x3, y3, smallBlock) != partFilter) continue; +#endif float imp; float4 p = AstcFetchWorkingPixel(baseX, baseY, x3, y3, effMode, imp); - float t = dot((p - meanP) * mask, axis); + float t = dot(p, maskedAxis) - meanProj; minT = min(minT, t); maxT = max(maxT, t); } @@ -470,7 +506,12 @@ void AstcFitSubsetEndpoints( [loop] for (uint iter = 0u; iter < refineIters; ++iter) { float4 dir = (e1 - e0) * mask; - if (dot(dir, dir) <= 1e-6) break; + float dirLenSq = dot(dir, dir); + if (dirLenSq <= 1e-6) break; + + bool useAlphaW = (effMode == ASTC_EFF_LDR_RGBA && _AstcUseAlphaWeight != 0u); + float4 scaledDir = dir / dirLenSq; + float projBias = -dot(e0, scaledDir); float a00_rgb = 0.0, a01_rgb = 0.0, a11_rgb = 0.0; float a00_a = 0.0, a01_a = 0.0, a11_a = 0.0; @@ -480,15 +521,25 @@ void AstcFitSubsetEndpoints( { [loop] for (uint xr = 0u; xr < BLOCK_X; ++xr) { +#if ASTC_ENABLE_2P if (partFilter < 2u && AstcSelectPartition2(partSeed, xr, yr, smallBlock) != partFilter) continue; +#endif float imp; float4 p = AstcFetchWorkingPixel(baseX, baseY, xr, yr, effMode, imp); float4 chImp = AstcGetChannelImp(effMode, imp); - float4 wDir = dir * chImp; - float denom = dot(wDir, dir); - float w = (denom > 1e-6) ? saturate(dot((p - e0) * mask, wDir) / denom) : 0.0; + float w; + if (useAlphaW) + { + float4 wDir = dir * chImp; + float denom = dot(wDir, dir); + w = (denom > 1e-6) ? saturate(dot((p - e0) * mask, wDir) / denom) : 0.0; + } + else + { + w = saturate(dot(p, scaledDir) + projBias); + } float omw = 1.0 - w; float wRgb = chImp.x; @@ -538,7 +589,7 @@ void AstcFitSubsetEndpoints( outE1 = e1; } -// Projects block pixels onto (e0, e1) and decimates onto g_AstcGrid0 (gridW x gridH). +// Projects block pixels onto (e0, e1) and decimates onto g_AstcGrid0 (gridW x gridH) using register-only Gather. void AstcComputeWeightGrid1P( uint baseX, uint baseY, uint effMode, @@ -546,59 +597,91 @@ void AstcComputeWeightGrid1P( float4 e0, float4 e1, uint gridW, uint gridH) { - uint gridCount = gridW * gridH; - [loop] for (uint i = 0u; i < ASTC_MAX_GRID_U; ++i) - { - g_AstcGrid0[i] = 0.0; - g_AstcDecimNum[i] = 0.0; - g_AstcDecimDen[i] = 0.0; - } - + bool exactGrid = (gridW == BLOCK_X && gridH == BLOCK_Y); float4 mask = AstcChannelMaskEx(effMode, excludedChannel); float4 dir = (e1 - e0) * mask; - bool exactGrid = (gridW == BLOCK_X && gridH == BLOCK_Y); - bool alphaWeightsRgbOnly = (mask.a == 0.0 && effMode == ASTC_EFF_LDR_RGBA && _AstcUseAlphaWeight != 0u); + float dirLenSq = dot(dir, dir); + float invDirLenSq = (dirLenSq > 1e-6) ? (1.0 / dirLenSq) : 0.0; + float4 scaledDir = dir * invDirLenSq; + float projBias = -dot(e0, scaledDir); + +#if defined(ASTC_HDR_VARIANT) + bool useAlphaW = false; + bool alphaWeightsRgbOnly = false; +#else + bool useAlphaW = (effMode == ASTC_EFF_LDR_RGBA && _AstcUseAlphaWeight != 0u); + bool alphaWeightsRgbOnly = (mask.a == 0.0 && useAlphaW); +#endif - [loop] for (uint y = 0u; y < BLOCK_Y; ++y) + if (exactGrid) { - [loop] for (uint x = 0u; x < BLOCK_X; ++x) + [loop] for (uint y = 0u; y < BLOCK_Y; ++y) { - float imp; - float4 p = AstcFetchWorkingPixel(baseX, baseY, x, y, effMode, imp); - float4 chImp = AstcGetChannelImp(effMode, imp); - float4 wDir = dir * chImp; - float denom = dot(wDir, dir); - float t = (denom > 1e-6) ? saturate(dot((p - e0) * mask, wDir) / denom) : 0.0; - - if (exactGrid) - { - g_AstcGrid0[y * gridW + x] = t; - } - else + uint rowOff = y * gridW; + [loop] for (uint x = 0u; x < BLOCK_X; ++x) { - uint js, jt; - uint4 tw; - AstcComputeInfillTap(x, y, BLOCK_X, BLOCK_Y, gridW, gridH, js, jt, tw); - uint idx00 = jt * gridW + js; - float decW = alphaWeightsRgbOnly ? imp : 1.0; - float f00 = (float)tw.x * decW; - float f10 = (float)tw.y * decW; - float f01 = (float)tw.z * decW; - float f11 = (float)tw.w * decW; - - g_AstcDecimNum[idx00] += f00 * t; g_AstcDecimDen[idx00] += f00; - if (tw.y > 0u) { g_AstcDecimNum[idx00 + 1u] += f10 * t; g_AstcDecimDen[idx00 + 1u] += f10; } - if (tw.z > 0u) { g_AstcDecimNum[idx00 + gridW] += f01 * t; g_AstcDecimDen[idx00 + gridW] += f01; } - if (tw.w > 0u) { g_AstcDecimNum[idx00 + gridW + 1u] += f11 * t; g_AstcDecimDen[idx00 + gridW + 1u] += f11; } + float imp; + float4 p = AstcFetchWorkingPixel(baseX, baseY, x, y, effMode, imp); + float t; + if (useAlphaW) + { + float4 chImp = AstcGetChannelImp(effMode, imp); + float4 wDir = dir * chImp; + float denom = dot(wDir, dir); + t = (denom > 1e-6) ? saturate(dot((p - e0) * mask, wDir) / denom) : 0.0; + } + else + { + t = saturate(dot(p, scaledDir) + projBias); + } + g_AstcGrid0[rowOff + x] = t; } } + return; } - if (!exactGrid) + // Gather the decoder's integer taps without storing scatter accumulators. + uint scaleX = AstcInfillScale(BLOCK_X, gridW); + uint scaleY = AstcInfillScale(BLOCK_Y, gridH); + + [loop] for (uint gy = 0u; gy < gridH; ++gy) { - [loop] for (uint k = 0u; k < gridCount; ++k) + uint2 ys = AstcGatherSpan(gy, scaleY, BLOCK_Y); + uint gRow = gy * gridW; + + [loop] for (uint gx = 0u; gx < gridW; ++gx) { - g_AstcGrid0[k] = (g_AstcDecimDen[k] > 1e-6) ? saturate(g_AstcDecimNum[k] / g_AstcDecimDen[k]) : 0.0; + uint2 xs = AstcGatherSpan(gx, scaleX, BLOCK_X); + + float num = 0.0; + float den = 0.0; + [loop] for (uint y = ys.x; y <= ys.y; ++y) + { + uint gt = AstcInfillCoord(y, scaleY); + [loop] for (uint x = xs.x; x <= xs.y; ++x) + { + uint gs = AstcInfillCoord(x, scaleX); + float tap = (float)AstcGatherTap(gs, gt, gx, gy); + float imp; + float4 p = AstcFetchWorkingPixel(baseX, baseY, x, y, effMode, imp); + float t; + if (useAlphaW) + { + float4 chImp = AstcGetChannelImp(effMode, imp); + float4 wDir = dir * chImp; + float denom = dot(wDir, dir); + t = (denom > 1e-6) ? saturate(dot((p - e0) * mask, wDir) / denom) : 0.0; + } + else + { + t = saturate(dot(p, scaledDir) + projBias); + } + float fw = tap * (alphaWeightsRgbOnly ? imp : 1.0); + num += fw * t; + den += fw; + } + } + g_AstcGrid0[gRow + gx] = (den > 1e-6) ? saturate(num / den) : 0.0; } } } @@ -611,63 +694,69 @@ void AstcComputePlane1WeightGrid( float c0, float c1, uint gridW, uint gridH) { - uint gridCount = gridW * gridH; - [loop] for (uint i = 0u; i < ASTC_MAX_GRID_U; ++i) - { - g_AstcGrid1[i] = 0.0; - g_AstcDecimNum[i] = 0.0; - g_AstcDecimDen[i] = 0.0; - } - float delta = c1 - c0; float invDelta = (abs(delta) > 1e-6) ? (1.0 / delta) : 0.0; bool exactGrid = (gridW == BLOCK_X && gridH == BLOCK_Y); +#if defined(ASTC_HDR_VARIANT) + bool weightByAlpha = false; +#else bool weightByAlpha = (plane1Channel < 3u && effMode == ASTC_EFF_LDR_RGBA && _AstcUseAlphaWeight != 0u); +#endif - [loop] for (uint y = 0u; y < BLOCK_Y; ++y) + if (exactGrid) { - [loop] for (uint x = 0u; x < BLOCK_X; ++x) + [loop] for (uint y = 0u; y < BLOCK_Y; ++y) { - float imp; - float4 p = AstcFetchWorkingPixel(baseX, baseY, x, y, effMode, imp); - float pv = AstcGetChannel(p, plane1Channel); - float t = (abs(delta) > 1e-6) ? saturate((pv - c0) * invDelta) : 0.0; - - if (exactGrid) - { - g_AstcGrid1[y * gridW + x] = t; - } - else + uint rowOff = y * gridW; + [loop] for (uint x = 0u; x < BLOCK_X; ++x) { - uint js, jt; - uint4 tw; - AstcComputeInfillTap(x, y, BLOCK_X, BLOCK_Y, gridW, gridH, js, jt, tw); - uint idx00 = jt * gridW + js; - float decW = weightByAlpha ? imp : 1.0; - float f00 = (float)tw.x * decW; - float f10 = (float)tw.y * decW; - float f01 = (float)tw.z * decW; - float f11 = (float)tw.w * decW; - - g_AstcDecimNum[idx00] += f00 * t; g_AstcDecimDen[idx00] += f00; - if (tw.y > 0u) { g_AstcDecimNum[idx00 + 1u] += f10 * t; g_AstcDecimDen[idx00 + 1u] += f10; } - if (tw.z > 0u) { g_AstcDecimNum[idx00 + gridW] += f01 * t; g_AstcDecimDen[idx00 + gridW] += f01; } - if (tw.w > 0u) { g_AstcDecimNum[idx00 + gridW + 1u] += f11 * t; g_AstcDecimDen[idx00 + gridW + 1u] += f11; } + float imp; + float4 p = AstcFetchWorkingPixel(baseX, baseY, x, y, effMode, imp); + float pv = AstcGetChannel(p, plane1Channel); + g_AstcGrid1[rowOff + x] = saturate((pv - c0) * invDelta); } } + return; } - if (!exactGrid) + uint scaleX = AstcInfillScale(BLOCK_X, gridW); + uint scaleY = AstcInfillScale(BLOCK_Y, gridH); + + [loop] for (uint gy = 0u; gy < gridH; ++gy) { - [loop] for (uint k = 0u; k < gridCount; ++k) + uint2 ys = AstcGatherSpan(gy, scaleY, BLOCK_Y); + uint gRow = gy * gridW; + + [loop] for (uint gx = 0u; gx < gridW; ++gx) { - g_AstcGrid1[k] = (g_AstcDecimDen[k] > 1e-6) ? saturate(g_AstcDecimNum[k] / g_AstcDecimDen[k]) : 0.0; + uint2 xs = AstcGatherSpan(gx, scaleX, BLOCK_X); + + float num = 0.0; + float den = 0.0; + [loop] for (uint y = ys.x; y <= ys.y; ++y) + { + uint gt = AstcInfillCoord(y, scaleY); + [loop] for (uint x = xs.x; x <= xs.y; ++x) + { + uint gs = AstcInfillCoord(x, scaleX); + float tap = (float)AstcGatherTap(gs, gt, gx, gy); + float imp; + float4 p = AstcFetchWorkingPixel(baseX, baseY, x, y, effMode, imp); + float pv = AstcGetChannel(p, plane1Channel); + float t = saturate((pv - c0) * invDelta); + float fw = tap * (weightByAlpha ? imp : 1.0); + num += fw * t; + den += fw; + } + } + g_AstcGrid1[gRow + gx] = (den > 1e-6) ? saturate(num / den) : 0.0; } } } #if !defined(ASTC_FAST_ONLY) +#if ASTC_ENABLE_2P // Projects 2-partition block pixels onto partition 0/1 endpoints and decimates onto g_AstcGrid0 (gridW x gridH). void AstcComputeWeightGrid2P( uint baseX, uint baseY, @@ -677,75 +766,121 @@ void AstcComputeWeightGrid2P( float4 e0_p1, float4 e1_p1, uint gridW, uint gridH) { - uint gridCount = gridW * gridH; - [loop] for (uint i = 0u; i < ASTC_MAX_GRID_U; ++i) - { - g_AstcGrid0[i] = 0.0; - g_AstcDecimNum[i] = 0.0; - g_AstcDecimDen[i] = 0.0; - } - float4 mask = AstcChannelMaskEx(effMode, 4u); float4 dir0 = (e1_p0 - e0_p0) * mask; float4 dir1 = (e1_p1 - e0_p1) * mask; + float lenSq0 = dot(dir0, dir0); + float lenSq1 = dot(dir1, dir1); + float4 scaledDir0 = dir0 * ((lenSq0 > 1e-6) ? (1.0 / lenSq0) : 0.0); + float4 scaledDir1 = dir1 * ((lenSq1 > 1e-6) ? (1.0 / lenSq1) : 0.0); + float projBias0 = -dot(e0_p0, scaledDir0); + float projBias1 = -dot(e0_p1, scaledDir1); + +#if defined(ASTC_HDR_VARIANT) + bool useAlphaW = false; +#else + bool useAlphaW = (effMode == ASTC_EFF_LDR_RGBA && _AstcUseAlphaWeight != 0u); +#endif bool exactGrid = (gridW == BLOCK_X && gridH == BLOCK_Y); bool smallBlock = (BLOCK_X * BLOCK_Y) < 32u; AstcPart2Params p2 = AstcPreparePartition2(partSeed, smallBlock); - [loop] for (uint y = 0u; y < BLOCK_Y; ++y) + if (exactGrid) { - [loop] for (uint x = 0u; x < BLOCK_X; ++x) + [loop] for (uint y = 0u; y < BLOCK_Y; ++y) { - float imp; - float4 p = AstcFetchWorkingPixel(baseX, baseY, x, y, effMode, imp); - float4 chImp = AstcGetChannelImp(effMode, imp); - uint part = AstcEvalPartition2(p2, x, y); - float t; - if (part == 0u) - { - float4 wDir0 = dir0 * chImp; - float denom0 = dot(wDir0, dir0); - t = (denom0 > 1e-6) ? saturate(dot((p - e0_p0) * mask, wDir0) / denom0) : 0.0; - } - else - { - float4 wDir1 = dir1 * chImp; - float denom1 = dot(wDir1, dir1); - t = (denom1 > 1e-6) ? saturate(dot((p - e0_p1) * mask, wDir1) / denom1) : 0.0; - } - - if (exactGrid) - { - g_AstcGrid0[y * gridW + x] = t; - } - else + uint rowOff = y * gridW; + [loop] for (uint x = 0u; x < BLOCK_X; ++x) { - uint js, jt; - uint4 tw; - AstcComputeInfillTap(x, y, BLOCK_X, BLOCK_Y, gridW, gridH, js, jt, tw); - uint idx00 = jt * gridW + js; - float f00 = (float)tw.x; - float f10 = (float)tw.y; - float f01 = (float)tw.z; - float f11 = (float)tw.w; - - g_AstcDecimNum[idx00] += f00 * t; g_AstcDecimDen[idx00] += f00; - if (tw.y > 0u) { g_AstcDecimNum[idx00 + 1u] += f10 * t; g_AstcDecimDen[idx00 + 1u] += f10; } - if (tw.z > 0u) { g_AstcDecimNum[idx00 + gridW] += f01 * t; g_AstcDecimDen[idx00 + gridW] += f01; } - if (tw.w > 0u) { g_AstcDecimNum[idx00 + gridW + 1u] += f11 * t; g_AstcDecimDen[idx00 + gridW + 1u] += f11; } + float imp; + float4 p = AstcFetchWorkingPixel(baseX, baseY, x, y, effMode, imp); + uint part = AstcEvalPartition2(p2, x, y); + float t; + if (useAlphaW) + { + float4 chImp = AstcGetChannelImp(effMode, imp); + if (part == 0u) + { + float4 wDir0 = dir0 * chImp; + float denom0 = dot(wDir0, dir0); + t = (denom0 > 1e-6) ? saturate(dot((p - e0_p0) * mask, wDir0) / denom0) : 0.0; + } + else + { + float4 wDir1 = dir1 * chImp; + float denom1 = dot(wDir1, dir1); + t = (denom1 > 1e-6) ? saturate(dot((p - e0_p1) * mask, wDir1) / denom1) : 0.0; + } + } + else + { + t = (part == 0u) + ? saturate(dot(p, scaledDir0) + projBias0) + : saturate(dot(p, scaledDir1) + projBias1); + } + g_AstcGrid0[rowOff + x] = t; } } + return; } - if (!exactGrid) + uint scaleX = AstcInfillScale(BLOCK_X, gridW); + uint scaleY = AstcInfillScale(BLOCK_Y, gridH); + + [loop] for (uint gy = 0u; gy < gridH; ++gy) { - [loop] for (uint k = 0u; k < gridCount; ++k) + uint2 ys = AstcGatherSpan(gy, scaleY, BLOCK_Y); + uint gRow = gy * gridW; + + [loop] for (uint gx = 0u; gx < gridW; ++gx) { - g_AstcGrid0[k] = (g_AstcDecimDen[k] > 1e-6) ? saturate(g_AstcDecimNum[k] / g_AstcDecimDen[k]) : 0.0; + uint2 xs = AstcGatherSpan(gx, scaleX, BLOCK_X); + + float num = 0.0; + float den = 0.0; + [loop] for (uint y = ys.x; y <= ys.y; ++y) + { + uint gt = AstcInfillCoord(y, scaleY); + [loop] for (uint x = xs.x; x <= xs.y; ++x) + { + uint gs = AstcInfillCoord(x, scaleX); + float tap = (float)AstcGatherTap(gs, gt, gx, gy); + float imp; + float4 p = AstcFetchWorkingPixel(baseX, baseY, x, y, effMode, imp); + uint part = AstcEvalPartition2(p2, x, y); + float t; + if (useAlphaW) + { + float4 chImp = AstcGetChannelImp(effMode, imp); + if (part == 0u) + { + float4 wDir0 = dir0 * chImp; + float denom0 = dot(wDir0, dir0); + t = (denom0 > 1e-6) ? saturate(dot((p - e0_p0) * mask, wDir0) / denom0) : 0.0; + } + else + { + float4 wDir1 = dir1 * chImp; + float denom1 = dot(wDir1, dir1); + t = (denom1 > 1e-6) ? saturate(dot((p - e0_p1) * mask, wDir1) / denom1) : 0.0; + } + } + else + { + t = (part == 0u) + ? saturate(dot(p, scaledDir0) + projBias0) + : saturate(dot(p, scaledDir1) + projBias1); + } + num += tap * t; + den += tap; + } + } + g_AstcGrid0[gRow + gx] = (den > 1e-6) ? saturate(num / den) : 0.0; } } } +#endif // ASTC_ENABLE_2P // Unified exact hardware-reconstructed candidate error evaluator for 1P (stage=0), Dual-Plane (stage=1), and 2P (stage=2). float AstcEvalCandidateError( @@ -753,21 +888,27 @@ float AstcEvalCandidateError( uint effMode, uint stage, uint ccs, +#if ASTC_ENABLE_2P AstcPart2Params p2, +#endif float4 e0_p0, float4 e1_p0, +#if ASTC_ENABLE_2P float4 e0_p1, float4 e1_p1, +#endif uint gridW, uint gridH, uint wQuant, uint epQuant, float bestError, out float4 outChanErr) { bool isDual = (stage == 1u); + float4 uq0_p0 = 0.0, uq1_p0 = 0.0; + bool swap0 = false; +#if ASTC_ENABLE_2P bool isTwoP = (stage == 2u); uint epPerPart = AstcGetEpCountForEffMode(effMode); uint partCnt = isTwoP ? 2u : 1u; - - float4 uq0_p0 = 0.0, uq1_p0 = 0.0, uq0_p1 = 0.0, uq1_p1 = 0.0; - bool swap0 = false, swap1 = false; + float4 uq0_p1 = 0.0, uq1_p1 = 0.0; + bool swap1 = false; [loop] for (uint pi = 0u; pi < partCnt; ++pi) { float4 te0 = (pi == 0u) ? e0_p0 : e0_p1; @@ -778,13 +919,11 @@ float AstcEvalCandidateError( if (pi == 0u) { uq0_p0 = uq0; uq1_p0 = uq1; swap0 = sw; } else { uq0_p1 = uq0; uq1_p1 = uq1; swap1 = sw; } } +#else + AstcQuantizeEndpoints(e0_p0, e1_p0, effMode, epQuant, 0u, uq0_p0, uq1_p0, swap0); +#endif uint gridCount = gridW * gridH; - [loop] for (uint i = 0u; i < ASTC_MAX_GRID_U; ++i) - { - g_AstcGridUq0[i] = 0u; - if (isDual) g_AstcGridUq1[i] = 0u; - } [loop] for (uint k = 0u; k < gridCount; ++k) { uint uq0; @@ -812,6 +951,7 @@ float AstcEvalCandidateError( ASTC_EVAL_INFILL(g_AstcGridUq0, x, y, BLOCK_X, BLOCK_Y, gridW, gridH, w0); float4 recon; +#if ASTC_ENABLE_2P if (isTwoP) { uint part = AstcEvalPartition2(p2, x, y); @@ -821,6 +961,7 @@ float AstcEvalCandidateError( : lerp(uq0_p1, uq1_p1, (float)effW0 * (1.0 / 64.0)); } else +#endif { uint effW0 = swap0 ? (64u - w0) : w0; recon = lerp(uq0_p0, uq1_p0, (float)effW0 * (1.0 / 64.0)); @@ -857,6 +998,7 @@ float AstcEvalCandidateError( return totalErr; } +#if ASTC_ENABLE_2P // Fits both 2-partition subsets simultaneously in 3 shared passes (mean + covariance + projection) instead of 8 separate passes. void AstcFitBothPartitions2P( uint baseX, uint baseY, @@ -969,6 +1111,7 @@ void AstcFitBothPartitions2P( AstcCanonicalizeEndpoints(effMode, outE0_p0, outE1_p0); AstcCanonicalizeEndpoints(effMode, outE0_p1, outE1_p1); } +#endif // ASTC_ENABLE_2P // Unified post-quantization ideal endpoint refit for 1P single-plane and Dual-Plane blocks. void AstcRefitEndpoints( @@ -1137,9 +1280,6 @@ void AstcRefitEndpoints( // Assembles the final winning AstcCandidate into a 128-bit physical ASTC block. uint4 AstcAssembleBlock(uint baseX, uint baseY, uint effMode, AstcCandidate c) { - [loop] for (uint e = 0u; e < 16u; ++e) g_AstcEpCodes[e] = 0u; - [loop] for (uint wi = 0u; wi < 64u; ++wi) g_AstcBiseVals[wi] = 0u; - uint epPerPart = AstcGetEpCountForEffMode(effMode); uint cem = AstcGetCemForEffMode(effMode); @@ -1147,8 +1287,8 @@ uint4 AstcAssembleBlock(uint baseX, uint baseY, uint effMode, AstcCandidate c) uint totalWeights = gridCount; float4 uqE0 = 0.0, uqE1 = 0.0; +#if ASTC_ENABLE_2P float4 uq0_p1 = 0.0, uq1_p1 = 0.0; -#if !defined(ASTC_FAST_ONLY) uint partCnt = (c.isTwoPart != 0u) ? 2u : 1u; [loop] for (uint pi = 0u; pi < partCnt; ++pi) { @@ -1165,75 +1305,140 @@ uint4 AstcAssembleBlock(uint baseX, uint baseY, uint effMode, AstcCandidate c) AstcQuantizeEndpoints(c.e0, c.e1, effMode, c.epQuant, 0u, uqE0, uqE1, dummySwapped); #endif -#if !defined(ASTC_FAST_ONLY) - if (c.isTwoPart != 0u) + uint4 block = uint4(0u, 0u, 0u, 0u); + bool weightsPackedDirect = false; + +#if defined(ASTC_FAST_ONLY) + // Fast direct MSB-descending weight packing for 1-plane exact-grid power-of-2 weight modes: + // eliminates g_AstcGrid0, g_AstcBiseVals, AstcEncodeBise (weights), and AstcReverse128. + if (c.isDualPlane == 0u && c.gridW == BLOCK_X && c.gridH == BLOCK_Y) { - AstcComputeWeightGrid2P(baseX, baseY, effMode, c.partSeed, uqE0, uqE1, uq0_p1, uq1_p1, c.gridW, c.gridH); - [loop] for (uint k = 0u; k < gridCount; ++k) + uint wRange, wBits, wTrits, wQuints; + AstcGetQuantParams(c.wQuant, wRange, wBits, wTrits, wQuints); + if (wTrits == 0u && wQuints == 0u && wBits >= 1u && wBits <= 4u) { - uint dummyUq; - g_AstcBiseVals[k] = AstcQuantizeWeight(g_AstcGrid0[k], c.wQuant, dummyUq); + float4 mask = AstcChannelMaskEx(effMode, 4u); + float4 dir = (uqE1 - uqE0) * mask; + float dirLenSq = dot(dir, dir); + float invDirLenSq = (dirLenSq > 1e-6) ? (1.0 / dirLenSq) : 0.0; + float4 scaledDir = dir * invDirLenSq; + float projBias = -dot(uqE0, scaledDir); +#if defined(ASTC_HDR_VARIANT) + bool useAlphaW = false; +#else + bool useAlphaW = (effMode == ASTC_EFF_LDR_RGBA && _AstcUseAlphaWeight != 0u); +#endif + + [loop] for (uint wy = 0u; wy < BLOCK_Y; ++wy) + { + [loop] for (uint wx = 0u; wx < BLOCK_X; ++wx) + { + float imp; + float4 p = AstcFetchWorkingPixel(baseX, baseY, wx, wy, effMode, imp); + float t; + if (useAlphaW) + { + float4 chImp = AstcGetChannelImp(effMode, imp); + float4 wDir = dir * chImp; + float denom = dot(wDir, dir); + t = (denom > 1e-6) ? saturate(dot((p - uqE0) * mask, wDir) / denom) : 0.0; + } + else + { + t = saturate(dot(p, scaledDir) + projBias); + } + + uint unusedWeight; + uint code = AstcQuantizePow2Weight(t, wRange - 1u, wBits, unusedWeight); + uint revCode = AstcReverseSmallBits(code, wBits); + uint wIdx = wy * BLOCK_X + wx; + AstcWriteBits128(block, 128u - (wIdx + 1u) * wBits, wBits, revCode); + } + } + weightsPackedDirect = true; } } - else #endif - { - bool isDual = (c.isDualPlane != 0u); - uint exclCh = isDual ? c.dualPlaneChannel : 4u; - AstcComputeWeightGrid1P(baseX, baseY, effMode, exclCh, uqE0, uqE1, c.gridW, c.gridH); - if (isDual) - { - AstcComputePlane1WeightGrid(baseX, baseY, effMode, c.dualPlaneChannel, AstcGetChannel(uqE0, c.dualPlaneChannel), AstcGetChannel(uqE1, c.dualPlaneChannel), c.gridW, c.gridH); - } -#if !defined(ASTC_FAST_ONLY) - [loop] for (uint zi = 0u; zi < ASTC_MAX_GRID_U; ++zi) + if (!weightsPackedDirect) + { +#if ASTC_ENABLE_2P + if (c.isTwoPart != 0u) { - g_AstcGridUq0[zi] = 0u; - if (isDual) g_AstcGridUq1[zi] = 0u; + AstcComputeWeightGrid2P(baseX, baseY, effMode, c.partSeed, uqE0, uqE1, uq0_p1, uq1_p1, c.gridW, c.gridH); + [loop] for (uint k = 0u; k < gridCount; ++k) + { + uint dummyUq; + g_AstcBiseVals[k] = AstcQuantizeWeight(g_AstcGrid0[k], c.wQuant, dummyUq); + } } + else #endif - [loop] for (uint k = 0u; k < gridCount; ++k) { - uint uq0; - uint code0 = AstcQuantizeWeight(g_AstcGrid0[k], c.wQuant, uq0); -#if !defined(ASTC_FAST_ONLY) - g_AstcGridUq0[k] = uq0; -#endif + bool isDual = (c.isDualPlane != 0u); + uint exclCh = isDual ? c.dualPlaneChannel : 4u; + AstcComputeWeightGrid1P(baseX, baseY, effMode, exclCh, uqE0, uqE1, c.gridW, c.gridH); if (isDual) { - uint uq1; - g_AstcBiseVals[2u * k] = code0; - g_AstcBiseVals[2u * k + 1u] = AstcQuantizeWeight(g_AstcGrid1[k], c.wQuant, uq1); + AstcComputePlane1WeightGrid(baseX, baseY, effMode, c.dualPlaneChannel, AstcGetChannel(uqE0, c.dualPlaneChannel), AstcGetChannel(uqE1, c.dualPlaneChannel), c.gridW, c.gridH); + } + + [loop] for (uint k = 0u; k < gridCount; ++k) + { + uint uq0; + uint code0 = AstcQuantizeWeight(g_AstcGrid0[k], c.wQuant, uq0); +#if !defined(ASTC_FAST_ONLY) + g_AstcGridUq0[k] = uq0; +#endif + if (isDual) + { + uint uq1; + g_AstcBiseVals[2u * k] = code0; + g_AstcBiseVals[2u * k + 1u] = AstcQuantizeWeight(g_AstcGrid1[k], c.wQuant, uq1); #if !defined(ASTC_FAST_ONLY) - g_AstcGridUq1[k] = uq1; + g_AstcGridUq1[k] = uq1; #endif + } + else + { + g_AstcBiseVals[k] = code0; + } } - else + if (isDual) totalWeights = gridCount * 2u; + +#if !defined(ASTC_FAST_ONLY) + if (_AstcQuality >= 1u) { - g_AstcBiseVals[k] = code0; + AstcRefitEndpoints(baseX, baseY, effMode, isDual, c.dualPlaneChannel, c.gridW, c.gridH, c.epQuant, uqE0, uqE1); } +#endif } - if (isDual) totalWeights = gridCount * 2u; -#if !defined(ASTC_FAST_ONLY) - if (_AstcQuality >= 1u) + // Fast direct MSB-descending weight packing when weight quant is pure power-of-2 (1..4 bits); + // otherwise pack via BISE at bit 0 and reverse all 128 bits. + uint wRange2, wBits2, wTrits2, wQuints2; + AstcGetQuantParams(c.wQuant, wRange2, wBits2, wTrits2, wQuints2); + if (wTrits2 == 0u && wQuints2 == 0u && wBits2 >= 1u && wBits2 <= 4u) { - AstcRefitEndpoints(baseX, baseY, effMode, isDual, c.dualPlaneChannel, c.gridW, c.gridH, c.epQuant, uqE0, uqE1); + [loop] for (uint wi = 0u; wi < totalWeights; ++wi) + { + uint revW = AstcReverseSmallBits(g_AstcBiseVals[wi], wBits2); + AstcWriteBits128(block, 128u - (wi + 1u) * wBits2, wBits2, revW); + } + } + else + { + uint4 wBuf = uint4(0u, 0u, 0u, 0u); + AstcEncodeBise(wBuf, 0u, c.wQuant, totalWeights); + block = AstcReverse128(wBuf); } -#endif } - // Encode weights at bit 0 into wBuf, then reverse all 128 bits so weights sit at MSB descending. - uint4 wBuf = uint4(0u, 0u, 0u, 0u); - AstcEncodeBise(wBuf, 0u, c.wQuant, totalWeights); - uint4 block = AstcReverse128(wBuf); - // Header: BlockMode (11 bits) + PartitionCount-1 (2 bits) AstcWriteBits128(block, 0u, 11u, c.blockMode); uint epStartBit = 17u; uint epTotalCount = epPerPart; -#if !defined(ASTC_FAST_ONLY) +#if ASTC_ENABLE_2P if (c.isTwoPart != 0u) { AstcWriteBits128(block, 11u, 2u, 1u); @@ -1264,15 +1469,25 @@ uint4 AstcAssembleBlock(uint baseX, uint baseY, uint effMode, AstcCandidate c) void AstcTryCandidate( uint baseX, uint baseY, uint effMode, - uint stage, uint ccs, uint partSeed, AstcPart2Params p2, - float4 e0_p0, float4 e1_p0, float4 e0_p1, float4 e1_p1, + uint stage, uint ccs, +#if ASTC_ENABLE_2P + uint partSeed, AstcPart2Params p2, +#endif + float4 e0_p0, float4 e1_p0, +#if ASTC_ENABLE_2P + float4 e0_p1, float4 e1_p1, +#endif uint bm, uint gw, uint gh, uint wQ, uint epQ, inout AstcCandidate best, inout float4 bestChanErr) { float4 chanErr; +#if ASTC_ENABLE_2P float err = AstcEvalCandidateError(baseX, baseY, effMode, stage, ccs, p2, e0_p0, e1_p0, e0_p1, e1_p1, gw, gh, wQ, epQ, best.error, chanErr); +#else + float err = AstcEvalCandidateError(baseX, baseY, effMode, stage, ccs, e0_p0, e1_p0, gw, gh, wQ, epQ, best.error, chanErr); +#endif if (err < best.error) { best.blockMode = bm; @@ -1282,16 +1497,18 @@ void AstcTryCandidate( best.epQuant = epQ; best.isDualPlane = (stage == 1u) ? 1u : 0u; best.dualPlaneChannel = (stage == 1u) ? ccs : 3u; - best.isTwoPart = (stage == 2u) ? 1u : 0u; - best.partSeed = (stage == 2u) ? partSeed : 0u; best.error = err; best.e0 = e0_p0; best.e1 = e1_p0; +#if ASTC_ENABLE_2P + best.isTwoPart = (stage == 2u) ? 1u : 0u; + best.partSeed = (stage == 2u) ? partSeed : 0u; if (stage == 2u) { best.e0_p1 = e0_p1; best.e1_p1 = e1_p1; } +#endif if (stage == 0u) { bestChanErr = chanErr; @@ -1299,6 +1516,7 @@ void AstcTryCandidate( } } +#if ASTC_ENABLE_2P // Curated 16 geometrically diverse ASTC 2-partition seeds (vertical, horizontal, diagonals, corners). uint AstcGetCuratedSeed(uint idx) { @@ -1402,6 +1620,7 @@ uint AstcSelectBestSeed2P(uint baseX, uint baseY, uint effMode) return bestSeed; } +#endif // ASTC_ENABLE_2P #endif // !ASTC_FAST_ONLY @@ -1411,58 +1630,140 @@ uint4 AstcEncodeBlock(uint blockXIdx, uint blockYIdx) uint baseX = blockXIdx * BLOCK_X; uint baseY = blockYIdx * BLOCK_Y; - bool isHdr = (_AstcMode == ASTC_MODE_HDR_RGB || _AstcMode == ASTC_MODE_HDR_RGBA); + uint effMode; + float4 preMeanP = 0.0; + float4 preMinC = 0.0; + float4 preMaxC = 0.0; + bool hasPreStats = true; +#if !defined(ASTC_HDR_VARIANT) // ------------------------------------------------------------------------ - // Step 1: Scan raw block stats (Void-Extent check + HDR alpha mode resolution) + // Step 1 + 2 (LDR): Single-pass texture load -> compact RGBA8 cache + Void-Extent + block stats // ------------------------------------------------------------------------ - float4 rawMin = float4(1e30, 1e30, 1e30, 1e30); - float4 rawMax = float4(-1e30, -1e30, -1e30, -1e30); - float4 rawFirst = 0.0; + bool isNormalMode = (_AstcMode == ASTC_MODE_LDR_NORMAL); + bool isRgbOnlyMode = (_AstcMode == ASTC_MODE_LDR_RGB); + bool useAlphaW = (_AstcMode == ASTC_MODE_LDR_RGBA && _AstcUseAlphaWeight != 0u); + + uint4 min8 = uint4(255u, 255u, 255u, 255u); + uint4 max8 = uint4(0u, 0u, 0u, 0u); + uint4 first8 = uint4(0u, 0u, 0u, 255u); + float4 sumP = 0.0; + float4 sumW = 0.0; [loop] for (uint y = 0u; y < BLOCK_Y; ++y) { + uint py = min(baseY + y, _AstcSrcHeight - 1u); + uint rowOff = y * BLOCK_X; [loop] for (uint x = 0u; x < BLOCK_X; ++x) { uint px = min(baseX + x, _AstcSrcWidth - 1u); - uint py = min(baseY + y, _AstcSrcHeight - 1u); - float4 r = _AstcSourceTex.Load(int3(px, py, _AstcMipLevel)); - if (isHdr) + float4 raw = _AstcSourceTex.Load(int3(px, py, _AstcMipLevel)); + float3 rgb = (_AstcIsSRGB != 0u) ? AstcLinearToSRGB(raw.rgb) : saturate(raw.rgb); + + uint4 c8; + if (isNormalMode) { - // Sanitize NaN / Inf / negative values consistently with AstcFloatToLns4 & AstcFloatToHalfU16 - // so a single NaN at (0,0) or +Inf cannot corrupt Void-Extent detection. - r = float4( - (r.r > 0.0) ? min(r.r, 65504.0) : 0.0, - (r.g > 0.0) ? min(r.g, 65504.0) : 0.0, - (r.b > 0.0) ? min(r.b, 65504.0) : 0.0, - (r.a > 0.0) ? min(r.a, 65504.0) : 0.0); + uint g8 = (uint)clamp(floor(rgb.g * 255.0 + 0.5), 0.0, 255.0); + uint r8 = (uint)clamp(floor(rgb.r * 255.0 + 0.5), 0.0, 255.0); + c8 = uint4(g8, 0u, 0u, r8); } - if (x == 0u && y == 0u) rawFirst = r; - rawMin = min(rawMin, r); - rawMax = max(rawMax, r); + else + { + uint a8 = isRgbOnlyMode ? 255u : (uint)clamp(floor(saturate(raw.a) * 255.0 + 0.5), 0.0, 255.0); + c8 = uint4( + (uint)clamp(floor(rgb.r * 255.0 + 0.5), 0.0, 255.0), + (uint)clamp(floor(rgb.g * 255.0 + 0.5), 0.0, 255.0), + (uint)clamp(floor(rgb.b * 255.0 + 0.5), 0.0, 255.0), + a8); + } + + g_AstcPackedBlock[rowOff + x] = AstcPackRgba8(c8); + if (x == 0u && y == 0u) first8 = c8; + min8 = min(min8, c8); + max8 = max(max8, c8); + + float4 pf = (float4)c8; + float imp = useAlphaW ? max(pf.a * (1.0 / 255.0), 0.02) : 1.0; + float4 chImp = useAlphaW ? float4(imp, imp, imp, 1.0) : float4(1.0, 1.0, 1.0, 1.0); + sumP += pf * chImp; + sumW += chImp; } } - // Resolve effective CEM mode per block - uint effMode = ASTC_EFF_LDR_RGB; - if (_AstcMode == ASTC_MODE_LDR_NORMAL) + if (isNormalMode) { effMode = ASTC_EFF_LDR_NORMAL; + if (min8.x == max8.x && min8.w == max8.w) + { + return AstcEncodeVoidExtentLDR(uint4(first8.x, first8.x, first8.x, first8.w) * 257u); + } } - else if (_AstcMode == ASTC_MODE_LDR_RGB) + else if (isRgbOnlyMode || min8.a == 255u) { + // Auto-promote opaque RGBA blocks to RGB CEM (6 endpoints -> higher precision!) effMode = ASTC_EFF_LDR_RGB; + if (min8.r == max8.r && min8.g == max8.g && min8.b == max8.b) + { + return AstcEncodeVoidExtentLDR(uint4(first8.rgb, 255u) * 257u); + } } - else if (_AstcMode == ASTC_MODE_LDR_RGBA) + else + { + effMode = ASTC_EFF_LDR_RGBA; + if (min8.r == max8.r && min8.g == max8.g && min8.b == max8.b && min8.a == max8.a) + { + return AstcEncodeVoidExtentLDR(first8 * 257u); + } + } + + preMeanP = sumP / max(sumW, 1e-6); + preMinC = (float4)min8; + preMaxC = (float4)max8; +#else + // ------------------------------------------------------------------------ + // Step 1 + 2 (HDR): Single-pass texture load -> LNS16 cache + Void-Extent + block stats + // ------------------------------------------------------------------------ + float4 rawMin = float4(1e30, 1e30, 1e30, 1e30); + float4 rawMax = float4(-1e30, -1e30, -1e30, -1e30); + float4 rawFirst = 0.0; + float4 sumLns = 0.0; + float4 minLns = float4(65535.0, 65535.0, 65535.0, 65535.0); + float4 maxLns = float4(0.0, 0.0, 0.0, 0.0); + bool isHdrRgbOnly = (_AstcMode == ASTC_MODE_HDR_RGB); + + [loop] for (uint y = 0u; y < BLOCK_Y; ++y) { - // Auto-promote opaque blocks to RGB CEM (6 endpoints -> higher precision!) - effMode = (rawMin.a >= (254.5 / 255.0)) ? ASTC_EFF_LDR_RGB : ASTC_EFF_LDR_RGBA; + uint py = min(baseY + y, _AstcSrcHeight - 1u); + uint rowOff = y * BLOCK_X; + [loop] for (uint x = 0u; x < BLOCK_X; ++x) + { + uint px = min(baseX + x, _AstcSrcWidth - 1u); + float4 r = _AstcSourceTex.Load(int3(px, py, _AstcMipLevel)); + // Sanitize NaN / Inf / negative values consistently with AstcFloatToLns4 & AstcFloatToHalfU16 + r = float4( + (r.r > 0.0) ? min(r.r, 65504.0) : 0.0, + (r.g > 0.0) ? min(r.g, 65504.0) : 0.0, + (r.b > 0.0) ? min(r.b, 65504.0) : 0.0, + (r.a > 0.0) ? min(r.a, 65504.0) : 0.0); + + if (x == 0u && y == 0u) rawFirst = r; + rawMin = min(rawMin, r); + rawMax = max(rawMax, r); + + float4 lns = AstcFloatToLns4(r); + if (isHdrRgbOnly) lns.a = 65535.0; + g_AstcPackedBlock[rowOff + x] = AstcPackRgba16(lns); + sumLns += lns; + minLns = min(minLns, lns); + maxLns = max(maxLns, lns); + } } - else if (_AstcMode == ASTC_MODE_HDR_RGB) + + if (isHdrRgbOnly) { effMode = ASTC_EFF_HDR_RGB; } - else // ASTC_MODE_HDR_RGBA + else { if (rawMin.a >= 0.999 && rawMax.a <= 1.001) effMode = ASTC_EFF_HDR_RGB; @@ -1472,81 +1773,46 @@ uint4 AstcEncodeBlock(uint blockXIdx, uint blockYIdx) effMode = ASTC_EFF_HDR_RGBA; } - // ------------------------------------------------------------------------ - // Step 2: Void-Extent constant color fast path (lossless!) - // ------------------------------------------------------------------------ - if (!isHdr) + bool isConstRgb = all(rawMax.rgb - rawMin.rgb <= max(abs(rawMax.rgb) * 1e-4, 1e-5)); + bool isConstA = (effMode == ASTC_EFF_HDR_RGB) || ((rawMax.a - rawMin.a) <= max(abs(rawMax.a) * 1e-4, 1e-5)); + if (isConstRgb && isConstA) { - // AstcLinearToSRGB is monotonic on [0, 1], so converting min/max preserves the exact - // range in sRGB code space and prevents dark sRGB gradients from being treated as flat. - float4 cmpMin = saturate(rawMin); - float4 cmpMax = saturate(rawMax); - if (_AstcIsSRGB != 0u) - { - cmpMin.rgb = AstcLinearToSRGB(rawMin.rgb); - cmpMax.rgb = AstcLinearToSRGB(rawMax.rgb); - } - - bool isConst; - if (effMode == ASTC_EFF_LDR_NORMAL) - isConst = (cmpMax.r - cmpMin.r < (0.5 / 255.0)) && (cmpMax.g - cmpMin.g < (0.5 / 255.0)); - else if (effMode == ASTC_EFF_LDR_RGB) - isConst = all(cmpMax.rgb - cmpMin.rgb < (0.5 / 255.0)); - else - isConst = all(cmpMax - cmpMin < (0.5 / 255.0)); + uint4 f16 = uint4( + AstcFloatToHalfU16(rawFirst.r), + AstcFloatToHalfU16(rawFirst.g), + AstcFloatToHalfU16(rawFirst.b), + (effMode == ASTC_EFF_HDR_RGB) ? 0x3C00u : AstcFloatToHalfU16(rawFirst.a)); + return AstcEncodeVoidExtentHDR(f16); + } - if (isConst) + if (effMode == ASTC_EFF_HDR_RGB_LDR_ALPHA) + { + // Scale LDR alpha [0,1] into [0,65535] to match CEM 14 working space. + [loop] for (uint cy = 0u; cy < BLOCK_Y; ++cy) { - float4 c = rawFirst; - float3 rgb = (_AstcIsSRGB != 0u) ? AstcLinearToSRGB(c.rgb) : saturate(c.rgb); - uint4 c8; - if (effMode == ASTC_EFF_LDR_NORMAL) - { - uint g8 = (uint)clamp(floor(rgb.g * 255.0 + 0.5), 0.0, 255.0); - uint r8 = (uint)clamp(floor(rgb.r * 255.0 + 0.5), 0.0, 255.0); - c8 = uint4(g8, g8, g8, r8); - } - else + uint py = min(baseY + cy, _AstcSrcHeight - 1u); + uint rowOff = cy * BLOCK_X; + [loop] for (uint cx = 0u; cx < BLOCK_X; ++cx) { - uint a8 = (effMode == ASTC_EFF_LDR_RGB) ? 255u : (uint)clamp(floor(saturate(c.a) * 255.0 + 0.5), 0.0, 255.0); - c8 = uint4( - (uint)clamp(floor(rgb.r * 255.0 + 0.5), 0.0, 255.0), - (uint)clamp(floor(rgb.g * 255.0 + 0.5), 0.0, 255.0), - (uint)clamp(floor(rgb.b * 255.0 + 0.5), 0.0, 255.0), - a8); + uint px = min(baseX + cx, _AstcSrcWidth - 1u); + float ra = saturate(_AstcSourceTex.Load(int3(px, py, _AstcMipLevel)).a); + uint a16 = (uint)clamp(floor(ra * 65535.0 + 0.5), 0.0, 65535.0); + uint2 pk = g_AstcPackedBlock[rowOff + cx]; + g_AstcPackedBlock[rowOff + cx] = uint2(pk.x, (pk.y & 0xFFFFu) | (a16 << 16u)); } - return AstcEncodeVoidExtentLDR(c8 * 257u); } + hasPreStats = false; } else { - bool isConstRgb = all(rawMax.rgb - rawMin.rgb <= max(abs(rawMax.rgb) * 1e-4, 1e-5)); - bool isConstA = (effMode == ASTC_EFF_HDR_RGB) || ((rawMax.a - rawMin.a) <= max(abs(rawMax.a) * 1e-4, 1e-5)); - if (isConstRgb && isConstA) - { - uint4 f16 = uint4( - AstcFloatToHalfU16(rawFirst.r), - AstcFloatToHalfU16(rawFirst.g), - AstcFloatToHalfU16(rawFirst.b), - (effMode == ASTC_EFF_HDR_RGB) ? 0x3C00u : AstcFloatToHalfU16(rawFirst.a)); - return AstcEncodeVoidExtentHDR(f16); - } - } - -#if ASTC_ENABLE_PIXEL_CACHE - [loop] for (uint cy = 0u; cy < BLOCK_Y; ++cy) - { - [loop] for (uint cx = 0u; cx < BLOCK_X; ++cx) - { - float dummyImp; - float4 wp = AstcLoadWorkingPixel(baseX, baseY, cx, cy, effMode, dummyImp); - g_AstcPackedBlock[cy * BLOCK_X + cx] = AstcPackRgba16(wp); - } + preMeanP = sumLns * (1.0 / (float)(BLOCK_X * BLOCK_Y)); + preMinC = minLns; + preMaxC = maxLns; } #endif // ------------------------------------------------------------------------ - // Step 3: Normal Map Dedicated Dual-Plane Path (GGGR -> CEM 4 LA + CCS=3) + // Step 3: Endpoint Fitting & Mode Selection // ------------------------------------------------------------------------ AstcCandidate best; best.blockMode = 0x251u; @@ -1556,24 +1822,33 @@ uint4 AstcEncodeBlock(uint blockXIdx, uint blockYIdx) best.epQuant = ASTC_QUANT_256; best.isDualPlane = 0u; best.dualPlaneChannel = 3u; - best.isTwoPart = 0u; - best.partSeed = 0u; best.error = 1e30; best.e0 = 0.0; best.e1 = 0.0; +#if ASTC_ENABLE_2P + best.isTwoPart = 0u; + best.partSeed = 0u; best.e0_p1 = 0.0; best.e1_p1 = 0.0; +#endif +#if defined(ASTC_HDR_VARIANT) + bool isNormal = false; + bool hasAlpha = (effMode != ASTC_EFF_HDR_RGB); +#else bool isNormal = (effMode == ASTC_EFF_LDR_NORMAL); - bool hasAlpha = (effMode == ASTC_EFF_LDR_RGBA || effMode == ASTC_EFF_HDR_RGB_LDR_ALPHA || effMode == ASTC_EFF_HDR_RGBA); + bool hasAlpha = (effMode == ASTC_EFF_LDR_RGBA); +#endif #if defined(ASTC_FAST_ONLY) uint refineIters = 0u; +#elif defined(ASTC_NO_2P) + uint refineIters = (!isNormal) ? 1u : 0u; #else - uint refineIters = (!isNormal && _AstcQuality >= 1u) ? 2u : 0u; + uint refineIters = (!isNormal && _AstcQuality >= 1u) ? ((_AstcQuality >= 2u) ? 2u : 1u) : 0u; #endif float4 e0, e1; - AstcFitSubsetEndpoints(baseX, baseY, effMode, isNormal ? 3u : 4u, 0u, 2u, refineIters, e0, e1); + AstcFitSubsetEndpoints(baseX, baseY, effMode, isNormal ? 3u : 4u, 0u, 2u, refineIters, hasPreStats, preMeanP, preMinC, preMaxC, e0, e1); #if defined(ASTC_FAST_ONLY) best.e0 = e0; @@ -1586,7 +1861,11 @@ uint4 AstcEncodeBlock(uint blockXIdx, uint blockYIdx) else if (!hasAlpha) { #if BLOCK_X == 4 - best.blockMode = 0x251u; best.gridW = 4u; best.gridH = 4u; best.wQuant = ASTC_QUANT_12; best.epQuant = ASTC_QUANT_256; + best.blockMode = 0x242u; best.gridW = 4u; best.gridH = 4u; best.wQuant = ASTC_QUANT_16; best.epQuant = ASTC_QUANT_192; +#elif BLOCK_X == 5 + best.blockMode = 0x0F3u; best.gridW = 5u; best.gridH = 5u; best.wQuant = ASTC_QUANT_8; best.epQuant = ASTC_QUANT_64; +#elif BLOCK_X == 6 + best.blockMode = 0x108u; best.gridW = 6u; best.gridH = 6u; best.wQuant = ASTC_QUANT_4; best.epQuant = ASTC_QUANT_80; #else best.blockMode = 0x0E3u; best.gridW = 5u; best.gridH = 5u; best.wQuant = ASTC_QUANT_6; best.epQuant = ASTC_QUANT_192; #endif @@ -1595,11 +1874,16 @@ uint4 AstcEncodeBlock(uint blockXIdx, uint blockYIdx) { #if BLOCK_X == 4 best.blockMode = 0x053u; best.gridW = 4u; best.gridH = 4u; best.wQuant = ASTC_QUANT_8; best.epQuant = ASTC_QUANT_192; +#elif BLOCK_X == 5 + best.blockMode = 0x0E2u; best.gridW = 5u; best.gridH = 5u; best.wQuant = ASTC_QUANT_4; best.epQuant = ASTC_QUANT_192; +#elif BLOCK_X == 6 + best.blockMode = 0x108u; best.gridW = 6u; best.gridH = 6u; best.wQuant = ASTC_QUANT_4; best.epQuant = ASTC_QUANT_24; #else best.blockMode = 0x0E2u; best.gridW = 5u; best.gridH = 5u; best.wQuant = ASTC_QUANT_4; best.epQuant = ASTC_QUANT_192; #endif } #else +#if !defined(ASTC_NO_2P) if (_AstcQuality == 0u) { best.e0 = e0; @@ -1612,7 +1896,11 @@ uint4 AstcEncodeBlock(uint blockXIdx, uint blockYIdx) else if (!hasAlpha) { #if BLOCK_X == 4 - best.blockMode = 0x251u; best.gridW = 4u; best.gridH = 4u; best.wQuant = ASTC_QUANT_12; best.epQuant = ASTC_QUANT_256; + best.blockMode = 0x242u; best.gridW = 4u; best.gridH = 4u; best.wQuant = ASTC_QUANT_16; best.epQuant = ASTC_QUANT_192; +#elif BLOCK_X == 5 + best.blockMode = 0x0F3u; best.gridW = 5u; best.gridH = 5u; best.wQuant = ASTC_QUANT_8; best.epQuant = ASTC_QUANT_64; +#elif BLOCK_X == 6 + best.blockMode = 0x108u; best.gridW = 6u; best.gridH = 6u; best.wQuant = ASTC_QUANT_4; best.epQuant = ASTC_QUANT_80; #else best.blockMode = 0x0E3u; best.gridW = 5u; best.gridH = 5u; best.wQuant = ASTC_QUANT_6; best.epQuant = ASTC_QUANT_192; #endif @@ -1621,33 +1909,67 @@ uint4 AstcEncodeBlock(uint blockXIdx, uint blockYIdx) { #if BLOCK_X == 4 best.blockMode = 0x053u; best.gridW = 4u; best.gridH = 4u; best.wQuant = ASTC_QUANT_8; best.epQuant = ASTC_QUANT_192; +#elif BLOCK_X == 5 + best.blockMode = 0x0E2u; best.gridW = 5u; best.gridH = 5u; best.wQuant = ASTC_QUANT_4; best.epQuant = ASTC_QUANT_192; +#elif BLOCK_X == 6 + best.blockMode = 0x108u; best.gridW = 6u; best.gridH = 6u; best.wQuant = ASTC_QUANT_4; best.epQuant = ASTC_QUANT_24; #else best.blockMode = 0x0E2u; best.gridW = 5u; best.gridH = 5u; best.wQuant = ASTC_QUANT_4; best.epQuant = ASTC_QUANT_192; #endif } } else +#endif { float4 bestChanErr = 0.0; +#if ASTC_ENABLE_2P AstcPart2Params p2Params; p2Params.seed1 = 0u; p2Params.seed2 = 0u; p2Params.seed3 = 0u; p2Params.seed4 = 0u; p2Params.offA = 0u; p2Params.offB = 0u; +#endif + +#if defined(ASTC_NO_2P) && !defined(ASTC_HDR_VARIANT) + // Use the unweighted LDR working-space SSE, not a decoded-image PSNR guarantee. + bool canEarlyOut = !isNormal && (!hasAlpha || _AstcUseAlphaWeight == 0u); + float earlyOutErr = (hasAlpha ? 4.0 : 3.0) * (255.0 * 255.0 * 1e-5) * (float)(BLOCK_X * BLOCK_Y); +#endif - // Unified 3-stage candidate search: stage 0 = 1P, stage 1 = Dual-Plane, stage 2 = 2P (High quality). + // Unified multi-stage candidate search: stage 0 = 1P, stage 1 = Dual-Plane, stage 2 = 2P (High quality). // Consolidates AstcTryCandidate / AstcEvalCandidateError / AstcComputeWeightGrid1P to a single inlined site. - [loop] for (uint stage = 0u; stage < 3u; ++stage) +#if ASTC_ENABLE_2P + const uint maxStage = 3u; +#else + const uint maxStage = 2u; +#endif + [loop] for (uint stage = 0u; stage < maxStage; ++stage) { if (stage == 0u && isNormal) continue; +#if defined(ASTC_NO_2P) && !defined(ASTC_HDR_VARIANT) + if (stage == 1u && canEarlyOut && best.error <= earlyOutErr) break; +#endif +#if ASTC_ENABLE_2P if (stage == 2u && (isNormal || _AstcQuality < 2u)) continue; +#endif uint stageCcs = 4u; - uint stageSeed = 0u; float4 sE0_p0 = e0, sE1_p0 = e1; +#if ASTC_ENABLE_2P + uint stageSeed = 0u; float4 sE0_p1 = 0.0, sE1_p1 = 0.0; +#endif uint candCount = 0u; if (stage == 0u) { +#if defined(ASTC_NO_2P) +#if BLOCK_X >= 6 + candCount = 4u; +#elif BLOCK_X >= 5 + candCount = 3u; +#else + candCount = 2u; +#endif +#else if (!hasAlpha) { #if BLOCK_X >= 8 @@ -1670,6 +1992,7 @@ uint4 AstcEncodeBlock(uint blockXIdx, uint blockYIdx) candCount = 3u; #endif } +#endif } else if (stage == 1u) { @@ -1681,14 +2004,19 @@ uint4 AstcEncodeBlock(uint blockXIdx, uint blockYIdx) if (bestChanErr.g > maxChErr) { maxChErr = bestChanErr.g; stageCcs = 1u; } if (bestChanErr.b > maxChErr) { maxChErr = bestChanErr.b; stageCcs = 2u; } if (hasAlpha && bestChanErr.a > maxChErr) { stageCcs = 3u; } - AstcFitSubsetEndpoints(baseX, baseY, effMode, stageCcs, 0u, 2u, 1u, sE0_p0, sE1_p0); + AstcFitSubsetEndpoints(baseX, baseY, effMode, stageCcs, 0u, 2u, 1u, hasPreStats, preMeanP, preMinC, preMaxC, sE0_p0, sE1_p0); } #if BLOCK_X >= 5 +#if defined(ASTC_NO_2P) + candCount = isNormal ? 4u : 2u; +#else candCount = isNormal ? 4u : 3u; +#endif #else candCount = 2u; #endif } +#if ASTC_ENABLE_2P else { bool smallBlock = (BLOCK_X * BLOCK_Y) < 32u; @@ -1701,6 +2029,7 @@ uint4 AstcEncodeBlock(uint blockXIdx, uint blockYIdx) candCount = 2u; #endif } +#endif uint cachedGW = 0u, cachedGH = 0u; [loop] for (uint ci = 0u; ci < candCount; ++ci) @@ -1708,6 +2037,50 @@ uint4 AstcEncodeBlock(uint blockXIdx, uint blockYIdx) uint bm, gw, gh, wQ, epQ; if (stage == 0u) { +#if defined(ASTC_NO_2P) + if (!hasAlpha) + { +#if BLOCK_X == 4 + if (ci == 0u) { bm = 0x251u; gw = 4u; gh = 4u; wQ = ASTC_QUANT_12; epQ = ASTC_QUANT_256; } + else { bm = 0x242u; gw = 4u; gh = 4u; wQ = ASTC_QUANT_16; epQ = ASTC_QUANT_192; } +#elif BLOCK_X == 5 + if (ci == 0u) { bm = 0x251u; gw = 4u; gh = 4u; wQ = ASTC_QUANT_12; epQ = ASTC_QUANT_256; } + else if (ci == 1u) { bm = 0x0E3u; gw = 5u; gh = 5u; wQ = ASTC_QUANT_6; epQ = ASTC_QUANT_192; } + else { bm = 0x0F3u; gw = 5u; gh = 5u; wQ = ASTC_QUANT_8; epQ = ASTC_QUANT_64; } +#elif BLOCK_X == 6 + if (ci == 0u) { bm = 0x108u; gw = 6u; gh = 6u; wQ = ASTC_QUANT_4; epQ = ASTC_QUANT_80; } + else if (ci == 1u) { bm = 0x114u; gw = 6u; gh = 6u; wQ = ASTC_QUANT_3; epQ = ASTC_QUANT_256; } + else if (ci == 2u) { bm = 0x0E3u; gw = 5u; gh = 5u; wQ = ASTC_QUANT_6; epQ = ASTC_QUANT_192; } + else { bm = 0x251u; gw = 4u; gh = 4u; wQ = ASTC_QUANT_12; epQ = ASTC_QUANT_256; } +#else + if (ci == 0u) { bm = 0x0E3u; gw = 5u; gh = 5u; wQ = ASTC_QUANT_6; epQ = ASTC_QUANT_192; } + else if (ci == 1u) { bm = 0x114u; gw = 6u; gh = 6u; wQ = ASTC_QUANT_3; epQ = ASTC_QUANT_256; } + else if (ci == 2u) { bm = 0x108u; gw = 6u; gh = 6u; wQ = ASTC_QUANT_4; epQ = ASTC_QUANT_80; } + else { bm = 0x251u; gw = 4u; gh = 4u; wQ = ASTC_QUANT_12; epQ = ASTC_QUANT_256; } +#endif + } + else + { +#if BLOCK_X == 4 + if (ci == 0u) { bm = 0x053u; gw = 4u; gh = 4u; wQ = ASTC_QUANT_8; epQ = ASTC_QUANT_192; } + else { bm = 0x043u; gw = 4u; gh = 4u; wQ = ASTC_QUANT_6; epQ = ASTC_QUANT_256; } +#elif BLOCK_X == 5 + if (ci == 0u) { bm = 0x053u; gw = 4u; gh = 4u; wQ = ASTC_QUANT_8; epQ = ASTC_QUANT_192; } + else if (ci == 1u) { bm = 0x0E2u; gw = 5u; gh = 5u; wQ = ASTC_QUANT_4; epQ = ASTC_QUANT_192; } + else { bm = 0x0F2u; gw = 5u; gh = 5u; wQ = ASTC_QUANT_5; epQ = ASTC_QUANT_80; } +#elif BLOCK_X == 6 + if (ci == 0u) { bm = 0x114u; gw = 6u; gh = 6u; wQ = ASTC_QUANT_3; epQ = ASTC_QUANT_96; } + else if (ci == 1u) { bm = 0x108u; gw = 6u; gh = 6u; wQ = ASTC_QUANT_4; epQ = ASTC_QUANT_24; } + else if (ci == 2u) { bm = 0x0E2u; gw = 5u; gh = 5u; wQ = ASTC_QUANT_4; epQ = ASTC_QUANT_192; } + else { bm = 0x053u; gw = 4u; gh = 4u; wQ = ASTC_QUANT_8; epQ = ASTC_QUANT_192; } +#else + if (ci == 0u) { bm = 0x0E2u; gw = 5u; gh = 5u; wQ = ASTC_QUANT_4; epQ = ASTC_QUANT_192; } + else if (ci == 1u) { bm = 0x0F2u; gw = 5u; gh = 5u; wQ = ASTC_QUANT_5; epQ = ASTC_QUANT_80; } + else if (ci == 2u) { bm = 0x114u; gw = 6u; gh = 6u; wQ = ASTC_QUANT_3; epQ = ASTC_QUANT_96; } + else { bm = 0x053u; gw = 4u; gh = 4u; wQ = ASTC_QUANT_8; epQ = ASTC_QUANT_192; } +#endif + } +#else if (!hasAlpha) { if (ci == 0u) { bm = 0x251u; gw = 4u; gh = 4u; wQ = ASTC_QUANT_12; epQ = ASTC_QUANT_256; } @@ -1734,6 +2107,7 @@ uint4 AstcEncodeBlock(uint blockXIdx, uint blockYIdx) else if (ci == 6u) { bm = 0x142u; gw = 6u; gh = 4u; wQ = ASTC_QUANT_4; epQ = ASTC_QUANT_192; } else { bm = 0x04Eu; gw = 4u; gh = 6u; wQ = ASTC_QUANT_4; epQ = ASTC_QUANT_192; } } +#endif } else if (stage == 1u) { @@ -1759,6 +2133,7 @@ uint4 AstcEncodeBlock(uint blockXIdx, uint blockYIdx) } bm = cfg.x; gw = cfg.y; gh = cfg.y; wQ = cfg.z; epQ = cfg.w; } +#if ASTC_ENABLE_2P else { uint4 cfg; @@ -1778,14 +2153,17 @@ uint4 AstcEncodeBlock(uint blockXIdx, uint blockYIdx) } bm = cfg.x; gw = cfg.y; gh = cfg.y; wQ = cfg.z; epQ = cfg.w; } +#endif if (gw != cachedGW || gh != cachedGH) { +#if ASTC_ENABLE_2P if (stage == 2u) { AstcComputeWeightGrid2P(baseX, baseY, effMode, stageSeed, sE0_p0, sE1_p0, sE0_p1, sE1_p1, gw, gh); } else +#endif { AstcComputeWeightGrid1P(baseX, baseY, effMode, stageCcs, sE0_p0, sE1_p0, gw, gh); if (stage == 1u) @@ -1797,7 +2175,11 @@ uint4 AstcEncodeBlock(uint blockXIdx, uint blockYIdx) cachedGH = gh; } +#if ASTC_ENABLE_2P AstcTryCandidate(baseX, baseY, effMode, stage, stageCcs, stageSeed, p2Params, sE0_p0, sE1_p0, sE0_p1, sE1_p1, bm, gw, gh, wQ, epQ, best, bestChanErr); +#else + AstcTryCandidate(baseX, baseY, effMode, stage, stageCcs, sE0_p0, sE1_p0, bm, gw, gh, wQ, epQ, best, bestChanErr); +#endif } } } diff --git a/Assets/ASTC Encoder/Runtime/Resources/AstcGpuEncoder.compute b/Assets/ASTC Encoder/Runtime/Resources/AstcGpuEncoder.compute index 832c7b4..c82cbc0 100644 --- a/Assets/ASTC Encoder/Runtime/Resources/AstcGpuEncoder.compute +++ b/Assets/ASTC Encoder/Runtime/Resources/AstcGpuEncoder.compute @@ -1,4 +1,5 @@ #pragma editor_sync_compilation +#pragma multi_compile_local _ ASTC_HDR_VARIANT #pragma kernel EncodeTex4x4 ASTC_BLOCK_4X4 #pragma kernel EncodeTex5x5 ASTC_BLOCK_5X5 @@ -14,6 +15,20 @@ #pragma kernel EncodeBuf10x10 ASTC_BLOCK_10X10 #pragma kernel EncodeBuf12x12 ASTC_BLOCK_12X12 +#pragma kernel EncodeTex4x4Med ASTC_BLOCK_4X4 ASTC_NO_2P +#pragma kernel EncodeTex5x5Med ASTC_BLOCK_5X5 ASTC_NO_2P +#pragma kernel EncodeTex6x6Med ASTC_BLOCK_6X6 ASTC_NO_2P +#pragma kernel EncodeTex8x8Med ASTC_BLOCK_8X8 ASTC_NO_2P +#pragma kernel EncodeTex10x10Med ASTC_BLOCK_10X10 ASTC_NO_2P +#pragma kernel EncodeTex12x12Med ASTC_BLOCK_12X12 ASTC_NO_2P + +#pragma kernel EncodeBuf4x4Med ASTC_BLOCK_4X4 ASTC_NO_2P +#pragma kernel EncodeBuf5x5Med ASTC_BLOCK_5X5 ASTC_NO_2P +#pragma kernel EncodeBuf6x6Med ASTC_BLOCK_6X6 ASTC_NO_2P +#pragma kernel EncodeBuf8x8Med ASTC_BLOCK_8X8 ASTC_NO_2P +#pragma kernel EncodeBuf10x10Med ASTC_BLOCK_10X10 ASTC_NO_2P +#pragma kernel EncodeBuf12x12Med ASTC_BLOCK_12X12 ASTC_NO_2P + #pragma kernel EncodeTex4x4Fast ASTC_BLOCK_4X4 ASTC_FAST_ONLY #pragma kernel EncodeTex5x5Fast ASTC_BLOCK_5X5 ASTC_FAST_ONLY #pragma kernel EncodeTex6x6Fast ASTC_BLOCK_6X6 ASTC_FAST_ONLY @@ -94,6 +109,20 @@ void DispatchToBuffer(uint3 id) [numthreads(8, 4, 1)] void EncodeBuf10x10(uint3 id : SV_DispatchThreadID) { DispatchToBuffer(id); } [numthreads(8, 4, 1)] void EncodeBuf12x12(uint3 id : SV_DispatchThreadID) { DispatchToBuffer(id); } +[numthreads(8, 8, 1)] void EncodeTex4x4Med(uint3 id : SV_DispatchThreadID) { DispatchToTexture(id); } +[numthreads(8, 8, 1)] void EncodeTex5x5Med(uint3 id : SV_DispatchThreadID) { DispatchToTexture(id); } +[numthreads(8, 8, 1)] void EncodeTex6x6Med(uint3 id : SV_DispatchThreadID) { DispatchToTexture(id); } +[numthreads(8, 4, 1)] void EncodeTex8x8Med(uint3 id : SV_DispatchThreadID) { DispatchToTexture(id); } +[numthreads(8, 4, 1)] void EncodeTex10x10Med(uint3 id : SV_DispatchThreadID) { DispatchToTexture(id); } +[numthreads(8, 4, 1)] void EncodeTex12x12Med(uint3 id : SV_DispatchThreadID) { DispatchToTexture(id); } + +[numthreads(8, 8, 1)] void EncodeBuf4x4Med(uint3 id : SV_DispatchThreadID) { DispatchToBuffer(id); } +[numthreads(8, 8, 1)] void EncodeBuf5x5Med(uint3 id : SV_DispatchThreadID) { DispatchToBuffer(id); } +[numthreads(8, 8, 1)] void EncodeBuf6x6Med(uint3 id : SV_DispatchThreadID) { DispatchToBuffer(id); } +[numthreads(8, 4, 1)] void EncodeBuf8x8Med(uint3 id : SV_DispatchThreadID) { DispatchToBuffer(id); } +[numthreads(8, 4, 1)] void EncodeBuf10x10Med(uint3 id : SV_DispatchThreadID) { DispatchToBuffer(id); } +[numthreads(8, 4, 1)] void EncodeBuf12x12Med(uint3 id : SV_DispatchThreadID) { DispatchToBuffer(id); } + [numthreads(8, 8, 1)] void EncodeTex4x4Fast(uint3 id : SV_DispatchThreadID) { DispatchToTexture(id); } [numthreads(8, 8, 1)] void EncodeTex5x5Fast(uint3 id : SV_DispatchThreadID) { DispatchToTexture(id); } [numthreads(8, 8, 1)] void EncodeTex6x6Fast(uint3 id : SV_DispatchThreadID) { DispatchToTexture(id); } diff --git a/Assets/ASTC Encoder/Tests/Editor/AstcEncoderTests.cs b/Assets/ASTC Encoder/Tests/Editor/AstcEncoderTests.cs index 28aeabd..680096c 100644 --- a/Assets/ASTC Encoder/Tests/Editor/AstcEncoderTests.cs +++ b/Assets/ASTC Encoder/Tests/Editor/AstcEncoderTests.cs @@ -1,10 +1,12 @@ using System; using System.IO; +using System.Reflection; using System.Runtime.InteropServices; using System.Threading; using System.Threading.Tasks; using Aperture.Astcenc.Runtime; using NUnit.Framework; +using UnityEditor; using UnityEngine; using UnityEngine.Experimental.Rendering; @@ -148,6 +150,113 @@ public void CompressRawPixels_CpuCrossDecode_MeetsQualityTarget() Assert.Greater(psnr, 32.0, $"Expected CPU ASTC 6x6 gradient PSNR > 32 dB, got {psnr:F2} dB"); } + [Test] + public void GpuWeightQuantization_PowerOfTwoModesChooseNearestDecodedValue() + { + int[][] decodedWeights = + { + new[] { 0, 64 }, + new[] { 0, 21, 43, 64 }, + new[] { 0, 9, 18, 27, 37, 46, 55, 64 }, + new[] { 0, 4, 8, 12, 17, 21, 25, 29, 35, 39, 43, 47, 52, 56, 60, 64 }, + new[] { 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, + 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64 }, + }; + const int samples = 1025; + uint[] results = RunGpuMathProbe("CheckWeightQuantization", samples * decodedWeights.Length, 17, decodedWeights.Length); + for (int mode = 0; mode < decodedWeights.Length; mode++) + { + int[] weights = decodedWeights[mode]; + for (int sample = 0; sample < samples; sample++) + { + uint result = results[mode * samples + sample]; + int code = (int)(result & 255u); + int decoded = (int)(result >> 8); + int bestError = int.MaxValue; + foreach (int weight in weights) + bestError = Math.Min(bestError, Math.Abs(sample - weight * 16)); + + if (code >= weights.Length || weights[code] != decoded || Math.Abs(sample - decoded * 16) != bestError) + Assert.Fail($"Invalid quantization: mode {weights.Length}, sample {sample}/1024, packed result {result:X8}"); + } + } + } + + [Test] + public void GpuWeightGather_MatchesIntegerInfillForSquareAndAnisotropicGrids() + { + const int texels = 144; + const int cases = 6 * 25; + uint[] results = RunGpuMathProbe("CheckGatherTaps", texels * cases, 9, cases); + for (int i = 0; i < results.Length; i++) + if (results[i] != 0u) + Assert.Fail($"Gather mismatch: case {i / texels}, texel {i % texels}, error {results[i]}"); + } + + private static uint[] RunGpuMathProbe(string kernelName, int count, int groupsX, int groupsY) + { + if (SystemInfo.graphicsDeviceType == UnityEngine.Rendering.GraphicsDeviceType.Null || !SystemInfo.supportsComputeShaders) + Assert.Ignore("GPU compute is required for the shader math probe."); + + string path = AssetDatabase.GUIDToAssetPath("b7bcd59a372f42048c80eeb04c00f82b"); + ComputeShader shader = AssetDatabase.LoadAssetAtPath(path); + Assert.IsNotNull(shader); + int kernel = shader.FindKernel(kernelName); + using var buffer = new ComputeBuffer(count, sizeof(uint)); + shader.SetBuffer(kernel, "_Results", buffer); + shader.Dispatch(kernel, groupsX, groupsY, 1); + var results = new uint[count]; + buffer.GetData(results); + return results; + } + + [Test] + public void GpuBufferPool_EnforcesByteBudgetAndReleasesStaleRentals() + { + if (!SystemInfo.supportsComputeShaders) + Assert.Ignore("GPU compute buffer support is required."); + + const BindingFlags flags = BindingFlags.Static | BindingFlags.NonPublic; + const int maxBlocks = (8 * 1024 * 1024) / 16; + Type backend = typeof(Encoder).Assembly.GetType("Aperture.Astcenc.Runtime.AstcGpuBackend", true); + MethodInfo acquire = backend.GetMethod("AcquireBlockBuffer", flags); + MethodInfo release = backend.GetMethod("ReturnBlockBuffer", flags); + FieldInfo generationField = backend.GetField("s_BufferPoolGeneration", flags); + ComputeBuffer Rent(int count) => (ComputeBuffer)acquire.Invoke(null, new object[] { count }); + void Return(ComputeBuffer buffer, uint generation) => release.Invoke(null, new object[] { buffer, generation }); + + var buffers = new ComputeBuffer[5]; + Encoder.ReleaseGpuCache(); + try + { + uint generation = (uint)generationField.GetValue(null); + for (int i = 0; i < 3; i++) + buffers[i] = Rent(maxBlocks); + buffers[3] = Rent(maxBlocks + 1); + Assert.AreEqual(maxBlocks + 1, buffers[3].count); + for (int i = 0; i < 4; i++) + Return(buffers[i], generation); + + Assert.IsTrue(buffers[0].IsValid() && buffers[1].IsValid()); + Assert.IsFalse(buffers[2].IsValid(), "Third 8 MiB buffer must exceed the total budget."); + Assert.IsFalse(buffers[3].IsValid(), "Over-limit buffer must not be cached."); + + buffers[4] = Rent(maxBlocks); + Assert.AreSame(buffers[1], buffers[4], "A current-generation rental should reuse the pool."); + Encoder.ReleaseGpuCache(); + Assert.IsTrue(buffers[4].IsValid(), "Clearing idle buffers must not release an outstanding rental."); + Return(buffers[4], generation); + Assert.IsFalse(buffers[4].IsValid(), "Outstanding rentals from before a cache clear must be released on return."); + } + finally + { + Encoder.ReleaseGpuCache(); + foreach (ComputeBuffer buffer in buffers) + if (buffer != null && buffer.IsValid()) + buffer.Release(); + } + } + [Test] public void GpuCrossDecode_AllBlockSizes_AndNpot_ValidAstcBlocks() { @@ -158,9 +267,9 @@ public void GpuCrossDecode_AllBlockSizes_AndNpot_ValidAstcBlocks() foreach (int dim in sizes) { Texture2D src = CreateTestTexture(dim, dim, normalMap: false); - byte[] refBytes = CreateGradientRgba8(dim, dim); try { + byte[] refBytes = src.GetRawTextureData().ToArray(); foreach (BlockSize bs in s_AllBlockSizes) { var options = AstcCompressOptions.Default; diff --git a/Assets/ASTC Encoder/Tests/Editor/AstcGpuMathProbe.compute b/Assets/ASTC Encoder/Tests/Editor/AstcGpuMathProbe.compute new file mode 100644 index 0000000..e26720e --- /dev/null +++ b/Assets/ASTC Encoder/Tests/Editor/AstcGpuMathProbe.compute @@ -0,0 +1,74 @@ +#pragma kernel CheckWeightQuantization +#pragma kernel CheckGatherTaps + +#include "../../Runtime/Gpu/Shaders/AstcGpuColor.hlsl" + +RWStructuredBuffer _Results; + +static const uint kPow2Modes[5] = +{ + ASTC_QUANT_2, ASTC_QUANT_4, ASTC_QUANT_8, ASTC_QUANT_16, ASTC_QUANT_32 +}; + +[numthreads(64, 1, 1)] +void CheckWeightQuantization(uint3 id : SV_DispatchThreadID) +{ + if (id.x > 1024u) return; + float target = (float)id.x / 1024.0; + uint bits = id.y + 1u; + uint maxK = (1u << bits) - 1u; + uint weight, directWeight; + uint code = AstcQuantizeWeight(target, kPow2Modes[id.y], weight); + uint directCode = AstcQuantizePow2Weight(target, maxK, bits, directWeight); + _Results[id.y * 1025u + id.x] = code == directCode && weight == directWeight + ? (weight << 8u) | code : 0xFFFFFFFFu; +} + +static const uint kBlockSizes[6] = { 4u, 5u, 6u, 8u, 10u, 12u }; + +[numthreads(16, 1, 1)] +void CheckGatherTaps(uint3 id : SV_DispatchThreadID) +{ + uint blockSize = kBlockSizes[id.y / 25u]; + uint gw = 4u + id.y % 5u; + uint gh = 4u + id.y % 25u / 5u; + uint index = id.y * 144u + id.x; + _Results[index] = 0u; + if (id.x >= blockSize * blockSize || gw > blockSize || gh > blockSize) return; + + uint x = id.x % blockSize; + uint y = id.x / blockSize; + uint js, jt; + uint4 weights; + AstcComputeInfillTap(x, y, blockSize, blockSize, gw, gh, js, jt, weights); + uint scaleX = AstcInfillScale(blockSize, gw); + uint scaleY = AstcInfillScale(blockSize, gh); + uint s = AstcInfillCoord(x, scaleX); + uint t = AstcInfillCoord(y, scaleY); + + [loop] for (uint gy = 0u; gy < gh; gy++) + { + uint2 ys = AstcGatherSpan(gy, scaleY, blockSize); + [loop] for (uint gx = 0u; gx < gw; gx++) + { + uint2 xs = AstcGatherSpan(gx, scaleX, blockSize); + bool inCells = gx >= js && gx <= js + 1u && gy >= jt && gy <= jt + 1u; + uint expected = inCells ? weights[((gy - jt) * 2u + gx - js) & 3u] : 0u; + bool inSpan = x >= xs.x && x <= xs.y && y >= ys.x && y <= ys.y; + if (inSpan && !inCells) + { + _Results[index] = 1u; + return; + } + uint actual = inSpan ? AstcGatherTap(s, t, gx, gy) : 0u; + if (actual != expected) + { + _Results[index] = 2u; + return; + } + } + } + + if (blockSize == 6u && gw == 5u && gh == 5u && x == 1u && y == 1u) + _Results[index] = AstcGatherTap(s, t, 1u, 1u) == 11u ? 0u : 3u; +} diff --git a/Assets/ASTC Encoder/Tests/Editor/AstcGpuMathProbe.compute.meta b/Assets/ASTC Encoder/Tests/Editor/AstcGpuMathProbe.compute.meta new file mode 100644 index 0000000..5d7df6e --- /dev/null +++ b/Assets/ASTC Encoder/Tests/Editor/AstcGpuMathProbe.compute.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b7bcd59a372f42048c80eeb04c00f82b +ComputeShaderImporter: + externalObjects: {} + preprocessorOverride: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/ASTC Encoder/package.json b/Assets/ASTC Encoder/package.json index 226a6cd..8ed58f1 100644 --- a/Assets/ASTC Encoder/package.json +++ b/Assets/ASTC Encoder/package.json @@ -1,7 +1,7 @@ { "name": "com.aperture.astcenc", "displayName": "Runtime ASTC Encoder", - "version": "2.3.0", + "version": "2.3.1", "unity": "2021.3", "keywords": ["Texture", "ASTC", "Runtime", "astcenc", "GPU", "ComputeShader", "KTX"], "description": "High-performance runtime ASTC texture compression (GPU Compute + native ARM astc-encoder CPU), GPU mipmap generation, KTX v1 disk caching, and Editor benchmarking for Unity.", diff --git a/README.md b/README.md index 26e846b..855afa6 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ [![Unity Multi-Platform E2E](https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity/actions/workflows/unity-multiplatform-e2e.yml/badge.svg)](https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity/actions/workflows/unity-multiplatform-e2e.yml) [![Build Native Plugins](https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity/actions/workflows/build-native-plugins.yml/badge.svg)](https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity/actions/workflows/build-native-plugins.yml) ![Unity 2021.3+](https://img.shields.io/badge/Unity-2021.3%2B-black?logo=unity) -![UPM v2.3.0](https://img.shields.io/badge/UPM-v2.3.0-blue) +![UPM v2.3.1](https://img.shields.io/badge/UPM-v2.3.1-blue) ![astc-encoder v5.7.1](https://img.shields.io/badge/astc--encoder-v5.7.1-informational) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](Assets/ASTC%20Encoder/LICENSE.md) @@ -45,10 +45,10 @@ A production-ready **runtime ASTC texture compression package** for Unity (`com. In Unity, open **Window → Package Manager → `+` → Add package from git URL...**: ```text -https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity.git?path=/Assets/ASTC%20Encoder#v2.3.0 +https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity.git?path=/Assets/ASTC%20Encoder#v2.3.1 ``` -*(Omit `#v2.3.0` to track the latest `master` branch.)* +*(Omit `#v2.3.1` to track the latest `master` branch.)* ### Option 2: Local Clone / Direct Copy @@ -154,35 +154,35 @@ Measured automatically via GitHub Actions on **`Apple Paravirtual device` (Metal | Block Size | Quality | GPU Median (ms) | CPU Median (ms) | GPU Speedup | GPU / CPU PSNR | VRAM Saved | | :--- | :--- | ---: | ---: | ---: | ---: | ---: | -| **ASTC 4x4** | `Fast` | 7.66 | 253.41 | **33.1×** | 48.9 / 49.0 dB | -75.0% | -| **ASTC 4x4** | `Medium` | 41.00 | 519.59 | **12.7×** | 46.4 / 50.2 dB | -75.0% | -| **ASTC 6x6** | `Fast` | 20.34 | 371.75 | **18.3×** | 29.3 / 41.7 dB | -88.8% | -| **ASTC 6x6** | `Medium` | 57.49 | 876.38 | **15.2×** | 32.6 / 43.2 dB | -88.8% | -| **ASTC 8x8** | `Fast` | 8.51 | 836.19 | **98.2×** | 43.4 / 46.0 dB | -93.8% | -| **ASTC 8x8** | `Medium` | 37.02 | 1848.60 | **49.9×** | 44.1 / 47.9 dB | -93.8% | -| **ASTC 12x12** | `Fast` | 10.85 | 710.89 | **65.5×** | 24.7 / 27.8 dB | -97.2% | -| **ASTC 12x12** | `Medium` | 30.73 | 1254.79 | **40.8×** | 25.3 / 30.1 dB | -97.2% | +| **ASTC 4x4** | `Fast` | 6.38 | 430.25 | **67.5×** | 48.9 / 49.0 dB | -75.0% | +| **ASTC 4x4** | `Medium` | 20.71 | 920.31 | **44.4×** | 48.7 / 50.2 dB | -75.0% | +| **ASTC 6x6** | `Fast` | 10.74 | 399.55 | **37.2×** | 34.7 / 41.7 dB | -88.8% | +| **ASTC 6x6** | `Medium` | 33.44 | 987.35 | **29.5×** | 39.4 / 43.2 dB | -88.8% | +| **ASTC 8x8** | `Fast` | 12.37 | 882.08 | **71.3×** | 43.4 / 46.0 dB | -93.8% | +| **ASTC 8x8** | `Medium` | 35.11 | 1705.45 | **48.6×** | 44.3 / 47.9 dB | -93.8% | +| **ASTC 12x12** | `Fast` | 10.86 | 677.65 | **62.4×** | 24.7 / 27.8 dB | -97.2% | +| **ASTC 12x12** | `Medium` | 20.88 | 1003.46 | **48.0×** | 25.5 / 30.1 dB | -97.2% | #### Key Runtime Highlights | Scenario | Median / Throughput | GC Alloc | Notes | | :--- | :--- | ---: | :--- | -| GPU Zero-Readback `CompressToTexture` (`1024×1024 6x6 Fast`) | **2.70 ms** (388.7 MP/s) | 0.0 KB | Direct `CopyTexture`, zero CPU readback | -| Single-`CommandBuffer` GPU MipGen + Encode (`1024×1024+Mips`) | **0.75 ms** (1861.7 MP/s) | 0.0 KB | Full 11-mip chain generated & encoded on GPU | -| Normal Map GGGR Encoding (`512×512 6x6 Medium`) | GPU **19.26 ms** vs CPU 319.21 ms | 0.0 KB | Mean angular error: GPU 0.27° vs CPU 0.15° | -| Zero-Alloc `CompressRawPixelsInto` (`512×512 6x6 Fast`) | **196.09 ms** (1.3 MP/s) | **4096 B** | Caller-owned `NativeArray` + `AstcContextPool` | -| KTX Disk Cache `AstcDiskCache.TryLoad` (`512×512+Mips`) | **0.66 ms** | 124.8 KB | Compress once, instant load on subsequent launches | +| GPU Zero-Readback `CompressToTexture` (`1024×1024 6x6 Fast`) | **2.98 ms** (352.2 MP/s) | 0.0 KB | Direct `CopyTexture`, zero CPU readback | +| Single-`CommandBuffer` GPU MipGen + Encode (`1024×1024+Mips`) | **3.84 ms** (363.6 MP/s) | 0.0 KB | Full 11-mip chain generated & encoded on GPU | +| Normal Map GGGR Encoding (`512×512 6x6 Medium`) | GPU **11.46 ms** vs CPU 568.57 ms | 0.0 KB | Mean angular error: GPU 0.27° vs CPU 0.15° | +| Zero-Alloc `CompressRawPixelsInto` (`512×512 6x6 Fast`) | **260.94 ms** (1.0 MP/s) | **5734 B** | Caller-owned `NativeArray` + `AstcContextPool` | +| KTX Disk Cache `AstcDiskCache.TryLoad` (`512×512+Mips`) | **0.87 ms** | 156.8 KB | Compress once, instant load on subsequent launches | #### Cross-Platform Native CPU SIMD (`astc-encoder v5.7.1`, `512×512` RGBA8 `ASTC_6x6`) | Platform / CPU | ISA | Threads | `Fast` (ms) | `Medium` (ms) | `Fast` MP/s | Decompress (ms) | | :--- | :--- | ---: | ---: | ---: | ---: | ---: | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `AVX2` | 4 | 40.04 | 173.18 | 6.55 | 1.28 | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `SSE4.1` | 4 | 43.90 | 180.55 | 5.97 | 1.87 | -| Darwin arm64 (`Apple M1 (Virtual)`) | `ARM64_NEON` | 3 | 34.68 | 154.93 | 7.56 | 1.51 | -| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `SSE4.1` | 4 | 50.48 | 197.06 | 5.19 | 2.18 | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `AVX2` | 4 | 52.70 | 233.61 | 4.97 | 3.16 | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `SSE4.1` | 4 | 71.97 | 241.71 | 3.64 | 2.51 | +| Darwin arm64 (`Apple M1 (Virtual)`) | `ARM64_NEON` | 3 | 67.29 | 211.06 | 3.90 | 2.99 | +| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `SSE4.1` | 4 | 50.51 | 197.62 | 5.19 | 2.17 | -> Provenance: Commit `d3223a5` · 2026-11-28 · [Full Benchmark Matrix & Regression Baseline (docs/Benchmarks.md)](docs/Benchmarks.md) · [Actions Run](https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity/actions/runs/46153027417) +> Provenance: Commit `44492de` · 2026-12-01 · [Full Benchmark Matrix & Regression Baseline (docs/Benchmarks.md)](docs/Benchmarks.md) · [Actions Run](https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity/actions/runs/46594790776) **Run Benchmarks Locally in Unity** (exports JSON / CSV / Markdown to `Logs/AstcBenchmarks/`): diff --git a/README_CN.md b/README_CN.md index 19da881..6045ee4 100644 --- a/README_CN.md +++ b/README_CN.md @@ -6,7 +6,7 @@ [![Unity Multi-Platform E2E](https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity/actions/workflows/unity-multiplatform-e2e.yml/badge.svg)](https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity/actions/workflows/unity-multiplatform-e2e.yml) [![Build Native Plugins](https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity/actions/workflows/build-native-plugins.yml/badge.svg)](https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity/actions/workflows/build-native-plugins.yml) ![Unity 2021.3+](https://img.shields.io/badge/Unity-2021.3%2B-black?logo=unity) -![UPM v2.3.0](https://img.shields.io/badge/UPM-v2.3.0-blue) +![UPM v2.3.1](https://img.shields.io/badge/UPM-v2.3.1-blue) ![astc-encoder v5.7.1](https://img.shields.io/badge/astc--encoder-v5.7.1-informational) [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](Assets/ASTC%20Encoder/LICENSE.md) @@ -45,10 +45,10 @@ 在 Unity 中打开 **Window → Package Manager → `+` → Add package from git URL...**: ```text -https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity.git?path=/Assets/ASTC%20Encoder#v2.3.0 +https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity.git?path=/Assets/ASTC%20Encoder#v2.3.1 ``` -*(去掉 `#v2.3.0` 可直接跟踪 `master` 分支最新提交。)* +*(去掉 `#v2.3.1` 可直接跟踪 `master` 分支最新提交。)* ### 方式二:本地克隆 / 直接拷贝 @@ -154,35 +154,35 @@ public void UpdateAtlasTile(CommandBuffer cmd, Texture tileSrc, Texture2D astcAt | 块尺寸 | 质量 | GPU 耗时 (ms) | CPU 耗时 (ms) | GPU 加速比 | GPU / CPU PSNR | 显存节省 | | :--- | :--- | ---: | ---: | ---: | ---: | ---: | -| **ASTC 4x4** | `Fast` | 7.66 | 253.41 | **33.1×** | 48.9 / 49.0 dB | -75.0% | -| **ASTC 4x4** | `Medium` | 41.00 | 519.59 | **12.7×** | 46.4 / 50.2 dB | -75.0% | -| **ASTC 6x6** | `Fast` | 20.34 | 371.75 | **18.3×** | 29.3 / 41.7 dB | -88.8% | -| **ASTC 6x6** | `Medium` | 57.49 | 876.38 | **15.2×** | 32.6 / 43.2 dB | -88.8% | -| **ASTC 8x8** | `Fast` | 8.51 | 836.19 | **98.2×** | 43.4 / 46.0 dB | -93.8% | -| **ASTC 8x8** | `Medium` | 37.02 | 1848.60 | **49.9×** | 44.1 / 47.9 dB | -93.8% | -| **ASTC 12x12** | `Fast` | 10.85 | 710.89 | **65.5×** | 24.7 / 27.8 dB | -97.2% | -| **ASTC 12x12** | `Medium` | 30.73 | 1254.79 | **40.8×** | 25.3 / 30.1 dB | -97.2% | +| **ASTC 4x4** | `Fast` | 6.38 | 430.25 | **67.5×** | 48.9 / 49.0 dB | -75.0% | +| **ASTC 4x4** | `Medium` | 20.71 | 920.31 | **44.4×** | 48.7 / 50.2 dB | -75.0% | +| **ASTC 6x6** | `Fast` | 10.74 | 399.55 | **37.2×** | 34.7 / 41.7 dB | -88.8% | +| **ASTC 6x6** | `Medium` | 33.44 | 987.35 | **29.5×** | 39.4 / 43.2 dB | -88.8% | +| **ASTC 8x8** | `Fast` | 12.37 | 882.08 | **71.3×** | 43.4 / 46.0 dB | -93.8% | +| **ASTC 8x8** | `Medium` | 35.11 | 1705.45 | **48.6×** | 44.3 / 47.9 dB | -93.8% | +| **ASTC 12x12** | `Fast` | 10.86 | 677.65 | **62.4×** | 24.7 / 27.8 dB | -97.2% | +| **ASTC 12x12** | `Medium` | 20.88 | 1003.46 | **48.0×** | 25.5 / 30.1 dB | -97.2% | #### 关键运行时特性实测 | 场景 | 中位数耗时 / 吞吐 | GC 分配 | 说明 | | :--- | :--- | ---: | :--- | -| GPU 零回读 `CompressToTexture` (`1024×1024 6x6 Fast`) | **2.70 ms** (388.7 MP/s) | 0.0 KB | 直拷硬件 ASTC 纹理,无 CPU 回读 | -| GPU 单 CommandBuffer MipGen + 编码 (`1024×1024+Mips`) | **0.75 ms** (1861.7 MP/s) | 0.0 KB | 11 级 Mip 生成与编码一体化完成 | -| 法线贴图 GGGR 编码 (`512×512 6x6 Medium`) | GPU **19.26 ms** vs CPU 319.21 ms | 0.0 KB | 平均角度误差:GPU 0.27° vs CPU 0.15° | -| 原始像素直压 `CompressRawPixelsInto` (`512×512 6x6 Fast`) | **196.09 ms** (1.3 MP/s) | **4096 B** | 复用 NativeArray + `AstcContextPool` | -| KTX 磁盘缓存秒开 `AstcDiskCache.TryLoad` (`512×512+Mips`) | **0.66 ms** | 124.8 KB | 一次压缩,后续启动直传 GPU | +| GPU 零回读 `CompressToTexture` (`1024×1024 6x6 Fast`) | **2.98 ms** (352.2 MP/s) | 0.0 KB | 直拷硬件 ASTC 纹理,无 CPU 回读 | +| GPU 单 CommandBuffer MipGen + 编码 (`1024×1024+Mips`) | **3.84 ms** (363.6 MP/s) | 0.0 KB | 11 级 Mip 生成与编码一体化完成 | +| 法线贴图 GGGR 编码 (`512×512 6x6 Medium`) | GPU **11.46 ms** vs CPU 568.57 ms | 0.0 KB | 平均角度误差:GPU 0.27° vs CPU 0.15° | +| 原始像素直压 `CompressRawPixelsInto` (`512×512 6x6 Fast`) | **260.94 ms** (1.0 MP/s) | **5734 B** | 复用 NativeArray + `AstcContextPool` | +| KTX 磁盘缓存秒开 `AstcDiskCache.TryLoad` (`512×512+Mips`) | **0.87 ms** | 156.8 KB | 一次压缩,后续启动直传 GPU | #### 跨平台原生 CPU 指令集实测(`astc-encoder v5.7.1`,`512×512` RGBA8 `ASTC_6x6`) | 平台 / CPU | 指令集(ISA) | 线程 | `Fast` (ms) | `Medium` (ms) | `Fast` 吞吐 | CPU 软解 (ms) | | :--- | :--- | ---: | ---: | ---: | ---: | ---: | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `AVX2` | 4 | 40.04 | 173.18 | 6.55 | 1.28 | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `SSE4.1` | 4 | 43.90 | 180.55 | 5.97 | 1.87 | -| Darwin arm64 (`Apple M1 (Virtual)`) | `ARM64_NEON` | 3 | 34.68 | 154.93 | 7.56 | 1.51 | -| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `SSE4.1` | 4 | 50.48 | 197.06 | 5.19 | 2.18 | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `AVX2` | 4 | 52.70 | 233.61 | 4.97 | 3.16 | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `SSE4.1` | 4 | 71.97 | 241.71 | 3.64 | 2.51 | +| Darwin arm64 (`Apple M1 (Virtual)`) | `ARM64_NEON` | 3 | 67.29 | 211.06 | 3.90 | 2.99 | +| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `SSE4.1` | 4 | 50.51 | 197.62 | 5.19 | 2.17 | -> 基准溯源:Commit `d3223a5` · 2026-11-28 · [查看完整全矩阵与基线对比(docs/Benchmarks.md)](docs/Benchmarks.md) · [Actions Run](https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity/actions/runs/46153027417) +> 基准溯源:Commit `44492de` · 2026-12-01 · [查看完整全矩阵与基线对比(docs/Benchmarks.md)](docs/Benchmarks.md) · [Actions Run](https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity/actions/runs/46594790776) **本地在 Unity 中运行完整基准套件**(自动导出 JSON / CSV / Markdown 至 `Logs/AstcBenchmarks/`): diff --git a/docs/API.md b/docs/API.md index ad777bb..f1f26b4 100644 --- a/docs/API.md +++ b/docs/API.md @@ -17,8 +17,8 @@ All compression methods accept `EncodeBackend` (default `EncodeBackend.Auto`: pr | `Encoder.SupportsGpuDirectCopy(blockSize, srgb, isHdr)` | Checks whether the GPU supports zero-readback `CopyTexture` into the target ASTC format | | `Encoder.IsSupport(Texture texture, EncodeBackend backend = EncodeBackend.Auto)` | Validates texture compatibility for the given backend (GPU accepts non-readable `Texture2D` and non-MSAA `RenderTexture`) | | `Encoder.GetTargetAstcFormat(sourceFormat, blockSize, textureType)` | Resolves the target ASTC `GraphicsFormat` (`TextureType.Normal` always resolves to linear `_UNorm`) | -| `Encoder.PreloadGpu(blockSize)` | Warms up Fast/Full GPU encoder kernels and the GPU mipmap generator | -| `Encoder.ReleaseGpuCache()` | Releases cached Compute Shader references | +| `Encoder.PreloadGpu(blockSize)` | Warms up the LDR and HDR Fast, Medium, and Full GPU kernels for both output types, plus the GPU mipmap generator | +| `Encoder.ReleaseGpuCache()` | On the Unity main thread, releases cached shader references and idle block buffers; in-flight readbacks release their buffers on completion | | `Encoder.ReleaseCpuContextPool()` | Releases all cached native `AstcContext` instances held by the static CPU pool | ### Compression & Encoding diff --git a/docs/Benchmarks.md b/docs/Benchmarks.md index 4f1ec57..4edcf3c 100644 --- a/docs/Benchmarks.md +++ b/docs/Benchmarks.md @@ -1,6 +1,6 @@ # Runtime ASTC Encoder — Performance Benchmarks & Regression Baseline -- **Updated**: `2026-11-28 14:45 UTC` | **Commit**: `d3223a5` | [GitHub Actions Run](https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity/actions/runs/46153027417) +- **Updated**: `2026-12-01 08:36 UTC` | **Commit**: `44492de` | [GitHub Actions Run](https://github.com/Overflowu/Runtime-ASTC-Encoder-For-Unity/actions/runs/46594790776) - **Baseline Comparison**: Deltas (`Δ vs Baseline`) compare each benchmark's median latency against the previous saved snapshot in `docs/benchmarks/baseline.json` (`🚀` ≥ 5% faster, `⚠️` ≥ 15% slower). ## 1. Unity Standalone Player (Real Hardware GPU + CPU) @@ -12,94 +12,94 @@ | Benchmark | Backend | Res | Block | Quality | Min (ms) | Median (ms) | P95 (ms) | MP/s | GC (KB) | RGB PSNR | Normal Err | Δ vs Baseline | | :--- | :--- | :--- | :--- | :--- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | -| `GPU_RGBA8_1024_ASTC_4x4_Fast` | GPU | 1024x1024 | ASTC_4x4 | Fast | 7.26 | **7.66** | 8.60 | 136.94 | 0.0 | 48.94 dB | — | new | -| `CPU_RGBA8_1024_ASTC_4x4_Fast` | CPU | 1024x1024 | ASTC_4x4 | Fast | 233.97 | **253.41** | 281.95 | 4.14 | 8.0 | 48.95 dB | — | new | -| `GPU_RGBA8_1024_ASTC_4x4_Medium` | GPU | 1024x1024 | ASTC_4x4 | Medium | 40.40 | **41.00** | 41.14 | 25.58 | 0.0 | 46.44 dB | — | new | -| `CPU_RGBA8_1024_ASTC_4x4_Medium` | CPU | 1024x1024 | ASTC_4x4 | Medium | 444.33 | **519.59** | 825.93 | 2.02 | 7.0 | 50.24 dB | — | new | -| `GPU_RGBA8_1024_ASTC_6x6_Fast` | GPU | 1024x1024 | ASTC_6x6 | Fast | 13.73 | **20.34** | 23.50 | 51.55 | 0.0 | 29.27 dB | — | new | -| `CPU_RGBA8_1024_ASTC_6x6_Fast` | CPU | 1024x1024 | ASTC_6x6 | Fast | 355.64 | **371.75** | 395.72 | 2.82 | 4.0 | 41.75 dB | — | new | -| `GPU_RGBA8_1024_ASTC_6x6_Medium` | GPU | 1024x1024 | ASTC_6x6 | Medium | 54.40 | **57.49** | 60.93 | 18.24 | 0.0 | 32.57 dB | — | new | -| `CPU_RGBA8_1024_ASTC_6x6_Medium` | CPU | 1024x1024 | ASTC_6x6 | Medium | 824.27 | **876.38** | 954.63 | 1.20 | 4.0 | 43.23 dB | — | new | -| `GPU_RGBA8_1024_ASTC_8x8_Fast` | GPU | 1024x1024 | ASTC_8x8 | Fast | 8.18 | **8.51** | 9.22 | 123.15 | 0.0 | 43.43 dB | — | new | -| `CPU_RGBA8_1024_ASTC_8x8_Fast` | CPU | 1024x1024 | ASTC_8x8 | Fast | 757.78 | **836.19** | 1017.42 | 1.25 | 3.0 | 45.99 dB | — | new | -| `GPU_RGBA8_1024_ASTC_8x8_Medium` | GPU | 1024x1024 | ASTC_8x8 | Medium | 36.27 | **37.02** | 40.93 | 28.32 | 0.8 | 44.05 dB | — | new | -| `CPU_RGBA8_1024_ASTC_8x8_Medium` | CPU | 1024x1024 | ASTC_8x8 | Medium | 1685.85 | **1848.60** | 2193.39 | 0.57 | 4.0 | 47.93 dB | — | new | -| `GPU_RGBA8_1024_ASTC_12x12_Fast` | GPU | 1024x1024 | ASTC_12x12 | Fast | 8.38 | **10.85** | 11.44 | 96.63 | 0.0 | 24.67 dB | — | new | -| `CPU_RGBA8_1024_ASTC_12x12_Fast` | CPU | 1024x1024 | ASTC_12x12 | Fast | 618.65 | **710.89** | 795.81 | 1.48 | 4.0 | 27.78 dB | — | new | -| `GPU_RGBA8_1024_ASTC_12x12_Medium` | GPU | 1024x1024 | ASTC_12x12 | Medium | 29.09 | **30.73** | 32.13 | 34.12 | 0.0 | 25.34 dB | — | new | -| `CPU_RGBA8_1024_ASTC_12x12_Medium` | CPU | 1024x1024 | ASTC_12x12 | Medium | 1095.57 | **1254.79** | 1345.90 | 0.84 | 4.0 | 30.08 dB | — | new | -| `GPU_RGBA8_512_ASTC_4x4_Fast` | GPU | 512x512 | ASTC_4x4 | Fast | 3.85 | **5.55** | 7.34 | 47.27 | 0.0 | 44.54 dB | — | new | -| `CPU_RGBA8_512_ASTC_4x4_Fast` | CPU | 512x512 | ASTC_4x4 | Fast | 115.25 | **148.60** | 168.08 | 1.76 | 3.2 | 44.51 dB | — | new | -| `GPU_RGBA8_512_ASTC_4x4_Medium` | GPU | 512x512 | ASTC_4x4 | Medium | 20.40 | **20.59** | 21.44 | 12.73 | 0.0 | 43.86 dB | — | new | -| `CPU_RGBA8_512_ASTC_4x4_Medium` | CPU | 512x512 | ASTC_4x4 | Medium | 254.42 | **277.40** | 387.44 | 0.95 | 3.2 | 47.81 dB | — | new | -| `GPU_RGBA8_512_ASTC_4x4_Thorough` | GPU | 512x512 | ASTC_4x4 | Thorough | 14.30 | **14.94** | 18.69 | 17.54 | 0.0 | 40.17 dB | — | new | -| `CPU_RGBA8_512_ASTC_4x4_Thorough` | CPU | 512x512 | ASTC_4x4 | Thorough | 542.45 | **593.42** | 639.67 | 0.44 | 4.0 | 51.62 dB | — | new | -| `GPU_RGBA8_512_ASTC_6x6_Fast` | GPU | 512x512 | ASTC_6x6 | Fast | 4.02 | **4.36** | 10.73 | 60.19 | 0.0 | 28.59 dB | — | new | -| `CPU_RGBA8_512_ASTC_6x6_Fast` | CPU | 512x512 | ASTC_6x6 | Fast | 136.68 | **147.53** | 157.66 | 1.78 | 3.2 | 37.20 dB | — | new | -| `GPU_RGBA8_512_ASTC_6x6_Medium` | GPU | 512x512 | ASTC_6x6 | Medium | 15.62 | **16.58** | 24.03 | 15.81 | 0.0 | 30.75 dB | — | new | -| `CPU_RGBA8_512_ASTC_6x6_Medium` | CPU | 512x512 | ASTC_6x6 | Medium | 303.94 | **321.06** | 564.12 | 0.82 | 3.2 | 38.69 dB | — | new | -| `GPU_RGBA8_512_ASTC_6x6_Thorough` | GPU | 512x512 | ASTC_6x6 | Thorough | 18.58 | **20.09** | 22.55 | 13.05 | 0.0 | 31.71 dB | — | new | -| `CPU_RGBA8_512_ASTC_6x6_Thorough` | CPU | 512x512 | ASTC_6x6 | Thorough | 668.67 | **703.41** | 732.16 | 0.37 | 4.0 | 39.10 dB | — | new | -| `GPU_RGBA8_512_ASTC_8x8_Fast` | GPU | 512x512 | ASTC_8x8 | Fast | 3.46 | **3.52** | 5.65 | 74.55 | 0.0 | 37.82 dB | — | new | -| `CPU_RGBA8_512_ASTC_8x8_Fast` | CPU | 512x512 | ASTC_8x8 | Fast | 175.76 | **229.24** | 260.96 | 1.14 | 3.2 | 41.99 dB | — | new | -| `GPU_RGBA8_512_ASTC_8x8_Medium` | GPU | 512x512 | ASTC_8x8 | Medium | 11.04 | **11.84** | 18.64 | 22.15 | 0.0 | 39.45 dB | — | new | -| `CPU_RGBA8_512_ASTC_8x8_Medium` | CPU | 512x512 | ASTC_8x8 | Medium | 327.95 | **373.93** | 389.11 | 0.70 | 3.2 | 43.14 dB | — | new | -| `GPU_RGBA8_512_ASTC_8x8_Thorough` | GPU | 512x512 | ASTC_8x8 | Thorough | 12.09 | **12.41** | 13.36 | 21.12 | 0.0 | 39.08 dB | — | new | -| `CPU_RGBA8_512_ASTC_8x8_Thorough` | CPU | 512x512 | ASTC_8x8 | Thorough | 631.27 | **675.98** | 762.20 | 0.39 | 4.0 | 47.48 dB | — | new | -| `GPU_RGBA8_512_ASTC_12x12_Fast` | GPU | 512x512 | ASTC_12x12 | Fast | 2.30 | **2.32** | 2.42 | 112.95 | 0.0 | 24.04 dB | — | new | -| `CPU_RGBA8_512_ASTC_12x12_Fast` | CPU | 512x512 | ASTC_12x12 | Fast | 136.28 | **158.24** | 171.77 | 1.66 | 3.2 | 26.31 dB | — | new | -| `GPU_RGBA8_512_ASTC_12x12_Medium` | GPU | 512x512 | ASTC_12x12 | Medium | 11.70 | **20.36** | 20.61 | 12.88 | 0.0 | 24.34 dB | — | new | -| `CPU_RGBA8_512_ASTC_12x12_Medium` | CPU | 512x512 | ASTC_12x12 | Medium | 250.49 | **308.17** | 369.28 | 0.85 | 3.2 | 27.73 dB | — | new | -| `GPU_RGBA8_512_ASTC_12x12_Thorough` | GPU | 512x512 | ASTC_12x12 | Thorough | 10.13 | **10.33** | 12.98 | 25.39 | 0.0 | 24.29 dB | — | new | -| `CPU_RGBA8_512_ASTC_12x12_Thorough` | CPU | 512x512 | ASTC_12x12 | Thorough | 519.84 | **558.45** | 592.55 | 0.47 | 4.0 | 27.42 dB | — | new | -| `GPU_ZeroReadback_1024_6x6_Fast` | GPU | 1024x1024 | ASTC_6x6 | Fast | 0.54 | **2.70** | 3.75 | 388.68 | 0.0 | — | — | new | -| `GPU_ZeroReadback_MipGen_1024_6x6_Fast` | GPU | 1024x1024+Mips | ASTC_6x6 | Fast | 0.66 | **0.75** | 1.63 | 1861.65 | 0.0 | — | — | new | -| `GPU_Normal_512_6x6_Medium` | GPU | 512x512 | ASTC_6x6 | Medium | 12.36 | **19.26** | 23.55 | 13.61 | 0.0 | — | 0.27° | new | -| `CPU_Normal_512_6x6_Medium` | CPU | 512x512 | ASTC_6x6 | Medium | 294.23 | **319.21** | 377.23 | 0.82 | 4.0 | — | 0.15° | new | -| `GPU_sRGB_512_6x6_Fast` | GPU | 512x512 | ASTC_6x6 | Fast | 4.26 | **6.57** | 10.52 | 39.88 | 0.0 | — | — | new | -| `GPU_HDR16F_512_6x6_Fast` | GPU | 512x512 | ASTC_6x6 | Fast | 0.01 | **0.01** | 0.02 | 23831.27 | 0.0 | — | — | new | -| `CPU_CompressRawPixels_512_6x6_Fast` | CPU | 512x512 | ASTC_6x6 | Fast | 171.83 | **181.33** | 191.89 | 1.45 | 4.0 | — | — | new | -| `CPU_CompressRawPixelsInto_512_6x6_Fast` | CPU | 512x512 | ASTC_6x6 | Fast | 180.29 | **196.09** | 216.09 | 1.34 | 4.0 | — | — | new | -| `CPU_Decompress_512_6x6_3T` | CPU | 512x512 | ASTC_6x6 | N/A | 1.29 | **1.55** | 7.97 | 169.35 | 416.0 | — | — | new | -| `DiskCache_TryLoad_512_6x6_FullMips` | Disk+GPU | 512x512+Mips | ASTC_6x6 | N/A | 0.33 | **0.66** | 0.98 | 529.18 | 124.8 | — | — | new | +| `GPU_RGBA8_1024_ASTC_4x4_Fast` | GPU | 1024x1024 | ASTC_4x4 | Fast | 6.07 | **6.38** | 8.62 | 164.43 | 0.0 | 48.92 dB | — | 🚀 -16.7% | +| `CPU_RGBA8_1024_ASTC_4x4_Fast` | CPU | 1024x1024 | ASTC_4x4 | Fast | 375.72 | **430.25** | 594.45 | 2.44 | 8.0 | 48.95 dB | — | ⚠️ +69.8% | +| `GPU_RGBA8_1024_ASTC_4x4_Medium` | GPU | 1024x1024 | ASTC_4x4 | Medium | 20.45 | **20.71** | 21.16 | 50.64 | 0.0 | 48.73 dB | — | 🚀 -49.5% | +| `CPU_RGBA8_1024_ASTC_4x4_Medium` | CPU | 1024x1024 | ASTC_4x4 | Medium | 622.89 | **920.31** | 1220.97 | 1.14 | 4.0 | 50.24 dB | — | ⚠️ +77.1% | +| `GPU_RGBA8_1024_ASTC_6x6_Fast` | GPU | 1024x1024 | ASTC_6x6 | Fast | 10.43 | **10.74** | 21.53 | 97.67 | 0.0 | 34.65 dB | — | 🚀 -47.2% | +| `CPU_RGBA8_1024_ASTC_6x6_Fast` | CPU | 1024x1024 | ASTC_6x6 | Fast | 371.55 | **399.55** | 433.08 | 2.62 | 4.0 | 41.75 dB | — | +7.5% | +| `GPU_RGBA8_1024_ASTC_6x6_Medium` | GPU | 1024x1024 | ASTC_6x6 | Medium | 28.93 | **33.44** | 42.79 | 31.36 | 0.0 | 39.44 dB | — | 🚀 -41.8% | +| `CPU_RGBA8_1024_ASTC_6x6_Medium` | CPU | 1024x1024 | ASTC_6x6 | Medium | 865.77 | **987.35** | 1313.96 | 1.06 | 4.0 | 43.23 dB | — | +12.7% | +| `GPU_RGBA8_1024_ASTC_8x8_Fast` | GPU | 1024x1024 | ASTC_8x8 | Fast | 10.34 | **12.37** | 22.45 | 84.74 | 0.0 | 43.43 dB | — | ⚠️ +45.3% | +| `CPU_RGBA8_1024_ASTC_8x8_Fast` | CPU | 1024x1024 | ASTC_8x8 | Fast | 836.11 | **882.08** | 892.36 | 1.19 | 3.0 | 45.99 dB | — | +5.5% | +| `GPU_RGBA8_1024_ASTC_8x8_Medium` | GPU | 1024x1024 | ASTC_8x8 | Medium | 31.20 | **35.11** | 42.38 | 29.87 | 0.0 | 44.29 dB | — | 🚀 -5.2% | +| `CPU_RGBA8_1024_ASTC_8x8_Medium` | CPU | 1024x1024 | ASTC_8x8 | Medium | 1422.01 | **1705.45** | 1919.65 | 0.61 | 3.0 | 47.93 dB | — | 🚀 -7.7% | +| `GPU_RGBA8_1024_ASTC_12x12_Fast` | GPU | 1024x1024 | ASTC_12x12 | Fast | 10.44 | **10.86** | 21.96 | 96.54 | 0.0 | 24.67 dB | — | +0.1% | +| `CPU_RGBA8_1024_ASTC_12x12_Fast` | CPU | 1024x1024 | ASTC_12x12 | Fast | 655.91 | **677.65** | 721.47 | 1.55 | 6.0 | 27.78 dB | — | -4.7% | +| `GPU_RGBA8_1024_ASTC_12x12_Medium` | GPU | 1024x1024 | ASTC_12x12 | Medium | 20.41 | **20.88** | 24.81 | 50.21 | 0.0 | 25.46 dB | — | 🚀 -32.0% | +| `CPU_RGBA8_1024_ASTC_12x12_Medium` | CPU | 1024x1024 | ASTC_12x12 | Medium | 928.08 | **1003.46** | 1128.96 | 1.04 | 4.0 | 30.08 dB | — | 🚀 -20.0% | +| `GPU_RGBA8_512_ASTC_4x4_Fast` | GPU | 512x512 | ASTC_4x4 | Fast | 10.96 | **11.70** | 14.17 | 22.40 | 0.0 | 44.54 dB | — | ⚠️ +111.0% | +| `CPU_RGBA8_512_ASTC_4x4_Fast` | CPU | 512x512 | ASTC_4x4 | Fast | 122.85 | **131.22** | 150.15 | 2.00 | 4.0 | 44.51 dB | — | 🚀 -11.7% | +| `GPU_RGBA8_512_ASTC_4x4_Medium` | GPU | 512x512 | ASTC_4x4 | Medium | 10.49 | **10.52** | 10.68 | 24.91 | 0.0 | 44.01 dB | — | 🚀 -48.9% | +| `CPU_RGBA8_512_ASTC_4x4_Medium` | CPU | 512x512 | ASTC_4x4 | Medium | 260.15 | **282.41** | 312.20 | 0.93 | 4.0 | 47.81 dB | — | +1.8% | +| `GPU_RGBA8_512_ASTC_4x4_Thorough` | GPU | 512x512 | ASTC_4x4 | Thorough | 20.76 | **21.22** | 22.44 | 12.35 | 0.0 | 44.03 dB | — | ⚠️ +42.0% | +| `CPU_RGBA8_512_ASTC_4x4_Thorough` | CPU | 512x512 | ASTC_4x4 | Thorough | 536.03 | **554.55** | 588.59 | 0.47 | 6.7 | 51.62 dB | — | 🚀 -6.6% | +| `GPU_RGBA8_512_ASTC_6x6_Fast` | GPU | 512x512 | ASTC_6x6 | Fast | 21.07 | **21.89** | 24.85 | 11.98 | 0.0 | 31.78 dB | — | ⚠️ +402.6% | +| `CPU_RGBA8_512_ASTC_6x6_Fast` | CPU | 512x512 | ASTC_6x6 | Fast | 83.17 | **117.27** | 139.19 | 2.24 | 4.0 | 37.20 dB | — | 🚀 -20.5% | +| `GPU_RGBA8_512_ASTC_6x6_Medium` | GPU | 512x512 | ASTC_6x6 | Medium | 10.23 | **10.28** | 20.61 | 25.49 | 0.0 | 33.65 dB | — | 🚀 -38.0% | +| `CPU_RGBA8_512_ASTC_6x6_Medium` | CPU | 512x512 | ASTC_6x6 | Medium | 369.45 | **419.43** | 470.16 | 0.62 | 4.8 | 38.69 dB | — | ⚠️ +30.6% | +| `GPU_RGBA8_512_ASTC_6x6_Thorough` | GPU | 512x512 | ASTC_6x6 | Thorough | 20.62 | **21.64** | 22.50 | 12.11 | 0.0 | 35.06 dB | — | +7.7% | +| `CPU_RGBA8_512_ASTC_6x6_Thorough` | CPU | 512x512 | ASTC_6x6 | Thorough | 563.54 | **642.29** | 699.94 | 0.41 | 4.0 | 39.10 dB | — | 🚀 -8.7% | +| `GPU_RGBA8_512_ASTC_8x8_Fast` | GPU | 512x512 | ASTC_8x8 | Fast | 10.43 | **10.51** | 10.85 | 24.95 | 0.0 | 37.82 dB | — | ⚠️ +198.8% | +| `CPU_RGBA8_512_ASTC_8x8_Fast` | CPU | 512x512 | ASTC_8x8 | Fast | 212.50 | **226.45** | 251.48 | 1.16 | 5.6 | 41.99 dB | — | -1.2% | +| `GPU_RGBA8_512_ASTC_8x8_Medium` | GPU | 512x512 | ASTC_8x8 | Medium | 20.51 | **21.07** | 21.17 | 12.44 | 0.0 | 39.51 dB | — | ⚠️ +78.0% | +| `CPU_RGBA8_512_ASTC_8x8_Medium` | CPU | 512x512 | ASTC_8x8 | Medium | 495.23 | **503.04** | 547.27 | 0.52 | 4.0 | 43.14 dB | — | ⚠️ +34.5% | +| `GPU_RGBA8_512_ASTC_8x8_Thorough` | GPU | 512x512 | ASTC_8x8 | Thorough | 20.45 | **20.99** | 21.23 | 12.49 | 0.0 | 39.65 dB | — | ⚠️ +69.1% | +| `CPU_RGBA8_512_ASTC_8x8_Thorough` | CPU | 512x512 | ASTC_8x8 | Thorough | 823.47 | **1170.89** | 1246.74 | 0.22 | 4.0 | 47.48 dB | — | ⚠️ +73.2% | +| `GPU_RGBA8_512_ASTC_12x12_Fast` | GPU | 512x512 | ASTC_12x12 | Fast | 10.26 | **10.58** | 20.34 | 24.78 | 0.0 | 24.04 dB | — | ⚠️ +355.8% | +| `CPU_RGBA8_512_ASTC_12x12_Fast` | CPU | 512x512 | ASTC_12x12 | Fast | 205.29 | **219.90** | 292.25 | 1.19 | 4.0 | 26.31 dB | — | ⚠️ +39.0% | +| `GPU_RGBA8_512_ASTC_12x12_Medium` | GPU | 512x512 | ASTC_12x12 | Medium | 10.32 | **10.66** | 21.18 | 24.59 | 0.0 | 24.67 dB | — | 🚀 -47.6% | +| `CPU_RGBA8_512_ASTC_12x12_Medium` | CPU | 512x512 | ASTC_12x12 | Medium | 354.56 | **390.23** | 415.87 | 0.67 | 4.0 | 27.73 dB | — | ⚠️ +26.6% | +| `GPU_RGBA8_512_ASTC_12x12_Thorough` | GPU | 512x512 | ASTC_12x12 | Thorough | 10.24 | **10.36** | 11.14 | 25.30 | 0.0 | 24.69 dB | — | +0.3% | +| `CPU_RGBA8_512_ASTC_12x12_Thorough` | CPU | 512x512 | ASTC_12x12 | Thorough | 737.93 | **807.69** | 819.81 | 0.32 | 4.0 | 27.42 dB | — | ⚠️ +44.6% | +| `GPU_ZeroReadback_1024_6x6_Fast` | GPU | 1024x1024 | ASTC_6x6 | Fast | 1.47 | **2.98** | 4.70 | 352.18 | 0.0 | — | — | +10.4% | +| `GPU_ZeroReadback_MipGen_1024_6x6_Fast` | GPU | 1024x1024+Mips | ASTC_6x6 | Fast | 3.42 | **3.84** | 5.33 | 363.63 | 0.0 | — | — | ⚠️ +412.0% | +| `GPU_Normal_512_6x6_Medium` | GPU | 512x512 | ASTC_6x6 | Medium | 10.30 | **11.46** | 12.29 | 22.88 | 0.0 | — | 0.27° | 🚀 -40.5% | +| `CPU_Normal_512_6x6_Medium` | CPU | 512x512 | ASTC_6x6 | Medium | 428.71 | **568.57** | 589.82 | 0.46 | 4.0 | — | 0.15° | ⚠️ +78.1% | +| `GPU_sRGB_512_6x6_Fast` | GPU | 512x512 | ASTC_6x6 | Fast | 10.47 | **10.66** | 10.97 | 24.58 | 0.0 | — | — | ⚠️ +62.2% | +| `GPU_HDR16F_512_6x6_Fast` | GPU | 512x512 | ASTC_6x6 | Fast | 10.91 | **11.11** | 22.17 | 23.60 | 0.0 | — | — | ⚠️ +100897.3% | +| `CPU_CompressRawPixels_512_6x6_Fast` | CPU | 512x512 | ASTC_6x6 | Fast | 263.25 | **271.74** | 304.64 | 0.96 | 4.0 | — | — | ⚠️ +49.9% | +| `CPU_CompressRawPixelsInto_512_6x6_Fast` | CPU | 512x512 | ASTC_6x6 | Fast | 254.79 | **260.94** | 411.23 | 1.00 | 5.6 | — | — | ⚠️ +33.1% | +| `CPU_Decompress_512_6x6_3T` | CPU | 512x512 | ASTC_6x6 | N/A | 2.53 | **4.24** | 15.39 | 61.79 | 415.2 | — | — | ⚠️ +174.1% | +| `DiskCache_TryLoad_512_6x6_FullMips` | Disk+GPU | 512x512+Mips | ASTC_6x6 | N/A | 0.55 | **0.87** | 2.28 | 404.03 | 156.8 | — | — | ⚠️ +31.0% | ## 2. Cross-Platform Native CPU (`astc-encoder v5.7.1`) | Platform / CPU | Benchmark | ISA | Threads | Min (ms) | Median (ms) | P95 (ms) | MP/s | Δ vs Baseline | | :--- | :--- | :--- | ---: | ---: | ---: | ---: | ---: | ---: | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_AVX2_512_ASTC_4x4_Fast_4T` | `AVX2` | 4 | 58.76 | **58.87** | 66.53 | 4.45 | new | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_AVX2_512_ASTC_4x4_Medium_4T` | `AVX2` | 4 | 180.32 | **191.24** | 192.53 | 1.37 | new | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_AVX2_512_ASTC_6x6_Fast_4T` | `AVX2` | 4 | 39.97 | **40.04** | 40.25 | 6.55 | new | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_AVX2_512_ASTC_6x6_Medium_4T` | `AVX2` | 4 | 172.89 | **173.18** | 186.41 | 1.51 | new | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_AVX2_512_ASTC_8x8_Fast_4T` | `AVX2` | 4 | 31.29 | **31.44** | 40.67 | 8.34 | new | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_AVX2_512_ASTC_8x8_Medium_4T` | `AVX2` | 4 | 87.35 | **87.52** | 98.31 | 3.00 | new | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_AVX2_512_ASTC_12x12_Fast_4T` | `AVX2` | 4 | 69.79 | **70.21** | 73.02 | 3.73 | new | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_AVX2_512_ASTC_12x12_Medium_4T` | `AVX2` | 4 | 297.92 | **308.52** | 311.08 | 0.85 | new | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_AVX2_Decompress_512_ASTC_6x6_4T` | `AVX2` | 4 | 1.24 | **1.28** | 1.37 | 204.85 | new | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_SSE4.1_512_ASTC_4x4_Fast_4T` | `SSE4.1` | 4 | 64.67 | **65.23** | 70.17 | 4.02 | new | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_SSE4.1_512_ASTC_4x4_Medium_4T` | `SSE4.1` | 4 | 193.89 | **200.34** | 206.89 | 1.31 | new | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_SSE4.1_512_ASTC_6x6_Fast_4T` | `SSE4.1` | 4 | 43.82 | **43.90** | 44.26 | 5.97 | new | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_SSE4.1_512_ASTC_6x6_Medium_4T` | `SSE4.1` | 4 | 180.35 | **180.55** | 192.34 | 1.45 | new | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_SSE4.1_512_ASTC_8x8_Fast_4T` | `SSE4.1` | 4 | 33.93 | **34.05** | 43.32 | 7.70 | new | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_SSE4.1_512_ASTC_8x8_Medium_4T` | `SSE4.1` | 4 | 92.35 | **93.42** | 103.63 | 2.81 | new | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_SSE4.1_512_ASTC_12x12_Fast_4T` | `SSE4.1` | 4 | 69.49 | **69.66** | 81.05 | 3.76 | new | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_SSE4.1_512_ASTC_12x12_Medium_4T` | `SSE4.1` | 4 | 283.73 | **296.89** | 297.93 | 0.88 | new | -| Windows AMD64 (`AMD EPYC 9V74 80-Core Processor`) | `Native_SSE4.1_Decompress_512_ASTC_6x6_4T` | `SSE4.1` | 4 | 1.84 | **1.87** | 1.99 | 140.04 | new | -| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_512_ASTC_4x4_Fast_3T` | `ARM64_NEON` | 3 | 61.30 | **73.72** | 89.83 | 3.56 | new | -| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_512_ASTC_4x4_Medium_3T` | `ARM64_NEON` | 3 | 155.97 | **186.31** | 248.39 | 1.41 | new | -| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_512_ASTC_6x6_Fast_3T` | `ARM64_NEON` | 3 | 34.40 | **34.68** | 35.09 | 7.56 | new | -| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_512_ASTC_6x6_Medium_3T` | `ARM64_NEON` | 3 | 144.50 | **154.93** | 202.13 | 1.69 | new | -| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_512_ASTC_8x8_Fast_3T` | `ARM64_NEON` | 3 | 27.69 | **28.03** | 28.47 | 9.35 | new | -| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_512_ASTC_8x8_Medium_3T` | `ARM64_NEON` | 3 | 71.27 | **71.79** | 90.55 | 3.65 | new | -| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_512_ASTC_12x12_Fast_3T` | `ARM64_NEON` | 3 | 54.55 | **55.24** | 57.33 | 4.75 | new | -| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_512_ASTC_12x12_Medium_3T` | `ARM64_NEON` | 3 | 198.91 | **232.17** | 246.13 | 1.13 | new | -| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_Decompress_512_ASTC_6x6_3T` | `ARM64_NEON` | 3 | 1.38 | **1.51** | 2.27 | 173.77 | new | -| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_4x4_Fast_4T` | `SSE4.1` | 4 | 73.24 | **73.32** | 73.77 | 3.58 | new | -| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_4x4_Medium_4T` | `SSE4.1` | 4 | 220.29 | **220.75** | 222.05 | 1.19 | new | -| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_6x6_Fast_4T` | `SSE4.1` | 4 | 50.00 | **50.48** | 51.02 | 5.19 | new | -| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_6x6_Medium_4T` | `SSE4.1` | 4 | 196.73 | **197.06** | 203.91 | 1.33 | new | -| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_8x8_Fast_4T` | `SSE4.1` | 4 | 37.80 | **37.84** | 37.94 | 6.93 | new | -| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_8x8_Medium_4T` | `SSE4.1` | 4 | 98.53 | **98.71** | 100.25 | 2.66 | new | -| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_12x12_Fast_4T` | `SSE4.1` | 4 | 74.94 | **75.14** | 75.41 | 3.49 | new | -| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_12x12_Medium_4T` | `SSE4.1` | 4 | 298.12 | **299.78** | 301.03 | 0.87 | new | -| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_Decompress_512_ASTC_6x6_4T` | `SSE4.1` | 4 | 2.15 | **2.18** | 2.21 | 120.44 | new | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_AVX2_512_ASTC_4x4_Fast_4T` | `AVX2` | 4 | 78.36 | **82.16** | 98.45 | 3.19 | ⚠️ +39.6% | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_AVX2_512_ASTC_4x4_Medium_4T` | `AVX2` | 4 | 235.64 | **236.00** | 249.70 | 1.11 | ⚠️ +23.4% | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_AVX2_512_ASTC_6x6_Fast_4T` | `AVX2` | 4 | 52.20 | **52.70** | 62.82 | 4.97 | ⚠️ +31.6% | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_AVX2_512_ASTC_6x6_Medium_4T` | `AVX2` | 4 | 224.34 | **233.61** | 240.19 | 1.12 | ⚠️ +34.9% | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_AVX2_512_ASTC_8x8_Fast_4T` | `AVX2` | 4 | 40.61 | **40.98** | 53.57 | 6.40 | ⚠️ +30.3% | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_AVX2_512_ASTC_8x8_Medium_4T` | `AVX2` | 4 | 112.72 | **112.76** | 126.54 | 2.33 | ⚠️ +28.8% | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_AVX2_512_ASTC_12x12_Fast_4T` | `AVX2` | 4 | 89.89 | **90.88** | 97.61 | 2.88 | ⚠️ +29.4% | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_AVX2_512_ASTC_12x12_Medium_4T` | `AVX2` | 4 | 424.56 | **508.74** | 527.41 | 0.52 | ⚠️ +64.9% | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_AVX2_Decompress_512_ASTC_6x6_4T` | `AVX2` | 4 | 2.34 | **3.16** | 6.01 | 82.84 | ⚠️ +147.2% | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_4x4_Fast_4T` | `SSE4.1` | 4 | 99.16 | **142.91** | 176.12 | 1.83 | ⚠️ +119.1% | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_4x4_Medium_4T` | `SSE4.1` | 4 | 310.36 | **359.63** | 396.19 | 0.73 | ⚠️ +79.5% | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_6x6_Fast_4T` | `SSE4.1` | 4 | 67.68 | **71.97** | 89.50 | 3.64 | ⚠️ +63.9% | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_6x6_Medium_4T` | `SSE4.1` | 4 | 222.75 | **241.71** | 306.93 | 1.08 | ⚠️ +33.9% | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_8x8_Fast_4T` | `SSE4.1` | 4 | 41.27 | **41.60** | 43.47 | 6.30 | ⚠️ +22.2% | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_8x8_Medium_4T` | `SSE4.1` | 4 | 108.11 | **108.95** | 121.08 | 2.41 | ⚠️ +16.6% | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_12x12_Fast_4T` | `SSE4.1` | 4 | 81.95 | **84.40** | 85.91 | 3.11 | ⚠️ +21.2% | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_12x12_Medium_4T` | `SSE4.1` | 4 | 325.16 | **335.28** | 338.67 | 0.78 | +12.9% | +| Windows AMD64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_Decompress_512_ASTC_6x6_4T` | `SSE4.1` | 4 | 2.46 | **2.51** | 2.62 | 104.55 | ⚠️ +33.9% | +| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_512_ASTC_4x4_Fast_3T` | `ARM64_NEON` | 3 | 71.95 | **77.48** | 85.77 | 3.38 | +5.1% | +| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_512_ASTC_4x4_Medium_3T` | `ARM64_NEON` | 3 | 226.93 | **248.59** | 372.45 | 1.05 | ⚠️ +33.4% | +| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_512_ASTC_6x6_Fast_3T` | `ARM64_NEON` | 3 | 57.83 | **67.29** | 79.33 | 3.90 | ⚠️ +94.0% | +| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_512_ASTC_6x6_Medium_3T` | `ARM64_NEON` | 3 | 194.88 | **211.06** | 230.28 | 1.24 | ⚠️ +36.2% | +| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_512_ASTC_8x8_Fast_3T` | `ARM64_NEON` | 3 | 30.31 | **34.27** | 36.59 | 7.65 | ⚠️ +22.3% | +| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_512_ASTC_8x8_Medium_3T` | `ARM64_NEON` | 3 | 83.56 | **92.62** | 102.94 | 2.83 | ⚠️ +29.0% | +| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_512_ASTC_12x12_Fast_3T` | `ARM64_NEON` | 3 | 71.17 | **75.96** | 87.00 | 3.45 | ⚠️ +37.5% | +| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_512_ASTC_12x12_Medium_3T` | `ARM64_NEON` | 3 | 300.57 | **311.98** | 353.67 | 0.84 | ⚠️ +34.4% | +| Darwin arm64 (`Apple M1 (Virtual)`) | `Native_ARM64_NEON_Decompress_512_ASTC_6x6_3T` | `ARM64_NEON` | 3 | 2.20 | **2.99** | 3.81 | 87.69 | ⚠️ +98.1% | +| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_4x4_Fast_4T` | `SSE4.1` | 4 | 73.46 | **73.50** | 73.59 | 3.57 | +0.2% | +| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_4x4_Medium_4T` | `SSE4.1` | 4 | 220.77 | **221.22** | 221.72 | 1.19 | +0.2% | +| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_6x6_Fast_4T` | `SSE4.1` | 4 | 50.37 | **50.51** | 51.51 | 5.19 | +0.1% | +| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_6x6_Medium_4T` | `SSE4.1` | 4 | 197.50 | **197.62** | 198.48 | 1.33 | +0.3% | +| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_8x8_Fast_4T` | `SSE4.1` | 4 | 38.09 | **38.12** | 38.29 | 6.88 | +0.7% | +| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_8x8_Medium_4T` | `SSE4.1` | 4 | 98.81 | **99.00** | 100.81 | 2.65 | +0.3% | +| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_12x12_Fast_4T` | `SSE4.1` | 4 | 75.58 | **75.88** | 76.01 | 3.46 | +1.0% | +| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_512_ASTC_12x12_Medium_4T` | `SSE4.1` | 4 | 299.59 | **300.47** | 303.46 | 0.87 | +0.2% | +| Linux x86_64 (`AMD EPYC 7763 64-Core Processor`) | `Native_SSE4.1_Decompress_512_ASTC_6x6_4T` | `SSE4.1` | 4 | 2.16 | **2.17** | 2.23 | 120.64 | -0.2% | diff --git a/docs/benchmarks/baseline.json b/docs/benchmarks/baseline.json index b4a0644..8ca0fad 100644 --- a/docs/benchmarks/baseline.json +++ b/docs/benchmarks/baseline.json @@ -1,11 +1,11 @@ { "SchemaVersion": "1.0", - "TimestampUtc": "2026-11-28T14:45:33.182883+00:00", - "GitCommit": "d3223a5", + "TimestampUtc": "2026-12-01T08:36:18.966594+00:00", + "GitCommit": "44492deeb3df90e2f8b61aaccb8e9e5d5502441c", "unity": { "SchemaVersion": "1.0", - "TimestampUtc": "2026-11-28T14:31:27.4006210Z", - "GitCommit": "d3223a509836e324829635f6c8b2fe25f893104a", + "TimestampUtc": "2026-12-01T07:32:21.9782420Z", + "GitCommit": "f1a9e0ec1efc61b3222fe4a25c0a953360ba37e7", "UnityVersion": "2021.3.6f1", "Platform": "OSXPlayer", "CpuModel": "Apple M1 (Virtual)", @@ -26,17 +26,17 @@ "Quality": "Fast", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 7.2574000000000005, - "MedianMs": 7.6572000000000005, - "MeanMs": 7.752280000000001, - "P95Ms": 8.5983, - "MaxMs": 8.5983, - "ThroughputMPixPerSec": 136.93987358303295, + "MinMs": 6.0663, + "MedianMs": 6.3769, + "MeanMs": 6.8845, + "P95Ms": 8.6204, + "MaxMs": 8.6204, + "ThroughputMPixPerSec": 164.43350217190172, "GcAllocBytesPerOp": 0, "OutputBytes": 1048576, "UncompressedBytes": 4194304, - "RgbPsnrDb": 48.93544461717621, - "RgbaPsnrDb": 46.447072388366934, + "RgbPsnrDb": 48.92450843503163, + "RgbaPsnrDb": 46.44376828685124, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -49,12 +49,12 @@ "Quality": "Fast", "WarmupRuns": 1, "Iterations": 4, - "MinMs": 233.97140000000002, - "MedianMs": 253.41470000000004, - "MeanMs": 255.68827500000003, - "P95Ms": 281.95230000000004, - "MaxMs": 281.95230000000004, - "ThroughputMPixPerSec": 4.137786797687742, + "MinMs": 375.71610000000004, + "MedianMs": 430.24905, + "MeanMs": 457.66677500000003, + "P95Ms": 594.4529, + "MaxMs": 594.4529, + "ThroughputMPixPerSec": 2.4371372813025385, "GcAllocBytesPerOp": 8192, "OutputBytes": 1048576, "UncompressedBytes": 4194304, @@ -72,17 +72,17 @@ "Quality": "Medium", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 40.400400000000005, - "MedianMs": 40.9972, - "MeanMs": 40.8319, - "P95Ms": 41.1408, - "MaxMs": 41.1408, - "ThroughputMPixPerSec": 25.57677109656269, + "MinMs": 20.452, + "MedianMs": 20.7076, + "MeanMs": 20.77802, + "P95Ms": 21.1641, + "MaxMs": 21.1641, + "ThroughputMPixPerSec": 50.63725395506963, "GcAllocBytesPerOp": 0, "OutputBytes": 1048576, "UncompressedBytes": 4194304, - "RgbPsnrDb": 46.44263612406823, - "RgbaPsnrDb": 46.385471914063544, + "RgbPsnrDb": 48.72546431517905, + "RgbaPsnrDb": 47.90553581250255, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -95,13 +95,13 @@ "Quality": "Medium", "WarmupRuns": 1, "Iterations": 4, - "MinMs": 444.3315, - "MedianMs": 519.5899, - "MeanMs": 577.3600250000001, - "P95Ms": 825.9288, - "MaxMs": 825.9288, - "ThroughputMPixPerSec": 2.018083877304005, - "GcAllocBytesPerOp": 7168, + "MinMs": 622.894, + "MedianMs": 920.31435, + "MeanMs": 921.123375, + "P95Ms": 1220.9708, + "MaxMs": 1220.9708, + "ThroughputMPixPerSec": 1.139367217299176, + "GcAllocBytesPerOp": 4096, "OutputBytes": 1048576, "UncompressedBytes": 4194304, "RgbPsnrDb": 50.239287043339836, @@ -118,17 +118,17 @@ "Quality": "Fast", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 13.733400000000001, - "MedianMs": 20.340600000000002, - "MeanMs": 19.591380000000004, - "P95Ms": 23.500700000000002, - "MaxMs": 23.500700000000002, - "ThroughputMPixPerSec": 51.55088837104117, + "MinMs": 10.431000000000001, + "MedianMs": 10.736, + "MeanMs": 12.961880000000003, + "P95Ms": 21.5338, + "MaxMs": 21.5338, + "ThroughputMPixPerSec": 97.66915052160952, "GcAllocBytesPerOp": 0, "OutputBytes": 467856, "UncompressedBytes": 4194304, - "RgbPsnrDb": 29.268915777475613, - "RgbaPsnrDb": 30.307801054984893, + "RgbPsnrDb": 34.65375714036666, + "RgbaPsnrDb": 34.82175997081236, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -141,12 +141,12 @@ "Quality": "Fast", "WarmupRuns": 1, "Iterations": 4, - "MinMs": 355.6427, - "MedianMs": 371.7456, - "MeanMs": 373.71317500000004, - "P95Ms": 395.71880000000004, - "MaxMs": 395.71880000000004, - "ThroughputMPixPerSec": 2.820681670475723, + "MinMs": 371.5528, + "MedianMs": 399.545, + "MeanMs": 400.93027500000005, + "P95Ms": 433.0783, + "MaxMs": 433.0783, + "ThroughputMPixPerSec": 2.624425283760277, "GcAllocBytesPerOp": 4096, "OutputBytes": 467856, "UncompressedBytes": 4194304, @@ -164,17 +164,17 @@ "Quality": "Medium", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 54.402300000000004, - "MedianMs": 57.4911, - "MeanMs": 57.579660000000004, - "P95Ms": 60.931900000000006, - "MaxMs": 60.931900000000006, - "ThroughputMPixPerSec": 18.238927416591437, + "MinMs": 28.933400000000002, + "MedianMs": 33.4386, + "MeanMs": 35.26520000000001, + "P95Ms": 42.788900000000005, + "MaxMs": 42.788900000000005, + "ThroughputMPixPerSec": 31.35825064446478, "GcAllocBytesPerOp": 0, "OutputBytes": 467856, "UncompressedBytes": 4194304, - "RgbPsnrDb": 32.56521584108872, - "RgbaPsnrDb": 33.413757354941964, + "RgbPsnrDb": 39.43512266907991, + "RgbaPsnrDb": 38.93003423714243, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -187,12 +187,12 @@ "Quality": "Medium", "WarmupRuns": 1, "Iterations": 4, - "MinMs": 824.2666, - "MedianMs": 876.3836000000001, - "MeanMs": 882.915575, - "P95Ms": 954.6285, - "MaxMs": 954.6285, - "ThroughputMPixPerSec": 1.1964806278894309, + "MinMs": 865.7718, + "MedianMs": 987.3541500000001, + "MeanMs": 1038.609625, + "P95Ms": 1313.9584, + "MaxMs": 1313.9584, + "ThroughputMPixPerSec": 1.0620059681726155, "GcAllocBytesPerOp": 4096, "OutputBytes": 467856, "UncompressedBytes": 4194304, @@ -210,17 +210,17 @@ "Quality": "Fast", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 8.1754, - "MedianMs": 8.5144, - "MeanMs": 8.653920000000001, - "P95Ms": 9.2192, - "MaxMs": 9.2192, - "ThroughputMPixPerSec": 123.1532462651508, + "MinMs": 10.3399, + "MedianMs": 12.3735, + "MeanMs": 15.648140000000001, + "P95Ms": 22.454900000000002, + "MaxMs": 22.454900000000002, + "ThroughputMPixPerSec": 84.74368610336607, "GcAllocBytesPerOp": 0, "OutputBytes": 262144, "UncompressedBytes": 4194304, - "RgbPsnrDb": 43.42779831094145, - "RgbaPsnrDb": 40.60758672519129, + "RgbPsnrDb": 43.4278249573573, + "RgbaPsnrDb": 40.60790010311347, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -233,12 +233,12 @@ "Quality": "Fast", "WarmupRuns": 1, "Iterations": 4, - "MinMs": 757.7843, - "MedianMs": 836.1885500000001, - "MeanMs": 861.894325, - "P95Ms": 1017.4159000000001, - "MaxMs": 1017.4159000000001, - "ThroughputMPixPerSec": 1.2539946881597457, + "MinMs": 836.1097000000001, + "MedianMs": 882.0752500000001, + "MeanMs": 873.154575, + "P95Ms": 892.3581, + "MaxMs": 892.3581, + "ThroughputMPixPerSec": 1.1887602559985668, "GcAllocBytesPerOp": 3072, "OutputBytes": 262144, "UncompressedBytes": 4194304, @@ -256,17 +256,17 @@ "Quality": "Medium", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 36.2685, - "MedianMs": 37.0248, - "MeanMs": 38.13978, - "P95Ms": 40.927600000000005, - "MaxMs": 40.927600000000005, - "ThroughputMPixPerSec": 28.320909228409068, - "GcAllocBytesPerOp": 819, + "MinMs": 31.2008, + "MedianMs": 35.1059, + "MeanMs": 35.047579999999996, + "P95Ms": 42.3817, + "MaxMs": 42.3817, + "ThroughputMPixPerSec": 29.868939409045204, + "GcAllocBytesPerOp": 0, "OutputBytes": 262144, "UncompressedBytes": 4194304, - "RgbPsnrDb": 44.05044601875516, - "RgbaPsnrDb": 42.709369884547755, + "RgbPsnrDb": 44.29241991071677, + "RgbaPsnrDb": 43.97339769829589, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -279,13 +279,13 @@ "Quality": "Medium", "WarmupRuns": 1, "Iterations": 4, - "MinMs": 1685.8475, - "MedianMs": 1848.6037000000001, - "MeanMs": 1894.110225, - "P95Ms": 2193.386, - "MaxMs": 2193.386, - "ThroughputMPixPerSec": 0.5672259554603293, - "GcAllocBytesPerOp": 4096, + "MinMs": 1422.0123, + "MedianMs": 1705.45475, + "MeanMs": 1688.141925, + "P95Ms": 1919.6459, + "MaxMs": 1919.6459, + "ThroughputMPixPerSec": 0.6148366000329237, + "GcAllocBytesPerOp": 3072, "OutputBytes": 262144, "UncompressedBytes": 4194304, "RgbPsnrDb": 47.9299764839495, @@ -302,17 +302,17 @@ "Quality": "Fast", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 8.3804, - "MedianMs": 10.851, - "MeanMs": 10.44922, - "P95Ms": 11.4383, - "MaxMs": 11.4383, - "ThroughputMPixPerSec": 96.63404294535064, + "MinMs": 10.4379, + "MedianMs": 10.8618, + "MeanMs": 13.229020000000002, + "P95Ms": 21.9633, + "MaxMs": 21.9633, + "ThroughputMPixPerSec": 96.53795871770791, "GcAllocBytesPerOp": 0, "OutputBytes": 118336, "UncompressedBytes": 4194304, - "RgbPsnrDb": 24.674982325540068, - "RgbaPsnrDb": 25.542357633894742, + "RgbPsnrDb": 24.67499416236455, + "RgbaPsnrDb": 25.542368285735364, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -325,13 +325,13 @@ "Quality": "Fast", "WarmupRuns": 1, "Iterations": 4, - "MinMs": 618.6504, - "MedianMs": 710.8868, - "MeanMs": 709.057275, - "P95Ms": 795.8051, - "MaxMs": 795.8051, - "ThroughputMPixPerSec": 1.4750252782862192, - "GcAllocBytesPerOp": 4096, + "MinMs": 655.9104, + "MedianMs": 677.65335, + "MeanMs": 683.1707, + "P95Ms": 721.4657000000001, + "MaxMs": 721.4657000000001, + "ThroughputMPixPerSec": 1.5473634122815152, + "GcAllocBytesPerOp": 6144, "OutputBytes": 118336, "UncompressedBytes": 4194304, "RgbPsnrDb": 27.781366326710703, @@ -348,17 +348,17 @@ "Quality": "Medium", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 29.087, - "MedianMs": 30.7282, - "MeanMs": 30.76426, - "P95Ms": 32.1287, - "MaxMs": 32.1287, - "ThroughputMPixPerSec": 34.12422465357554, + "MinMs": 20.413700000000002, + "MedianMs": 20.884800000000002, + "MeanMs": 21.66576, + "P95Ms": 24.812, + "MaxMs": 24.812, + "ThroughputMPixPerSec": 50.207615107638084, "GcAllocBytesPerOp": 0, "OutputBytes": 118336, "UncompressedBytes": 4194304, - "RgbPsnrDb": 25.3429802507935, - "RgbaPsnrDb": 26.152520573829854, + "RgbPsnrDb": 25.463016702688137, + "RgbaPsnrDb": 26.265851529264822, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -371,12 +371,12 @@ "Quality": "Medium", "WarmupRuns": 1, "Iterations": 4, - "MinMs": 1095.5699, - "MedianMs": 1254.7936, - "MeanMs": 1237.7655, - "P95Ms": 1345.9049, - "MaxMs": 1345.9049, - "ThroughputMPixPerSec": 0.8356561589093218, + "MinMs": 928.0785000000001, + "MedianMs": 1003.4602, + "MeanMs": 1015.99, + "P95Ms": 1128.9611, + "MaxMs": 1128.9611, + "ThroughputMPixPerSec": 1.0449602286169397, "GcAllocBytesPerOp": 4096, "OutputBytes": 118336, "UncompressedBytes": 4194304, @@ -394,17 +394,17 @@ "Quality": "Fast", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 3.8549, - "MedianMs": 5.546, - "MeanMs": 5.69054, - "P95Ms": 7.339600000000001, - "MaxMs": 7.339600000000001, - "ThroughputMPixPerSec": 47.26721961774251, + "MinMs": 10.9588, + "MedianMs": 11.7019, + "MeanMs": 12.11222, + "P95Ms": 14.170900000000001, + "MaxMs": 14.170900000000001, + "ThroughputMPixPerSec": 22.401832181098797, "GcAllocBytesPerOp": 0, "OutputBytes": 262144, "UncompressedBytes": 1048576, - "RgbPsnrDb": 44.53700235141254, - "RgbaPsnrDb": 41.26932203173269, + "RgbPsnrDb": 44.537253417989504, + "RgbaPsnrDb": 41.2694448901384, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -417,13 +417,13 @@ "Quality": "Fast", "WarmupRuns": 1, "Iterations": 5, - "MinMs": 115.2474, - "MedianMs": 148.5983, - "MeanMs": 148.80894, - "P95Ms": 168.0774, - "MaxMs": 168.0774, - "ThroughputMPixPerSec": 1.7641117024891941, - "GcAllocBytesPerOp": 3276, + "MinMs": 122.8499, + "MedianMs": 131.2185, + "MeanMs": 134.04786, + "P95Ms": 150.1514, + "MaxMs": 150.1514, + "ThroughputMPixPerSec": 1.9977670831475742, + "GcAllocBytesPerOp": 4096, "OutputBytes": 262144, "UncompressedBytes": 1048576, "RgbPsnrDb": 44.51269121516561, @@ -440,17 +440,17 @@ "Quality": "Medium", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 20.3961, - "MedianMs": 20.5929, - "MeanMs": 20.745380000000004, - "P95Ms": 21.438100000000002, - "MaxMs": 21.438100000000002, - "ThroughputMPixPerSec": 12.729824356938556, + "MinMs": 10.4948, + "MedianMs": 10.524600000000001, + "MeanMs": 10.54818, + "P95Ms": 10.6837, + "MaxMs": 10.6837, + "ThroughputMPixPerSec": 24.907739961613736, "GcAllocBytesPerOp": 0, "OutputBytes": 262144, "UncompressedBytes": 1048576, - "RgbPsnrDb": 43.86294401381787, - "RgbaPsnrDb": 43.275775224534534, + "RgbPsnrDb": 44.012514899360504, + "RgbaPsnrDb": 43.495986335878115, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -463,13 +463,13 @@ "Quality": "Medium", "WarmupRuns": 1, "Iterations": 5, - "MinMs": 254.42360000000002, - "MedianMs": 277.3986, - "MeanMs": 303.12138, - "P95Ms": 387.4411, - "MaxMs": 387.4411, - "ThroughputMPixPerSec": 0.9450083742311605, - "GcAllocBytesPerOp": 3276, + "MinMs": 260.1548, + "MedianMs": 282.4075, + "MeanMs": 284.02168, + "P95Ms": 312.2001, + "MaxMs": 312.2001, + "ThroughputMPixPerSec": 0.9282473022139991, + "GcAllocBytesPerOp": 4096, "OutputBytes": 262144, "UncompressedBytes": 1048576, "RgbPsnrDb": 47.809063278540656, @@ -486,17 +486,17 @@ "Quality": "Thorough", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 14.299900000000001, - "MedianMs": 14.9433, - "MeanMs": 15.5565, - "P95Ms": 18.692, - "MaxMs": 18.692, - "ThroughputMPixPerSec": 17.542577610032588, + "MinMs": 20.7562, + "MedianMs": 21.2225, + "MeanMs": 21.34436, + "P95Ms": 22.442400000000003, + "MaxMs": 22.442400000000003, + "ThroughputMPixPerSec": 12.352173400871715, "GcAllocBytesPerOp": 0, "OutputBytes": 262144, "UncompressedBytes": 1048576, - "RgbPsnrDb": 40.16757368603386, - "RgbaPsnrDb": 40.083057035072514, + "RgbPsnrDb": 44.02522661129568, + "RgbaPsnrDb": 43.52910104120675, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -509,13 +509,13 @@ "Quality": "Thorough", "WarmupRuns": 1, "Iterations": 3, - "MinMs": 542.447, - "MedianMs": 593.4178, - "MeanMs": 591.8444000000001, - "P95Ms": 639.6684, - "MaxMs": 639.6684, - "ThroughputMPixPerSec": 0.4417528426009465, - "GcAllocBytesPerOp": 4096, + "MinMs": 536.0316, + "MedianMs": 554.5472, + "MeanMs": 559.7224666666667, + "P95Ms": 588.5886, + "MaxMs": 588.5886, + "ThroughputMPixPerSec": 0.4727172006278275, + "GcAllocBytesPerOp": 6826, "OutputBytes": 262144, "UncompressedBytes": 1048576, "RgbPsnrDb": 51.61825196152206, @@ -532,17 +532,17 @@ "Quality": "Fast", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 4.0154000000000005, - "MedianMs": 4.355, - "MeanMs": 6.534700000000001, - "P95Ms": 10.7311, - "MaxMs": 10.7311, - "ThroughputMPixPerSec": 60.19380022962112, + "MinMs": 21.066200000000002, + "MedianMs": 21.8871, + "MeanMs": 22.414840000000005, + "P95Ms": 24.847900000000003, + "MaxMs": 24.847900000000003, + "ThroughputMPixPerSec": 11.977100666602702, "GcAllocBytesPerOp": 0, "OutputBytes": 118336, "UncompressedBytes": 1048576, - "RgbPsnrDb": 28.586939937588962, - "RgbaPsnrDb": 29.206400857941198, + "RgbPsnrDb": 31.77718421737993, + "RgbaPsnrDb": 31.555049684387846, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -555,13 +555,13 @@ "Quality": "Fast", "WarmupRuns": 1, "Iterations": 5, - "MinMs": 136.68110000000001, - "MedianMs": 147.535, - "MeanMs": 146.57762000000002, - "P95Ms": 157.6611, - "MaxMs": 157.6611, - "ThroughputMPixPerSec": 1.7768258379367607, - "GcAllocBytesPerOp": 3276, + "MinMs": 83.16850000000001, + "MedianMs": 117.2655, + "MeanMs": 114.34716, + "P95Ms": 139.1908, + "MaxMs": 139.1908, + "ThroughputMPixPerSec": 2.2354742017046783, + "GcAllocBytesPerOp": 4096, "OutputBytes": 118336, "UncompressedBytes": 1048576, "RgbPsnrDb": 37.20279527435642, @@ -578,17 +578,17 @@ "Quality": "Medium", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 15.623700000000001, - "MedianMs": 16.5832, - "MeanMs": 19.02482, - "P95Ms": 24.0272, - "MaxMs": 24.0272, - "ThroughputMPixPerSec": 15.807805489893383, + "MinMs": 10.234300000000001, + "MedianMs": 10.2828, + "MeanMs": 12.351360000000001, + "P95Ms": 20.6128, + "MaxMs": 20.6128, + "ThroughputMPixPerSec": 25.493445365075658, "GcAllocBytesPerOp": 0, "OutputBytes": 118336, "UncompressedBytes": 1048576, - "RgbPsnrDb": 30.75457332597972, - "RgbaPsnrDb": 31.112740704460407, + "RgbPsnrDb": 33.653274880067656, + "RgbaPsnrDb": 33.18404062563782, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -601,13 +601,13 @@ "Quality": "Medium", "WarmupRuns": 1, "Iterations": 5, - "MinMs": 303.9388, - "MedianMs": 321.06350000000003, - "MeanMs": 372.89476, - "P95Ms": 564.1246, - "MaxMs": 564.1246, - "ThroughputMPixPerSec": 0.816486458286289, - "GcAllocBytesPerOp": 3276, + "MinMs": 369.451, + "MedianMs": 419.43330000000003, + "MeanMs": 416.54204, + "P95Ms": 470.16380000000004, + "MaxMs": 470.16380000000004, + "ThroughputMPixPerSec": 0.6249956786931319, + "GcAllocBytesPerOp": 4915, "OutputBytes": 118336, "UncompressedBytes": 1048576, "RgbPsnrDb": 38.69152133990712, @@ -624,17 +624,17 @@ "Quality": "Thorough", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 18.582700000000003, - "MedianMs": 20.090700000000002, - "MeanMs": 20.208180000000002, - "P95Ms": 22.554000000000002, - "MaxMs": 22.554000000000002, - "ThroughputMPixPerSec": 13.04802719666313, + "MinMs": 20.619, + "MedianMs": 21.6417, + "MeanMs": 21.558500000000002, + "P95Ms": 22.4995, + "MaxMs": 22.4995, + "ThroughputMPixPerSec": 12.112911647421413, "GcAllocBytesPerOp": 0, "OutputBytes": 118336, "UncompressedBytes": 1048576, - "RgbPsnrDb": 31.71124165594157, - "RgbaPsnrDb": 31.941820212359037, + "RgbPsnrDb": 35.056507212458506, + "RgbaPsnrDb": 34.49356076841126, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -647,12 +647,12 @@ "Quality": "Thorough", "WarmupRuns": 1, "Iterations": 3, - "MinMs": 668.6659000000001, - "MedianMs": 703.4123000000001, - "MeanMs": 701.4114333333333, - "P95Ms": 732.1561, - "MaxMs": 732.1561, - "ThroughputMPixPerSec": 0.3726747456648113, + "MinMs": 563.5367, + "MedianMs": 642.2877000000001, + "MeanMs": 635.2536333333334, + "P95Ms": 699.9365, + "MaxMs": 699.9365, + "ThroughputMPixPerSec": 0.4081410869303584, "GcAllocBytesPerOp": 4096, "OutputBytes": 118336, "UncompressedBytes": 1048576, @@ -670,17 +670,17 @@ "Quality": "Fast", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 3.4631000000000003, - "MedianMs": 3.5162, - "MeanMs": 4.280340000000001, - "P95Ms": 5.6505, - "MaxMs": 5.6505, - "ThroughputMPixPerSec": 74.55321085262499, + "MinMs": 10.430200000000001, + "MedianMs": 10.507200000000001, + "MeanMs": 10.59602, + "P95Ms": 10.849300000000001, + "MaxMs": 10.849300000000001, + "ThroughputMPixPerSec": 24.94898736104766, "GcAllocBytesPerOp": 0, "OutputBytes": 65536, "UncompressedBytes": 1048576, - "RgbPsnrDb": 37.82328035034816, - "RgbaPsnrDb": 34.93831232955961, + "RgbPsnrDb": 37.82329372691998, + "RgbaPsnrDb": 34.93848331021229, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -693,13 +693,13 @@ "Quality": "Fast", "WarmupRuns": 1, "Iterations": 5, - "MinMs": 175.7562, - "MedianMs": 229.2415, - "MeanMs": 227.67186, - "P95Ms": 260.962, - "MaxMs": 260.962, - "ThroughputMPixPerSec": 1.1435276771439724, - "GcAllocBytesPerOp": 3276, + "MinMs": 212.50480000000002, + "MedianMs": 226.45270000000002, + "MeanMs": 229.1419, + "P95Ms": 251.4798, + "MaxMs": 251.4798, + "ThroughputMPixPerSec": 1.1576103972264404, + "GcAllocBytesPerOp": 5734, "OutputBytes": 65536, "UncompressedBytes": 1048576, "RgbPsnrDb": 41.99044094046325, @@ -716,17 +716,17 @@ "Quality": "Medium", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 11.0385, - "MedianMs": 11.8375, - "MeanMs": 13.002480000000002, - "P95Ms": 18.6398, - "MaxMs": 18.6398, - "ThroughputMPixPerSec": 22.14521647307286, + "MinMs": 20.5088, + "MedianMs": 21.0704, + "MeanMs": 20.89018, + "P95Ms": 21.1722, + "MaxMs": 21.1722, + "ThroughputMPixPerSec": 12.441339509454021, "GcAllocBytesPerOp": 0, "OutputBytes": 65536, "UncompressedBytes": 1048576, - "RgbPsnrDb": 39.452376239565865, - "RgbaPsnrDb": 37.99502546644384, + "RgbPsnrDb": 39.507041833334846, + "RgbaPsnrDb": 39.09957707012548, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -739,13 +739,13 @@ "Quality": "Medium", "WarmupRuns": 1, "Iterations": 5, - "MinMs": 327.946, - "MedianMs": 373.92900000000003, - "MeanMs": 364.06718, - "P95Ms": 389.10900000000004, - "MaxMs": 389.10900000000004, - "ThroughputMPixPerSec": 0.7010528736738793, - "GcAllocBytesPerOp": 3276, + "MinMs": 495.23400000000004, + "MedianMs": 503.0443, + "MeanMs": 511.27902000000006, + "P95Ms": 547.2737000000001, + "MaxMs": 547.2737000000001, + "ThroughputMPixPerSec": 0.5211151383685293, + "GcAllocBytesPerOp": 4096, "OutputBytes": 65536, "UncompressedBytes": 1048576, "RgbPsnrDb": 43.13611451487135, @@ -762,17 +762,17 @@ "Quality": "Thorough", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 12.0862, - "MedianMs": 12.4115, - "MeanMs": 12.6273, - "P95Ms": 13.3628, - "MaxMs": 13.3628, - "ThroughputMPixPerSec": 21.121057084155822, + "MinMs": 20.445700000000002, + "MedianMs": 20.9909, + "MeanMs": 20.86938, + "P95Ms": 21.2274, + "MaxMs": 21.2274, + "ThroughputMPixPerSec": 12.488459284737672, "GcAllocBytesPerOp": 0, "OutputBytes": 65536, "UncompressedBytes": 1048576, - "RgbPsnrDb": 39.081942246119404, - "RgbaPsnrDb": 37.92068444019468, + "RgbPsnrDb": 39.654503861299524, + "RgbaPsnrDb": 39.18611694988962, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -785,12 +785,12 @@ "Quality": "Thorough", "WarmupRuns": 1, "Iterations": 3, - "MinMs": 631.2668, - "MedianMs": 675.9754, - "MeanMs": 689.8156333333333, - "P95Ms": 762.2047, - "MaxMs": 762.2047, - "ThroughputMPixPerSec": 0.38780109453687217, + "MinMs": 823.4685000000001, + "MedianMs": 1170.8876, + "MeanMs": 1080.3663, + "P95Ms": 1246.7428, + "MaxMs": 1246.7428, + "ThroughputMPixPerSec": 0.22388485453257853, "GcAllocBytesPerOp": 4096, "OutputBytes": 65536, "UncompressedBytes": 1048576, @@ -808,17 +808,17 @@ "Quality": "Fast", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 2.3033, - "MedianMs": 2.3208, - "MeanMs": 2.3386199999999997, - "P95Ms": 2.4247, - "MaxMs": 2.4247, - "ThroughputMPixPerSec": 112.95415374008962, + "MinMs": 10.256400000000001, + "MedianMs": 10.5774, + "MeanMs": 12.544900000000002, + "P95Ms": 20.338800000000003, + "MaxMs": 20.338800000000003, + "ThroughputMPixPerSec": 24.78340613005086, "GcAllocBytesPerOp": 0, "OutputBytes": 29584, "UncompressedBytes": 1048576, - "RgbPsnrDb": 24.038719926033405, - "RgbaPsnrDb": 24.210460117508077, + "RgbPsnrDb": 24.038719151184136, + "RgbaPsnrDb": 24.210458606062613, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -831,13 +831,13 @@ "Quality": "Fast", "WarmupRuns": 1, "Iterations": 5, - "MinMs": 136.28040000000001, - "MedianMs": 158.24190000000002, - "MeanMs": 154.74398, - "P95Ms": 171.7731, - "MaxMs": 171.7731, - "ThroughputMPixPerSec": 1.6566029604042922, - "GcAllocBytesPerOp": 3276, + "MinMs": 205.28750000000002, + "MedianMs": 219.89710000000002, + "MeanMs": 239.54264000000003, + "P95Ms": 292.254, + "MaxMs": 292.254, + "ThroughputMPixPerSec": 1.1921212239724852, + "GcAllocBytesPerOp": 4096, "OutputBytes": 29584, "UncompressedBytes": 1048576, "RgbPsnrDb": 26.30605487174393, @@ -854,17 +854,17 @@ "Quality": "Medium", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 11.7005, - "MedianMs": 20.3552, - "MeanMs": 17.84424, - "P95Ms": 20.6083, - "MaxMs": 20.6083, - "ThroughputMPixPerSec": 12.878478226693915, + "MinMs": 10.3176, + "MedianMs": 10.659, + "MeanMs": 12.92328, + "P95Ms": 21.1817, + "MaxMs": 21.1817, + "ThroughputMPixPerSec": 24.593676705131813, "GcAllocBytesPerOp": 0, "OutputBytes": 29584, "UncompressedBytes": 1048576, - "RgbPsnrDb": 24.34345030501926, - "RgbaPsnrDb": 24.558534132224565, + "RgbPsnrDb": 24.669789595620628, + "RgbaPsnrDb": 24.86844528978509, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -877,13 +877,13 @@ "Quality": "Medium", "WarmupRuns": 1, "Iterations": 5, - "MinMs": 250.4934, - "MedianMs": 308.17150000000004, - "MeanMs": 304.94888000000003, - "P95Ms": 369.2776, - "MaxMs": 369.2776, - "ThroughputMPixPerSec": 0.8506432295004566, - "GcAllocBytesPerOp": 3276, + "MinMs": 354.55920000000003, + "MedianMs": 390.22650000000004, + "MeanMs": 392.31136000000004, + "P95Ms": 415.868, + "MaxMs": 415.868, + "ThroughputMPixPerSec": 0.6717739569198913, + "GcAllocBytesPerOp": 4096, "OutputBytes": 29584, "UncompressedBytes": 1048576, "RgbPsnrDb": 27.734647003620406, @@ -900,17 +900,17 @@ "Quality": "Thorough", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 10.1324, - "MedianMs": 10.325800000000001, - "MeanMs": 11.079600000000003, - "P95Ms": 12.9783, - "MaxMs": 12.9783, - "ThroughputMPixPerSec": 25.387282341319796, + "MinMs": 10.2433, + "MedianMs": 10.3611, + "MeanMs": 10.561160000000001, + "P95Ms": 11.1431, + "MaxMs": 11.1431, + "ThroughputMPixPerSec": 25.300788526314772, "GcAllocBytesPerOp": 0, "OutputBytes": 29584, "UncompressedBytes": 1048576, - "RgbPsnrDb": 24.288070214311787, - "RgbaPsnrDb": 24.50926032733177, + "RgbPsnrDb": 24.68952752862399, + "RgbaPsnrDb": 24.884316599876392, "MeanNormalDeg": 0.0, "Notes": "" }, @@ -923,12 +923,12 @@ "Quality": "Thorough", "WarmupRuns": 1, "Iterations": 3, - "MinMs": 519.839, - "MedianMs": 558.4536, - "MeanMs": 556.9486, - "P95Ms": 592.5532000000001, - "MaxMs": 592.5532000000001, - "ThroughputMPixPerSec": 0.46941052936179467, + "MinMs": 737.9346, + "MedianMs": 807.6864, + "MeanMs": 788.4762999999999, + "P95Ms": 819.8079, + "MaxMs": 819.8079, + "ThroughputMPixPerSec": 0.32456161203160033, "GcAllocBytesPerOp": 4096, "OutputBytes": 29584, "UncompressedBytes": 1048576, @@ -946,12 +946,12 @@ "Quality": "Fast", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 0.5436, - "MedianMs": 2.6978, - "MeanMs": 2.2973800000000004, - "P95Ms": 3.7534, - "MaxMs": 3.7534, - "ThroughputMPixPerSec": 388.6781822225517, + "MinMs": 1.4698, + "MedianMs": 2.9774000000000003, + "MeanMs": 3.02176, + "P95Ms": 4.7027, + "MaxMs": 4.7027, + "ThroughputMPixPerSec": 352.17841069389397, "GcAllocBytesPerOp": 0, "OutputBytes": 0, "UncompressedBytes": 4194304, @@ -969,12 +969,12 @@ "Quality": "Fast", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 0.6574, - "MedianMs": 0.751, - "MeanMs": 1.0459, - "P95Ms": 1.6328, - "MaxMs": 1.6328, - "ThroughputMPixPerSec": 1861.652463382157, + "MinMs": 3.4221000000000004, + "MedianMs": 3.8448, + "MeanMs": 4.29458, + "P95Ms": 5.3266, + "MaxMs": 5.3266, + "ThroughputMPixPerSec": 363.63425925925924, "GcAllocBytesPerOp": 0, "OutputBytes": 0, "UncompressedBytes": 5592404, @@ -992,18 +992,18 @@ "Quality": "Medium", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 12.363100000000001, - "MedianMs": 19.2589, - "MeanMs": 17.895720000000004, - "P95Ms": 23.5485, - "MaxMs": 23.5485, - "ThroughputMPixPerSec": 13.611576985186069, + "MinMs": 10.3034, + "MedianMs": 11.4593, + "MeanMs": 11.40942, + "P95Ms": 12.2858, + "MaxMs": 12.2858, + "ThroughputMPixPerSec": 22.876091907882678, "GcAllocBytesPerOp": 0, "OutputBytes": 118336, "UncompressedBytes": 1048576, "RgbPsnrDb": 0.0, "RgbaPsnrDb": 0.0, - "MeanNormalDeg": 0.271126460396895, + "MeanNormalDeg": 0.27053858212219745, "Notes": "" }, { @@ -1015,12 +1015,12 @@ "Quality": "Medium", "WarmupRuns": 1, "Iterations": 5, - "MinMs": 294.2321, - "MedianMs": 319.2051, - "MeanMs": 328.59056, - "P95Ms": 377.23, - "MaxMs": 377.23, - "ThroughputMPixPerSec": 0.8212400115161066, + "MinMs": 428.70950000000005, + "MedianMs": 568.5723, + "MeanMs": 519.76524, + "P95Ms": 589.8190000000001, + "MaxMs": 589.8190000000001, + "ThroughputMPixPerSec": 0.4610565797876541, "GcAllocBytesPerOp": 4096, "OutputBytes": 118336, "UncompressedBytes": 1048576, @@ -1038,12 +1038,12 @@ "Quality": "Fast", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 4.2633, - "MedianMs": 6.5738, - "MeanMs": 7.49838, - "P95Ms": 10.5243, - "MaxMs": 10.5243, - "ThroughputMPixPerSec": 39.877087833520946, + "MinMs": 10.4651, + "MedianMs": 10.663300000000001, + "MeanMs": 10.68828, + "P95Ms": 10.970500000000001, + "MaxMs": 10.970500000000001, + "ThroughputMPixPerSec": 24.583759249012967, "GcAllocBytesPerOp": 0, "OutputBytes": 118336, "UncompressedBytes": 1048576, @@ -1061,14 +1061,14 @@ "Quality": "Fast", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 0.0098, - "MedianMs": 0.011000000000000001, - "MeanMs": 0.013300000000000001, - "P95Ms": 0.023200000000000002, - "MaxMs": 0.023200000000000002, - "ThroughputMPixPerSec": 23831.272727272724, + "MinMs": 10.9146, + "MedianMs": 11.1097, + "MeanMs": 13.2837, + "P95Ms": 22.1659, + "MaxMs": 22.1659, + "ThroughputMPixPerSec": 23.595956686499186, "GcAllocBytesPerOp": 0, - "OutputBytes": 0, + "OutputBytes": 118336, "UncompressedBytes": 2097152, "RgbPsnrDb": 0.0, "RgbaPsnrDb": 0.0, @@ -1084,12 +1084,12 @@ "Quality": "Fast", "WarmupRuns": 1, "Iterations": 5, - "MinMs": 171.83110000000002, - "MedianMs": 181.3308, - "MeanMs": 182.50498000000002, - "P95Ms": 191.8865, - "MaxMs": 191.8865, - "ThroughputMPixPerSec": 1.445667255645483, + "MinMs": 263.2534, + "MedianMs": 271.7403, + "MeanMs": 280.4919, + "P95Ms": 304.641, + "MaxMs": 304.641, + "ThroughputMPixPerSec": 0.9646857679924545, "GcAllocBytesPerOp": 4096, "OutputBytes": 118336, "UncompressedBytes": 1048576, @@ -1107,13 +1107,13 @@ "Quality": "Fast", "WarmupRuns": 1, "Iterations": 5, - "MinMs": 180.29340000000002, - "MedianMs": 196.0909, - "MeanMs": 200.31318000000002, - "P95Ms": 216.09220000000002, - "MaxMs": 216.09220000000002, - "ThroughputMPixPerSec": 1.3368493897473057, - "GcAllocBytesPerOp": 4096, + "MinMs": 254.78830000000002, + "MedianMs": 260.9431, + "MeanMs": 297.65378, + "P95Ms": 411.2327, + "MaxMs": 411.2327, + "ThroughputMPixPerSec": 1.0046021527298479, + "GcAllocBytesPerOp": 5734, "OutputBytes": 118336, "UncompressedBytes": 1048576, "RgbPsnrDb": 0.0, @@ -1130,13 +1130,13 @@ "Quality": "N/A", "WarmupRuns": 2, "Iterations": 5, - "MinMs": 1.2926, - "MedianMs": 1.5479, - "MeanMs": 2.8080400000000005, - "P95Ms": 7.9678, - "MaxMs": 7.9678, - "ThroughputMPixPerSec": 169.35460947089604, - "GcAllocBytesPerOp": 425984, + "MinMs": 2.5259, + "MedianMs": 4.2426, + "MeanMs": 7.65308, + "P95Ms": 15.386500000000002, + "MaxMs": 15.386500000000002, + "ThroughputMPixPerSec": 61.78852590392683, + "GcAllocBytesPerOp": 425164, "OutputBytes": 1048576, "UncompressedBytes": 1048576, "RgbPsnrDb": 0.0, @@ -1153,13 +1153,13 @@ "Quality": "N/A", "WarmupRuns": 1, "Iterations": 5, - "MinMs": 0.3297, - "MedianMs": 0.6605000000000001, - "MeanMs": 0.6789400000000001, - "P95Ms": 0.9799, - "MaxMs": 0.9799, - "ThroughputMPixPerSec": 529.1824375473126, - "GcAllocBytesPerOp": 127795, + "MinMs": 0.5532, + "MedianMs": 0.8651000000000001, + "MeanMs": 1.1067, + "P95Ms": 2.2835, + "MaxMs": 2.2835, + "ThroughputMPixPerSec": 404.0284360189573, + "GcAllocBytesPerOp": 160563, "OutputBytes": 158536, "UncompressedBytes": 1398100, "RgbPsnrDb": 0.0, @@ -1172,10 +1172,10 @@ "native": [ { "SchemaVersion": "1.0", - "TimestampUtc": "2026-11-28T14:07:39.502223+00:00", - "GitCommit": "d3223a509836e324829635f6c8b2fe25f893104a", + "TimestampUtc": "2026-12-01T07:00:10.971858+00:00", + "GitCommit": "f1a9e0ec1efc61b3222fe4a25c0a953360ba37e7", "Platform": "Windows AMD64", - "CpuModel": "AMD EPYC 9V74 80-Core Processor", + "CpuModel": "AMD EPYC 7763 64-Core Processor", "CpuCores": 4, "ThreadsUsed": 4, "Results": [ @@ -1188,12 +1188,12 @@ "Quality": "Fast", "Threads": 4, "OutputBytes": 262144, - "MinMs": 58.763, - "MedianMs": 58.874, - "MeanMs": 61.089, - "P95Ms": 66.531, - "MaxMs": 66.531, - "ThroughputMPixPerSec": 4.453 + "MinMs": 78.358, + "MedianMs": 82.16, + "MeanMs": 84.268, + "P95Ms": 98.446, + "MaxMs": 98.446, + "ThroughputMPixPerSec": 3.191 }, { "Name": "Native_AVX2_512_ASTC_4x4_Medium_4T", @@ -1204,12 +1204,12 @@ "Quality": "Medium", "Threads": 4, "OutputBytes": 262144, - "MinMs": 180.323, - "MedianMs": 191.237, - "MeanMs": 187.208, - "P95Ms": 192.525, - "MaxMs": 192.525, - "ThroughputMPixPerSec": 1.371 + "MinMs": 235.639, + "MedianMs": 235.995, + "MeanMs": 241.251, + "P95Ms": 249.698, + "MaxMs": 249.698, + "ThroughputMPixPerSec": 1.111 }, { "Name": "Native_AVX2_512_ASTC_6x6_Fast_4T", @@ -1220,12 +1220,12 @@ "Quality": "Fast", "Threads": 4, "OutputBytes": 118336, - "MinMs": 39.971, - "MedianMs": 40.044, - "MeanMs": 40.107, - "P95Ms": 40.254, - "MaxMs": 40.254, - "ThroughputMPixPerSec": 6.546 + "MinMs": 52.198, + "MedianMs": 52.7, + "MeanMs": 55.033, + "P95Ms": 62.824, + "MaxMs": 62.824, + "ThroughputMPixPerSec": 4.974 }, { "Name": "Native_AVX2_512_ASTC_6x6_Medium_4T", @@ -1236,12 +1236,12 @@ "Quality": "Medium", "Threads": 4, "OutputBytes": 118336, - "MinMs": 172.891, - "MedianMs": 173.18, - "MeanMs": 175.842, - "P95Ms": 186.411, - "MaxMs": 186.411, - "ThroughputMPixPerSec": 1.514 + "MinMs": 224.335, + "MedianMs": 233.614, + "MeanMs": 232.684, + "P95Ms": 240.195, + "MaxMs": 240.195, + "ThroughputMPixPerSec": 1.122 }, { "Name": "Native_AVX2_512_ASTC_8x8_Fast_4T", @@ -1252,12 +1252,12 @@ "Quality": "Fast", "Threads": 4, "OutputBytes": 65536, - "MinMs": 31.294, - "MedianMs": 31.441, - "MeanMs": 33.507, - "P95Ms": 40.675, - "MaxMs": 40.675, - "ThroughputMPixPerSec": 8.338 + "MinMs": 40.614, + "MedianMs": 40.983, + "MeanMs": 43.513, + "P95Ms": 53.573, + "MaxMs": 53.573, + "ThroughputMPixPerSec": 6.396 }, { "Name": "Native_AVX2_512_ASTC_8x8_Medium_4T", @@ -1268,12 +1268,12 @@ "Quality": "Medium", "Threads": 4, "OutputBytes": 65536, - "MinMs": 87.35, - "MedianMs": 87.523, - "MeanMs": 89.625, - "P95Ms": 98.315, - "MaxMs": 98.315, - "ThroughputMPixPerSec": 2.995 + "MinMs": 112.724, + "MedianMs": 112.759, + "MeanMs": 115.552, + "P95Ms": 126.538, + "MaxMs": 126.538, + "ThroughputMPixPerSec": 2.325 }, { "Name": "Native_AVX2_512_ASTC_12x12_Fast_4T", @@ -1284,12 +1284,12 @@ "Quality": "Fast", "Threads": 4, "OutputBytes": 29584, - "MinMs": 69.794, - "MedianMs": 70.21, - "MeanMs": 70.842, - "P95Ms": 73.022, - "MaxMs": 73.022, - "ThroughputMPixPerSec": 3.734 + "MinMs": 89.888, + "MedianMs": 90.879, + "MeanMs": 93.132, + "P95Ms": 97.608, + "MaxMs": 97.608, + "ThroughputMPixPerSec": 2.885 }, { "Name": "Native_AVX2_512_ASTC_12x12_Medium_4T", @@ -1300,12 +1300,12 @@ "Quality": "Medium", "Threads": 4, "OutputBytes": 29584, - "MinMs": 297.921, - "MedianMs": 308.518, - "MeanMs": 305.041, - "P95Ms": 311.076, - "MaxMs": 311.076, - "ThroughputMPixPerSec": 0.85 + "MinMs": 424.558, + "MedianMs": 508.737, + "MeanMs": 486.409, + "P95Ms": 527.413, + "MaxMs": 527.413, + "ThroughputMPixPerSec": 0.515 }, { "Name": "Native_AVX2_Decompress_512_ASTC_6x6_4T", @@ -1316,12 +1316,12 @@ "Quality": "N/A", "Threads": 4, "OutputBytes": 1048576, - "MinMs": 1.244, - "MedianMs": 1.28, - "MeanMs": 1.293, - "P95Ms": 1.369, - "MaxMs": 1.369, - "ThroughputMPixPerSec": 204.848 + "MinMs": 2.337, + "MedianMs": 3.164, + "MeanMs": 3.794, + "P95Ms": 6.009, + "MaxMs": 6.009, + "ThroughputMPixPerSec": 82.839 }, { "Name": "Native_SSE4.1_512_ASTC_4x4_Fast_4T", @@ -1332,12 +1332,12 @@ "Quality": "Fast", "Threads": 4, "OutputBytes": 262144, - "MinMs": 64.665, - "MedianMs": 65.233, - "MeanMs": 66.888, - "P95Ms": 70.172, - "MaxMs": 70.172, - "ThroughputMPixPerSec": 4.019 + "MinMs": 99.161, + "MedianMs": 142.91, + "MeanMs": 139.091, + "P95Ms": 176.121, + "MaxMs": 176.121, + "ThroughputMPixPerSec": 1.834 }, { "Name": "Native_SSE4.1_512_ASTC_4x4_Medium_4T", @@ -1348,12 +1348,12 @@ "Quality": "Medium", "Threads": 4, "OutputBytes": 262144, - "MinMs": 193.89, - "MedianMs": 200.342, - "MeanMs": 199.998, - "P95Ms": 206.889, - "MaxMs": 206.889, - "ThroughputMPixPerSec": 1.308 + "MinMs": 310.356, + "MedianMs": 359.632, + "MeanMs": 354.1, + "P95Ms": 396.189, + "MaxMs": 396.189, + "ThroughputMPixPerSec": 0.729 }, { "Name": "Native_SSE4.1_512_ASTC_6x6_Fast_4T", @@ -1364,12 +1364,12 @@ "Quality": "Fast", "Threads": 4, "OutputBytes": 118336, - "MinMs": 43.821, - "MedianMs": 43.903, - "MeanMs": 43.978, - "P95Ms": 44.255, - "MaxMs": 44.255, - "ThroughputMPixPerSec": 5.971 + "MinMs": 67.682, + "MedianMs": 71.971, + "MeanMs": 74.948, + "P95Ms": 89.504, + "MaxMs": 89.504, + "ThroughputMPixPerSec": 3.642 }, { "Name": "Native_SSE4.1_512_ASTC_6x6_Medium_4T", @@ -1380,12 +1380,12 @@ "Quality": "Medium", "Threads": 4, "OutputBytes": 118336, - "MinMs": 180.349, - "MedianMs": 180.548, - "MeanMs": 183.347, - "P95Ms": 192.336, - "MaxMs": 192.336, - "ThroughputMPixPerSec": 1.452 + "MinMs": 222.747, + "MedianMs": 241.709, + "MeanMs": 252.99, + "P95Ms": 306.932, + "MaxMs": 306.932, + "ThroughputMPixPerSec": 1.085 }, { "Name": "Native_SSE4.1_512_ASTC_8x8_Fast_4T", @@ -1396,12 +1396,12 @@ "Quality": "Fast", "Threads": 4, "OutputBytes": 65536, - "MinMs": 33.927, - "MedianMs": 34.053, - "MeanMs": 36.386, - "P95Ms": 43.321, - "MaxMs": 43.321, - "ThroughputMPixPerSec": 7.698 + "MinMs": 41.275, + "MedianMs": 41.602, + "MeanMs": 41.924, + "P95Ms": 43.474, + "MaxMs": 43.474, + "ThroughputMPixPerSec": 6.301 }, { "Name": "Native_SSE4.1_512_ASTC_8x8_Medium_4T", @@ -1412,12 +1412,12 @@ "Quality": "Medium", "Threads": 4, "OutputBytes": 65536, - "MinMs": 92.349, - "MedianMs": 93.423, - "MeanMs": 95.138, - "P95Ms": 103.63, - "MaxMs": 103.63, - "ThroughputMPixPerSec": 2.806 + "MinMs": 108.112, + "MedianMs": 108.952, + "MeanMs": 111.505, + "P95Ms": 121.085, + "MaxMs": 121.085, + "ThroughputMPixPerSec": 2.406 }, { "Name": "Native_SSE4.1_512_ASTC_12x12_Fast_4T", @@ -1428,12 +1428,12 @@ "Quality": "Fast", "Threads": 4, "OutputBytes": 29584, - "MinMs": 69.488, - "MedianMs": 69.655, - "MeanMs": 71.951, - "P95Ms": 81.051, - "MaxMs": 81.051, - "ThroughputMPixPerSec": 3.763 + "MinMs": 81.954, + "MedianMs": 84.398, + "MeanMs": 84.05, + "P95Ms": 85.908, + "MaxMs": 85.908, + "ThroughputMPixPerSec": 3.106 }, { "Name": "Native_SSE4.1_512_ASTC_12x12_Medium_4T", @@ -1444,12 +1444,12 @@ "Quality": "Medium", "Threads": 4, "OutputBytes": 29584, - "MinMs": 283.726, - "MedianMs": 296.889, - "MeanMs": 294.053, - "P95Ms": 297.927, - "MaxMs": 297.927, - "ThroughputMPixPerSec": 0.883 + "MinMs": 325.157, + "MedianMs": 335.28, + "MeanMs": 334.055, + "P95Ms": 338.671, + "MaxMs": 338.671, + "ThroughputMPixPerSec": 0.782 }, { "Name": "Native_SSE4.1_Decompress_512_ASTC_6x6_4T", @@ -1460,19 +1460,19 @@ "Quality": "N/A", "Threads": 4, "OutputBytes": 1048576, - "MinMs": 1.843, - "MedianMs": 1.872, - "MeanMs": 1.883, - "P95Ms": 1.992, - "MaxMs": 1.992, - "ThroughputMPixPerSec": 140.042 + "MinMs": 2.461, + "MedianMs": 2.507, + "MeanMs": 2.513, + "P95Ms": 2.617, + "MaxMs": 2.617, + "ThroughputMPixPerSec": 104.548 } ] }, { "SchemaVersion": "1.0", - "TimestampUtc": "2026-11-28T14:07:36.824413+00:00", - "GitCommit": "d3223a509836e324829635f6c8b2fe25f893104a", + "TimestampUtc": "2026-12-01T07:00:13.841792+00:00", + "GitCommit": "f1a9e0ec1efc61b3222fe4a25c0a953360ba37e7", "Platform": "Darwin arm64", "CpuModel": "Apple M1 (Virtual)", "CpuCores": 3, @@ -1487,12 +1487,12 @@ "Quality": "Fast", "Threads": 3, "OutputBytes": 262144, - "MinMs": 61.302, - "MedianMs": 73.717, - "MeanMs": 73.585, - "P95Ms": 89.827, - "MaxMs": 89.827, - "ThroughputMPixPerSec": 3.556 + "MinMs": 71.951, + "MedianMs": 77.477, + "MeanMs": 79.106, + "P95Ms": 85.768, + "MaxMs": 85.768, + "ThroughputMPixPerSec": 3.383 }, { "Name": "Native_ARM64_NEON_512_ASTC_4x4_Medium_3T", @@ -1503,12 +1503,12 @@ "Quality": "Medium", "Threads": 3, "OutputBytes": 262144, - "MinMs": 155.975, - "MedianMs": 186.312, - "MeanMs": 199.06, - "P95Ms": 248.393, - "MaxMs": 248.393, - "ThroughputMPixPerSec": 1.407 + "MinMs": 226.929, + "MedianMs": 248.593, + "MeanMs": 279.667, + "P95Ms": 372.452, + "MaxMs": 372.452, + "ThroughputMPixPerSec": 1.055 }, { "Name": "Native_ARM64_NEON_512_ASTC_6x6_Fast_3T", @@ -1519,12 +1519,12 @@ "Quality": "Fast", "Threads": 3, "OutputBytes": 118336, - "MinMs": 34.399, - "MedianMs": 34.682, - "MeanMs": 34.722, - "P95Ms": 35.095, - "MaxMs": 35.095, - "ThroughputMPixPerSec": 7.559 + "MinMs": 57.832, + "MedianMs": 67.289, + "MeanMs": 66.198, + "P95Ms": 79.329, + "MaxMs": 79.329, + "ThroughputMPixPerSec": 3.896 }, { "Name": "Native_ARM64_NEON_512_ASTC_6x6_Medium_3T", @@ -1535,12 +1535,12 @@ "Quality": "Medium", "Threads": 3, "OutputBytes": 118336, - "MinMs": 144.503, - "MedianMs": 154.927, - "MeanMs": 162.468, - "P95Ms": 202.133, - "MaxMs": 202.133, - "ThroughputMPixPerSec": 1.692 + "MinMs": 194.875, + "MedianMs": 211.064, + "MeanMs": 211.037, + "P95Ms": 230.283, + "MaxMs": 230.283, + "ThroughputMPixPerSec": 1.242 }, { "Name": "Native_ARM64_NEON_512_ASTC_8x8_Fast_3T", @@ -1551,12 +1551,12 @@ "Quality": "Fast", "Threads": 3, "OutputBytes": 65536, - "MinMs": 27.69, - "MedianMs": 28.028, - "MeanMs": 28.125, - "P95Ms": 28.466, - "MaxMs": 28.466, - "ThroughputMPixPerSec": 9.353 + "MinMs": 30.314, + "MedianMs": 34.273, + "MeanMs": 33.778, + "P95Ms": 36.59, + "MaxMs": 36.59, + "ThroughputMPixPerSec": 7.649 }, { "Name": "Native_ARM64_NEON_512_ASTC_8x8_Medium_3T", @@ -1567,12 +1567,12 @@ "Quality": "Medium", "Threads": 3, "OutputBytes": 65536, - "MinMs": 71.271, - "MedianMs": 71.789, - "MeanMs": 76.23, - "P95Ms": 90.547, - "MaxMs": 90.547, - "ThroughputMPixPerSec": 3.652 + "MinMs": 83.565, + "MedianMs": 92.621, + "MeanMs": 92.583, + "P95Ms": 102.939, + "MaxMs": 102.939, + "ThroughputMPixPerSec": 2.83 }, { "Name": "Native_ARM64_NEON_512_ASTC_12x12_Fast_3T", @@ -1583,12 +1583,12 @@ "Quality": "Fast", "Threads": 3, "OutputBytes": 29584, - "MinMs": 54.552, - "MedianMs": 55.24, - "MeanMs": 55.734, - "P95Ms": 57.326, - "MaxMs": 57.326, - "ThroughputMPixPerSec": 4.746 + "MinMs": 71.175, + "MedianMs": 75.964, + "MeanMs": 77.73, + "P95Ms": 87.001, + "MaxMs": 87.001, + "ThroughputMPixPerSec": 3.451 }, { "Name": "Native_ARM64_NEON_512_ASTC_12x12_Medium_3T", @@ -1599,12 +1599,12 @@ "Quality": "Medium", "Threads": 3, "OutputBytes": 29584, - "MinMs": 198.911, - "MedianMs": 232.169, - "MeanMs": 223.726, - "P95Ms": 246.128, - "MaxMs": 246.128, - "ThroughputMPixPerSec": 1.129 + "MinMs": 300.572, + "MedianMs": 311.976, + "MeanMs": 318.973, + "P95Ms": 353.667, + "MaxMs": 353.667, + "ThroughputMPixPerSec": 0.84 }, { "Name": "Native_ARM64_NEON_Decompress_512_ASTC_6x6_3T", @@ -1615,19 +1615,19 @@ "Quality": "N/A", "Threads": 3, "OutputBytes": 1048576, - "MinMs": 1.378, - "MedianMs": 1.509, - "MeanMs": 1.587, - "P95Ms": 2.266, - "MaxMs": 2.266, - "ThroughputMPixPerSec": 173.768 + "MinMs": 2.196, + "MedianMs": 2.989, + "MeanMs": 3.056, + "P95Ms": 3.81, + "MaxMs": 3.81, + "ThroughputMPixPerSec": 87.689 } ] }, { "SchemaVersion": "1.0", - "TimestampUtc": "2026-11-28T14:07:47.359244+00:00", - "GitCommit": "d3223a509836e324829635f6c8b2fe25f893104a", + "TimestampUtc": "2026-12-01T07:00:15.024467+00:00", + "GitCommit": "f1a9e0ec1efc61b3222fe4a25c0a953360ba37e7", "Platform": "Linux x86_64", "CpuModel": "AMD EPYC 7763 64-Core Processor", "CpuCores": 4, @@ -1642,12 +1642,12 @@ "Quality": "Fast", "Threads": 4, "OutputBytes": 262144, - "MinMs": 73.24, - "MedianMs": 73.321, - "MeanMs": 73.386, - "P95Ms": 73.768, - "MaxMs": 73.768, - "ThroughputMPixPerSec": 3.575 + "MinMs": 73.463, + "MedianMs": 73.495, + "MeanMs": 73.508, + "P95Ms": 73.594, + "MaxMs": 73.594, + "ThroughputMPixPerSec": 3.567 }, { "Name": "Native_SSE4.1_512_ASTC_4x4_Medium_4T", @@ -1658,12 +1658,12 @@ "Quality": "Medium", "Threads": 4, "OutputBytes": 262144, - "MinMs": 220.288, - "MedianMs": 220.75, - "MeanMs": 221.086, - "P95Ms": 222.05, - "MaxMs": 222.05, - "ThroughputMPixPerSec": 1.188 + "MinMs": 220.768, + "MedianMs": 221.222, + "MeanMs": 221.259, + "P95Ms": 221.722, + "MaxMs": 221.722, + "ThroughputMPixPerSec": 1.185 }, { "Name": "Native_SSE4.1_512_ASTC_6x6_Fast_4T", @@ -1674,12 +1674,12 @@ "Quality": "Fast", "Threads": 4, "OutputBytes": 118336, - "MinMs": 49.998, - "MedianMs": 50.477, - "MeanMs": 50.47, - "P95Ms": 51.025, - "MaxMs": 51.025, - "ThroughputMPixPerSec": 5.193 + "MinMs": 50.372, + "MedianMs": 50.513, + "MeanMs": 50.722, + "P95Ms": 51.512, + "MaxMs": 51.512, + "ThroughputMPixPerSec": 5.19 }, { "Name": "Native_SSE4.1_512_ASTC_6x6_Medium_4T", @@ -1690,12 +1690,12 @@ "Quality": "Medium", "Threads": 4, "OutputBytes": 118336, - "MinMs": 196.728, - "MedianMs": 197.062, - "MeanMs": 198.472, - "P95Ms": 203.908, - "MaxMs": 203.908, - "ThroughputMPixPerSec": 1.33 + "MinMs": 197.5, + "MedianMs": 197.616, + "MeanMs": 197.783, + "P95Ms": 198.482, + "MaxMs": 198.482, + "ThroughputMPixPerSec": 1.327 }, { "Name": "Native_SSE4.1_512_ASTC_8x8_Fast_4T", @@ -1706,12 +1706,12 @@ "Quality": "Fast", "Threads": 4, "OutputBytes": 65536, - "MinMs": 37.801, - "MedianMs": 37.838, - "MeanMs": 37.865, - "P95Ms": 37.94, - "MaxMs": 37.94, - "ThroughputMPixPerSec": 6.928 + "MinMs": 38.087, + "MedianMs": 38.117, + "MeanMs": 38.153, + "P95Ms": 38.289, + "MaxMs": 38.289, + "ThroughputMPixPerSec": 6.877 }, { "Name": "Native_SSE4.1_512_ASTC_8x8_Medium_4T", @@ -1722,12 +1722,12 @@ "Quality": "Medium", "Threads": 4, "OutputBytes": 65536, - "MinMs": 98.531, - "MedianMs": 98.711, - "MeanMs": 98.964, - "P95Ms": 100.252, - "MaxMs": 100.252, - "ThroughputMPixPerSec": 2.656 + "MinMs": 98.811, + "MedianMs": 98.999, + "MeanMs": 99.442, + "P95Ms": 100.811, + "MaxMs": 100.811, + "ThroughputMPixPerSec": 2.648 }, { "Name": "Native_SSE4.1_512_ASTC_12x12_Fast_4T", @@ -1738,12 +1738,12 @@ "Quality": "Fast", "Threads": 4, "OutputBytes": 29584, - "MinMs": 74.945, - "MedianMs": 75.137, - "MeanMs": 75.161, - "P95Ms": 75.406, - "MaxMs": 75.406, - "ThroughputMPixPerSec": 3.489 + "MinMs": 75.583, + "MedianMs": 75.884, + "MeanMs": 75.849, + "P95Ms": 76.008, + "MaxMs": 76.008, + "ThroughputMPixPerSec": 3.455 }, { "Name": "Native_SSE4.1_512_ASTC_12x12_Medium_4T", @@ -1754,12 +1754,12 @@ "Quality": "Medium", "Threads": 4, "OutputBytes": 29584, - "MinMs": 298.122, - "MedianMs": 299.777, - "MeanMs": 299.545, - "P95Ms": 301.034, - "MaxMs": 301.034, - "ThroughputMPixPerSec": 0.874 + "MinMs": 299.593, + "MedianMs": 300.473, + "MeanMs": 300.931, + "P95Ms": 303.463, + "MaxMs": 303.463, + "ThroughputMPixPerSec": 0.872 }, { "Name": "Native_SSE4.1_Decompress_512_ASTC_6x6_4T", @@ -1770,12 +1770,12 @@ "Quality": "N/A", "Threads": 4, "OutputBytes": 1048576, - "MinMs": 2.146, - "MedianMs": 2.177, - "MeanMs": 2.176, - "P95Ms": 2.213, - "MaxMs": 2.213, - "ThroughputMPixPerSec": 120.441 + "MinMs": 2.16, + "MedianMs": 2.173, + "MeanMs": 2.19, + "P95Ms": 2.23, + "MaxMs": 2.23, + "ThroughputMPixPerSec": 120.644 } ] }