This commit changes the MVKSmallVector to a C-Style array because the parameters array will not have to resize, and it seems that a C-Style array is just as capable of doing the job.
The changes are as follows:
* Moved the code around to fit with the ordering system
* Added a function to get available cpu cores
* Renamed variables with _ in front of them
* Added mutexes and lock guards for the getters and setters of the max concurrency and result variables
* Made max concurrency dynamic by returning 0 when the operation is finished
Implemented deferred host operations in this commit. It was pretty simple with nothing Metal specific. I am a bit concerned on the return types of MVKDeferredOperation::join and about how to store the operation to be executed for later.
- When forcing the window system to use the same high-power GPU as the app,
move the call to MTLCreateSystemDefaultDevice() to MVKDevice constructor,
instead of MVKDevice::createSwapchain(), and test whether the
VK_KHR_swapchain extension is enabled to determine the need to swap GPUs.
- After calling MTLCreateSystemDefaultDevice() the GPU will already be
the same high-power GPU, so remove attempting to replace the MTLDevice.
- Remove MVKPhysicalDevice::replaceMTLDevice() as no longer used.
- Remove many unnecessary inline declarations in MVKDevice.h (unrelated).
As of macOS Big Sur and iOS/tvOS 14, the `discard_fragment()` function
in MSL is defined to have demote semantics; that is, fragment shader
output is discarded, but the fragment shader thread continues to run as
a helper invocation. This is very useful for Direct3D emulation, since
this is the semantic that HLSL `discard` has.
Signed-off-by: Chip Davis <chip@holochip.com>
- [MTLDrawable presentAtTime:] syncs to display vsync. To support
VK_PRESENT_MODE_IMMEDIATE_KHR while using VkPresentTimeGOOGLE::presentID,
only call presentAtTime: if VkPresentTimeGOOGLE::desiredPresentTime has
been explicitly set to a non-zero value.
- Clarify initially clearing MVKImagePresentInfo to all zeros.
- Only log performance stats on FPS logging if logging style is explicitly
set to MVK_CONFIG_ACTIVITY_PERFORMANCE_LOGGING_STYLE_FRAME_COUNT (unrelated).
The same compute encoder is used across dispatches and other commands,
which may override compute state, and end up breaking subsequent dispatches.
- Mark compute encoding state dirty when following commands,
which use Metal compute encoders, are issued:
- vkCmdCopyBuffer()
- vkCmdClearColorImage()
- vkCmdClearDepthStencilImage()
- vkCmdFillBuffer()
- vkCmdCopyQueryPoolResults()
- MVKCommandEncoder move marking compute state dirty from
endCurrentMetalEncoding() to getMTLComputeEncoder().
- For efficiency, don't prematurely force end of query copy compute encoder
used on renderpass end, in case compute dispatches follow.
- Update MoltenVK to 1.2.5 (unrelated).
Advertise VK_KHR_depth_stencil_resolve extension on early iOS devices,
since VK_RESOLVE_MODE_SAMPLE_ZERO_BIT is supported on all devices,
even if other resolve modes are not, and makes it consistent with
Vulkan 1.2 mandatory support for VK_RESOLVE_MODE_SAMPLE_ZERO_BIT.
- MTLDevice registryID is not constant across OS reboots,
which is not conformant with deviceUUID requirements.
- Replace with combination of MTLDevice location, locationNumber,
peerGroupID, and peerIndex, which should define uniqueness,
and should be constant across OS reboots.
- Populate deviceLUID from MTLDevice registryID.
- Report error, but do not fail on request for timestamp query pool
that is too large for MTLCounterSampleBuffer.
- Change reported error to VK_ERROR_OUT_OF_DEVICE_MEMORY and clarify
text of error reported when timestamp query pool is too large.
- Clarify error reported for occlusion query pool errors (unrelated).
- Make MVKDevice::enableFeatures() functions into templates to pass struct type.
- Add mvkGetAddressOfFirstMember() to retrieve the address of the first member of
a struct, taking into consideration whether the struct has a Vulkan pNext member.
- Add mvk::getTypeName() and mvk::getOrdinalSuffix() string functions.
Fix depth clamp and texture swizzle feature discovery on simulator builds
Both of these features are not supported by the iphone simulator
and leads to crashes when used