Skip to content

perf(gpu): 4x-6.7x faster compute shader compilation & zero shader warnings across all platforms - #8

Merged
Overflowu merged 9 commits into
masterfrom
develop
Dec 1, 2026
Merged

Overflowu merged 9 commits into
masterfrom
develop

Conversation

@Overflowu

Copy link
Copy Markdown
Owner

Summary

1. Compute Shader Compile-Time Optimization (4.3× – 6.7× faster cold builds)

  • Split & unified shader layout (55f7a45): Split monolithic encoder into 12 per-block LDR/HDR .compute files (4x4..12x12), unified output to RWTexture2D<uint4> + lightweight AstcGpuBufferCopy.compute (CopyTexToBuf), halving total encoder variants from 72 → 36 and removing invalid #pragma editor_sync_compilation.
  • Single-site HLSL inlining (1002145, 49e19ed, d61b617): Consolidated every heavy function in AstcGpuCore.hlsl & AstcGpuColor.hlsl to single inlined call sites (AstcQuantizeEndpoints 3→1, AstcFitSubsetEndpoints 2→1, AstcComputeWeightGrid1P/2P/Plane1 2→1, AstcEncodeBise 2→1, AstcQuantizeWeight 4→2, AstcComputeInfillTap 4→2 via ASTC_EVAL_INFILL_PAIR, and unified HDR 2-pass color quantization).
  • Indexable temp packing (49e19ed, 2512a13, eb2f3f8): Packed g_AstcGrid0/1/Uq + g_AstcBiseVals into a single uint4 g_AstcGrid[ASTC_MAX_GRID], g_AstcEpCodes/BestEpCodes into uint2, g_AstcHdrCodes/RawV/CandCodes/UqV into uint4 g_AstcHdrWork[6], and HDR g_AstcPackedBlock into uint4 pixel pairs — reducing mutable static arrays from 11 → 3 (LDR) / 4 (HDR) and completely eliminating warning X4714.

2. Zero Shader Warnings Across All 5 Platforms

  • Fixed AstcQuantizeWeight / AstcQuantizeColorRange / AstcUnquantizeColor / AstcPack5Trits / AstcPack3Quints / AstcEncodeBlock early-return & uninitialized variable warnings (100189e, 49e19ed).
  • Guarded ternary denominators in AstcComputeWeightGrid2P against compile-time division by zero.
  • Fixed single-iteration [loop] warnings in EncodeMed & HDR EncodeFast (2512a13) and removed unsupported #pragma editor_sync_compilation from AstcGpuMipGenerator.compute.
  • Verified 0 shader warnings across Win64 (D3D11), Linux64 (OpenGLCore + Vulkan), macOS (Metal), iOS (Metal), and Android (Vulkan + GLES3).

3. Editor & Sample Fixes

  • Encoder.CanCreateAstcTexture now consistently checks SystemInfo.IsFormatSupported even in the Editor (3a066d6), avoiding Texture creation failed / NullReferenceException on non-ASTC desktop Editors.
  • Kept Sample.cs minimal without KTX fallback (45e3379).

Cold Build Time Comparison (All 6 Block Sizes Separate, Zero Runtime Regression)

Platform v2.3.1 (72 variants) After Optimization (36 variants) Speedup
Win64 24m59s 5m01s – 5m47s 4.3× – 5.0×
iOS 37m18s 5m42s – 8m42s 4.3× – 6.5×
macOS 32m28s 7m02s – 7m10s 4.5× – 4.6×
Linux64 56m56s 8m29s – 8m36s 6.6× – 6.7×
Android 55m50s 8m57s – 11m25s 4.9× – 6.2×

Verification

@Overflowu
Overflowu merged commit 7841ed8 into master Dec 1, 2026
13 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant