diff --git a/docs/experiments.md b/docs/experiments.md index 85111b13b9..6c30d84af6 100644 --- a/docs/experiments.md +++ b/docs/experiments.md @@ -16589,7 +16589,7 @@ ctest --preset release --no-tests=error --output-on-failure -j 1 -R '^startup_ad #### Volumes in the 4 KiB standard layout -Slot 70 also reads a single-mip, uncompressed 3D texture whose layout is `0x105`. addrlib lays it +Slot 70 also reads an uncompressed 3D texture whose layout is `0x105`, at first a single mip. addrlib lays it out in thick 4 KiB blocks (`GFX10_SW_4K_S3_PATINFO`). `startup_gfx10_volume` needs no device. It checks the address bit of every x, y and z bit against the restated one-pipe rows for the five element sizes, the block sizes, and the order of blocks in a 17 by 17 by 17 RGBA8 volume. It also checks that @@ -16613,6 +16613,26 @@ Two local mutations were run once and are not registered tests: the layer pitch to zero, and the hold counting one footprint per layer. Each fails `startup_address_console_warp`: the first on the first volume's pixels, the second on the held volume. +Volumes with a mip chain are read too. Each layer of blocks holds that layer of every mip: the tail +block first, then the mips from the smallest to the largest. A mip at most a block wide and half a +block high goes in the tail while at most five mips remain, at an origin read from its byte offset +in the tail block. `startup_gfx10_volume` checks the addresses of a 32 by 32 by 32 RGBA8 volume with +six mips: 11 blocks to a layer, mip 1 after the tail block, mip 0 after mip 1, and mips 2 to 5 at +(0,8), (4,4), (4,0) and (0,4) in the tail block. It also checks the distinct bytes and tile/detile +round trips of every mip of ten chains (a tail from mip 0, a chain with no tail, odd sides, a deep +volume whose depth allows the mip count), and the mip chains slot 70 takes and the views of them it +allows. `startup_gfx10_volume_tail_control` puts every tail mip at the start of the tail block and +must fail. `startup_gfx10_volume_addrlib` now also compares every mip count of four chains for each +element size: 305 volumes and 12,704,487 element addresses with 0 mismatches. + +`startup_address_console_{warp,hardware}` draws four mips of two chains, RGBA8 32 by 32 by 32 with +six mips (mip 1, and mip 3 in the tail) and 20 by 24 by 16 with five mips (mip 1, and mip 3 in the +tail), from a backing that holds every mip with its own texels. All 65,536 pixels of each must match. +A local mutation that drops the tail origins of a volume, run once, fails it on the first tail mip, +which then reads another mip's texels. A chain whose layout runs past the size the XG stand-in +reports is held as before: RGBA8 33 by 9 by 18 with six mips takes 135,168 bytes in the layout against +65,536 reported. + ```powershell ctest --preset release --no-tests=error --output-on-failure -R '^startup_gfx10_volume' ctest --preset release --no-tests=error --output-on-failure -j 1 -R '^startup_address_console_(hardware|warp)$' diff --git a/docs/startup-runtime.md b/docs/startup-runtime.md index ed27d52db1..b5e2e009fd 100644 --- a/docs/startup-runtime.md +++ b/docs/startup-runtime.md @@ -3565,17 +3565,23 @@ no target, depth or unordered-access flag, and a format with a known element siz texels and BC1 to BC7, whose largest mip must then be whole 4x4 blocks). The view must use a supported typed format that matches the storage format or belongs to its typeless parent. The 1D, 2D or 2D-array view must match the texture's dimension and fit the mip and slice ranges. A cube view is taken on a 2D array of exactly six slices (the faces, +X to -Z) and is bound where a translation's manifest declares `texcube`; `tools/startup/gfx2hlsl.py` does not emit that kind yet, because it refuses `dim:SQ_RSRC_IMG_CUBE`. A mismatched or interior view overlapping a live resource preserves the destination descriptor. -A three-dimensional description is taken in one layout only: `0x105` (4 KiB standard), one mip, one -sample, at most 2048 texels on each side and an uncompressed format with a known element size, -viewed as a Texture3D. addrlib lays a 3D resource in a standard or display mode out in thick blocks +A three-dimensional description is taken in one layout only: `0x105` (4 KiB standard), one sample, +at most 2048 texels on each side and an uncompressed format with a known element size, with one mip +or a mip chain its largest side (depth included) allows, viewed as a Texture3D whose mips fit the +chain. addrlib lays a 3D resource in a standard or display mode out in thick blocks (`Gfx10Lib::HwlIsThick`): the 12 address bits of a block follow the one-pipe rows of `GFX10_SW_4K_S3_PATINFO`, the block is 16x16x16, 8x16x16, 8x16x8, 8x8x8 or 4x8x8 elements for 1- to -16-byte elements, and blocks follow along x, then y, then a layer of blocks at a time along z, with -every side padded to whole blocks. Each depth layer is copied to its own footprint rows. +16-byte elements, and the volume is stored a layer of blocks (one block deep) at a time. Each layer +holds that layer of every mip: first the shared tail block when the chain has one, then the mips from +the smallest to the largest, each in blocks along x, then y, with every side rounded up at each level +and padded to whole blocks. A mip is in the tail when it is at most a block wide and half a block high +and at most five mips remain; tail mip k from the end starts at byte k x 256 of the tail block, which, +read as 256-byte micro blocks, gives its origin in x and y (`ComputeSurfaceInfoMacroTiled`). Each +depth layer is copied to its own footprint rows. Anything else is refused as before and leaves the destination descriptor unchanged: layout `0` without a live texture, cube views of other arrays, three-dimensional descriptions in any -other layout, with a mip chain or with a block-compressed format, multisampled textures, the XOR -swizzle modes and every other layout value. The texels must be readable and span +other layout or with a block-compressed format, multisampled textures, the XOR swizzle modes and +every other layout value. The texels must be readable and span at most 64 MiB. A console-layout description is held (not published, descriptor unchanged) in the two cases a @@ -3615,8 +3621,9 @@ Limits and choices that are not measured against a console: in `startup_gfx10_layout_check.cpp` (all five element sizes) and in the Python oracle of `startup_address_console_check.py` (4- and 8-byte elements), both written from the same source. - The thick `0x105` volume layout is compared with addrlib itself when the build has it - (`startup_gfx10_volume_addrlib`: every element address of 190 volumes). Mip chains, block-compressed - volumes and volumes in the other modes are not handled; they stay refused. + (`startup_gfx10_volume_addrlib`: every element address of every mip of 305 volumes, 115 of them + with a mip chain). Block-compressed volumes and volumes in the other modes are not handled; they + stay refused. Log lines (stderr and `X2W_TRAP_LOG`): @@ -3777,7 +3784,8 @@ footprint layout (256-byte row pitch alignment and 512-byte subresource placemen `startup_address_volume_srv_*` exercises volume SRVs on a device (WARP and hardware) with multiple depth slices and mip levels, where footprint row pitch (256 bytes) exceeds packed row bytes (16 bytes), and verifies refusal lines for mismatched view dimensions, short backings, out-of-bounds mips, explicit clamps, -and console layouts. On Windows 11 Build 26100 with an AMD Radeon RX 6600M (driver 32.0.21045.11001), +and a console-layout description over the live volume (`overlapping_resource`; before mip chains of `0x105` +volumes were read, `unsupported_description`). On Windows 11 Build 26100 with an AMD Radeon RX 6600M (driver 32.0.21045.11001), `startup_address_volume_srv_hardware` passed with all 32 RGBA pixels exact. - `ctest --preset release --no-tests=error -R '^startup_memory_srv_(report|buffer|volume)$' -V` diff --git a/src/startup_stubs/address_texture.h b/src/startup_stubs/address_texture.h index 96adf146b7..59171ef235 100644 --- a/src/startup_stubs/address_texture.h +++ b/src/startup_stubs/address_texture.h @@ -33,7 +33,9 @@ inline bool console_address_texture(const D3D12_RESOURCE_DESC& r) r.DepthOrArraySize > D3D12_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION || // The draw uploads a one-dimensional texture only when it is not an array (d3d12_draw.inl). (r.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE1D && r.DepthOrArraySize != 1) || - !((std::max)(r.Width, UINT64{r.Height}) >> (r.MipLevels - 1)) || + // The largest side, depth included for a volume, must allow the mip count. + !((std::max)({r.Width, UINT64{r.Height}, + UINT64{r.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D ? r.DepthOrArraySize : 1u}}) >> (r.MipLevels - 1)) || (r.Alignment && r.Alignment != D3D12_SMALL_RESOURCE_PLACEMENT_ALIGNMENT && r.Alignment != D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT) || address_depth_format(r.Format)) diff --git a/src/startup_stubs/gfx10_layout.h b/src/startup_stubs/gfx10_layout.h index 0445d4036c..f07d39f743 100644 --- a/src/startup_stubs/gfx10_layout.h +++ b/src/startup_stubs/gfx10_layout.h @@ -72,13 +72,14 @@ inline UINT block_log2(UINT mode) } // A three-dimensional texture in the 4 KiB standard mode (0x105), which addrlib lays out in thick blocks -// (Gfx10Lib::HwlIsThick: a 3D resource in a standard or display mode): one mip of uncompressed texels. +// (Gfx10Lib::HwlIsThick: a 3D resource in a standard or display mode): uncompressed texels, with a mip +// chain or without. inline bool supports_volume(const D3D12_RESOURCE_DESC& d) { const Element element = element_of(d.Format); return d.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D && swizzle_mode(d) == 5 && element.bytes && element.texels == 1 && d.Width && d.Height && d.DepthOrArraySize && d.Width <= 2048 && d.Height <= 2048 && d.DepthOrArraySize <= 2048 && - d.MipLevels == 1 && d.SampleDesc.Count == 1; + d.MipLevels && d.MipLevels <= max_mips && d.SampleDesc.Count == 1; } // A two-dimensional, single-sample texture whose memory this header can address, a one-dimensional @@ -111,8 +112,9 @@ struct Layout { std::array row_pitch{}; // elements per row of a linear mip std::array x_bits{}, y_bits{}; // in-block byte offset contributed by a coordinate // A volume (supports_volume): its depth, the depth of a thick block, the in-block offset contributed by z, - // and the bytes of one layer of blocks. Its one slice holds every depth layer; a 2D texture keeps 1, 1, 0. - UINT depth = 1, block_depth = 1, blocks_high = 0; + // and the bytes of one layer of blocks, which holds that layer of every mip. Its one slice holds every + // depth layer; a 2D texture keeps 1, 1, 0. + UINT depth = 1, block_depth = 1; std::array z_bits{}; std::uint64_t layer_size = 0; @@ -217,14 +219,22 @@ struct Layout { } } - // A volume in the 4 KiB standard mode, one mip (supports_volume). The 12 address bits of a thick block - // follow the one-pipe rows of GFX10_SW_4K_S3_PATINFO (nibble01 rows 29-33, nibble2 rows 131-135), by - // element size; "0" is a bit inside the element. The block is 2^n texels on each axis, n counting that - // axis in the row (addrlib ComputeThickBlockDimension: Block1K_3d scaled to 4 KiB). Blocks follow in x, - // then y, then z, a layer of pitch x height blocks at a time (Gfx10Lib::ComputeSurfaceAddrFromCoord- - // MacroTiled for a thick, single-mip surface: the slice size times the block depth per layer). + // A volume in the 4 KiB standard mode (supports_volume). The 12 address bits of a thick block follow the + // one-pipe rows of GFX10_SW_4K_S3_PATINFO (nibble01 rows 29-33, nibble2 rows 131-135), by element size; + // "0" is a bit inside the element. The block is 2^n texels on each axis, n counting that axis in the row + // (addrlib ComputeThickBlockDimension: Block1K_3d scaled to 4 KiB). + // + // The volume is stored a layer of blocks (block_depth texels deep) at a time, and each layer holds that + // layer of every mip (Gfx10Lib::ComputeSurfaceInfoMacroTiled and ComputeSurfaceAddrFromCoordMacroTiled + // for a thick surface): first the shared tail block when the chain has one, then the mips from the + // smallest to the largest, each pitch x height blocks in x, then y. Mip sizes round up at every level + // (GetMipSize). A mip is in the tail when it is at most a block wide and half a block high + // (GetMipTailDim: a 4 KiB block halves its height) and at most five mips remain (GetMaxNumMipsInTail for + // a thick 4 KiB block). Tail mip k from the end sits at byte (k << 8) of the tail block; that offset, + // read back as 256-byte micro blocks of Block256_3d, is its origin in x and y. Its z is not moved. void thick(const D3D12_RESOURCE_DESC& d) { + static constexpr UINT micro[5][2] = {{8, 4}, {4, 4}, {4, 4}, {4, 2}, {2, 2}}; // Block256_3d width, height static constexpr const char* rows4k[5] = { "X0X1Z0Y0Z1Y1X2Z2Y2X3Z3Y3", "--X0Z0Y0Z1Y1X1Z2Y2X2Z3Y3", "----X0Y0Z0Y1X1Z1Y2X2Z2Y3", "------X0Z0Y0X1Z1Y1X2Z2Y2", "--------Z0Y0X0Z1Y1X1Z2Y2"}; @@ -253,11 +263,36 @@ struct Layout { if (bit < ys) y_bits[v] |= 1u << y_at[bit]; if (bit < zs) z_bits[v] |= 1u << z_at[bit]; } + const auto shifted = [](UINT v, UINT mip) { return (std::max)(1u, (v + (1u << mip) - 1) >> mip); }; + constexpr UINT tail_mips = 5; first_tail = mips; - blocks_wide[0] = (width + block_width - 1) / block_width; - blocks_high = (height + block_height - 1) / block_height; - layer_size = std::uint64_t{blocks_wide[0]} * blocks_high * block_bytes; + for (UINT mip = 0; mips > 1 && mip < mips; ++mip) + if (shifted(width, mip) <= block_width && shifted(height, mip) <= block_height / 2 && mips - mip <= tail_mips) { + first_tail = mip; + break; + } + std::array size{}; + for (UINT mip = 0; mip < first_tail; ++mip) { + blocks_wide[mip] = (shifted(width, mip) + block_width - 1) / block_width; + size[mip] = std::uint64_t{blocks_wide[mip]} * ((shifted(height, mip) + block_height - 1) / block_height) * block_bytes; + } + std::uint64_t offset = first_tail < mips ? block_bytes : 0; + for (UINT mip = first_tail; mip-- > 0;) { + start[mip] = offset; + offset += size[mip]; + } + layer_size = offset; slice_size = layer_size * ((depth + block_depth - 1) / block_depth); + for (UINT mip = first_tail; mip < mips; ++mip) { + const UINT tail_offset = (tail_mips - 1 - (mip - first_tail)) << 8; + UINT x = 0, y = 0; + for (UINT bit = 0; bit < 2; ++bit) { + y |= ((tail_offset >> (8 + 2 * bit)) & 1) << bit; + x |= ((tail_offset >> (9 + 2 * bit)) & 1) << bit; + } + origin_x[mip] = x * micro[element_log2][0]; + origin_y[mip] = y * micro[element_log2][1]; + } } // Elements a mip holds, with the desktop's mip sizes (rounded down, at least one texel). @@ -270,10 +305,14 @@ struct Layout { // layer of a volume. std::uint64_t address(UINT mip, UINT x, UINT y, UINT slice, UINT z = 0) const { - if (block_depth > 1) // a volume (thick) - return std::uint64_t{z / block_depth} * layer_size + - (std::uint64_t{y / block_height} * blocks_wide[0] + x / block_width) * block_bytes + - (x_bits[x % block_width] | y_bits[y % block_height] | z_bits[z % block_depth]); + if (block_depth > 1) { // a volume (thick) + const std::uint64_t layer = std::uint64_t{z / block_depth} * layer_size + start[mip]; + const UINT in_z = z_bits[z % block_depth]; + if (mip >= first_tail) + return layer + (x_bits[(origin_x[mip] + x) % block_width] | y_bits[(origin_y[mip] + y) % block_height] | in_z); + return layer + (std::uint64_t{y / block_height} * blocks_wide[mip] + x / block_width) * block_bytes + + (x_bits[x % block_width] | y_bits[y % block_height] | in_z); + } const std::uint64_t base = slice * slice_size; if (is_linear) return base + start[mip] + (std::uint64_t{y} * row_pitch[mip] + x) * bytes_per_element; if (mip >= first_tail) return base + (x_bits[(origin_x[mip] + x) & 255] | y_bits[(origin_y[mip] + y) & 255]); diff --git a/tests/cmake/startup_gfx10_volume.cmake b/tests/cmake/startup_gfx10_volume.cmake index 2eff66639d..d81d067e33 100644 --- a/tests/cmake/startup_gfx10_volume.cmake +++ b/tests/cmake/startup_gfx10_volume.cmake @@ -1,8 +1,10 @@ -# Volumes in the 4 KiB standard console layout (0x105, one mip; src/startup_stubs/gfx10_layout.h) and the -# slot-70 descriptions and views that use them (src/startup_stubs/address_texture.h), without a device: -# address equations against addrlib's GFX10_SW_4K_S3 rows (Mesa 25.1.0, src/amd/addrlib, MIT), block -# order, distinct addresses, round trips and refusals. The thin run lays each volume out as a 2D array of -# its layers and is the negative control; the addrlib run compares every element address with addrlib +# Volumes in the 4 KiB standard console layout (0x105, with or without a mip chain; +# src/startup_stubs/gfx10_layout.h) and the slot-70 descriptions and views that use them +# (src/startup_stubs/address_texture.h), without a device: address equations against addrlib's +# GFX10_SW_4K_S3 rows (Mesa 25.1.0, src/amd/addrlib, MIT), block order, the mip chain and its tail, +# distinct addresses, round trips and refusals. The thin run lays each volume out as a 2D array of its +# layers and the tail run puts every tail mip at the start of the tail block; both are negative +# controls. The addrlib run compares every element address with addrlib # and skips (77) without it. add_executable(startup_gfx10_volume_check tests/startup_gfx10_volume_check.cpp) target_compile_features(startup_gfx10_volume_check PRIVATE cxx_std_17) @@ -14,5 +16,7 @@ endif() add_test(NAME startup_gfx10_volume COMMAND startup_gfx10_volume_check) add_test(NAME startup_gfx10_volume_thin_control COMMAND startup_gfx10_volume_check --mutate thin) set_tests_properties(startup_gfx10_volume_thin_control PROPERTIES WILL_FAIL TRUE) +add_test(NAME startup_gfx10_volume_tail_control COMMAND startup_gfx10_volume_check --mutate tail) +set_tests_properties(startup_gfx10_volume_tail_control PROPERTIES WILL_FAIL TRUE) add_test(NAME startup_gfx10_volume_addrlib COMMAND startup_gfx10_volume_check --addrlib) set_tests_properties(startup_gfx10_volume_addrlib PROPERTIES TIMEOUT 120 SKIP_RETURN_CODE 77) diff --git a/tests/startup_address_console_check.py b/tests/startup_address_console_check.py index ae8f8fdc90..10e07f388d 100644 --- a/tests/startup_address_console_check.py +++ b/tests/startup_address_console_check.py @@ -1,6 +1,6 @@ """Draw textures published by address (device slot 70) whose texels are in a console layout. - fourteen textures, three cubes and two volumes, each drawn once; every + fourteen textures, three cubes and six volume mips, each drawn once; every pixel of the 512x128 target is compared with the texel the view names; then three held descriptions and one texture whose address is announced as XG rows after it was published @@ -120,25 +120,46 @@ def address(self, mip, x, y): return self.start[mip] + (block << self.log2) + self.in_block(x % self.block_w, y % self.block_h) -# A volume in the 4 KiB standard mode (0x105), one mip: addrlib lays a 3D resource in a standard mode out in -# thick blocks (Gfx10Lib::HwlIsThick). The 12 address bits of a 4-byte element follow the one-pipe row of -# GFX10_SW_4K_S3_PATINFO; the block is 8x16x8 elements, and blocks follow in x, then y, then a layer of -# blocks at a time in z. +# A volume in the 4 KiB standard mode (0x105): addrlib lays a 3D resource in a standard mode out in thick +# blocks (Gfx10Lib::HwlIsThick). The 12 address bits of a 4-byte element follow the one-pipe row of +# GFX10_SW_4K_S3_PATINFO; the block is 8x16x8 elements. The volume is stored a layer of blocks (8 deep) at +# a time, and each layer holds that layer of every mip: the shared tail block first when the chain has +# one, then the mips from the smallest to the largest, blocks in x, then y. Mip sizes round up. A mip is in +# the tail when it is at most 8 wide and 8 high and at most five mips remain; tail mip k from the end sits +# at byte (k << 8) of the tail block, which, read as 4x4x4 micro blocks, is its origin in x and y. THICK_4K_S3 = {4: "0 0 X0 Y0 Z0 Y1 X1 Z1 Y2 X2 Z2 Y3"} class ConsoleVolume: - def __init__(self, width, height, depth, element): + def __init__(self, width, height, depth, element, mips=1): self.width, self.height, self.depth = width, height, depth self.bits = THICK_4K_S3[element].split() self.block = [1 << sum(b[0] == axis for b in self.bits) for axis in "XYZ"] - self.wide, high, layers = (-(-side // block) for side, block in zip((width, height, depth), self.block)) - self.layer = self.wide * high * 4096 - self.bytes = self.layer * layers - - def address(self, x, y, z): bw, bh, bd = self.block - value = (z // bd) * self.layer + ((y // bh) * self.wide + x // bw) * 4096 + size = [(max(1, -(-width // (1 << m))), max(1, -(-height // (1 << m)))) for m in range(mips)] + tail = next((m for m, (w, h) in enumerate(size) if mips > 1 and w <= bw and h <= bh // 2 and mips - m <= 5), + mips) + self.wide, self.start, self.origin = {}, {}, {} + offset = 4096 if tail < mips else 0 + for m in reversed(range(tail)): + self.wide[m] = -(-size[m][0] // bw) + self.start[m] = offset + offset += self.wide[m] * -(-size[m][1] // bh) * 4096 + for m in range(tail, mips): + at = (4 - (m - tail)) << 8 + self.start[m] = 0 + self.origin[m] = (4 * ((at >> 9 & 1) | (at >> 10 & 2)), 4 * ((at >> 8 & 1) | (at >> 9 & 2))) + self.layer = offset + self.bytes = self.layer * -(-depth // bd) + + def address(self, x, y, z, mip=0): + bw, bh, bd = self.block + value = (z // bd) * self.layer + self.start[mip] + if mip in self.origin: + x, y = x + self.origin[mip][0], y + self.origin[mip][1] + else: + value += ((y // bh) * self.wide[mip] + x // bw) * 4096 + x, y = x % bw, y % bh for bit, name in enumerate(self.bits): coordinate = {"X": x % bw, "Y": y % bh, "Z": z % bd}.get(name[0]) if coordinate is not None and (coordinate >> int(name[1:])) & 1: @@ -180,38 +201,51 @@ def bc1_block(mip, x, y): ] -def volume_texel(x, y, z): - return bytes(((7 * x + 1) & 255, (5 * y + 3) & 255, (29 * z + 11) & 255, 255)) +def volume_texel(x, y, z, mip=0): + return bytes(((7 * x + 1) & 255, (5 * y + 3) & 255, (29 * z + 11) & 255, 255 - 16 * mip)) -# name, width, height, depth, format, layout: one mip of RGBA8 in the 4 KiB standard mode, viewed as a -# Texture3D. Each target tile of the texture's width and height draws one depth layer. +# name, width, height, depth, format, layout, mips, viewed mip: RGBA8 in the 4 KiB standard mode, one mip +# viewed as a Texture3D. Each target tile of the viewed mip's width and height draws one depth layer. The +# chains view a mip outside the tail and one inside it. VOLUMES = [ - ("RGBA8 volume 17x17x17 4 KiB standard", 17, 17, 17, RGBA8, 0x105), - ("RGBA8 volume 33x9x18 4 KiB standard", 33, 9, 18, RGBA8, 0x105), + ("RGBA8 volume 17x17x17 4 KiB standard", 17, 17, 17, RGBA8, 0x105, 1, 0), + ("RGBA8 volume 33x9x18 4 KiB standard", 33, 9, 18, RGBA8, 0x105, 1, 0), + ("RGBA8 volume 32x32x32 6 mips, mip 1", 32, 32, 32, RGBA8, 0x105, 6, 1), + ("RGBA8 volume 32x32x32 6 mips, mip 3 in the tail", 32, 32, 32, RGBA8, 0x105, 6, 3), + ("RGBA8 volume 20x24x16 5 mips, mip 1", 20, 24, 16, RGBA8, 0x105, 5, 1), + ("RGBA8 volume 20x24x16 5 mips, mip 3 in the tail", 20, 24, 16, RGBA8, 0x105, 5, 3), ] -def build_volume(width, height, depth): - """Backing bytes of a volume, built from the S3 row above.""" - console = ConsoleVolume(width, height, depth, 4) +def mip_sides(width, height, depth, mip): + return max(1, width >> mip), max(1, height >> mip), max(1, depth >> mip) + + +def build_volume(width, height, depth, mips=1): + """Backing bytes of a volume and its mips, built from the S3 row above.""" + console = ConsoleVolume(width, height, depth, 4, mips) backing = bytearray(console.bytes) seen = set() - for z in range(depth): - for y in range(height): - for x in range(width): - at = console.address(x, y, z) - if at in seen or at + 4 > len(backing): - raise AssertionError(f"oracle address {at:#x} of ({x},{y},{z}) is shared or outside the volume") - seen.add(at) - backing[at:at + 4] = volume_texel(x, y, z) + for mip in range(mips): + w, h, d = mip_sides(width, height, depth, mip) + for z in range(d): + for y in range(h): + for x in range(w): + at = console.address(x, y, z, mip) + if at in seen or at + 4 > len(backing): + raise AssertionError(f"oracle address {at:#x} of mip {mip} ({x},{y},{z}) is shared or outside " + "the volume") + seen.add(at) + backing[at:at + 4] = volume_texel(x, y, z, mip) return backing def check_volume(directory, consumer, backend, case, held=None): - name, width, height, depth, fmt, layout = case + name, width, height, depth, fmt, layout, mips, viewed = case source = directory / "texels.bin" - source.write_bytes(build_volume(width, height, depth)) + source.write_bytes(build_volume(width, height, depth, mips)) + width, height, depth = mip_sides(width, height, depth, viewed) across = -(-TARGET_W // width) hlsl = ("Texture3D t : register(t0);\n" "float4 main(float4 p : SV_Position) : SV_Target {\n" @@ -220,7 +254,7 @@ def check_volume(directory, consumer, backend, case, held=None): f" return t.Load(int4(x % {width}, y % {height}, z, 0));\n}}\n") trap_log = directory / "trap.log" modes = {"X2W_TEST_CONSOLE_VIEW": str(source), "X2W_TRAP_LOG": str(trap_log), - "X2W_TEST_CONSOLE_DESC": f"{width},{height},1,{fmt},{layout},0,{depth}"} + "X2W_TEST_CONSOLE_DESC": f"{case[1]},{case[2]},{mips},{fmt},{layout},{viewed},{case[3]}"} actual = draw_texture(directory, consumer, backend, hlsl, modes, "tex3d") if actual is None: return 77 @@ -240,7 +274,7 @@ def check_volume(directory, consumer, backend, case, held=None): z = (x // width + (y // height) * across) % depth layers.add(z) pixel = actual[4 * (y * TARGET_W + x):4 * (y * TARGET_W + x) + 4] - expect = volume_texel(x % width, y % height, z) + expect = volume_texel(x % width, y % height, z, viewed) if pixel != expect: raise AssertionError(f"{name}: pixel ({x},{y}) layer {z} actual {pixel.hex()} expected {expect.hex()}") if len(layers) != depth: @@ -254,7 +288,7 @@ def check_volume(directory, consumer, backend, case, held=None): # A volume past the size the XG stand-in reports: 64x8x40 RGBA8 is eight blocks across, one down and five # layers of blocks (163,840 bytes); the desktop footprint (40 layers of 8 rows of 256 bytes) rounded to # 64 KiB is 131,072. A volume has one slice, so the footprint is not counted once per layer. -HELD_VOLUME = (("RGBA8 volume 64x8x40 4 KiB standard past the XG size", 64, 8, 40, RGBA8, 0x105), +HELD_VOLUME = (("RGBA8 volume 64x8x40 4 KiB standard past the XG size", 64, 8, 40, RGBA8, 0x105, 1, 0), "console_layout_beyond_xg_size") diff --git a/tests/startup_address_srv.cpp b/tests/startup_address_srv.cpp index 9e45d833a4..78f2a31719 100644 --- a/tests/startup_address_srv.cpp +++ b/tests/startup_address_srv.cpp @@ -1186,7 +1186,7 @@ int draw_volume_address_srvs(ID3D12Device* desktop, void* guest, void* list) bad_clamp.view.Texture3D.ResourceMinLODClamp = 1.0f; invoke(guest, 70, ptr(&desc), ptr(&bad_clamp), cpu); - // 5. Wrong layout (console layout 0x105) + // 5. A console layout (0x105) over the live desktop-layout volume: refused as overlapping_resource D3D12_RESOURCE_DESC bad_layout = desc; bad_layout.Layout = static_cast(0x105); invoke(guest, 70, ptr(&bad_layout), ptr(&v), cpu); diff --git a/tests/startup_address_volume_srv_check.py b/tests/startup_address_volume_srv_check.py index 40a90cdd6c..de35461e5e 100644 --- a/tests/startup_address_volume_srv_check.py +++ b/tests/startup_address_volume_srv_check.py @@ -38,9 +38,10 @@ def check_refusal_lines(log): + res_base + r" view\{dim=8 fmt=28 map=0x1688 mostmip=1 mips=1 clamp=1\} " + rf"dest={HEX} dest_in_view_heap=1 address={HEX} address_readable=1", - # 5. Wrong layout (0x105) + # 5. A console layout (0x105) over the live desktop-layout volume: the description is one slot 70 + # reads by address, but the address is inside a live resource. prefix - + r"unsupported memory SRV arguments: reason=unsupported_description " + + r"unavailable texture at the supplied base and layout: reason=overlapping_resource " + res_swizzle + r" view\{dim=8 fmt=28 map=0x1688 mostmip=1 mips=1 clamp=0\} " + rf"dest={HEX} dest_in_view_heap=1 address={HEX} address_readable=1", diff --git a/tests/startup_gfx10_volume_check.cpp b/tests/startup_gfx10_volume_check.cpp index 40401a99b2..a7f617195c 100644 --- a/tests/startup_gfx10_volume_check.cpp +++ b/tests/startup_gfx10_volume_check.cpp @@ -1,16 +1,19 @@ -// Checks the volume layout of src/startup_stubs/gfx10_layout.h (a single-mip 3D texture in the 4 KiB -// standard mode, 0x105, which addrlib lays out in thick blocks) without a device: +// Checks the volume layout of src/startup_stubs/gfx10_layout.h (a 3D texture in the 4 KiB standard mode, +// 0x105, which addrlib lays out in thick blocks) without a device: // - the address bit of every x, y and z bit against the one-pipe rows of addrlib's GFX10_SW_4K_S3_PATINFO, // restated below, and the block each element size gives; // - the order of blocks: along x, then y, then a layer of blocks at a time along z, with the sides of // the texture padded to whole blocks; +// - a mip chain: each layer of blocks holds the tail block, then the mips from the smallest to the largest, +// and the tail mips sit at their origins inside the tail block; // - that every element of a volume gets its own bytes inside the texture, and that a tile followed by a -// detile (with padded row and layer pitches) returns the texels it started from; +// detile (with padded row and layer pitches) returns the texels it started from, for every mip; // - the descriptions it takes and refuses, and the slot-70 views it allows on them. // `--addrlib` compares the size and every element address of a set of volumes with // Addr2ComputeSurfaceInfo and Addr2ComputeSurfaceAddrFromCoord (ADDR_RSRC_TEX_3D, ADDR_SW_4KB_S) and // skips (77) when the build has no addrlib. `--mutate thin` lays each volume out as a thin 2D array of -// its depth layers and is the negative control: it must fail. +// its depth layers, and `--mutate tail` puts every mip of the tail at the start of the tail block; both +// are negative controls and must fail. // // Reference: AMD addrlib as Mesa carries it under src/amd/addrlib, at the revision tools/fetch_addrlib.py // pins (Mesa 25.1.0, commit 5c142e46f3f6e752ed745fd48912ebb8fad67145): src/gfx10/gfx10SwizzlePattern.h, @@ -21,6 +24,7 @@ #include "startup_stubs/address_texture.h" #include "startup_stubs/gfx10_layout.h" +#include #include #include #include @@ -29,7 +33,8 @@ namespace { using x2w_startup::gfx10::Layout; int failures = 0; -bool thin = false; // --mutate thin +bool thin = false; // --mutate thin +bool flat_tail = false; // --mutate tail void fail(const std::string& what) { @@ -50,15 +55,18 @@ D3D12_RESOURCE_DESC volume(UINT width, UINT height, UINT depth, DXGI_FORMAT form return d; } -// The layout under test; the control reads the volume as a thin array of its layers. +// The layout under test; the controls read the volume as a thin array of its layers, or move every tail +// mip to the start of the tail block. Layout layout_of(D3D12_RESOURCE_DESC d) { if (thin) d.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; - return Layout(d); + Layout l(d); + for (UINT mip = l.first_tail; flat_tail && mip < l.mips; ++mip) l.origin_x[mip] = l.origin_y[mip] = 0; + return l; } -std::uint64_t at(const Layout& l, UINT x, UINT y, UINT z) +std::uint64_t at(const Layout& l, UINT x, UINT y, UINT z, UINT mip = 0) { - return thin ? l.address(0, x, y, z) : l.address(0, x, y, 0, z); + return thin ? l.address(mip, x, y, z) : l.address(mip, x, y, 0, z); } // One format per element size: 1, 2, 4, 8 and 16 bytes. @@ -111,23 +119,54 @@ void check_block_order() expect("last element", at(l, 16, 16, 16), (2ull * 6 + 1 * 3 + 2) * 4096); } +// 32x32x32 RGBA8 with six mips, in 8x16x8 blocks. Mips 2 to 5 (8x8 and smaller, at most five from the +// end) share the tail block. A layer of blocks holds the tail block, mip 1 (2x1 blocks) and mip 0 (4x2 +// blocks): 11 blocks. The tail mips sit at byte (k << 8) of the tail block for k = 4, 3, 2, 1, read as +// 4x4x4 micro blocks: (0,8), (4,4), (4,0) and (0,4). +void check_mip_chain() +{ + const Layout l = layout_of(volume(32, 32, 32, DXGI_FORMAT_R8G8B8A8_UNORM, 0x105, 6)); + const auto expect = [](const char* what, std::uint64_t got, std::uint64_t want) { + if (got != want) fail(std::string("mip chain: ") + what + " " + std::to_string(got) + ", expected " + std::to_string(want)); + }; + expect("bytes", l.bytes(), 4ull * 11 * 4096); + expect("mip 0", at(l, 0, 0, 0, 0), 3 * 4096); + expect("mip 0 next row of blocks", at(l, 0, 16, 0, 0), 7 * 4096); + expect("mip 0 next layer of blocks", at(l, 0, 0, 8, 0), 14 * 4096); + expect("mip 1", at(l, 0, 0, 0, 1), 4096); + expect("mip 1 next block in x", at(l, 8, 0, 0, 1), 2 * 4096); + expect("mip 1 next layer of blocks", at(l, 0, 0, 8, 1), 12 * 4096); + expect("mip 2 at (0,8)", at(l, 0, 0, 0, 2), 0x800); // y 8: Y3, bit 11 + expect("mip 3 at (4,4)", at(l, 0, 0, 0, 3), 0x300); // x 4: X2, bit 9; y 4: Y2, bit 8 + expect("mip 4 at (4,0)", at(l, 0, 0, 0, 4), 0x200); + expect("mip 5 at (0,4)", at(l, 0, 0, 0, 5), 0x100); + expect("mip 2 next layer of blocks", at(l, 0, 0, 8, 2), 11 * 4096 + 0x800); +} + struct Shape { UINT width, height, depth; DXGI_FORMAT format; + UINT mips = 1; }; const Shape shapes[] = { {17, 17, 17, DXGI_FORMAT_R16G16B16A16_FLOAT}, {32, 32, 32, DXGI_FORMAT_R8G8B8A8_UNORM}, {33, 33, 33, DXGI_FORMAT_R16G16B16A16_FLOAT}, {32, 32, 32, DXGI_FORMAT_A8_UNORM}, {16, 16, 8, DXGI_FORMAT_R16_FLOAT}, {16, 16, 16, DXGI_FORMAT_R8G8_UNORM}, {32, 32, 32, DXGI_FORMAT_R10G10B10A2_UNORM}, {5, 3, 7, DXGI_FORMAT_R32G32B32A32_FLOAT}, {1, 1, 2, DXGI_FORMAT_R8_UNORM}, {64, 8, 40, DXGI_FORMAT_R32_FLOAT}, + // Mip chains: whole and partial, a tail that starts at mip 0, a chain with no tail, odd sides. + {32, 32, 32, DXGI_FORMAT_R8_UNORM, 6}, {32, 32, 32, DXGI_FORMAT_R8G8B8A8_UNORM, 6}, + {64, 64, 32, DXGI_FORMAT_R16G16_FLOAT, 7}, {128, 128, 128, DXGI_FORMAT_R16G16B16A16_FLOAT, 8}, + {16, 16, 16, DXGI_FORMAT_R32G32B32A32_FLOAT, 5}, {8, 4, 8, DXGI_FORMAT_R8G8B8A8_UNORM, 4}, + {64, 64, 64, DXGI_FORMAT_R16_FLOAT, 2}, {33, 17, 9, DXGI_FORMAT_R16G16B16A16_FLOAT, 6}, + {4, 4, 64, DXGI_FORMAT_R8_UNORM, 7}, {256, 32, 8, DXGI_FORMAT_R16_FLOAT, 9}, }; void check_distinct_and_round_trip() { for (const Shape& s : shapes) { - const D3D12_RESOURCE_DESC d = volume(s.width, s.height, s.depth, s.format); + const D3D12_RESOURCE_DESC d = volume(s.width, s.height, s.depth, s.format, 0x105, s.mips); const std::string name = std::to_string(s.width) + "x" + std::to_string(s.height) + "x" + std::to_string(s.depth) + - " format " + std::to_string(s.format); + " format " + std::to_string(s.format) + " mips " + std::to_string(s.mips); if (!x2w_startup::gfx10::supports(d)) { fail(name + ": refused"); continue; @@ -136,32 +175,39 @@ void check_distinct_and_round_trip() const UINT e = l.bytes_per_element; const std::uint64_t size = l.bytes(); std::vector used(static_cast(size)); + // Every element of every mip has its own bytes. bool clash = false; - for (UINT z = 0; z < s.depth; ++z) - for (UINT y = 0; y < s.height; ++y) - for (UINT x = 0; x < s.width; ++x) { - const std::uint64_t a = at(l, x, y, z); - if (a % e || a + e > size) { - clash = true; - continue; + for (UINT mip = 0; mip < s.mips; ++mip) + for (UINT z = 0; z < l.layers(mip); ++z) + for (UINT y = 0; y < l.rows(mip); ++y) + for (UINT x = 0; x < l.columns(mip); ++x) { + const std::uint64_t a = at(l, x, y, z, mip); + if (a % e || a + e > size) { + clash = true; + continue; + } + if (used[static_cast(a)]) clash = true; + used[static_cast(a)] = 1; } - if (used[static_cast(a)]) clash = true; - used[static_cast(a)] = 1; - } if (clash) fail(name + ": elements share bytes or fall outside the texture"); if (thin) continue; - const std::size_t pitch = (std::size_t{s.width} * e + 255) & ~std::size_t{255}, layer = pitch * (s.height + 1); - std::vector rows(layer * s.depth), back(rows.size()), tiled(static_cast(size)); - for (std::size_t i = 0; i < rows.size(); ++i) rows[i] = static_cast(i * 131 + 7); - l.tile(0, 0, tiled.data(), rows.data(), pitch, layer); - l.detile(0, 0, tiled.data(), back.data(), pitch, layer); - for (UINT z = 0; z < s.depth; ++z) - for (UINT y = 0; y < s.height; ++y) - if (std::memcmp(&rows[z * layer + y * pitch], &back[z * layer + y * pitch], std::size_t{s.width} * e)) { - fail(name + ": round trip differs at layer " + std::to_string(z) + " row " + std::to_string(y)); - z = s.depth; - break; - } + std::vector tiled(static_cast(size)); + for (UINT mip = 0; mip < s.mips; ++mip) { + const UINT w = l.columns(mip), h = l.rows(mip), n = l.layers(mip); + const std::size_t pitch = (std::size_t{w} * e + 255) & ~std::size_t{255}, layer = pitch * (h + 1); + std::vector rows(layer * n), back(rows.size()); + for (std::size_t i = 0; i < rows.size(); ++i) rows[i] = static_cast(i * 131 + 7 + mip); + l.tile(mip, 0, tiled.data(), rows.data(), pitch, layer); + l.detile(mip, 0, tiled.data(), back.data(), pitch, layer); + for (UINT z = 0; z < n; ++z) + for (UINT y = 0; y < h; ++y) + if (std::memcmp(&rows[z * layer + y * pitch], &back[z * layer + y * pitch], std::size_t{w} * e)) { + fail(name + ": round trip differs in mip " + std::to_string(mip) + " at layer " + std::to_string(z) + + " row " + std::to_string(y)); + z = n; + break; + } + } } } @@ -173,8 +219,12 @@ void check_descriptions() const D3D12_RESOURCE_DESC good = volume(32, 32, 32, DXGI_FORMAT_R8G8B8A8_UNORM); supported("4 KiB standard RGBA8", good, true); D3D12_RESOURCE_DESC d = good; - d.MipLevels = 2; - supported("two mips", d, false); + d.MipLevels = 6; + supported("a whole mip chain", d, true); + d.MipLevels = 16; + supported("more mips than a layout holds", d, false); + d.MipLevels = 0; + supported("no mips", d, false); supported("BC1", volume(32, 32, 32, DXGI_FORMAT_BC1_UNORM), false); supported("BC7", volume(32, 32, 32, DXGI_FORMAT_BC7_UNORM), false); supported("4 KiB display", volume(32, 32, 32, DXGI_FORMAT_R8G8B8A8_UNORM, 0x106), false); @@ -203,7 +253,10 @@ void check_descriptions() address("BC7", volume(32, 32, 32, DXGI_FORMAT_BC7_UNORM), false); d = good; d.MipLevels = 6; - address("mip chain", d, false); + address("mip chain", d, true); + d.MipLevels = 7; + address("more mips than the sides allow", d, false); + address("mips the depth allows", volume(4, 4, 64, DXGI_FORMAT_R8_UNORM, 0x105, 7), true); D3D12_SHADER_RESOURCE_VIEW_DESC v{}; v.Format = DXGI_FORMAT_R8G8B8A8_UNORM; @@ -215,6 +268,14 @@ void check_descriptions() if (!x2w_startup::address_view_fits(good, v)) fail("view: one mip"); v.Texture3D.MostDetailedMip = 1; if (x2w_startup::address_view_fits(good, v)) fail("view: mip past the volume"); + D3D12_RESOURCE_DESC chain = good; + chain.MipLevels = 6; + v.Texture3D.MostDetailedMip = 2; + v.Texture3D.MipLevels = 4; + if (!x2w_startup::address_view_fits(chain, v)) fail("view: the last four mips of a chain"); + v.Texture3D.MipLevels = 5; + if (x2w_startup::address_view_fits(chain, v)) fail("view: mips past the chain"); + v.Texture3D.MipLevels = 1; v.Texture3D.MostDetailedMip = 0; D3D12_RESOURCE_DESC typeless = good; typeless.Format = DXGI_FORMAT_R8G8B8A8_TYPELESS; @@ -269,11 +330,18 @@ int addrlib_check() if (AddrCreate(&create, &created) != ADDR_OK) return 1; const AddrFormat addr_formats[5] = {ADDR_FMT_8, ADDR_FMT_16, ADDR_FMT_8_8_8_8, ADDR_FMT_16_16_16_16, ADDR_FMT_32_32_32_32}; std::vector cases; - for (const Shape& s : shapes) cases.push_back(volume(s.width, s.height, s.depth, s.format)); + for (const Shape& s : shapes) cases.push_back(volume(s.width, s.height, s.depth, s.format, 0x105, s.mips)); for (UINT size = 0; size < 5; ++size) for (UINT w : {1u, 3u, 9u, 24u}) for (UINT h : {1u, 7u, 17u}) for (UINT dep : {1u, 5u, 18u}) cases.push_back(volume(w, h, dep, by_size[size])); + // Every mip count of a set of chains, so that each mip in turn is the first in the tail or the last + // outside it. + constexpr UINT chains[4][3] = {{64, 64, 64}, {40, 24, 12}, {17, 33, 5}, {8, 8, 32}}; + for (UINT size = 0; size < 5; ++size) + for (const auto& side : chains) + for (UINT mips = 2; ((std::max)({side[0], side[1], side[2]}) >> (mips - 1)) != 0; ++mips) + cases.push_back(volume(side[0], side[1], side[2], by_size[size], 0x105, mips)); unsigned compared = 0, elements = 0, mismatches = 0; for (const D3D12_RESOURCE_DESC& d : cases) { const Layout l(d); @@ -291,47 +359,49 @@ int addrlib_check() in.width = l.width; in.height = l.height; in.numSlices = l.depth; - in.numMipLevels = 1; + in.numMipLevels = l.mips; in.numSamples = 1; in.numFrags = 1; ++compared; char name[64]; - std::snprintf(name, sizeof name, "%ux%ux%u %u-byte", l.width, l.height, l.depth, l.bytes_per_element); + std::snprintf(name, sizeof name, "%ux%ux%u %u-byte %u mips", l.width, l.height, l.depth, l.bytes_per_element, l.mips); if (Addr2ComputeSurfaceInfo(created.hLib, &in, &out) != ADDR_OK || out.surfSize != l.bytes()) { if (++mismatches <= 12) std::printf("FAIL %s: size 0x%llx, addrlib 0x%llx\n", name, static_cast(l.bytes()), static_cast(out.surfSize)); continue; } - for (UINT z = 0; z < l.depth; ++z) - for (UINT y = 0; y < l.height; ++y) - for (UINT x = 0; x < l.width; ++x) { - ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT ain{}; - ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT aout{}; - ain.size = sizeof ain; - aout.size = sizeof aout; - ain.x = x; - ain.y = y; - ain.slice = z; - ain.swizzleMode = ADDR_SW_4KB_S; - ain.flags.texture = 1; - ain.resourceType = ADDR_RSRC_TEX_3D; - ain.bpp = in.bpp; - ain.unalignedWidth = l.width; - ain.unalignedHeight = l.height; - ain.numSlices = l.depth; - ain.numMipLevels = 1; - ain.numSamples = 1; - ain.numFrags = 1; - ain.pitchInElement = out.pitch; - ++elements; - const std::uint64_t mine = l.address(0, x, y, 0, z); - if (Addr2ComputeSurfaceAddrFromCoord(created.hLib, &ain, &aout) != ADDR_OK || aout.addr != mine) { - if (++mismatches <= 12) - std::printf("FAIL %s (%u,%u,%u): 0x%llx, addrlib 0x%llx\n", name, x, y, z, - static_cast(mine), static_cast(aout.addr)); + for (UINT mip = 0; mip < l.mips; ++mip) + for (UINT z = 0; z < l.layers(mip); ++z) + for (UINT y = 0; y < l.rows(mip); ++y) + for (UINT x = 0; x < l.columns(mip); ++x) { + ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_INPUT ain{}; + ADDR2_COMPUTE_SURFACE_ADDRFROMCOORD_OUTPUT aout{}; + ain.size = sizeof ain; + aout.size = sizeof aout; + ain.x = x; + ain.y = y; + ain.slice = z; + ain.mipId = mip; + ain.swizzleMode = ADDR_SW_4KB_S; + ain.flags.texture = 1; + ain.resourceType = ADDR_RSRC_TEX_3D; + ain.bpp = in.bpp; + ain.unalignedWidth = l.width; + ain.unalignedHeight = l.height; + ain.numSlices = l.depth; + ain.numMipLevels = l.mips; + ain.numSamples = 1; + ain.numFrags = 1; + ain.pitchInElement = out.pitch; + ++elements; + const std::uint64_t mine = l.address(mip, x, y, 0, z); + if (Addr2ComputeSurfaceAddrFromCoord(created.hLib, &ain, &aout) != ADDR_OK || aout.addr != mine) { + if (++mismatches <= 12) + std::printf("FAIL %s mip %u (%u,%u,%u): 0x%llx, addrlib 0x%llx\n", name, mip, x, y, z, + static_cast(mine), static_cast(aout.addr)); + } } - } } AddrDestroy(created.hLib); std::printf("startup_gfx10_volume --addrlib: %u volumes, %u element addresses compared, %u mismatches (Mesa 25.1.0 addrlib, " @@ -343,20 +413,23 @@ int addrlib_check() int main(int argc, char** argv) { if (argc == 2 && std::strcmp(argv[1], "--addrlib") == 0) return addrlib_check(); - thin = argc == 3 && std::strcmp(argv[1], "--mutate") == 0 && std::strcmp(argv[2], "thin") == 0; - if (argc != 1 && !thin) { - std::printf("usage: startup_gfx10_volume_check [--addrlib | --mutate thin]\n"); + const bool mutate = argc == 3 && std::strcmp(argv[1], "--mutate") == 0; + thin = mutate && std::strcmp(argv[2], "thin") == 0; + flat_tail = mutate && std::strcmp(argv[2], "tail") == 0; + if (argc != 1 && !thin && !flat_tail) { + std::printf("usage: startup_gfx10_volume_check [--addrlib | --mutate thin | --mutate tail]\n"); return 2; } check_equations(); check_block_order(); + check_mip_chain(); check_distinct_and_round_trip(); check_descriptions(); if (failures) { std::printf("startup_gfx10_volume: %d failures\n", failures); return 1; } - std::printf("startup_gfx10_volume: PASS (5 element sizes, block order, %zu round trips, 15 layouts, 6 address descriptions, " - "7 views)\n", sizeof(shapes) / sizeof(shapes[0])); + std::printf("startup_gfx10_volume: PASS (5 element sizes, block order, a mip chain, %zu volumes round-tripped mip by mip, " + "17 layouts, 8 address descriptions, 9 views)\n", sizeof(shapes) / sizeof(shapes[0])); return 0; }