From ff9d54cf2a6e90a96a48de75f8fe2d39f3a85017 Mon Sep 17 00:00:00 2001 From: Lucas Boyles Date: Wed, 25 Nov 2026 11:12:25 -0600 Subject: [PATCH] lanes: draw through the second of two raster root tables Add the `raster-tables` self-test scenario, the Lanes coverage #168 left for a follow-up. Two hand-written console programs (`raster_fixture.py`) draw a fullscreen triangle through the Xbox stream pipeline. The pixel program loads one dword from slot 2 of the root's second descriptor table, which its FSSM records and PSV binding name `t3, space2`. The title's root declares `t0` to `t3` in space 1 for that table, so the draw writes the expected value only under the root the provider reflects from both programs. Under the title's root the pipeline becomes a stand-in and the target keeps its clear value; a wrong table or slot reads a decoy that names its view. The reflected root is serialized while the game runs, so nothing can be prepared before launch. The `lanes-raster-tables` verify suite runs the scenario with the host worker and `TUXBOX_TRACE_RASTER_ROOTS=1`. It requires the reflected trace and pipeline lines, no stand-in, and no translation of either program without a root, and removes only these programs' cache entries. Like `xbox-shader`, the scenario stays out of `LANES_SCENARIOS`. The production xshader translates both programs against no root, the title's root and the expected reflected root, and DXC and DXV accept all six. A dxbc test pins the binding the pixel program resolves to under the title's root. --- build.py | 1 + examples/lanes/README.md | 13 ++ examples/lanes/raster_fixture.py | 122 +++++++++++++++++++ examples/lanes/selftest.cpp | 147 ++++++++++++++++++++++- project_tuxbox/verify.py | 66 +++++++++- runtime/dxbc/src/tests/compute_table.rs | 16 +++ tests/test_lanes_raster.py | 138 +++++++++++++++++++++ tools/reference/portable_link_fixture.py | 14 ++- 8 files changed, 509 insertions(+), 8 deletions(-) create mode 100644 examples/lanes/raster_fixture.py create mode 100644 tests/test_lanes_raster.py diff --git a/build.py b/build.py index 49bd3226..be0a512b 100644 --- a/build.py +++ b/build.py @@ -333,6 +333,7 @@ def build_target(tools, target, dxc, d3d12_reference=None): controls = tools.compile(src / "input.cpp", objects) game = tools.compile(src / "game.cpp", objects) subprocess.run([sys.executable, str(src / "shader_fixture.py"), "xbox_shader.h"], cwd=objects, check=True) + subprocess.run([sys.executable, str(src / "raster_fixture.py"), "raster_shader.h"], cwd=objects, check=True) selftest = tools.compile(src / "selftest.cpp", objects, f"/I{objects}") xmem, d3d, gameinput = OUTPUT / "xmem-smoke", OUTPUT / "d3d12-smoke", OUTPUT / "gameinput" tools.link(objects / "lanes.exe", course, screen, controls, game, selftest, xmem / "xmem.lib", diff --git a/examples/lanes/README.md b/examples/lanes/README.md index 78559fff..58bf2eae 100644 --- a/examples/lanes/README.md +++ b/examples/lanes/README.md @@ -54,6 +54,7 @@ The game also imports Windows core API sets for services such as files, timing a | `descriptor-reclaim` | Shader-visible descriptor heap reclamation across completed batches, overlapping in-flight `Reset()`, `ClearState`, evicted-slot rebinding, and unsubmitted pin exhaustion | | `xbox-shader` | A console shader's pipeline and dispatch ([shader cache](#shader-cache)) | | `wave64-shader` | A console shader that sums across 64-lane waves, translated while the game runs; not part of `all` | +| `raster-tables` | A console vertex and pixel pair drawn under a root with two descriptor tables, reading through the second ([raster tables](#raster-tables)) | ```sh python tuxbox.py verify --only lanes-selftest --output build/lanes-selftest.json @@ -110,6 +111,18 @@ Lanes also carries a console program that sums across 64-lane waves. The `wave64 These checks run on the Proton backend. They remove only these shaders' cache entries from the prefix. +## Raster tables + +The `raster-tables` scenario draws a fullscreen triangle with two hand-written console programs (`raster_fixture.py`; not taken from any game). The pixel program reads one dword through slot 2 of the root's second descriptor table and writes it to a uint target. Its FSSM records and PSV binding name that descriptor `t3, space2`, while the root declares `t0` to `t3` in space 1 there. The provider has to build the root the program was compiled against, with the register at that slot, and translate both programs for it. Under the title's root the pipeline becomes a stand-in and the target keeps its clear value. A wrong table or slot reads a decoy that names its view. + +That root is made while the game runs, so nothing can be prepared before launch. `verify` runs the scenario with the host worker, requires the provider to report the reflected root and pipeline, and fails if either program was translated without a root. + +```sh +python tuxbox.py verify --only lanes-raster-tables --output build/lanes-raster-tables.json +``` + +It runs on the Proton backend and removes only these programs' cache entries from the prefix. + ## Deterministic replay ```sh diff --git a/examples/lanes/raster_fixture.py b/examples/lanes/raster_fixture.py new file mode 100644 index 00000000..6e68d028 --- /dev/null +++ b/examples/lanes/raster_fixture.py @@ -0,0 +1,122 @@ +"""The synthetic Xbox vertex and pixel programs of the `raster-tables` self-test. + +Both are small hand-written console programs, not taken from any game. The +vertex program draws a fullscreen triangle. The pixel program reads one dword +through table 1 of a root with two descriptor tables, from the table pointer in +s9 at slot 2, and writes it to a uint render target. Its FSSM records and PSV +binding name that descriptor `t3, space2`, a register the title's root does not +declare, so the pipeline needs the root its tables are reflected into. +""" +from pathlib import Path +import struct +import sys +import zlib + +sys.path.insert(0, str(Path(__file__).resolve().parents[2])) +from tools.reference.portable_link_fixture import VERTEX_CODE, pack # noqa: E402 + +# gfx1030, checked with `llvm-mc -mcpu=gfx1030 -show-encoding`. +PIXEL_CODE = ( + 0xBE800309, # s_mov_b32 s0, s9 table 1 pointer + 0xBE810380, # s_mov_b32 s1, 0 + 0xF4080100, 0xFA000040, # s_load_dwordx4 s[4:7], s[0:1], 0x40 slot 2 + 0xBF8CC07F, # s_waitcnt lgkmcnt(0) + 0xE0300000, 0x80010000, # buffer_load_dword v0, off, s[4:7], 0 + 0xBF8C3F70, # s_waitcnt vmcnt(0) + 0xF8001801, 0x00000000, # exp mrt0 v0, off, off, off done vm + 0xBF810000, # s_endpgm +) +# FSSM rows [class, dword offset, width or register, register or shape, location]. +# The user-data row puts the descriptor in table 1 (s9) at dword 16; the used row +# names it a raw SRV, register 3, with its table in the location's high half. +PIXEL_USER = ([3, 16, 1, 3, 0x109],) +PIXEL_USED = ([0x300, 16, 3, 1, 0x1_0904],) +# PSV binding [type, space, lower, upper]: raw SRV t3, space2. +PIXEL_RESOURCES = ([4, 2, 3, 3],) +# The value the pixel program must read, and what the other descriptors hold. +EXPECTED = 0x7AB1E001 +DECOY = 0xD0000000 + +ABSENT = 0xDEADBEEFDEADBEEF +ROWS_AT, CODE_AT = 0x240, 0x280 + + +def image(slot, code, user=(), used=(), inputs=0): + """An FSSM 1.1 image with one stage descriptor at 0x68, after the directory.""" + data = bytearray(CODE_AT) + struct.pack_into(" #include #include @@ -12,6 +13,7 @@ #include "course_shader.h" #include "gpu_indirect_shader.h" #include "xbox_shader.h" +#include "raster_shader.h" #include "reclaim_shader.h" #include #include @@ -37,6 +39,7 @@ constexpr size_t slot_copy_memory = 62, slot_write32 = 71, slot_write64 = 72, sl slot_emit_sizes = 120, slot_sync_top = 131, slot_sync_bottom = 132; constexpr size_t slot_compute_root = 33, device_create_compute = 62, device_create_stream = 86; constexpr size_t slot_bind_heaps = 32, slot_compute_table = 35, queue_wait = 17; +constexpr size_t slot_graphics_root = 34, slot_graphics_table = 36, slot_targets = 50, slot_clear_target = 52; constexpr size_t slot_execute_indirect = 61, slot_root_constants = 39, slot_root_uav = 45; constexpr size_t queue_signal = 16, queue_execute_frame = 35, device_place = 44, device_create_list = 73; @@ -60,6 +63,8 @@ using SetConstants = void (WINAPI*)(ID3D12GraphicsCommandList*, UINT, UINT, cons using SetUav = void (WINAPI*)(ID3D12GraphicsCommandList*, UINT, D3D12_GPU_VIRTUAL_ADDRESS); using BindHeaps = void (WINAPI*)(ID3D12GraphicsCommandList*, UINT, ID3D12DescriptorHeap* const*); using SetTable = void (WINAPI*)(ID3D12GraphicsCommandList*, UINT, D3D12_GPU_DESCRIPTOR_HANDLE); +using SetTargets = void (WINAPI*)(ID3D12GraphicsCommandList*, UINT, const D3D12_CPU_DESCRIPTOR_HANDLE*, BOOL, + const D3D12_CPU_DESCRIPTOR_HANDLE*); using WaitQueue = HRESULT (WINAPI*)(ID3D12CommandQueue*, ID3D12Fence*, UINT64); using GpuHandle = UINT64 (WINAPI*)(ID3D12DescriptorHeap*); using EmitSizes = void (WINAPI*)(ID3D12GraphicsCommandList*, @@ -487,6 +492,144 @@ void wave64_shader_scenario(ID3D12Device* device) { } } +// A console pixel program reads a descriptor through the second of two root +// tables. Its FSSM records and PSV binding name it t3, space2 at slot 2 of +// table 1, which the title's root declares as t2, space1. The provider must +// build the root the program was compiled against (`raster_fixture.py`) and +// draw with it; under the title's root the pipeline becomes a stand-in and the +// target keeps its clear value. +void raster_tables(ID3D12Device* device) { + D3D12_DESCRIPTOR_RANGE1 ranges[]{ + {D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 1, 0, 0, D3D12_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_VOLATILE, 0}, + {D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 4, 0, 1, D3D12_DESCRIPTOR_RANGE_FLAG_DESCRIPTORS_VOLATILE, 0}}; + D3D12_ROOT_PARAMETER1 params[3]{}; + for (UINT i = 0; i < 2; ++i) { + params[i].ParameterType = D3D12_ROOT_PARAMETER_TYPE_DESCRIPTOR_TABLE; + params[i].DescriptorTable = {1, &ranges[i]}; + } + params[2].ParameterType = D3D12_ROOT_PARAMETER_TYPE_32BIT_CONSTANTS; + params[2].Constants = {500, 0, 1}; + D3D12_VERSIONED_ROOT_SIGNATURE_DESC signature{D3D_ROOT_SIGNATURE_VERSION_1_1}; + signature.Desc_1_1 = {3, params, 0, nullptr, D3D12_ROOT_SIGNATURE_FLAG_NONE}; + ComPtr serialized; + check(D3D12SerializeVersionedRootSignature(&signature, &serialized, nullptr), + "serialize two-table root signature"); + ComPtr root; + check(device->CreateRootSignature(0, serialized->GetBufferPointer(), serialized->GetBufferSize(), + IID_PPV_ARGS(&root)), "create two-table root signature"); + + frame_abi::RasterPipelineStream parts; + parts.root.payload = root.Get(); + parts.vs.payload = {raster_vertex, sizeof(raster_vertex)}; + parts.ps.payload = {raster_pixel, sizeof(raster_pixel)}; + parts.raster.payload.FillMode = D3D12_FILL_MODE_SOLID; + parts.raster.payload.CullMode = D3D12_CULL_MODE_NONE; + parts.raster.payload.DepthClipEnable = TRUE; + parts.blend.payload.RenderTarget[0].RenderTargetWriteMask = D3D12_COLOR_WRITE_ENABLE_ALL; + parts.dsv.payload = DXGI_FORMAT_UNKNOWN; + parts.formats.payload.NumRenderTargets = 1; + parts.formats.payload.RTFormats[0] = DXGI_FORMAT_R32_UINT; + D3D12_PIPELINE_STATE_STREAM_DESC stream{sizeof(parts), &parts}; + ComPtr pipeline; + check(method(device, device_create_stream)(device, &stream, IID_PPV_ARGS(&pipeline)), + "create pipeline from console raster programs"); + + // Sixteen raw views. Table 0 starts at view 0 and table 1 at view 8, so the + // program's descriptor is view 10. Every other view holds a decoy naming it. + constexpr UINT views = 16, view_bytes = 256, side = 16, pitch = 256; + std::vector words(views * view_bytes / 4); + for (UINT i = 0; i < views; ++i) words[i * view_bytes / 4] = i == 10 ? raster_expected : raster_decoy | i; + auto data = buffer(device, D3D12_HEAP_TYPE_UPLOAD, words.size() * 4, D3D12_RESOURCE_STATE_GENERIC_READ); + compute_fixture::upload(data.Get(), words.data(), words.size() * 4); + D3D12_DESCRIPTOR_HEAP_DESC view_desc{D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, views, + D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, 1}; + ComPtr view_heap; + check(device->CreateDescriptorHeap(&view_desc, IID_PPV_ARGS(&view_heap)), "create view heap"); + const UINT stride = device->GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV); + const SIZE_T cpu_base = method(view_heap.Get(), 9)(view_heap.Get()); + const UINT64 gpu_base = method(view_heap.Get(), 10)(view_heap.Get()); + for (UINT i = 0; i < views; ++i) { + D3D12_SHADER_RESOURCE_VIEW_DESC srv{}; + srv.Format = DXGI_FORMAT_R32_TYPELESS; + srv.ViewDimension = D3D12_SRV_DIMENSION_BUFFER; + srv.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING; + srv.Buffer = {UINT64(i) * view_bytes / 4, view_bytes / 4, 0, D3D12_BUFFER_SRV_FLAG_RAW}; + device->CreateShaderResourceView(data.Get(), &srv, {cpu_base + SIZE_T(i) * stride}); + } + + D3D12_HEAP_PROPERTIES heap{}; + heap.Type = D3D12_HEAP_TYPE_DEFAULT; + heap.CreationNodeMask = heap.VisibleNodeMask = 1; + D3D12_RESOURCE_DESC target_desc{}; + target_desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D; + target_desc.Width = target_desc.Height = side; + target_desc.DepthOrArraySize = target_desc.MipLevels = 1; + target_desc.SampleDesc.Count = 1; + target_desc.Format = DXGI_FORMAT_R32_UINT; + target_desc.Flags = D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET; + ComPtr target; + check(device->CreateCommittedResource(&heap, D3D12_HEAP_FLAG_NONE, &target_desc, D3D12_RESOURCE_STATE_RENDER_TARGET, + nullptr, IID_PPV_ARGS(&target)), "create uint render target"); + auto readback = buffer(device, D3D12_HEAP_TYPE_READBACK, side * pitch, D3D12_RESOURCE_STATE_COPY_DEST); + D3D12_DESCRIPTOR_HEAP_DESC target_heap_desc{D3D12_DESCRIPTOR_HEAP_TYPE_RTV, 1, D3D12_DESCRIPTOR_HEAP_FLAG_NONE, 0}; + ComPtr target_heap; + check(device->CreateDescriptorHeap(&target_heap_desc, IID_PPV_ARGS(&target_heap)), "create target heap"); + const D3D12_CPU_DESCRIPTOR_HANDLE rtv{method(target_heap.Get(), 9)(target_heap.Get())}; + device->CreateRenderTargetView(target.Get(), nullptr, rtv); + + Queue direct(device, D3D12_COMMAND_LIST_TYPE_DIRECT); + auto* list = direct.list.Get(); + constexpr float clear[4]{}; + method(list, slot_clear_target)(list, rtv, clear, 0, nullptr); + method(list, slot_graphics_root)(list, root.Get()); + ID3D12DescriptorHeap* bound[]{view_heap.Get()}; + method(list, slot_bind_heaps)(list, 1, bound); + method(list, slot_graphics_table)(list, 0, {gpu_base}); + method(list, slot_graphics_table)(list, 1, {gpu_base + 8ull * stride}); + method(list, slot_targets)(list, 1, &rtv, FALSE, nullptr); + const D3D12_VIEWPORT viewport{0, 0, float(side), float(side), 0, 1}; + const D3D12_RECT scissor{0, 0, LONG(side), LONG(side)}; + list->RSSetViewports(1, &viewport); + list->RSSetScissorRects(1, &scissor); + list->SetPipelineState(pipeline.Get()); + list->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST); + list->DrawInstanced(3, 1, 0, 0); + compute_fixture::transition(list, target.Get(), D3D12_RESOURCE_STATE_RENDER_TARGET, + D3D12_RESOURCE_STATE_COPY_SOURCE); + D3D12_TEXTURE_COPY_LOCATION from{}, to{}; + from.pResource = target.Get(); + from.Type = D3D12_TEXTURE_COPY_TYPE_SUBRESOURCE_INDEX; + to.pResource = readback.Get(); + to.Type = D3D12_TEXTURE_COPY_TYPE_PLACED_FOOTPRINT; + to.PlacedFootprint = {0, {DXGI_FORMAT_R32_UINT, side, side, 1, pitch}}; + method(list, slot_copy_texture)(list, &to, 0, 0, 0, &from, nullptr, 0); + direct.submit(); + direct.finish("draw with two root tables"); + + std::vector texels(side * pitch / 4); + D3D12_RANGE range{0, side * pitch}, empty{}; + void* mapped{}; + check(readback->Map(0, &range, &mapped), "map render target readback"); + std::memcpy(texels.data(), mapped, side * pitch); + readback->Unmap(0, &empty); + for (UINT y = 0; y < side; ++y) { + for (UINT x = 0; x < side; ++x) { + const UINT found = texels[y * pitch / 4 + x]; + if (found == raster_expected) continue; + char message[160]; + if (!found) + std::snprintf(message, sizeof(message), "texel %u,%u is 0: a stand-in pipeline or a skipped draw", x, y); + else if ((found & ~0xffu) == raster_decoy) + std::snprintf(message, sizeof(message), "texel %u,%u read view %u, not table 1 slot 2 (view 10)", x, y, + found & 0xffu); + else + std::snprintf(message, sizeof(message), "texel %u,%u: expected %#x, found %#x", x, y, + raster_expected, found); + throw std::runtime_error(message); + } + } +} + ComPtr compute_pipeline(ID3D12Device* device, ComPtr& root, D3D12_SHADER_BYTECODE bytecode) { D3D12_ROOT_PARAMETER params[2]{}; @@ -1516,6 +1659,7 @@ constexpr Scenario scenarios[] = { {L"descriptor-reclaim", descriptor_reclaim}, {L"xbox-shader", xbox_shader_scenario}, {L"wave64-shader", wave64_shader_scenario}, + {L"raster-tables", raster_tables}, }; // A fresh Scarlett device on the requested adapter. The factory is reached @@ -1567,7 +1711,8 @@ const wchar_t* const selftest_scenarios[] = {L"labels", L"cross-queue L"indirect-dispatch", L"gpu-indirect-dispatch", L"dispatch-wait", L"texture-readback", L"ray-tracing-builder", L"thread-dimensions", L"descriptor-reclaim", - L"xbox-shader", L"wave64-shader"}; + L"xbox-shader", L"wave64-shader", + L"raster-tables"}; const unsigned selftest_scenario_count = static_cast(std::size(selftest_scenarios)); static_assert(std::size(selftest_scenarios) == std::size(scenarios)); diff --git a/project_tuxbox/verify.py b/project_tuxbox/verify.py index 674dc683..f6af1954 100644 --- a/project_tuxbox/verify.py +++ b/project_tuxbox/verify.py @@ -21,7 +21,7 @@ ROOT = Path(__file__).resolve().parents[1] BUILD = ROOT / "build" -BASE_SUITES = ("cpu", "xmem", "xapu", "xgameruntime", "xcrdapi", "graphics", "graphics-abi", "guest-frame", "present", "lanes", "lanes-selftest", "lanes-shader-cache", "lanes-benchmark", +BASE_SUITES = ("cpu", "xmem", "xapu", "xgameruntime", "xcrdapi", "graphics", "graphics-abi", "guest-frame", "present", "lanes", "lanes-selftest", "lanes-shader-cache", "lanes-raster-tables", "lanes-benchmark", "cpu-benchmark", "d3d12-exports", "d3d12-features", "d3d12-indirect", "d3d12-queries", "d3d12-queues", "d3d12-tables", "d3d12-heaps", "d3d12-placement", "d3d12-copy-resource", "d3d12-draw", "d3d12-stream", "d3d12-frame-events", "d3d12-guids", "d3d12-signatures", "xg-provider") @@ -324,6 +324,67 @@ def missing_provider_imports(modules, provider, expected): return sorted(set(expected) - found) +def lanes_raster_tables(host, check, gpu_args, pci, memory_symbols): + """Draw with the Lanes console raster programs under a root with two tables. + + The pixel program reads a register the title's root does not declare, so it + draws only under the root the provider reflects from both programs. That + root is serialized while the game runs, so nothing is prepared before + launch: the host worker translates both programs against it. + """ + from examples.lanes.raster_fixture import pixel, vertex + from .runtime_shaders import shader_session + from .shader_prep import SOURCE_CACHE + + sources = Path(host.env["WINEPREFIX"]) / SOURCE_CACHE + rootless = {hashlib.sha256(data).hexdigest() for data in (vertex(), pixel())} + messages = [] + + def compiled(): + return {line.removeprefix("Compiled Xbox shader ") for line in messages + if line.startswith("Compiled Xbox shader ")} + + def forget(keys): + # Only these programs' entries; a prefix may hold a title cache. + for key in keys: + for path in [*sources.glob(f"{key}.*"), *sources.parent.glob(f"runtime/*/{key}.*")]: + path.unlink() + + def expect_reflected(output): + if "substituted null " in output: + return "the provider substituted a stand-in pipeline" + # +debugstr escapes the quotes of the logged map. + if not re.search(r'multi-table raster roots after 1 pipelines: \{\\?"reflected\\?": 1\}', output): + return "the provider did not reflect the two-table root" + if "created raster pipeline with 3 reflected FSSM descriptor slots" not in output: + return "the provider did not create the pipeline under the reflected root" + if compiled() & rootless: + return f"the worker translated a program without its root: {messages}" + return None + + names = ("TUXBOX_LOG", "WINEDEBUG", "TUXBOX_TRACE_RASTER_ROOTS", "TUXBOX_SHADER_SESSION", "TUXBOX_RASTER_ROOT_FALLBACK") + saved = {name: host.env.get(name) for name in names} + host.env.update(TUXBOX_LOG="1", WINEDEBUG="-all,+debugstr", TUXBOX_TRACE_RASTER_ROOTS="1") + # The fallback translates against the title's root and would hide a missing reflection. + for name in ("TUXBOX_SHADER_SESSION", "TUXBOX_RASTER_ROOT_FALLBACK"): + host.env.pop(name, None) + try: + forget(rootless) + with shader_session(sources.parent, host.env, messages.append): + check("lanes-raster-tables", "lanes/lanes.exe", ["--selftest", "raster-tables", *gpu_args, "--report"], + rf"lanes-selftest PASS pci={pci} scenario=raster-tables passed=1", + providers={"lanes/xmem.dll": memory_symbols, "lanes/GameInput.dll": ("#1",), + "lanes/d3d12_xs.dll": ("D3D12XboxCreateDevice",)}, + config="lanes/MicrosoftGame.config", device_factory="xbox", log_check=expect_reflected) + finally: + forget(rootless | compiled()) + for name, value in saved.items(): + if value is None: + host.env.pop(name, None) + else: + host.env[name] = value + + def verify(host, output, adapter, selected=None, samples=1): if adapter and not re.fullmatch(r"[0-9a-fA-F]{4}:[0-9a-fA-F]{4}", adapter): raise ValueError("Adapter must be a PCI vendor:device pair in hexadecimal") @@ -650,6 +711,8 @@ def exports_receipt(_imports): if "lanes-shader-cache" in selected and host.backend == "proton": lanes_shader_cache(host, check, gpu_args, pci, memory_symbols, work) lanes_wave_shader(host, check, gpu_args, pci, memory_symbols) + if "lanes-raster-tables" in selected and host.backend == "proton": + lanes_raster_tables(host, check, gpu_args, pci, memory_symbols) if "cpu-benchmark" in selected: readings = [] for _ in range(samples): @@ -760,6 +823,7 @@ def exports_receipt(_imports): "lanes-shader-cache-reused": "The worker's translation reused on the next launch without compiling", "lanes-wave-shader-narrow": "A 64-lane console shader translated for 32-lane waves while the game runs", "lanes-wave-shader-host": "A 64-lane console shader with the translation this graphics card needs", + "lanes-raster-tables": "Console raster programs drawn under the root reflected from their two descriptor tables", "lanes-package-replay": "Lanes gameplay replay (earlier guest with desktop graphics)", "cpu-replay": "8,388,608-move CPU replay", } diff --git a/runtime/dxbc/src/tests/compute_table.rs b/runtime/dxbc/src/tests/compute_table.rs index 0860e4d3..3f061414 100644 --- a/runtime/dxbc/src/tests/compute_table.rs +++ b/runtime/dxbc/src/tests/compute_table.rs @@ -200,6 +200,22 @@ fn multi_table_raster_buffer_views_follow_psv() { assert_eq!(bindings(&uav, 0), None); } +#[test] +fn multi_table_raster_raw_view_keeps_the_shader_register() { + // The Lanes `raster-tables` pixel program: a raw SRV t3 space2 at slot 2 of + // table 1, under a root whose table 1 declares t0..t3 in space 1. + let range = |num, space| RootRange { range_type: 0, num, base_register: 0, space, offset_in_table: 0 }; + let root = tables_then(&[RootParamKind::Table(vec![range(1, 0)]), RootParamKind::Table(vec![range(4, 1)]), + RootParamKind::Constants { register: 500, space: 0, num32: 1 }]); + let pixel = raster_shader(0, &[[3, 16, 1, 3, 0x109]], &[[0x300, 16, 3, 1, 0x1_0904]], &[[4, 2, 3, 3]]); + let vertex = raster_shader(1, &[], &[], &[]); + let merged = root_bindings(&vertex, 1, &root).zip(root_bindings(&pixel, 0, &root)) + .and_then(|(v, p)| merge_raster_bindings(v, p)); + assert_eq!(merged, Some(vec![Binding { table: 1, kind: 0, register: 3, space: 2, slot: 2 }])); + // Without the user-data row the descriptor is unconfirmed. + assert_eq!(root_bindings(&raster_shader(0, &[], &[[0x300, 16, 3, 1, 0x1_0904]], &[[4, 2, 3, 3]]), 0, &root), None); +} + #[test] fn same_register_at_two_slots_fails_closed() { let image = program( diff --git a/tests/test_lanes_raster.py b/tests/test_lanes_raster.py new file mode 100644 index 00000000..ac7f43ff --- /dev/null +++ b/tests/test_lanes_raster.py @@ -0,0 +1,138 @@ +from contextlib import contextmanager +import hashlib +from pathlib import Path +import re +import struct +from tempfile import TemporaryDirectory +from types import SimpleNamespace +import unittest +from unittest import mock +import zlib + +from examples.lanes import raster_fixture +from project_tuxbox.shader_prep import SOURCE_CACHE +from project_tuxbox.verify import BASE_SUITES, LANES_SCENARIOS, lanes_raster_tables + + +def parts(data): + count = struct.unpack_from("> 16, stage) + self.assertEqual(found[b"PSV0"][28], stage) + pixel = parts(raster_fixture.pixel()) + program = fssm(pixel[b"DXIL"]) + self.assertEqual(struct.unpack_from("