diff --git a/docs/d3d12_vulkan.md b/docs/d3d12_vulkan.md index cd0da8039..09456d037 100644 --- a/docs/d3d12_vulkan.md +++ b/docs/d3d12_vulkan.md @@ -2872,7 +2872,16 @@ The console has two list topologies Vulkan lacks: rectangle list (`IASetPrimitiv - `CopyTiles` transfers RGBA8 tiles in either direction. Partial edge blocks use the full 512-byte linear row pitch and transfer only in-bounds texels. Byte-unaligned offsets use transfer scratch. `d3d12_texture_tiles_test` compares initially unmapped tiles, column mappings, aliases, and a fence-delayed - remap with native D3D12, including clipped edges and byte-unaligned offsets. + remap with native D3D12, including clipped edges at 4-byte and byte-unaligned offsets. `CopyTiles` documents no + alignment for `BufferStartOffsetInBytes`; at a byte-unaligned offset WARP also runs, to confirm the test's + expectations (it meets them at every offset tried, 1-8), and the layer is held to them. Two Windows D3D12 + drivers measured so far do not. Judging by the texel values (the D3D12 debug layer was not run), they move + whole tiles as if the offset were rounded down to a multiple of 4. AMD's (RX 7900 XT, 26.11.2) does so in both + directions, so a row-major copy finds each texel 1-3 bytes early and texels that straddle a tile seam differ in + the `CopyTiles` reads. Intel's (Iris Xe, 32.0.101.7092, measured on that host in #964) does so only in the + tiles-to-buffer copies, so the row-major copy matches and the `CopyTiles` reads of every nonzero texel differ. + The test prints a note when every checked read of a native run matches one of those two models, the same one + for every case on the device, and fails on any other divergence ([testing.md](testing.md#known-problems)). - `D3D12_RESOURCE_DESC::Layout`: the public `ROW_MAJOR` and `64KB_STANDARD_SWIZZLE` values plus the Xbox `0x101` tiled value from slot 76. Row-major textures need `VK_IMAGE_TILING_LINEAR` (not usable for RT/DS) or a staging copy; `64KB_STANDARD_SWIZZLE` and `0x101` have no direct Vulkan equivalent. If the game uploads console-tiled data, diff --git a/docs/testing.md b/docs/testing.md index ffe729d24..25a1038d4 100644 --- a/docs/testing.md +++ b/docs/testing.md @@ -806,6 +806,7 @@ game's device ignores it`, so leaving them set cannot slow a game down (`run_tin | With `--wave64-emulate` (or `LEONIDA_W64_EMULATE=1`) on an NVIDIA RTX 5080 with Windows driver 32.0.16.1692 (616.92), `crosslane_fuzz.py --seed 91001 --dpp --no-maskdata` reports a hard mismatch for `cs_xl64_9100373886`: after `s_xor_b64 s[16:17], vcc, vcc` (0 in every lane), the second of two nested `v_cndmask_b32_e64 … s[16:17]` returns the old register instead of the lane id | An NVIDIA driver miscompile, not the translator (SHADER-720). The same SPIR-V (spirv-val clean) matches the model on an RTX 3060 with 616.64, an RTX 5060 Ti (Blackwell) with 621.14, an RTX 5070 Ti with 621.24 and an RTX 5080 with the Linux 580.65.06 driver. Hand edits narrow it to a value selected through the `%active` gate of a store; on the Linux 580 driver a similar pattern, a subgroup shuffle selected by an `%active` that is false, still fails in three wave32 `v_permlane16`/`v_permlanex16` programs of the same seed (#3796, #3918) | Update the NVIDIA driver to 621.14 or newer on Windows. If a crosslane mismatch only shows on one driver, check another driver or GPU before changing the translator | | `lds_fuzz.py --wave 64` (native, not `--emulate`) reports a `ds_bpermute_b32` mismatch on an AMD GPU on Windows, e.g. `cs_ldsfuzz_s7031_496_w64` (seed 7031): small values like `0x14` where the model wants another lane's data, while `--oracle hw` and `--emulate` on another GPU agree with the model | The AMD Windows driver (32.0.21042.62, gfx1036) miscompiles a native wave64 compute shader with two subgroup shuffles; a reduced SPIR-V module is in #4613 | Not a translator regression: check the same seed with `--oracle hw` and with `--emulate`. Native wave64 results on that driver need that cross-check | | On AMD's Windows driver a compute pipeline creation takes tens of minutes: `vk_pipeline_check` prints `still compiling after ...s` with one busy thread, or a compute PSO creation through the D3D12 layer seems never to return | The driver's compiler on one module in the dispatch-loop form (`"control_flow": "dispatch loop"` in the translated `index.json`). Measured on a Radeon gfx1036 iGPU, driver 32.0.21042.62 (SHADER-995): `XboxBvhBuilder.dll`'s `LeafRehydration` in that form (a 581-case switch in a loop) was created after 34 minutes of one busy thread (XXTESTING), while its structured module is created in 2.9 s and an RTX 3070 (NVIDIA 610.74) created the dispatch-loop one in 11 s. It is not every such module: ten other programs of that DLL compile in that form on the Radeon in 0.4 to 40 s ([embedded_shaders.md](embedded_shaders.md), section 7). Not tried on another AMD GPU or driver branch | Translate with current `main`. Since SHADER-427 only a tree nested deeper than 64, a graph that cannot be made reducible or `--dispatch-loop` gives that form, and none of that DLL's programs has it; the shaders stage translates again by itself when the translator changed. A wave64 compute shader that still has it comes out in another form with `--wave64-emulate on` (12.4 s for this program on that driver), which that driver can crash on for other programs (#857) | +| `d3d12_texture_tiles` passes but prints `NOTE: native D3D12 broke the expectations at N of M checked reads, every read as CopyTiles would with linear offset X rounded down to Y in both directions` (or `only in the tiles-to-buffer copies`; Y is X rounded down to a multiple of 4; the test runs X = 1 and 3) | Two Windows D3D12 drivers measured so far run `CopyTiles` at a byte-unaligned `BufferStartOffsetInBytes` as if the offset were rounded down to a multiple of 4: AMD's (RX 7900 XT, 26.11.2, `32.0.32029.2010`) in both directions, Intel's (Iris Xe, `32.0.101.7092`, measured on that host in #964) only in the tiles-to-buffer copies. That is inferred from the texel values; the D3D12 debug layer was not run. A device whose cases match different models fails. `CopyTiles` documents no alignment, WARP meets the test's expectations at every offset tried (1-8), and so does the layer, which stages such offsets through aligned scratch | Nothing: the note is harmless. The test still fails when a native run diverges in any other way, or at a 4-byte offset | ### Signed zero in a float storage image (SHADER-605) diff --git a/runtime/test/d3d12_texture_tiles_test.cpp b/runtime/test/d3d12_texture_tiles_test.cpp index 4d15415f3..dd4ac0948 100644 --- a/runtime/test/d3d12_texture_tiles_test.cpp +++ b/runtime/test/d3d12_texture_tiles_test.cpp @@ -1,5 +1,7 @@ -// D3D-285: compare synthetic sparse RGBA8 texture tiles on the Vulkan shim and native D3D12. +// D3D-285: compare synthetic sparse RGBA8 texture tiles on the Vulkan shim and native D3D12; at byte-unaligned +// CopyTiles offsets WARP also confirms the expectations. #include "../shims/d3d12_com.h" +#include "host_wine.h" #include #include @@ -77,18 +79,114 @@ void transition(ID3D12GraphicsCommandList& list, ID3D12Resource* resource, list.ResourceBarrier(1, &barrier); } -bool compare_pixel(std::vector& result, std::uint32_t actual, std::uint32_t expected, - const char* read, UINT tile, UINT x, UINT y) { - if (actual != expected) { - std::fprintf(stderr, "%s tile %u at (%u,%u): got %#x, expected %#x\n", read, tile, x, y, actual, expected); - return false; +// The tiles' texels in the upload buffer, from `data` = the buffer at the CopyTiles offset. +void fill_tiles(std::uint8_t* data) { + for (UINT tile = 0; tile < tiles; ++tile) + for (UINT y = 0; y < tile_height; ++y) + for (UINT x = 0; x < tile_width; ++x) { + const auto value = pixel(tile, x, y); + std::memcpy(data + tile * tile_bytes + y * row_pitch + x * sizeof(value), &value, sizeof(value)); + } +} + +std::uint32_t load(const std::uint8_t* bytes, UINT64 offset) { + std::uint32_t value = 0; + std::memcpy(&value, bytes + offset, sizeof(value)); + return value; +} + +// Every readback texel run() checks: `visit(read, tile, x, y, offset, expected)` with its readback offset and the +// value the D3D12 rules put there. Stops at the first false. +template +bool for_each_checked(UINT width, UINT height, UINT64 tile_copy_offset, Visit&& visit) { + for (UINT tile = 0; tile < tiles; ++tile) { + const UINT first_y = (tile / 2) * tile_height, first_x = (tile % 2) * tile_width; + if (first_y >= height || first_x >= width) continue; // a texture smaller than the tile grid + const UINT rows = std::min(tile_height, height - first_y), columns = std::min(tile_width, width - first_x); + for (UINT y = 0; y < rows; ++y) { + for (UINT x = 0; x < columns; ++x) { + const auto tiled = tile_copy_offset + tile * tile_bytes + y * row_pitch + x * sizeof(std::uint32_t); + if (!visit("initially unbound", tile, x, y, tiled, 0u)) return false; + const UINT source_x = ((tile ^ 1) % 2) * tile_width; + // The source never wrote the texels beyond its own clipped edge. + if (source_x + x < width) { + const auto aliased = pixel(tile ^ 1, x, y); + const auto row_major = row_major_offset + + ((first_y + y) * full_width + first_x + x) * sizeof(std::uint32_t); + if (!visit("alias", tile, x, y, image_bytes + tiled, aliased)) return false; + if (!visit("row-major alias", tile, x, y, row_major, aliased)) return false; + } + const auto remapped = tile < 2 ? pixel(0, x, y) : 0u; + if (!visit("remap", tile, x, y, 2 * image_bytes + tiled, remapped)) return false; + } + } } - result.push_back(actual); return true; } -bool run(ID3D12Device& device, UINT width, UINT height, UINT64 tile_copy_offset, - std::vector& result, bool layer, bool separate_copy_queue, bool& sparse) { +// The readback buffer run() leaves if every CopyTiles moves whole 64 KiB tiles (clipped texels too) with its linear +// offset taken as `upload_linear` when it reads the buffer (to_tiled) and as `readback_linear` when it writes it +// (to_linear). Both == tile_copy_offset gives the D3D12 rules (main() checks that against the expectations above); +// the driver patterns described in main() round one or both down to a multiple of 4. +std::vector modelled_readback(UINT width, UINT height, UINT64 tile_copy_offset, UINT64 upload_linear, + UINT64 readback_linear) { + std::vector upload(tile_copy_offset + image_bytes), heap(image_bytes), + readback(row_major_offset + image_bytes); + fill_tiles(upload.data() + tile_copy_offset); + // The heap tile behind each of a's tiles (UpdateTileMappings: the left column, then the right); b swaps the + // columns (CopyTileMappings). Snapshot 0 reads a unmapped: zeros, as the buffer starts. + constexpr UINT a_heap_tile[tiles] = {0, 2, 1, 3}; + const auto b_tile = [&](UINT tile) { return heap.data() + a_heap_tile[tile ^ 1] * tile_bytes; }; + for (UINT tile = 0; tile < tiles; ++tile) + std::memcpy(heap.data() + a_heap_tile[tile] * tile_bytes, upload.data() + upload_linear + tile * tile_bytes, + tile_bytes); + for (UINT tile = 0; tile < tiles; ++tile) + std::memcpy(readback.data() + readback_linear + image_bytes + tile * tile_bytes, b_tile(tile), tile_bytes); + for (UINT y = 0; y < height; ++y) // CopyTextureRegion, at an aligned footprint + for (UINT x = 0; x < width; ++x) + std::memcpy(readback.data() + row_major_offset + (y * full_width + x) * sizeof(std::uint32_t), + b_tile((y / tile_height) * 2 + x / tile_width) + (y % tile_height) * row_pitch + + (x % tile_width) * sizeof(std::uint32_t), + sizeof(std::uint32_t)); + // The gated remap: b's top row reuses heap tile 0 (a's first tile), its bottom row is unmapped (zeros). + for (UINT tile = 0; tile < tiles; ++tile) + if (tile < 2) + std::memcpy(readback.data() + readback_linear + 2 * image_bytes + tile * tile_bytes, heap.data(), + tile_bytes); + else + std::memset(readback.data() + readback_linear + 2 * image_bytes + tile * tile_bytes, 0, tile_bytes); + return readback; +} + +// The model with the true offset must reproduce the expectations, or it cannot judge a native divergence. +bool model_matches_rules(UINT width, UINT height, UINT64 tile_copy_offset) { + const auto model = modelled_readback(width, height, tile_copy_offset, tile_copy_offset, tile_copy_offset); + return for_each_checked(width, height, tile_copy_offset, + [&](const char* read, UINT tile, UINT x, UINT y, UINT64 offset, std::uint32_t expected) { + if (load(model.data(), offset) == expected) return true; + std::fprintf(stderr, "the CopyTiles model breaks the expectations: %s tile %u at (%u,%u)\n", read, tile, x, y); + return false; + }); +} + +// One measured driver pattern: the readback modelled_readback gives for it, and how many checked reads differ from it. +struct DriverModel { + const char* rounding; // which CopyTiles round the offset down, as the NOTE names it + std::vector readback; + std::uint64_t unmodelled = 0; + char first_unmodelled[160] = {}; +}; + +// A native run at a byte-unaligned offset reads every texel quietly instead of stopping at the first that breaks the +// D3D12 rules: how many do, and how many differ from each driver model. +struct Advisory { + std::vector models; + std::uint64_t texels = 0, differ = 0; +}; + +// False when a call fails, or (unless `advisory`) a texel breaks the D3D12 rules. +bool run(ID3D12Device& device, UINT width, UINT height, UINT64 tile_copy_offset, std::vector& result, + bool layer, bool separate_copy_queue, bool& sparse, Advisory* advisory = nullptr) { ComPtr a, b, upload, readback; const auto desc = texture_desc(width, height); EXPECT(SUCCEEDED(device.CreateReservedResource(&desc, D3D12_RESOURCE_STATE_COMMON, nullptr, IID_PPV_ARGS(&a)))); @@ -114,13 +212,10 @@ bool run(ID3D12Device& device, UINT width, UINT height, UINT64 tile_copy_offset, const D3D12_RANGE empty{0, 0}; void* mapped = nullptr; EXPECT(SUCCEEDED(upload->Map(0, &empty, &mapped))); - auto* data = static_cast(mapped) + tile_copy_offset; - for (UINT tile = 0; tile < tiles; ++tile) - for (UINT y = 0; y < tile_height; ++y) - for (UINT x = 0; x < tile_width; ++x) { - const auto value = pixel(tile, x, y); - std::memcpy(data + tile * tile_bytes + y * row_pitch + x * sizeof(value), &value, sizeof(value)); - } + // modelled_readback() reads the bytes before the CopyTiles offset when it rounds the offset down: zero them + // explicitly rather than rely on a committed resource starting zeroed. + std::memset(mapped, 0, static_cast(tile_copy_offset)); + fill_tiles(static_cast(mapped) + tile_copy_offset); upload->Unmap(0, nullptr); ComPtr gate, done; @@ -220,36 +315,34 @@ bool run(ID3D12Device& device, UINT width, UINT height, UINT64 tile_copy_offset, EXPECT(WaitForSingleObject(event.handle, 15000) == WAIT_OBJECT_0); EXPECT(SUCCEEDED(readback->Map(0, nullptr, &mapped))); - const auto read_pixel = [mapped](UINT64 offset) { - std::uint32_t value = 0; - std::memcpy(&value, static_cast(mapped) + offset, sizeof(value)); - return value; - }; - for (UINT tile = 0; tile < tiles; ++tile) { - const UINT first_y = (tile / 2) * tile_height, first_x = (tile % 2) * tile_width; - const UINT rows = std::min(tile_height, height - first_y), columns = std::min(tile_width, width - first_x); - for (UINT y = 0; y < rows; ++y) { - for (UINT x = 0; x < columns; ++x) { - const auto tiled = tile_copy_offset + tile * tile_bytes + y * row_pitch + x * sizeof(std::uint32_t); - EXPECT(compare_pixel(result, read_pixel(tiled), 0, "initially unbound", tile, x, y)); - const UINT source_x = ((tile ^ 1) % 2) * tile_width; - // The source never wrote the texels beyond its own clipped edge. - if (source_x + x < width) { - const auto aliased = pixel(tile ^ 1, x, y); - const auto row_major = row_major_offset + - ((first_y + y) * full_width + first_x + x) * sizeof(std::uint32_t); - EXPECT(compare_pixel(result, read_pixel(image_bytes + tiled), aliased, "alias", tile, x, y)); - EXPECT(compare_pixel(result, read_pixel(row_major), aliased, "row-major alias", tile, x, y)); - } - const auto remapped = tile < 2 ? pixel(0, x, y) : 0; - EXPECT(compare_pixel(result, read_pixel(2 * image_bytes + tiled), remapped, "remap", tile, x, y)); + const auto* bytes = static_cast(mapped); + const auto judge = [&](const char* read, UINT tile, UINT x, UINT y, UINT64 offset, std::uint32_t expected) { + const auto actual = load(bytes, offset); + if (advisory) { + ++advisory->texels; + advisory->differ += actual != expected; + for (auto& model : advisory->models) { + const auto modelled = load(model.readback.data(), offset); + if (actual == modelled) continue; + if (model.unmodelled == 0) + std::snprintf(model.first_unmodelled, sizeof(model.first_unmodelled), + "%s tile %u at (%u,%u): got %#x, expected %#x, modelled %#x", read, tile, x, y, + actual, expected, modelled); + ++model.unmodelled; } + } else if (actual != expected) { + std::fprintf(stderr, "%s tile %u at (%u,%u): got %#x, expected %#x\n", read, tile, x, y, actual, expected); + return false; } - } + if (actual == expected) result.push_back(actual); + return true; + }; + EXPECT(for_each_checked(width, height, tile_copy_offset, judge)); readback->Unmap(0, &empty); return true; } +// Under Wine and Proton the host D3D12 is vkd3d, and "WARP" is vkd3d-proton on the GPU: neither is compared. // D3D12 on the adapter `luid` names, when it has tiled resources tier 2 or more; null otherwise. ComPtr tiled_device(IDXGIFactory4& factory, LUID luid, bool print = true) { ComPtr adapter; @@ -275,6 +368,7 @@ ComPtr tiled_device(IDXGIFactory4& factory, LUID luid, bool print // host_adapter.h picks it), so a PC with two GPUs compares the layer with its own GPU's driver; when that adapter // has no tier 2, the first hardware adapter with tier 2 or more. ComPtr native_device(LUID layer_luid) { + if (hostwine::host_is_wine()) return {}; ComPtr factory; if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&factory)))) return {}; char want[128] = {}; @@ -313,9 +407,28 @@ ComPtr native_device(LUID layer_luid) { return {}; } +ComPtr warp_device() { + if (hostwine::host_is_wine()) return {}; + ComPtr factory; + ComPtr adapter; + ComPtr device; + D3D12_FEATURE_DATA_D3D12_OPTIONS options{}; + if (FAILED(CreateDXGIFactory1(IID_PPV_ARGS(&factory))) || + FAILED(factory->EnumWarpAdapter(IID_PPV_ARGS(&adapter))) || + FAILED(D3D12CreateDevice(adapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&device))) || + FAILED(device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &options, sizeof(options))) || + options.TiledResourcesTier < D3D12_TILED_RESOURCES_TIER_2) { + std::puts("No WARP with tiled resources tier 2: nothing confirms the expectations at byte-unaligned offsets"); + return {}; + } + std::printf("WARP: tiled resources tier %u\n", unsigned(options.TiledResourcesTier)); + return device; +} + } // namespace int main() { + std::setvbuf(stdout, nullptr, _IONBF, 0); // progress in order with the failures on stderr ComPtr vulkan; if (FAILED(rt::d3d12::create_vulkan_device_standalone(IID_PPV_ARGS(&vulkan)))) { std::puts("Vulkan standalone device unavailable"); @@ -346,20 +459,39 @@ int main() { return 1; } } + // Byte-unaligned CopyTiles offsets. CopyTiles documents no alignment for BufferStartOffsetInBytes, and WARP meets + // the expectations at every offset tried (1-8), so at such an offset WARP runs too, to confirm them; the layer is + // held to the expectations. Two Windows drivers measured so far do not meet them. Judging by the texel values + // (the D3D12 debug layer was not run), they move the tiles as if the offset were rounded down to a multiple of 4: + // - AMD (RX 7900 XT, 26.11.2) in both directions. The row-major copy then finds each texel 1-3 bytes early, and + // texels that straddle a tile seam differ in the CopyTiles reads too. + // - Intel (Iris Xe, 32.0.101.7092, measured on that host in pull request #964) only in the tiles-to-buffer + // copies: the upload honours the offset, so the row-major copy matches and the CopyTiles reads of every + // nonzero texel differ. + // Such a native run is a NOTE only when every checked read matches one of those two models (modelled_readback), + // and every case on the device matches the same one; any other divergence fails, and so does any texel at a + // 4-byte offset. + const auto warp = warp_device(); const auto* info = rt::d3d12::vulkan_device_info(vulkan.Get()); const bool dedicated_copy = info && !info->copy_queues.empty() && info->copy_family != info->queue_family; struct ReplayCase { UINT width, height, linear_offset; bool separate_copy_queue; }; - constexpr std::array cases{ReplayCase{256, 256, 4, false}, ReplayCase{256, 240, 1, false}, + // Clipped edges at a 4-byte offset keep native strict on partial tiles on every GPU. + constexpr std::array cases{ReplayCase{256, 256, 4, false}, ReplayCase{256, 240, 4, false}, + ReplayCase{240, 240, 4, false}, ReplayCase{256, 240, 1, false}, ReplayCase{240, 240, 3, false}, ReplayCase{256, 256, 4, true}}; if (!dedicated_copy) std::puts("No separate Vulkan copy family for the cross-family case"); + const char* device_rounding = nullptr; // the model the first diverging native case matched for (const auto& [width, height, linear_offset, separate_copy_queue] : cases) { if (separate_copy_queue && !dedicated_copy) continue; bool sparse = false; - std::vector observed, expected; - if (!run(*vulkan.Get(), width, height, linear_offset, observed, true, separate_copy_queue, sparse)) return 1; + std::vector observed, expected, reference; + if (!run(*vulkan.Get(), width, height, linear_offset, observed, true, separate_copy_queue, sparse)) { + std::fprintf(stderr, "Vulkan replay failed: %u x %u, linear offset %u\n", width, height, linear_offset); + return 1; + } if (!sparse) { std::printf("Vulkan device does not support compatible sparse RGBA8 tiling for %u x %u\n", width, height); if (height == 256) return 77; @@ -368,10 +500,66 @@ int main() { std::printf("Vulkan replay: %u x %u, linear offset %u, initially unbound, aliased, row-major, gated remap%s\n", width, height, linear_offset, separate_copy_queue ? ", COPY-to-DIRECT handoff" : ""); + const bool byte_offset = linear_offset % 4 != 0; + if (byte_offset && !model_matches_rules(width, height, linear_offset)) return 1; if (native) { - if (!run(*native.Get(), width, height, linear_offset, expected, false, separate_copy_queue, sparse) || - observed != expected) return 1; - std::printf("Native D3D12 matched all %zu verified pixels\n", observed.size()); + const UINT rounded_offset = linear_offset & ~3u; + Advisory advisory; + if (byte_offset) { + advisory.models.push_back({"in both directions", modelled_readback(width, height, linear_offset, + rounded_offset, rounded_offset)}); + advisory.models.push_back({"only in the tiles-to-buffer copies", + modelled_readback(width, height, linear_offset, linear_offset, + rounded_offset)}); + } + if (!run(*native.Get(), width, height, linear_offset, expected, false, separate_copy_queue, sparse, + byte_offset ? &advisory : nullptr) || + (!advisory.differ && observed != expected)) { + std::fprintf(stderr, "Native D3D12 failed: %u x %u, linear offset %u\n", width, height, linear_offset); + return 1; + } + const DriverModel* fit = nullptr; + for (const auto& model : advisory.models) + if (!model.unmodelled) { + fit = &model; + break; + } + if (!advisory.differ) { + std::printf("Native D3D12 matched all %zu verified pixels\n", observed.size()); + } else if (fit) { + if (device_rounding && std::strcmp(device_rounding, fit->rounding) != 0) { + std::fprintf(stderr, "Native D3D12 failed: %u x %u, linear offset %u matches the offset rounded " + "down %s, but an earlier case matched it rounded down %s\n", width, height, + linear_offset, fit->rounding, device_rounding); + return 1; + } + std::printf("NOTE: native D3D12 broke the expectations at %llu of %llu checked reads, every read as " + "CopyTiles would with linear offset %u rounded down to %u %s " + "(docs/testing.md, Known problems); not a failure\n", + static_cast(advisory.differ), + static_cast(advisory.texels), linear_offset, rounded_offset, + fit->rounding); + device_rounding = fit->rounding; + } else { + std::fprintf(stderr, "Native D3D12 failed: %u x %u, linear offset %u: %llu of %llu checked reads " + "break the expectations\n", + width, height, linear_offset, static_cast(advisory.differ), + static_cast(advisory.texels)); + for (const auto& model : advisory.models) + std::fprintf(stderr, " %llu differ from the model with the offset rounded down to %u %s; " + "first: %s\n", + static_cast(model.unmodelled), rounded_offset, model.rounding, + model.first_unmodelled); + return 1; + } + } + if (byte_offset && warp) { + if (!run(*warp.Get(), width, height, linear_offset, reference, false, separate_copy_queue, sparse)) { + std::fprintf(stderr, "WARP failed: %u x %u, linear offset %u\n", width, height, linear_offset); + return 1; + } + std::printf("WARP meets the expectations at linear offset %u (%zu pixels)\n", linear_offset, + reference.size()); } } return 0;