perf(vk): lift 1% lows +48.5% (+95% Market) and speed up ASTC decode 5.3x on non-ASTC GPUs via LDS scratch and loop hoisting #2194
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2194
Loading…
Reference in a new issue
No description provided.
Delete branch "Jer9/Longshot:perf/vk-astc-shaders"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
On GPUs without native hardware ASTC decoding (targets non-ASTC GPUs: AMD RDNA 3.5 tested; NVIDIA Warp32, Intel Xe, and Linux RADV/ACO pending Test Farm; applies under both default
RX_VK_PRECOMPILE=1andRX_VK_PRECOMPILE=0), the Vulkan backend decodes ASTC textures on the GPU viagpu/vk/host_shaders/astc_decoder.comp. Decoding large ASTC texture arrays (such as the two1365x136590-layer terrain arrays in Kokiri Forest, totaling 447.2 Mpx across 6.99 million ASTC 8x8 blocks) stalled save loading for2.42 s(2,309 msof ASTC decode) and caused81 mstexture-upload spikes during 3-zone traversal, pulling Market 1% lows down to14.66 FPS.Profiling showed that
astc_decoder.compsuffered from severe private-memory spilling and redundant per-texel work:result_vector[64],color_values[32],endpoints0/1[4]) exceeded 512 bytes per thread, forcing shader compilers (including AMD LLPC) to spill local arrays to scratch memory and limiting SIMD occupancy.DecodeColorValueslinearly scannedencoding_valuesto find the ISE encoding range instead of binary-searching.color_endpoint_datawas declared without an initializer, causing uninitialized-register reads whenever a final trit/quint color block crossed a 32-bit word boundary pastcolor_data_bits(instead of the ASTC-spec-mandated zero bits).This change optimizes
gpu/vk/host_shaders/astc_decoder.compand regeneratesgpu/vk/host_shaders/astc_decoder_comp_spv.h:shared uint s_buf[16][65], 4,160 bytes per workgroup, bank-conflict-free stride, strict per-thread ownership with zero workgroup barriers) and scalar endpoints.DecodeColorValues.color_endpoint_datatouvec4(0u)before streaming color bits.Standalone on
main @ 9e10f6f7, GPU ASTC decoding is5.34xfaster on1365x1365x90terrain arrays (2,309.0 ms -> 432.0 ms),4.87xfaster across all slow ASTC uploads, cuts save-load max frame time by4.22x(2,422.83 ms -> 573.47 ms), and lifts 3-zone traversal 1% lows by+48.5%(21.71 -> 32.25 FPS; up to+95.4%in Market,14.66 -> 28.64 FPS) while cutting frames >= 50 ms by-78.1%(32 -> 7) with output bit-exact against the ASTC spec reference (one deliberate UB fix vs.main: initializingcolor_endpoint_data = uvec4(0u)).Read first:
gpu/vk/host_shaders/astc_decoder.comp,tests/test_astc_decoder_gpu.py, andtests/astc_decoder_gpu.cpp.Testing
Tested: Windows 11, AMD Radeon 860M (Adrenalin 26.10.1 LLPC),
handheld_profile=1(1600x1000,67%render scale,sharpness=80,vsync=0,amd_anti-lag_2=1,threaded_rendering=0).tests/test_astc_decoder_gpu.py+tests/astc_decoder_gpu.cpp(rebased ontomain @ a2dc5385, head28beeb4d): passes in default CPU-only mode (compile + SPIR-V header check + CPU reference across all 14 block sizes, asserting error blocks decode to zeros and all valid blocks decode non-zero) and in--gpumode on AMD Radeon 860M (28readback cases,22,680pixels covering all 14 ASTC block sizes4x4..12x12, odd image dimensions, linear and Switch 2 native tiling, 1–4 partitions, dual-plane across all 4 secondary channels, void-extent LDR, and error blocks;0mismatches againstTegra::Texture::ASTC::DecompressSerialwithin 0 tol for void-extent/error and<=1LSB forastc.cpp's65536vs Vulkan UNORM865535rounding).0mismatches across1,695,694decoded pixels covering all 14 ASTC block sizes (4x4..12x12), odd image dimensions, linear and Switch 2 native tiling, all 16 color endpoint modes (LDR and HDR), 1–4 partitions, dual-plane, void-extent, and error blocks (baseline differed frommainonly bycolor_endpoint_data = uvec4(0u)per ASTC spec); isolated1365x1365(1 layer, 20-iter avg) compute microbenchmark6.769 ms -> 1.095 ms(6.18x).0VK_ERROR_DEVICE_LOST, flat steady VRAM, and a zoomed Market Dev FPS counter side-by-side capture.RX_VK_SHOT_FX=1visual parity captures vsmainacross Kokiri Forest (PSNR 38.62 dB,MAE 1.11), Hyrule Field (PSNR 35.98 dB,MAE 2.46), and Market (PSNR 26.80 dB,MAE 5.85) — expected minor live time-of-day/NPC phase drift across independent runs, zero corruption or color artifacts.python -I scripts/shaders.py host --checkpasses (host shaders: 4 match) and all targeted checks pass on28beeb4d:tests/test_astc_decoder_gpu.py(CPU-only +--gpu),tests/test_vulkan_fixtures_ci.py,tests/test_host_shaders.py,tests/test_astc_upload_chunking.py,tests/test_bc_scratch_layers.py,tests/test_bc_copy_layer_pitch.py,tests/test_bc_small_scratch.py,tests/test_utf8_paths.py,tests/test_doc_anchors.py,tests/test_cpp_preflight.py, andscripts/check_third_party.py. Pre-existing / host caveats:tests/test_switch_table.pyfails identically onmain(RX_VK_GRASS_DISTANCEordering; this PR does not touchswitches.def), andtests/test_job_queue.pyis excluded on Windows shared consoles.Still to test:
RX_VK_ASTC_RGBA8=1path on Intel Xe SIMD16/32 by handMeasurements
Verdict: Standalone on
main @ 9e10f6f7, speeds up GPU ASTC1365x1365x90decoding by5.34x(2,309 -> 432 ms), cuts save-load max stall by4.22x(2,423 -> 573 ms), lifts 3-zone traversal 1% lows by+48.5%(21.71 -> 32.25 FPS; up to+95.4%in Market), and cuts frames >= 50 ms by-78.1%(32 -> 7) with output bit-exact against the ASTC spec reference (one deliberate UB fix vs.main: initializingcolor_endpoint_data = uvec4(0u)).Setup: Windows 11 (26200), AMD Ryzen AI 7 350, AMD Radeon 860M (RDNA 3.5, Adrenalin 26.10.1 LLPC);
handheld_profile=1(1600x1000,67%render scale,sharpness=80,vsync=0,amd_anti-lag_2=1,threaded_rendering=0),RX_VK_PRECOMPILE=0; Kokiri Forest save load (12 s settle) + 3-zone traversal (Kokiri Forest, Hyrule Field, Market), 3 interleaved unprofiled runs each, median[min, max].Rebase note: Branch is rebased onto
main @ a2dc5385(#2174simulated-turf floor +#1722castle-gate save); measurements below remain frommain @ 9e10f6f7because#2174did not affect ourKokiri Forest -> Hyrule Field -> Markettour (Hyrule Fieldmax_msonmain @ 9e10f6f7was30.94 / 71.01 / 72.49 ms,gt_50ms0 / 4 / 4, zero 250 ms turf stalls).9e10f6f7bb3fa08a1365x1365x90upload time (save load)uploads_mstex_lookup_msCold cache (1 run each, empty cache,
RX_VK_PRECOMPILE=0):1365x1365x90upload time:2,377.0 ms -> 472.0 ms(5.04xfaster)3,754.3 ms -> 756.4 ms(4.96xfaster)2,709.9 ms -> 2,268.0 ms(-441.9 ms)2,998 MB -> 3,062 MBIsolated GPU compute microbenchmark (
1365x1365, 1 layer, 20-iter avg):astc_decoder6.769 ms -> 1.095 ms(6.18x).Raw
longshot_log.txtlines (Round 1 save load and Round 1 traversal):Risks
astc_decoder.compis rewritten to useshared uint s_buf[16][65](4,160 bytes per workgroup, well below Vulkan's 16,384-byte guaranteed minimum, with strict per-thread column ownership0..63and no workgroup barriers across AMD Wave32/64, NVIDIA Warp32, and Intel Xe SIMD16/32) and diverges from the upstream Eden source it originated from (so future upstream syncs will need manual merging). Output is verified bit-exact across 1,695,694 decoded pixels covering all 14 block sizes and fixes an uninitializedcolor_endpoint_dataread onmain, though non-AMD compilers (NVIDIA, Intel, RADV/ACO) still need Tier 1 verification.RX_VK_ASTC_CPU=1) as a diagnostic fallback, and reverting the commit restores the previous shader cleanly.Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (scripts/shaders.py host --check,tests/test_astc_decoder_gpu.pyCPU-only +--gpu,tests/test_vulkan_fixtures_ci.py, and 8 targeted ASTC/BC/shader/preflight/repo checks pass on Windows;test_switch_table.pyfails identically onmain, andtest_job_queue.pyis excluded on Windows shared consoles).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.Tested in game: Windows 11 (26200), AMD Radeon 860M (Adrenalin 26.10.1 LLPC), handheld_profile=1 (1600x1000, 67%, sharpness=80), RX_VK_PRECOMPILE=0. Kokiri Forest save load (3 interleaved rounds): 1365x1365x90 ASTC upload 2,309 -> 432 ms (5.34x faster), max frame stall 2,423 -> 573 ms (4.22x faster), Load click to in-play 10.83 -> 8.55 s (-2.28 s / -21.0%), 0 device lost. 3-zone traversal (Kokiri Forest, Hyrule Field, Market, 3 interleaved rounds): aggregate 1% low 21.71 -> 32.25 FPS (+48.5%), Market 1% low 14.66 -> 28.64 FPS (+95.4%), >=50 ms frames 32 -> 7 (-78.1%), 0/1,695,694 pixel mismatches across all 14 ASTC block sizes, visual parity verified across all 3 zones, 0 device lost.
Possibly related, for context:
Independent test log on a second RDNA 3.5 system (courtesy of
nwgaton Discord):Setup: Windows 11 (
10.0.26300), AMD Ryzen AI 9 365, AMD Radeon 880M (Adrenalin26.11.2 LLPC),1920x1080,handheld_profile=1, FSR 4, VSync on,threaded_rendering=1, defaultRX_VK_LOAD=create(RX_VK_PRECOMPILE=1),KokiriForest_Child(82.5 ssession,pr-2194-bb3fa08a). For ASTC upload comparison on the same PC and identicallongshot_options.ini, the siblingpr-2193-e4ad718brun (74.7 s) uses unmodifiedmainastc_decoder.comp.ASTC upload & load-stall results on Radeon 880M:
astc_decoder.comp(pr-2193-e4ad718b)pr-2194-bb3fa08a)1365x1365x90ASTC→BC3 uploads1,031.0 + 1,040.8 ms)160.4 + 156.3 ms)vk: slow upload(count / sum)vk: status)slow submit 2,193.8 ms)slow submit 454.7 ms)uploads(Title/Kokiri)Kokiriupload / memsync hitchestexture_upload: 5,memsync: 5texture_upload: 3,memsync: 0-2/-5device_lost/program_failed/draws_left_out)0/0/00/0/0Note on tester's audio/stuttering report: The tester reported "had a really bad audio/stuttering on this one for some reason". Checking the perf report (
1795320425-0.json) andlongshot_log.txt, the stutter was CPU/vcore scheduling contention (game_cpu) rather than ASTC uploads or GPU stalls:Title and introscreen before gameplay ASTC decoding (game_cpu: 7vs.0,movie.decode_ms: 909.7 msvs.537.1 ms,movie.dropped: 168vs.106,slowest 230.6 msvs.62.3 ms).samples[33..38], ~34–39 s), FPS dipped to8–18 FPS(slowest 370.9 ms) whilegpu_mswas only149 ms / 1,008 ms, withgame_cpu: 10hitches (vs.4) and largevcoresOS waits (BaseProcExecutor4 longest 743.3 ms,Resource Memory 389.2 ms,nn.npln.Worker 180.7 ms,sead::MainThread 129.8 ms) plusvk: GPU timeclimbing from~20 msto25–33 ms— consistent with transient background host load or laptop APU power/thermal throttling during that run (this PR only changesgpu/vk/host_shaders/astc_decoder.comp). Re-testing on a second clean run or on the Test Farm is still welcome to double-check.Key lines from
longshot_log.txt(pr-2194-bb3fa08a):Side-by-side real-time wall-clock comparisons (
Before: main @ 9e10f6f7vsAfter: this PR @ bb3fa08a,HOS_HEADLESS=1,RX_VK_SHOT_MENU=1,RX_VK_PRECOMPILE=0):0.50 spre-roll before clicking Load; timer starts att = 0.00 son Load click):ASTC 1365x1365x90drops2,299 ms -> 389 ms, max stall2,563 ms -> 634 ms, and the Dev FPS counter's 10 s1% lowdrops2,843 ms -> 359 ms. (Note: the-6.15 sgap in this single capture also includes a2.58 sprogram-load hiccup onmain; across 3 unprofiled interleaved runs, Load click to in-play improved10.83 s -> 8.55 s,-2.28 s / -21.0%.)+95.4%unprofiled 1% low zone:14.66 -> 28.64 FPS,>=50 msframes16 -> 4): tightly cropped to the FPS /1% low/ 100 ms frame-time graph with dimmed background for comfortable viewing across the 30 s Market tour.The 1% low headline is measured against
9e10f6f7, not current maina2dc5385. The headbb3fa08ais based on9e10f6f7; current main has #2174 (8dce60ed), which removes Hyrule Field's 250 ms stalls on area entry — exactly what the 3-zone "before" 1% lows and the>=50 msframe counts include. The after at this head also lacks #2174. The ASTC decode/upload numbers are isolated and should hold, but the +48.5% aggregate, the Hyrule Field row and the frames >=50 ms delta are not a current-main comparison; rebase and re-measure those rows, or state the baseline is pre-#2174. The checklist's "on current main" is not true in substance."100% bit-exact" is against the spec reference, not main. The PR notes the baseline differs from main by
color_endpoint_data = uvec4(0u); that is the intentional fix of an uninitialized read. Say "bit-exact against the spec reference; one deliberate difference from main" so the TL;DR cannot be read as main-identical.The bit-exact decode verification is not in the repo.
tests/test_host_shaders.pyonly recompiles the SPIR-V; the ASTC tests cover upload/BC scratch, not decoded pixels. The 1,695,694-pixel verification is a standalone harness, so a later shader edit has no CI red. A small committed game-free decode fixture (all 14 block sizes, odd sizes, dual-plane, error blocks) would pin the claim."All desktop and laptop AMD, NVIDIA, Intel" is not yet evidenced. Only AMD RDNA 3.5 (860M, plus the 880M comment) ran; NVIDIA Warp32, Intel Xe SIMD16/32, RADV/ACO and Linux are still to test. The
shared uint s_buf[16][65]shape reads correctly: 64 invocations, columns 0..63, 4,160 B, per-thread ownership and no cross-thread barrier;result_indexmax 64 lands in row 15. But the player-facing "Players on … AMD, NVIDIA, Intel" should be "AMD tested; other compilers pending" until those runs.The independent 880M "stock" is
pr-2193-e4ad718b, not main. The shader is unmodified main, but the rest of #2193 can affect upload/queue timing; the 6.54x/7.81x is a sibling-PR comparison, not a second main comparison. Keep the primary main table as the main claim.No new switch; the path is on for every non-ASTC GPU, with
RX_VK_ASTC_CPU=1only as a slower diagnostic and reverting as the fallback. No approval, no fix claim.bb3fa08ad73dd1f448a7Thanks for the review @dazemc! I've rebased onto
main @ a2dc5385and addressed each point in3dd1f448:tests/test_astc_decoder_gpu.py+tests/astc_decoder_gpu.cpp):tests/test_vulkan_copy_span.pypattern (RUN_ALL_ARGS = ["--cxx", "{cxx}", "--headers", "{vulkan_headers}"]), leavingtests/test_vulkan_fixtures_ci.pyuntouched and passing (11/11 OK).gpu/vk/host_shaders/astc_decoder_comp_spv.handgpu/third_party/suyu/video_core/textures/astc.cpp, validates the embedded SPIR-V header, and runs the CPU ASTC reference across all 14 block sizes.--gpu/--gpu-device <substr>dispatches the real compiledASTC_DECODER_COMP_SPVcompute shader on Vulkan across all 14 ASTC block sizes (4x4..12x12), odd image dimensions, linear and Switch 2 native tiling, 1–4 partitions, dual-plane (all 4 secondary channels), void-extent LDR, and error blocks (28readback cases,22,680pixels), comparing againstTegra::Texture::ASTC::DecompressSerial(0tolerance on replicated-byte void-extent and error blocks;<= 1LSB on interpolated LDR to account forastc.cpp's255 * C / 65536vs VulkanR8G8B8A8_UNORM'sC / 65535rounding). Verified passing on AMD Radeon 860M in both default and--gpumodes, alongsidescripts/shaders.py host --check(host shaders: 4 match) and the existing ASTC/BC/shader tests."100% bit-exact"in Summary and Verdict with"bit-exact against the ASTC spec reference (one deliberate UB fix vs. main: initializing color_endpoint_data = uvec4(0u))"."targets non-ASTC GPUs (AMD RDNA 3.5 tested; NVIDIA Warp32, Intel Xe, and Linux RADV/ACO pending Test Farm)".main @ 9e10f6f7numbers still hold onmain @ a2dc5385(#2174did not affect ourKokiri Forest -> Hyrule Field -> Markettour: Hyrule Fieldmax_msonmain @ 9e10f6f7was30.94 / 71.01 / 72.49 ms,gt_50ms0 / 4 / 4, zero 250 ms turf stalls).Before: main @ 9e10f6f7table in the PR description remains the primary claim.3dd1f448a728beeb4d71Tested in game: Linux (CachyOS, kernel 7.3), RTX 3090 24 GB, NVIDIA proprietary driver, Ryzen 9 7900X. Headless through the job queue (timing mode), Render resolution fixed at 67 %, uncapped (
HOS_FPS_MAX=1000), V-Sync off, default settings otherwise (RX_VK_PRECOMPILEunset).Verdict: the terrain arrays decode about 1.6x faster on this card, with nothing worse and no corruption seen; the frame-time effect here is small (a fast desktop GPU), as expected. This PR @
bb3fa08aagainstmain@9e10f6f7(its merge base), the same base and pack layer, interleaved main / PR rounds after a warm-up run of the PR's runtime. The PR's first measured run is left out: its pipeline cache was still cold (62k draws left out in Market, the same on #2193's runtime, which shares nothing with this change).Routine:
kokiri-startsave, 12 s settle, teleport to Kokiri Forest, Market and Hyrule Field with a 10 s camera spin in each, back to Kokiri Forest, then three pause menus (PLUS, 4 s, PLUS, 5 s measured).9e10f6f7(3 runs)slow uploadms (both together)mainand 42–58 ms here. On the 860M of the description they were 2.3 s; a 3090 decodes them fast enough that the save-load stall it removes there is barely there to begin with, so the frame-time rows are mostly within the spread (p99 and frames >= 50 ms lean the PR's way).mainincluded, shows one or two isolatedslow uploadof ~730 ms (and once 2.2 s on this PR) for a single small ASTC texture; they come and go between runs of the same build, so I don't count them for or against this change.main(the camera spin leaves different angles, so no pixel comparison). Not attached (the game's frames).Not tested here: AMD (RADV), Intel, the 860M's own numbers.
@Beanstalk
Beanstalk test farm · 🔄 testing (0 of 1 report so far)
Commit
28beeb4· approved by HumanBean (reviewed) · dashboard⚠️ Note: The farm plan does not run the game-free ASTC reference fixture or isolate individual decode/upload timings; the load and frame metrics are indirect measures.
⚠️ Note: Picture differences can include animation or time-of-day drift, and the intentional decoder initialization fix may also differ from main.
Done (started 16:17 UTC). Comment
@Beanstalkto run it again.anyWhat was tested
What will be tested · AI plan (
gpt-6.1-terra)Compare the PR with main during a Kokiri Forest, Hyrule Field and Market tour, including the Kokiri save load, in about 30 minutes per tester. The plan measures load time, whole-run hitches and 1% low frame times, and compares pictures for texture corruption. Crashes, device loss, substantial visual differences or regressions beyond the performance limits fail the plan.
kokiri-start, then teleport to Kokiri Forest, take the picture kokiri to compare with main, measure kokiri for 10 s (after 2 s warm-up), teleport to Hyrule Field, take the picture field to compare with main, measure field for 10 s (after 2 s warm-up), teleport to Market, take the picture market to compare with main, measure market for 10 s (after 2 s warm-up); 3 runs on each side.Recommendation: Wait (on the Beanstalk run in progress and one Tier 1 RADV run, Steam Deck or RX 6000+). The rewrite reads correct against the old shader everywhere I checked, and its gain is real and large on AMD APUs and visible on an RTX 3090. Mesa's ACO is a different compiler from the two this has run on, and Tier 1 hardware is tested before merge. I would approve once those runs are clean; there is nothing in the code to change first.
For players on GPUs without hardware ASTC (every desktop GPU), the ASTC decode shader stops spilling its scratch arrays to VRAM. Large terrain arrays decode several times faster, so save loads stall less and texture-heavy areas have fewer upload hitches. The code gets better: the same algorithm with block-invariant work hoisted, a direct-grid fast path, and one real uninitialised read fixed. It adds no switch and no new path.
Does it help: Yes.
9e10f6f7): the two 1365x1365x90 arrays decode in 432 ms instead of 2,309 ms. The spreads don't overlap ([338, 451] against [2,306, 2,525]). Save-load max frame time goes from 2,423 to 573 ms. Traversal 1% lows go from 21.71 to 32.25 fps, with non-overlapping spreads ([13.2, 26.5] against [29.0, 34.0]), and frames of 50 ms or more drop from 32 to 7.The base is pre-#2174. That doesn't touch the decode numbers, which are the claim this change rests on.
Other systems:
RX_VK_ASTC_CPU=1CPU path is untouched. The BC re-encode downstream reads the same RGBA. VRAM is unchanged (the scratch is on-chip shared memory). The build is unchanged (the SPIR-V is prebuilt). The only one-off cost is a driver pipeline compile of the new SPIR-V.Switches: none.
Reviewed: head
28beeb4dagainst its merge basea2dc5385. The shader commit108d98b0is identical to the earlier headbb3fa08aapart from the rebase (git diff bb3fa08a 108d98b0only shows main's own changes).gpu/vk/host_shaders/astc_decoder.comp, compared function by function with the old file;tests/test_astc_decoder_gpu.py.tests/astc_decoder_gpu.cpp(block builders, CPU-only mode, GPU compare loop, loader use).astc_decoder_comp_spv.h(its opening comment and its format only, not the words).Fixed in this review: nothing.
Checked and fine:
local_sizeis 8x8x1, and both dispatch sites invk_texture.cppuse(n + 7) / 8. Sogl_LocalInvocationIndexis 0..63, under the 65 columns.result_indexis capped atresult_vector_max_index, which is at most 64 for weights andmin(32, n)for colours.EmitByteonly writes rows 0..15.FlushBytesonly writes on a partial word, soresult_index == 64never touches row 16.maxComputeSharedMemorySize.barrier(), the earlyreturns inmainare legal, and wave or subgroup size (Intel SIMD8/16/32, AMD wave32/64, NVIDIA 32) can't change the result. The stride of 65 keeps one row's 64 lanes on distinct banks.num_valuesentries and all are emitted. Weight reads are belownum_weight_vals, with the dual-plane2*idx+1under2*area, and the scaled-grid reads are guarded by< areaas before. A new word startspack_wordfrom zero.GetBitLength(n, i)is non-decreasing inifor everyn: the table interleaves J(k+1) ≤ T(k) ≤ J(k+2) ≤ Q(k) ≤ T(k+1), and the ceil terms keep that order. Index 0 (0 bits) always fits,hi = 21is the last index, andmid = (lo + hi + 1) >> 1ends.gs/gtmaths givesfs = ft = 0andjs = sfor all 14 block widths. I worked it out for 4, 5, 6, 8, 10 and 12:Ds*(b-1)is between 1022 and 1026, so the error stays inside the +32 rounding. That makes it bit-identical to the bilinear path. It is only taken when the area is 64 or less.canddare zeroed for fewer than 3 or 4 partitions as before, and the select order is unchanged.sec_chan = (plane_index + 1) & 3on the(a, r, g, b)endpoint layout, the same as before. Plane weights are interleaved as before.any_hdr, the endpoints stay raw andEvalHDRTexelshifts them by 4. LDR partitions in a mixed block still go throughReplicateByteTo16. The CEM 14 alpha uses* 0x101as before.max_x/max_yclip edge blocks just asStoreTexeldid, so the RX 6750 XT out-of-bounds fix is kept.weight_bitsbits, like the old byte-clearing loop, including at 32, 64 and 96.color_endpoint_data = uvec4(0u): a real fix. The old private global had no initialiser, and the trit/quint reader can read one word pastcolor_data_bits./ 65535.0freplaced by* (1/65535.0f): this can move the float by one ulp, which can't flip a UNORM8 rounding (C/257 is never within 0.002 of a .5). Most drivers fold the division that way anyway.scripts/shaders.py host. CI'stests/test_host_shaders.pyrecompiles it with the pinned glslang 16.6.0 on Linux and compares the SPIR-V, so a stale header goes red there. That job is pending on this head.--gpu, and writes only to a temporary folder.Suggestions (the author may take or leave)
gpu/vk/host_shaders/astc_decoder.comp:77:s_buf's 64 columns depend onlocal_size8x8 in another line of the file. Name it once, for example#define WG_SIZE 64uwithshared uint s_buf[16][WG_SIZE + 1u]. Then a later change to the workgroup size can't overrun the columns silently.tests/test_astc_decoder_gpu.py:4: the default (CI) mode checks the SPIR-V magic number and runs suyu's CPUastc.cpp. It never runs this shader, so a later shader edit that breaks decoding still passes CI; only--gpuchecks the PR's code. Say that in the docstring and the description ("CI checks the reference; run--gpuafter editing the shader"), or add it where a GPU runner exists.tests/astc_decoder_gpu.cpp:122: the comment aboveencode_block_mode(lines 122–145) is a draft of the author's reasoning ("wait", "Let's check exact bits!", and contradictory layouts). Replace it with the two layouts the function actually uses.gpu/vk/host_shaders/astc_decoder_comp_spv.h:11: the provenance comment lists the Eden and Eglantine authors. Add that Longshot reworked it here (#2194: LDS scratch, hoisting), since a future upstream sync has to merge by hand.any_hdrsplit.Testing:
--gpufixture on the 860M.28beeb4d.Overlaps and merge order: none found.
@ -75,0 +74,4 @@// Wave32/Wave64 access) instead of dynamically-indexed private arrays that spill to VRAM scratch.// Phase 1 holds <=32 decoded color values (0..255); Phase 2 holds <=64 unquantized weights (0..64).// Each invocation accesses only its own column [tid], so no workgroup barrier() is needed.shared uint s_buf[16][65];Correct as it stands: local_size 8x8x1 gives tids 0..63 under 65 columns, and rows stay 0..15. But the 64 columns rely on local_size in another line. Naming it once, e.g.
#define WG_SIZE 64uandshared uint s_buf[16][WG_SIZE + 1u], keeps a later workgroup-size change from overrunning them silently.@ -0,0 +119,4 @@}// Encode a valid ASTC block mode using Table C.2.8 layout 0:// bits [1:0]=00, [3:2]=B (weight_h-2), [4]=R0, [6:5]=A (weight_w-4), [8:7]=R2:R1, [9]=H, [10]=D.Nit: lines 122-145 are a draft of the reasoning ("wait", "Let's check exact bits!", contradictory layouts). Replace them with the two layouts the function actually uses (layout 0 and layout 4).
@ -0,0 +1,90 @@# SPDX-License-Identifier: GPL-3.0-or-later"""Game-free Vulkan ASTC decoder verification against Longshot's CPU ASTC reference.Default mode (used by run_all.py, no GPU or Vulkan loader required):The default (CI) mode checks the SPIR-V magic number and runs suyu's CPU astc.cpp; it never runs this shader. A later shader edit that breaks decoding still passes CI, and only --gpu checks it. Worth saying in the docstring and the PR description.