astc_decode (ctest) checks the CPU decoder on void-extent blocks (the color in both decode modes, the
reserved bits, HDR void extents and empty extents), and on Amberlith's illegal block and HDR partition block
against its reference decoder's texels.
astc_blocks (ctest) holds the CPU decoder to single blocks from rEden's decoder tests, texel for texel: an
illegal block at each error exit, HDR partitions, color data cut short inside a trit or quint group under every
value of the unallocated bits, the color value limits, void extents with their bounds in and out of order, and
astcenc's blocks.
astc_glsl (ctest, no GPU) runs astc_decode.glsl on the CPU through glsl.hpp, compiled as C++, and
compares it byte for byte with the CPU decoder: all 14 footprints in both decode modes, random blocks through all
2048 block modes, sizes that are not a multiple of the footprint, strips of several slices, and all 7 tile
shapes. Each invocation of a workgroup runs on a thread of its own and they meet at a std::barrier, so a race
on the tile is a race in the test: built with -fsanitize=thread it reports none, and reports the race when the
barrier is taken out. It also checks the
shader's Unorm16To8 for every input and the layer's built-ins against values from the GLSL specification.
astc_vulkan and astc_vulkan_pieces (ctest with -DSNX_TEST_VULKAN=ON) build tests/astc_vulkan.c with the
production vk/astc.c, vk/cmd.c and vk/memory.c, vk/devmem.c, volk and the SPIR-V the build makes, and compare raw image
readbacks with the CPU decoder byte for byte. They cover all 14 footprints with UNORM and SRGB images, each against
the CPU decoder in its decode mode, and decode the same blocks in both modes for every footprint, checking that
alpha is the same, that R, G and B differ by at most one step, and that some do. They also cover images whose size
is not a multiple of the block size, dispatch padding, five mip levels down to 1x1, six layers, 3D slices batched
into strips, scratch chunking, frame reuse and staging ring growth. astc_vulkan_pieces runs it under a 4 MiB
allocation cap, so the bigger images are bound in pieces and read back in bands. astc_vulkan_sync runs it under
the validation layer with its synchronization checks (VK_LAYER_VALIDATE_SYNC=1), an error each a failure: a
hazard there is a wrong result on a driver that runs commands abreast. It is skipped where the layer isn't installed.
No game files or window are needed:
cmake -B build -DSNX_TEST_VULKAN=ON && cmake --build build --target snx-test-astc-vulkan
VK_DRIVER_FILES=/usr/share/vulkan/icd.d/lvp_icd.x86_64.json ctest --test-dir build -R astc_vulkan
Without the validation layer installed, the "zero validation errors" line only means that nothing reported an
error. build/src/nx/snx-test-astc-vulkan --large decodes a 2D texture of 11584x11584 (4x4 blocks) and a 3D one of
512^3 (8x8 blocks), 512 MiB each, past the 256 MiB cap, and compares every byte.
build/src/nx/snx-test-astc-vulkan --bench [file.astc] times a 4096x4096 level and a 2040x2040 one as RGBA8 and
as BC7, in milliseconds, texels and BC7 blocks a second, of random 8x8 blocks or a file's (astcenc's .astc)
repeated over the level: the encoder's time depends on what it encodes, and random blocks are no game's.
astc_bc7_glsl (ctest, no GPU) runs astc_bc7.comp's body on the CPU and holds its blocks, byte for byte, to the
encoder's (bc7_cpu.cpp) over the texels the CPU's ASTC decoder makes of the same blocks, which is what the two
dispatches wrote: all 14 footprints in both decode modes, each of the encoder's builds, random blocks through all
2048 block modes, sizes on no block of either kind, strips of several slices, the two passes of the full and the
fast build (the same blocks, some of them the second pass's), a texture's whole levels in one strip (each level's
blocks those of the level on its own: square, sides on no block, layers, a volume, each build), and the division by
the footprint for every footprint and coordinate. snx-test-astc-bc7-glsl --measure file.astc... gives the PSNR and
the modes of each build on a game's own blocks (astc_dump=DIR keeps the levels a game loads as such files).
bc7_glsl (ctest, no GPU) runs bc7_encode.glsl on the CPU (tests/glsl/bc7_cpu.cpp, which gives it pictures
through tests/glsl/bc7_main.inc, as no shader encodes texels any more) and decodes its blocks
with the CPU reference, tests/support/bcn.c: the encoder's 16 weights are the format's, its least squares fit
gives a line's ends back and a constant alpha its value in every subset of every partition, blocks of one colour,
blocks that lie on a line mode 6 holds and blocks each other mode holds (modes 4 and 5 in each rotation and index
selection) come back exact, blocks with one channel apart come back closer than the same encoder built without
modes 4 and 5 brings them (SNX_BC7_MODES_4_5 0, bc7_encode_cpu_without_45), Amberlith's astcimage picture comes
back no worse than the PSNR each region is held to (the fast build, mode 6 alone and the quick build,
bc7_encode_cpu_quick, to theirs, the fast build keeping mode 6 on more blocks than the full one, mode 6 alone and
the quick build on all), and a 13x7 image of three slices encodes slice
by slice as each alone.
astc_vulkan and astc_vulkan_pieces also upload random blocks into BC7 images, footprints whose strips step
4, 2 and 1 block rows, with mips, layers, slices and many strips, and compare the GPU's blocks with the same
encoder run on the CPU over the CPU decoder's texels, byte for byte, in the build the level takes (vk_bc7_build).
They do it also for arrays whose layers go up a level at a time, all of them at once (vk_astc_upload_layers), as
RGBA8 and as BC7.
astc_kind (ctest, no GPU) holds gpu/texture/astc_kind.h to the CPU decoder: 168,000 random blocks of every
block mode, partition count and endpoint mode, and 42,000 of RGB and RGBA modes whose values make grey ends or
ends a level or two apart, all 14 footprints, both decode modes: a block said to have no colour decodes grey within
two levels in every texel (these come to one), each RGB or RGBA partition's endpoints as far apart as the decoder's
own (tests/support/astc.c's astc_block_endpoints), RGBA direct with G a level over R luminance and alpha and with
G 2 levels over R colour, one said to have no alpha opaque, one said to be colour on one line no more than 1.6
(squared) off one, and only blocks the decoder makes all the error colour are taken for it. Each format comes from
at least 500 of them. Then a level's kind read through block linear layouts (GOB blocks of several heights and
depths, padding columns, slices) and pitch rows, the padding blocks of the error colour left out, a coloured block
found wherever it is, a layout a byte short refused; the ISE's bit counts and the colour values' encoding against the
specification's search; and the format each of the 16 kinds takes in each decode mode.
astc_kind_glsl (ctest, no GPU) runs astc_kind.comp's body on the CPU. Each block's kind is
snx_astc_block_kind's at every footprint in both decode modes, on random blocks (one in two of one LDR endpoint
mode), every block mode with void extents valid and not, runs of one colour, void extents of random colours, RGBA
direct blocks whose ends lie up to 3 levels apart and base and offset blocks whose ends the decoders clamp at white.
Then levels of mostly one kind with blocks of others among them, pitch and block linear, a few layers a dispatch,
their memory cut short of their blocks one time in four: the workgroups' first blocks give snx_astc_level_kind's
kind, its early stop too.
astc_bcn_glsl (ctest, no GPU) runs astc_bcn.comp's body on the CPU over levels of random blocks of each kind at
every footprint, decodes its blocks (tests/support/bcn.c) as the view gives them back and holds the loss against
the CPU decoder's texels to the floors measured (the table above), BC1's blocks to four colours; a block of one value
or colour comes back exact as BC4 and BC5, within a level as BC1. --measure gives the table's columns.
astc_vulkan and astc_vulkan_pieces upload random blocks straight into BC1, BC4 and BC5 images (BC1 in sRGB
too), the strips BC7's take, with mips, layers and many strips, and hold the GPU's blocks to the CPU's, byte for
byte; --bench times them beside RGBA8 and BC7. vulkan_headless's check_astc_kind (SNX_TEST_ASTC_KIND_ONLY=1
runs it alone) makes 128x96 ASTC 8x8 textures of luminance, of luminance and alpha, of colour on one line, of sRGB
luminance and of RGBA direct blocks with grey ends under Auto, checks each is made RGBA8 (Exact with room) with its
blocks kept and its kind to come, then held as BC4, BC5, BC1, sRGB BC1 or BC5 once its kind is back, its blocks let
go (the same RGBA blocks with ends apart stay RGBA8, their Exact twin's texels), its image as the
view gives it back within the floors of its Exact twin, and the view's components for two of the header's
swizzles; then loads one BC4 texture again with blocks of luminance and alpha (BC5), and writes one block of colour
and alpha over it (loaded whole, RGBA8, its Exact twin's texels exactly).
tex_upload_rows checks what texture.c hands vk_astc_upload: an ASTC level's block rows, strip by strip,
against the block-linear layout walked byte by byte, and the bands other formats take past the cap. It also checks
the BC7 cache's key: made only where vk_astc_cached says, the same for the same bytes, another for a byte of any
layer changed, none where the GPU holds bytes, and kept in the texture for the encoder between frames.
bc7_cache (ctest, no GPU) checks bc7_cache.c: the key changes with each field of the level, its build, every bit
of its bytes and every word of its layout; blocks come back as stored while the cache holds them, and a new cache
holds none; past its bound the levels used most stay, none goes that the last two presents used, and the counts
halve with time; a low memory word frees what no recent present used; a hit queued for the recording thread is
copied from blocks that are still there however the level left; the bound follows the machine's memory; and a
file an earlier version left is said and kept.
astc_vulkan and astc_vulkan_pieces upload a level into a new BC7 image three times with the cache's key: strips
of 4, 2 and 1 block rows, layers, slices and many strips. The first encodes; the second and the third
encode nothing (vk_astc_stats counts the levels and the hits, vk_astc_dispatches the
encoder's dispatches) and their bytes are the first's; a changed block misses; and 100 encodes in one submission
are all stored. vulkan_headless (tests/vulkan_astc_later.inc) stores the levels the encoder makes between frames
and gives them to a second texture of the same bytes in its first frame, with no encode.
vulkan_headless's check_resident_astc and check_resident_astc_stacks make ASTC textures with holes in their
mapping through NVN's sparse layout, held as BC7, against the same texture made whole: 4x4 and 8x8 ones bound a
tile at a time, the 8x8 one in stacks, with memory for the device's blocks under their mapped tiles alone as tiles
are mapped and unmapped; a 16384x16384 8x8 one, 341 MiB made whole, with 896 KiB bound for two tiles of level 0,
level 5 and its mip tail; and an 8x5 one bound by the device's blocks (tex_bind), which binds its mip tail
whatever is mapped. Each holds the texels made whole where memory maps them and zeros elsewhere
(SNX_TEST_RESIDENT_ASTC_ONLY=1 runs them alone). Where the device binds no BC7 image a tile or a block at a time
with what isn't bound reading as zeros (lavapipe), they say so and are skipped.
Made from docs/layers/gpu/astc.md at 69237645142c. GPL-3.0-or-later.