Repository navigation
Interop slices, formats and GPU waits; enable2-only Vulkan; GPU skybox; mirror flips; fades on own frames - #81
Open
feimos-dev wants to merge 19 commits into
Open
feimos-dev wants to merge 19 commits into
feimos-dev wants to merge 19 commits into
Conversation
…rmats and GPU waits, flipped mirrors, fades in own frames
feimos-dev
marked this pull request as ready for review
November 20, 2026 23:32
…mat, Vulkan array layers out of range
…r turning both ways kept
…on a busy Vulkan queue, skybox grids
…the copy waits on every stage; more copies kept
…slices share a copy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Graphics interop (OpenGL and Vulkan copied through D3D11)
Array slices. The layer shown is chosen the same way the native compositors choose it. OpenGL: SubmitWithArrayIndex's slice, else the eye's for
Submit_GlArrayTexture(read withglFramebufferTextureLayer). Vulkan: SubmitWithArrayIndex's slice, elseVRVulkanTextureArrayData_t::m_unArrayIndexforSubmit_VulkanTextureWithArrayData.OpenGL renderbuffers and multisampled textures.
Submit_GlRenderBufferandGL_TEXTURE_2D_MULTISAMPLEsources are copied too. A multisampled one goes through a resolving blit, which can't also flip rows or change the format: that copy stays in GL row order, and the bounds flip it instead (vMin > vMax, which the D3D11 shader pass applies); a format with no D3D11 format of the same texels is refused. A single-sampled renderbuffer is copied as a texture is. Copies are keyed by name and kind, because a renderbuffer and a texture can share a name. A name of another kind than the submit says isn't read as the texture bound before it.More formats. The formats now come from the compositors' format table. Two new functions in
FormatTabledo the mapping, both unit-tested:SameTexelsInfinds another API's format with the same texels.ConvertibleColourIngives a format a GL blit can convert into without losing range: 8-bit RGBA with the same sRGB-ness, or 16-bit float RGBA.GPU-side waits for Vulkan. Two
ID3D11Fences are created withD3D11_FENCE_FLAG_SHAREDand imported into the game's device as semaphores (vkImportSemaphoreWin32HandleKHR,VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_D3D11_FENCE_BIT). Values are passed throughVkD3D12FenceSubmitInfoKHR. Each frame:Signals andFlushes.Waits for the copy's value.This replaces the CPU fence wait of up to 100 ms per eye per frame. If either side lacks the fences or semaphores, the CPU wait stays as before, and the choice is logged once. The D3D11 device's context is made multithread-protected, as the game's submits and overlays both use it.
A ring of command buffers. Four command buffers and fences are used in turn (two eyes, two frames running), so an eye's copy doesn't wait for the other's. Copies are kept per image and array layer, up to 32.
Vulkan device extensions
GetVulkanDeviceExtensionsRequirednow usespPhysicalDevice, but only for a device thatGetOutputDevicereturned. The conformance suite passes arbitrary pointers, and a pointer that isn't a physical device can't be told apart from one.VK_KHR_external_semaphoreandVK_KHR_external_semaphore_win32when the device has both; the instance list hasVK_KHR_external_semaphore_capabilities.vkCreateDevicefail; leaving it out risks only a failed session, which has a fallback.Vulkan on runtimes with XR_KHR_vulkan_enable2 alone
xr_extwrappers then go throughxrGetVulkanGraphicsDevice2KHRandxrGetVulkanGraphicsRequirements2KHR.xrCreateVulkanInstanceKHRandxrCreateVulkanDeviceKHR.xrCreateVulkanDeviceKHR.scripts/gfx_vk_enable2.jsonwithexpect/gfx_vk_enable2.json.Six-face skybox on the GPU (D3D11)
Compositor::InvokeCubemap. In D3D11 it:ps_cube). The shader mirrorsCubeFacesToEquirect's face selection and orientation exactly, and handles sRGB the same way as the existing pass.D3D11 mirror texture: flipped bounds
MirrorUpdatenow applies flipped bounds by copying one row or column at a time, sinceCopySubresourceRegioncan't flip. When both directions flip, the copy goes through a texture of the area's size, kept for the next frame. A multisampled frame is resolved first, as before.Fades on own frames
Own frames carry the fade over the scene, the same way the game's frames do. A visible fade keeps own frames running.
Checked on Linux
scripts/ci/build-linux.sh --tests x64(including the new unit tests), the stand-in runtime ctest,scripts/ci/conformance-linux.sh x64andabort_sites.py --checkall pass.ps_cubeis compiled at runtime withD3DCompile. If it fails to compile, skyboxes fall back to the CPU path.Fixed after the GPU checks
SubmitWithArrayIndexthrough the interop. The slice was applied to the game's texture by the interop's copy, and again by the D3D11 compositor to the copy, which holds only that slice: the submit answered InvalidTexture. The compositor now reads the copy's only slice.m_unArraySizeare refused; the copy's semaphore wait covers all its commands.Checked on a GPU
On Windows with an NVIDIA GPU, against the stand-in runtime, with new conformance cases (in CI; the OpenGL and Vulkan ones skip there, as CI has no driver for them). The Vulkan cases also ran with the Khronos validation layer on, which reported nothing.
skybox-6matchesexpect/skybox.jsonand the log has no "joined on the CPU": the GPU pass drew it.skybox-6andskybox-1. The grids are pinned inexpect/skybox.json.gfx-vk-interop-gpu-wait"painted"): the last frame's colour shows. A build without D3D11's wait showed the frame before's in one eye, now and then, so the case can catch that.GetVulkanDeviceExtensionsRequirednames (gfx-vk-interop-gpu-wait): the log says "waited for on the GPU (shared fences)", and frames show. Frame time, as the Submit calls' time per frame over 300 frames (--case-arg time=300), with the game's queue still clearing a 4096 x 4096 image 40 times when it submits (--case-arg busy=40): 0.95 ms with the GPU wait against 3.49 ms with the CPU wait (--case-arg plain=1). With the GPU idle, the GPU wait costs a little more: 0.45 ms against 0.17 ms, for the fence signal and flush per copy.gfx-vk-interop): the log says "on the CPU", and frames show.gfx-gl-interop-odd,gfx-vk-interop-odd):Submit_GlArrayTexture,Submit_VulkanTextureWithArrayDataandSubmitWithArrayIndexeach show the right slice. (SubmitWithArrayIndexonly since the fix above.)gfx-gl-interop-odd, with another texture left bound in the context, as games have): upright; a renderbuffer with flipped bounds is upside down, as it should be.gfx-gl-interop-formats,gfx-vk-interop-formats, under a runtime with D3D11 alone and RGBA8 sRGB swapchains only):GL_RGB8,GL_R11F_G11F_B10F,GL_RGBA16F,GL_RGB10_A2, VulkanB10G11R11_UFLOAT,R16G16B16A16_SFLOAT,A2B10G10R10_UNORMandB8G8R8A8_SRGBall show the pattern.GetMirrorTextureD3D11with flipped bounds (mirror-flipped): the mirror is the right way round for bounds flipped in v, in u and in both.own-frames-fade): own frames keep going, each with the fade over the game's last frame.The fade, mirror and interop array, renderbuffer and multisampled cases also ran against
main's code: each failed there, but for the Vulkan array data one.Not in this change