Skip to content
Open
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions runtime/shims/d3d12_vulkan_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5828,6 +5828,16 @@ class Resource final
};
VkMemoryRequirements requirements{};
vk.vkGetBufferMemoryRequirements(device_.info.device, buffer_, &requirements);
// On GPUs where UNIFORM_BUFFER_BIT rounds requirements.size past `bytes` (e.g. above minImportedHostPointerAlignment),
// D3D12 CBVs need 256-byte address and size alignment anyway and the layer encodes CBVs as raw V#s, so drop
// UNIFORM_BUFFER_BIT when the UBO size rounding exceeds the imported host range.
if (requirements.size > bytes) {
vk.vkDestroyBuffer(device_.info.device, buffer_, nullptr);
buffer_ = VK_NULL_HANDLE;
info.usage &= ~VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
if (vk.vkCreateBuffer(device_.info.device, &info, nullptr, &buffer_) != VK_SUCCESS) return decline(E_OUTOFMEMORY);
vk.vkGetBufferMemoryRequirements(device_.info.device, buffer_, &requirements);
}
VkMemoryHostPointerPropertiesEXT host{VK_STRUCTURE_TYPE_MEMORY_HOST_POINTER_PROPERTIES_EXT};
if (device_.get_host_pointer_properties(device_.info.device,
VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT, base_address,
Expand Down
4 changes: 3 additions & 1 deletion runtime/test/d3d12_existing_heap_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -606,9 +606,11 @@ int check_title_placed_all(ID3D12Device* device) {
failures += check_title_placed(device, "VirtualAlloc range", pages, size);
failures += check_placed_texture_views(device, pages);
// Inside a page, as the title places small UAV buffers (64-byte aligned, found in review on an RTX 5090): the
// import starts at the page and the buffer is bound at the offset.
// import starts at the page and the buffer is bound at the offset. Also check a 16-byte slice 64 bytes from the
// end of the committed range, where 256-byte uniform-buffer size rounding would run past the page.
failures += check_title_placed(device, "64 bytes into a page", static_cast<char*>(pages) + 64, 0x1000 - 64);
failures += check_host_prefix_buffers(device);
failures += check_title_placed(device, "16 bytes near the end of the range", static_cast<char*>(pages) + size - 64, 16);
VirtualFree(pages, 0, MEM_RELEASE);
HANDLE section = CreateFileMappingW(INVALID_HANDLE_VALUE, nullptr, PAGE_READWRITE, 0, DWORD(size), nullptr);
void* view = section ? MapViewOfFile(section, FILE_MAP_ALL_ACCESS, 0, 0, size) : nullptr;
Expand Down
Loading