From 76d708e03186bad5d43df743ea7526495649359b Mon Sep 17 00:00:00 2001 From: Kelbo Date: Sun, 29 Nov 2026 14:25:36 -0500 Subject: [PATCH 1/3] compute: size an output token's view against the record, not the desktop header The guest record is ViewRecord::uav_desc_bytes wide, but the check used sizeof(D3D12_UNORDERED_ACCESS_VIEW_DESC): 40 bytes with the in-box header and 48 with the Agility SDK 1.620.2 header. Under Agility every output token was judged unmaterialized and the dispatch was refused, so the UAV kept the sentinel fill. Compare against the record width and copy only the bytes the record has. --- src/startup_stubs/d3d12_compute_dispatch.inl | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/startup_stubs/d3d12_compute_dispatch.inl b/src/startup_stubs/d3d12_compute_dispatch.inl index 9356b70f3f..dfd1485c29 100644 --- a/src/startup_stubs/d3d12_compute_dispatch.inl +++ b/src/startup_stubs/d3d12_compute_dispatch.inl @@ -694,7 +694,13 @@ const char* compute_token_output(Wrapper* list, const std::uint32_t* words, Comp output.guest_resource = record.resource; output.description_bytes = record.desc_bytes; output.counter = record.counter; - if (record.desc_bytes >= sizeof(output.view)) std::memcpy(&output.view, record.desc, sizeof(output.view)); + // The guest record is ViewRecord::uav_desc_bytes wide whatever the desktop struct is: the Agility + // SDK 1.620.2 header makes D3D12_UNORDERED_ACCESS_VIEW_DESC 48 bytes where the in-box header and + // the record use 40. Zero-initialised view{} keeps the tail defined. + if (record.desc_bytes >= ViewRecord::uav_desc_bytes) { + const std::size_t copy = record.desc_bytes < sizeof(output.view) ? record.desc_bytes : sizeof(output.view); + std::memcpy(&output.view, record.desc, copy); + } auto* owner = as_wrapper(reinterpret_cast(record.resource)); auto* resource = owner && owner->own().kind == resource_kind ? static_cast(owner->own().real) : nullptr; const ResourceInfo* info = owner && owner->own().kind == resource_kind ? resource_info(owner) : nullptr; @@ -703,7 +709,7 @@ const char* compute_token_output(Wrapper* list, const std::uint32_t* words, Comp output.guest_base = reinterpret_cast(owner->own().title_memory); output.backing = info->console; } - if (!output.created || !record.resource || record.counter || record.desc_bytes < sizeof(output.view)) + if (!output.created || !record.resource || record.counter || record.desc_bytes < ViewRecord::uav_desc_bytes) return "an output token lacks a materialized explicit counterless UAV"; if (output.view.ViewDimension != D3D12_UAV_DIMENSION_BUFFER || !info || info->console.Dimension != D3D12_RESOURCE_DIMENSION_BUFFER) From a11cdd6b16e12ea32d1c7e423cd38b95670db3d6 Mon Sep 17 00:00:00 2001 From: Kelbo Date: Sun, 29 Nov 2026 17:34:53 -0500 Subject: [PATCH 2/3] ci: retrigger the Windows check From 7c52ab9ec91db14bc3afe95b80ac12e648b87953 Mon Sep 17 00:00:00 2001 From: Kelbo Date: Sun, 29 Nov 2026 17:47:43 -0500 Subject: [PATCH 3/3] compute: copy the record width directly, as the sibling path does Review follow-up: the guard already holds desc_bytes to at least ViewRecord::uav_desc_bytes and the record is 64 bytes wide, so a fixed 40-byte copy needs no clamp. Same form as d3d12_compute_dispatch.inl:952. --- src/startup_stubs/d3d12_compute_dispatch.inl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/startup_stubs/d3d12_compute_dispatch.inl b/src/startup_stubs/d3d12_compute_dispatch.inl index dfd1485c29..57d8943143 100644 --- a/src/startup_stubs/d3d12_compute_dispatch.inl +++ b/src/startup_stubs/d3d12_compute_dispatch.inl @@ -696,11 +696,10 @@ const char* compute_token_output(Wrapper* list, const std::uint32_t* words, Comp output.counter = record.counter; // The guest record is ViewRecord::uav_desc_bytes wide whatever the desktop struct is: the Agility // SDK 1.620.2 header makes D3D12_UNORDERED_ACCESS_VIEW_DESC 48 bytes where the in-box header and - // the record use 40. Zero-initialised view{} keeps the tail defined. - if (record.desc_bytes >= ViewRecord::uav_desc_bytes) { - const std::size_t copy = record.desc_bytes < sizeof(output.view) ? record.desc_bytes : sizeof(output.view); - std::memcpy(&output.view, record.desc, copy); - } + // the record use 40. Zero-initialised view{} keeps the tail defined, and the static_asserts below + // hold the desktop struct to at least the record width. + if (record.desc_bytes >= ViewRecord::uav_desc_bytes) + std::memcpy(&output.view, record.desc, ViewRecord::uav_desc_bytes); auto* owner = as_wrapper(reinterpret_cast(record.resource)); auto* resource = owner && owner->own().kind == resource_kind ? static_cast(owner->own().real) : nullptr; const ResourceInfo* info = owner && owner->own().kind == resource_kind ? resource_info(owner) : nullptr;