Files
metal2vulkan/crates
Anees Iqbal cd5d7df2f0 Runtime: every acquire of a Direct3D 11 plane names the general layout, the first included
A consumer's video path showed green frames. A plane's first acquire named the undefined layout
unless Surface::external_writes_done had been called before the first commit that used it, and a
transition from the undefined layout need not keep the bytes (section 12.5.1: "implying that the
contents of the image subresource need not be preserved"). What 9737a44d98 and its test 7c5df5a317
left open: whether that first acquire discards depended on the order the commit and the call
arrived in. The consumer's decode order today is fence wait, external_writes_done, then the
session's signal, so the hole is reached by a guest command buffer that reads a new cache's planes
without waiting on the session, committed between the draw's completion and the call.

Now Image::handed names the general layout as the old layout of every acquire, the first included,
and of every release. A Direct3D 11 plane is made owing no move (its homed flag set), so no upload
moves it, as before 9737a44d98. Surface::external_writes_done records nothing and changes nothing
for a Direct3D 11 surface; Image::external_access, which it called, is gone. No barrier, command
buffer, submission or wait is added or removed: the acquire is the same barrier with another old
layout.

The spec's form for this handle type. Section 12.5.2: "When images created with external memory
handle types listed in the external image implied layouts table are accessed outside of Vulkan,
they must be in the layout specified in the table, and can be assumed to be in that layout when
they are accessed in Vulkan after external access", and Table 17 gives
VK_EXTERNAL_MEMORY_HANDLE_TYPE_D3D11_TEXTURE_BIT the layout VK_IMAGE_LAYOUT_GENERAL. The conflict
9737a44d98 met (a plane rt uses before any Direct3D 11 access, whose image is made undefined) is
answered by section 12.10.1's note on an image bound to memory another API owns: "Such an image is
not usable until it acquires ownership of its memory from the existing owner. Therefore, the layout
specified as part of this transition will be the true initial layout of the image. The undefined
layout specified when creating it is a placeholder to simplify valid usage requirements."
Direct3D 11 made the texture, so it is that owner, and VUID-VkImageMemoryBarrier-
srcQueueFamilyIndex-12332 allows the general layout for any acquire of such an image from
VK_QUEUE_FAMILY_EXTERNAL ("oldLayout must be VK_IMAGE_LAYOUT_GENERAL or
VK_IMAGE_LAYOUT_UNDEFINED"). Left open by the text: whether Direct3D 11's making of a texture with
no initial data counts as an access "outside of Vulkan"; such a texture's bytes are undefined
either way, and the acquire that names the general layout is allowed by the VUID.

The suite now states this rule: every_device_acquires_a_direct3d_11_plane_from_the_general_layout_
first_included replaces the first-use test and reads the old layouts from Work::acquired, the
general layout for every acquire, with and without the call first. The d3d11 module's doc,
import_d3d11_surface's Layout, Ownership and precondition paragraphs, external_writes_done's doc
and the runtime README say so; the consumer's precondition no longer names the call.

Not yet run on a device: the red test's run at d68f165aae and this commit's run of tests::d3d11
on the UHD 630 wait for the card, which potluck does not list on the Windows host as this is
committed; their jobs are reported with the lane's tip. The Windows cross-build of this commit is
its compile check.
2026-12-02 02:22:45 -08:00
..