Repository navigation
borealis: exact buffer-alias and VA-range tracking for ALIAS_BIT render sync and packing - #1220
Conversation
…er sync and packing Applications running through D3D12-to-Vulkan layers (vkd3d-proton) set VK_IMAGE_CREATE_ALIAS_BIT on every placed render target even when those targets live in image-only heaps at disjoint virtual addresses. Treating every ALIAS_BIT attachment as a general memory writer and every ALIAS_BIT layout transition as aliasing previously forced HK_SYNC_GFX_MEM on the majority of renders (preventing TA/3D pipelining) and broke cross-command- buffer render packing at render-target layout-decay barriers. 1. Track atomic has_image_binding and has_buffer_binding flags on hk_device_memory plus a monotonic hk_device::buffer_alias_mem_gen counter bumped when a buffer is first bound to an image-bearing memory. Exempt optimal ALIAS_BIT attachments on image-only, non-external memory from m5_attachments_reach_memory (HK_SYNC_GFX_MEM), and conservatively upgrade affected streams and intra-CB vertex waits at submit time if buffer_alias_mem_gen advanced after recording. 2. Check GPU VA-range overlap (hk_image_va_range) for non-sparse, non-external ALIAS_BIT image layout transitions in pass merging and cross-command-buffer render packing, and treat content-preserving (oldLayout != UNDEFINED) layout transitions on non-sparse images as transparent for single-sample render packing. Signed-off-by: DjDeveloperr <hey@djdev.me>
|
J773g (M4 Mac mini, G16G B0, HAL200, second generation) at Both arms are release Borealis Vulkan overlays built natively on the Mac and loaded from private prefixes through
|
|
Verdict at Blockers None. Checked
Edge (not blocking). The submit-time check only covers command buffers submitted after the bind. If a buffer is bound to the memory while a command buffer that rendered into it is still running, a later render whose vertex stage writes that buffer (storage or transform feedback) narrows its vertex wait past the earlier render. Reads through the buffer are undefined there anyway; only that write ordering is affected. Raising the queue's prior |
Summary
Replaces blanket
VK_IMAGE_CREATE_ALIAS_BITworst-case render synchronization and pass-merge/render-pack refusal with exact per-memory buffer-aliasing and GPU VA-range tracking:hk_device_memorybuffer/image binding tracking with submit-time resolution (has_image_binding,has_buffer_binding,buffer_alias_mem_gen):hk_device_memorywhether any image and/or any buffer has been bound to it, plus a monotonic device-wide counterhk_device::buffer_alias_mem_genincremented whenever a buffer is bound to an image-bearing memory (or an image to a buffer-bearing memory).ALIAS_BITimages on image-only memory heaps (the standard D3D12-on-Vulkan /vkd3d-protonplaced render-target heap layout) no longer conservatively forceHK_SYNC_GFX_MEMon every render pass, restoring vertex/tiling (ta=S) pipelining across passes.hk_sync_resolve_submit_ex()), ifbuffer_alias_mem_genchanged after command buffer recording (a buffer was bound to an image-bearing memory post-record), Borealis conservatively upgrades affected streams (alias_image_render) back toHK_SYNC_GFX_MEMand widens intra-CBbarrier_ta/prior_ta, preserving 100% soundness against late buffer aliasing.ALIAS_BITlayout transitions:ALIAS_BITimage's bound GPU VA range (hk_image_va_range) and allows content-preserving (oldLayout != UNDEFINED), non-ownership-transfer layout transitions ofALIAS_BITimages to stay transparent in pass merging (hk_m5_pass_merge_classify()) and cross-CB render packing (hk_render_pack_classify()/hk_render_pack_begin()) when their VA range does not overlap any attachment of the pass.vkd3d-protonrender-target layout decay (GENERAL <-> COLOR_ATTACHMENT_OPTIMAL) on disjointALIAS_BITimages sharing one device heap.Soundness & Invariants
VkBufferbound to aVkDeviceMemorythat already has (or later receives) aVkImageincrementshk_device::buffer_alias_mem_genwith release/acquire ordering. Command buffers record the generation observed during recording (alias_mem_gen) and mark render streams that skippedHK_SYNC_GFX_MEM(alias_image_render); if the generation advances before submit,hk_sync_resolve_submit_ex()upgrades those streams to fullHK_SYNC_GFX_MEMand widensbarrier_ta/prior_ta.ALIAS_BITsafety: Sparse images (VK_IMAGE_CREATE_SPARSE_BINDING_BIT),oldLayout == UNDEFINEDdiscard transitions, queue-family ownership transfers, and anyALIAS_BITimage whose bound GPU VA range overlaps an active pass attachment still conservatively end pass merging and render packing (HK_M5_MERGE_DEP_END).src/asahi/vulkan/tests/test-hk-sync-prior.ccovering image-only alias heaps, buffer-bound alias heaps, late post-record buffer binding upgrade at submit time, and disjoint vs overlapping VA-range layout transitions.Verification (J714s / AGX3C / HAL300, Slot
s4, base9830668dd6b1)--suite asahi):Fail: 0,SpillRepeatPair: 14 OK, 0 FAILED).-Db_ndebug=false): 331/331 PASS (Fail: 0).hk-vulkan-render-pack-replay: 440/440 scenario submissions exact (0faults).vulkan-storage-alias: 32/32 case groups pass (0faults).synchronization2,memory.requirements,dynamic_rendering.primary_cmd_buff.basic,renderpass2.suballocation.load_store_op_none): 313 Pass / 8 Skip / 0 Fail (0faults).-Werror:0warnings/errors in touched files.3024x1964, native internal resolution,ResScalingType=0, VSync off, isolated kits on same boot,A1 B1 B2 A2,0GPU faults /crashed=0/quarantined=0, screenshots visually verified):A1:P0=56.36 P1=51.86 P2=51.59 P3=55.54 P4=54.33B1:P0=55.95 P1=51.59 P2=52.81 P3=57.66 P4=55.17B2:P0=56.02 P1=51.75 P2=52.40 P3=57.88 P4=55.41A2:P0=56.22 P1=51.94 P2=52.53 P3=57.74 P4=55.38P2 +1.05%(52.06 -> 52.61),P3 +2.00%(56.64 -> 57.77),P4 +0.79%(54.86 -> 55.29),P0 -0.54%,P1 -0.44%.Not yet
Nothing — J714s (AGX3C/HAL300) exact-head verification above and J773g (AGX3B/HAL200) 2nd-gen verification (
#issuecomment-7215198124, 33,097 CTS cases, 440/440 replay, 214/214 unit tests, 0 faults) atbcd0ad703e4fare both complete.