mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-27 00:45:53 +01:00
[PR #1458] d3d12: drop UNIFORM_BUFFER_BIT on sub-page host imports refused by 256B UBO alignment (D3D12-HOST-BUFFER-SUBPAGE-UBO) #1488
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1488
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1458
Author: @robot00f
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/host-buffer-subpage-ubo📝 Commits (1)
9f85ac6d3d12: drop UNIFORM_BUFFER_BIT on sub-page host imports refused by 256B UBO alignment📊 Changes
2 files changed (+13 additions, -1 deletions)
View changed files
📝
runtime/shims/d3d12_vulkan_device.cpp(+10 -0)📝
runtime/test/d3d12_existing_heap_test.cpp(+3 -1)📄 Description
Claimed in the coordination issue as: D3D12-HOST-BUFFER-SUBPAGE-UBO (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7148550801)
What and why
On
main(b4b7756e),d3d12_existing_heapfails deterministically (3/3) on NVIDIA Pascal atruntime/test/d3d12_existing_heap_test.cpp:196duringcheck_title_placed(device, "64 bytes into a page", pages + 64, 0x1000 - 64)(d3d12_existing_heap_test.cpp:271), whereResource::create_host_bufferreturnsE_NOTIMPL(0x80004001) andcreate_at_host_addressfalls back to a non-aliasing buffer.Measured cause on NVIDIA GeForce GTX 1050 Ti (driver 582.28):
host_pointer_alignment = 4096,minUniformBufferOffsetAlignment = 256,minStorageBufferOffsetAlignment = 16.Resource::create_host_buffer(runtime/shims/d3d12_vulkan_device.cpp:2077) unconditionally requestsVK_BUFFER_USAGE_UNIFORM_BUFFER_BIT.minUniformBufferOffsetAlignment = 64), a 4032-byte buffer at sub-pageoffset = 64reportsrequirements.alignment = 64andrequirements.size = 4032, which fits inbytes = 4096.minUniformBufferOffsetAlignment = 256),VK_BUFFER_USAGE_UNIFORM_BUFFER_BITraisesrequirements.alignmentfrom16to256and roundsrequirements.sizeup to a multiple of256(4032 -> 4096,16 -> 256). Atoffset = 64, both guards atd3d12_vulkan_device.cpp:2092fail (64 % 256 != 0and4096 < 64 + 4096); a 16-byte UAV placed 64 bytes before the end of a page (offset = 4032,size = 16) likewise fails both checks (4032 % 256 != 0and4096 < 4032 + 256). WithoutVK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, the same buffers reportrequirements.alignment = 16andrequirements.size = 4032/16.D3D12 constant-buffer views require 256-byte address and size alignment (
D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT) anyway, and the layer encodes CBVs as 16-byte GFX10 rawV#descriptors (CreateConstantBufferView,d3d12_vulkan_device.cpp:6560) rather thanVK_DESCRIPTOR_TYPE_UNIFORM_BUFFER.Changes:
Resource::create_host_buffer(runtime/shims/d3d12_vulkan_device.cpp), when(offset % requirements.alignment) || requirements.size > bytes - offset, recreatebuffer_withoutVK_BUFFER_USAGE_UNIFORM_BUFFER_BITand re-queryVkMemoryRequirementsbefore checking the final alignment and room guards (written asrequirements.size > bytes - offsetto avoid unsigned addition wrap). Page-aligned and 256-byte-aligned slices keep the existing usage flags unchanged, and genuinely unaligned addresses (bytes + 1) still take the committed-buffer fallback.runtime/test/d3d12_existing_heap_test.cpp, add a 16-byte sub-page case 64 bytes from the end of the committed range ("16 bytes near the end of the range") so both the sub-256-byte offset and the 256-byte UBO size-rounding overflow past the page boundary are covered.Tested
Built with MSVC 19.44 (Visual Studio 2022 Professional), Ninja,
RelWithDebInfo,VK_LOADER_LAYERS_DISABLE=~implicit~.mainb4b7756e)fix/host-buffer-subpage-ubo)d3d12_existing_heap(3 consecutive runs)1.18 s,0.73 s,0.73 s) at line 196 ("64 bytes into a page",E_NOTIMPL)0.89 s,0.67 s,0.67 s), including"64 bytes into a page","16 bytes near the end of the range", and all 8OpenExistingHeapFromAddressparity cases against GTX 1050 Ti and WARPdevice_proxy,xmem,vk_host_region_import,d3d12_xmem_placed,d3d12_descriptor,d3d12_console_descriptor_heap)2.29 stotal)Additional checks:
python -I scripts/check_no_game_data.py runtime/shims/d3d12_vulkan_device.cpp runtime/test/d3d12_existing_heap_test.cpp(exit 0)python -I tests/test_docs_links.py(16 tests, OK) andpython -I tests/test_docs_table_rows.py(2 tests, OK)git diff --check(exit 0)LEONIDA_VK_VALIDATION=1(VK_LAYER_KHRONOS_validationis not installed on this machine), the fullctestsuite, Windows 11, Turing+/AMD/Intel GPUs, or Linux/Wine.GPUs tested: NVIDIA GeForce GTX 1050 Ti (Pascal, 4 GB), driver 582.28, Vulkan 1.4.312, Windows 10 Pro 10.0.19045
AI-assisted: yes (Antigravity)
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.