diff --git a/src/startup_stubs/d3d12_compute_dispatch.inl b/src/startup_stubs/d3d12_compute_dispatch.inl index 9356b70f3f..57d8943143 100644 --- a/src/startup_stubs/d3d12_compute_dispatch.inl +++ b/src/startup_stubs/d3d12_compute_dispatch.inl @@ -694,7 +694,12 @@ 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, 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; @@ -703,7 +708,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)