Repository navigation
d3d12: drop UNIFORM_BUFFER_BIT on sub-page host imports refused by 256B UBO alignment (D3D12-HOST-BUFFER-SUBPAGE-UBO) - #1458
Conversation
|
I checked #1192 includes the page prefix in the Vulkan buffer size and binds at offset zero. Based on the reported 256-byte rounding, both Pascal cases here should fit in a 4 KiB import with that approach. The two aliasing cases in this PR would help verify whether #1192 covers them on Pascal. This is a source comparison and merge check. I did not run either head on Pascal. AI-assisted. |
|
Independent verification on both of our GPUs (native Windows 11, validation on):
One honest caveat: neither of our GPUs has AI-assisted verification. |
12862a6 to
96b22d7
Compare
…6B UBO alignment Resource::create_host_buffer adds VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT to every imported host buffer. On GPUs whose minUniformBufferOffsetAlignment is 256 bytes (measured on NVIDIA GeForce GTX 1050 Ti, Pascal), that raises VkMemoryRequirements::alignment from 16 to 256 and rounds requirements.size up to a multiple of 256, refusing 64-byte-aligned sub-page slot-133 placements such as "64 bytes into a page" in d3d12_existing_heap_test with E_NOTIMPL. D3D12 constant-buffer views require 256-byte address and size alignment anyway, and the layer encodes CBVs as raw GFX10 V# descriptors rather than Vulkan uniform buffers. Recreate the VkBuffer without VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT when the UBO requirement rejects a sub-page offset or size, compare remaining bytes without addition wrap, and add a 16-byte end-of-range sub-page case to d3d12_existing_heap_test.
96b22d7 to
9f85ac6
Compare
|
Rebased (9f85ac6) onto current main (�0f3d399, after #1192 merged) and verified on 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) |
Claimed in the coordination issue as: D3D12-HOST-BUFFER-SUBPAGE-UBO (#14 (comment))
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)