Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for extension VK_EXT_headless_surface. #2086

Merged

Conversation

billhollings
Copy link
Contributor

@billhollings billhollings commented Dec 3, 2023

  • Consolidate info about CAMetalLayer and headless in MVKSurface.
  • MVKSwapchainImage remove getCAMetalDrawable() and focus on abstracting getMTLTexture().
  • MVKPresentableSwapchainImage::getCAMetalDrawable() return nil if headless.
  • Add MVKPresentableSwapchainImage::_mtlTextureHeadless to support a fixed MTLTexture that is not retrieved from a CAMetalDrawable.
  • MVKPresentableSwapchainImage refactor signalling semaphores and fences.
  • MVKPresentableSwapchainImage don't lock when signalling semaphores and fences.
  • If no present occurs, actualPresentTime will be zero. Set it to current time, instead of to desiredPresentTime, since it's more accurate.
  • Rework timestamps:
    • Remove _mvkTimestampBase so mvkGetTimestamp() is equal to mach_absolute_time(), which is used in presentation timing.
    • Add mvkGetRuntimeNanoseconds().
    • Rename mvkGetAbsoluteTime() to mvkGetContinuousNanoseconds().
    • Remove mvkGetTimestampPeriod() as unused.
  • MVKSemaphoreMTLEvent::encodeDeferredSignal remove redundant nil test (unrelated).
  • Fix swapchain and surface bugs when windowing system is accessed from off the main thread (unrelated).
  • Log warning when deprecated functions vkCreateMacOSSurfaceMVK()
    or vkCreateIOSSurfaceMVK() are used (unrelated).
  • Remove documentation for visionos, as support is not ready (unrelated).

Fixes #2049.
Fixes #2085.

Passes all related CTS WSI tests.

@billhollings billhollings requested a review from cdavis5e December 3, 2023 00:32
@billhollings
Copy link
Contributor Author

@cdavis5e

The (now renamed) mvkGetContinuousNanoseconds() was introduced for VK_EXT_calibrated_timestamps. Is there a reason why that time must be continuous (mach_continuous_time())? Or can it be replaced with mvkGetRuntimeNanoseconds()?

@cdavis5e
Copy link
Collaborator

cdavis5e commented Dec 3, 2023

Is there a reason why that time must be continuous (mach_continuous_time())?

Yes. This is the function that's used for the CLOCK_MONOTONIC_RAW domain. VK_EXT_calibrated_timestamps doesn't have CLOCK_UPTIME or CLOCK_UPTIME_RAW domains. See the comment starting on line 1182 of MVKDevice.mm.

Copy link
Collaborator

@cdavis5e cdavis5e left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A minor grammatical error and... well, a preëxisting bug, but since you're changing that code...

MoltenVK/MoltenVK/GPUObjects/MVKImage.mm Outdated Show resolved Hide resolved
MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm Show resolved Hide resolved
MoltenVK/MoltenVK/GPUObjects/MVKSwapchain.mm Outdated Show resolved Hide resolved
- Consolidate info about CAMetalLayer and headless in MVKSurface.
- MVKSwapchainImage remove getCAMetalDrawable()
  and focus on abstracting getMTLTexture().
- MVKPresentableSwapchainImage::getCAMetalDrawable() return nil if headless.
- Add MVKPresentableSwapchainImage::_mtlTextureHeadless to support
  a fixed MTLTexture that is not retrieved from a CAMetalDrawable.
- MVKPresentableSwapchainImage refactor signalling semaphores and fences.
- MVKPresentableSwapchainImage don't lock when signalling semaphores and fences.
- If no present occurs, actualPresentTime will be zero. Set it to current
  time, instead of to desiredPresentTime, since it's more accurate.
- Rework timestamps:
  - Remove _mvkTimestampBase so mvkGetTimestamp() is equal to
    mach_absolute_time(), which is used in presentation timing.
  - Add mvkGetRuntimeNanoseconds().
  - Rename mvkGetAbsoluteTime() to mvkGetContinuousNanoseconds().
  - Remove mvkGetTimestampPeriod() as unused.
- MVKSemaphoreMTLEvent::encodeDeferredSignal remove redundant nil test (unrelated).
- Fix swapchain and surface bugs when windowing system
  is accessed from off the main thread (unrelated).
- Log warning when deprecated functions vkCreateMacOSSurfaceMVK()
  or vkCreateIOSSurfaceMVK() are used (unrelated).
- Remove documentation for visionos, as support is not ready (unrelated).
@billhollings billhollings force-pushed the VK_EXT_headless_surface branch from 7a25719 to 90eb1af Compare December 4, 2023 16:56
@billhollings billhollings requested a review from cdavis5e December 4, 2023 16:56
@billhollings
Copy link
Contributor Author

Thanks for noticing the connection to #2085.

While I was in there, I made a couple of additional changes about windowing systems. And while I was doing that, I also removed the documentation for visionos support, as it's really not properly supported and doesn't build correctly. Also added a deprecation warning for the old macOS and iOS surface creation extensions.

@billhollings billhollings merged commit e6a3886 into KhronosGroup:main Dec 5, 2023
5 checks passed
@billhollings billhollings deleted the VK_EXT_headless_surface branch December 5, 2023 14:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calling vkCreateSwapchainKHR on non-main thread causes errors. Support VK_EXT_headless_surface
2 participants