Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/startup_stubs/d3d12_compute_dispatch.inl
Original file line number Diff line number Diff line change
Expand Up @@ -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<void*>(record.resource));
auto* resource = owner && owner->own().kind == resource_kind ? static_cast<ID3D12Resource*>(owner->own().real) : nullptr;
const ResourceInfo* info = owner && owner->own().kind == resource_kind ? resource_info(owner) : nullptr;
Expand All @@ -703,7 +708,7 @@ const char* compute_token_output(Wrapper* list, const std::uint32_t* words, Comp
output.guest_base = reinterpret_cast<u64>(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)
Expand Down
Loading