Ensure non-Apple GPU's enable memory barriers.
A previous commit inadvertently disabled GPU memory barriers.
Change tests for memory barriers to runtime test for Apple GPU, instead of
build-time test for Apple Silicon, to accommodate running on Rosetta2, and
refactor tests for Apple Silicon and OS version on some macOS GPU feature settings.
For a combined depth-stencil format in a MVKImageView attachment with
VK_IMAGE_ASPECT_STENCIL_BIT, the attachment format may have been swizzled
to a stencil-only format. In this case, we want to guard against an attempt
to store the non-existent depth component.
Pass MVKImageView attachment to MVKRenderPassAttachment::encodeStoreAction()
and MVKRenderPassAttachment::populateMTLRenderPassAttachmentDescriptor() to
check attachment depth format component.
Consolidate calls to MVKImageView::populateMTLRenderPassAttachmentDescriptor() by calling
it from within MVKRenderPassAttachment::populateMTLRenderPassAttachmentDescriptor().
When flattening shader inputs for stage_in, which are to be read from a buffer
that was populated as nested structs during an earlier stage, the structs will
be aligned according to C++ rules, which can affect the alignment of the first
member of the flattened input struct.
Add SPIRVShaderOutput::firstStructMemberAlignment to track the alignment
requirements of the first member of a nested structure, and recursively
determine the alignment of the first member of each nested output structure.
Move sizeOfOutput() from MVKPipeline.mm to SPIRVReflection.h,
rename to getShaderOutputSize(), and add getShaderOutputAlignment()
to extract member alignment.
If using GPU counters, on all Apple GPUs lock timestampPeriod to 1.0,
since Apple GPUs use nanoseconds, and on non-Apple GPUs, dynamically
adapt value of timestampPeriod by correlating GPU ticks with GPU ticks.
If using CPU sync, set timestampPeriod to OS CPU timestamp tick period.
Previously, on Apple Silicon (iOS, tvOS & macOS M1), we tried to guess
deviceID from GPU parameters, but this is becoming harder as the types
of Apple Silicon is growing, and the actual device SoC itself is less
relevant that the GPU capabilities. So we now set deviceID from the
combination of OS version and GPU type.
Rename MVKDevice::getHighestMTLFeatureSet() to getHighestGPUCapability().
Older Metal does not support rendering without subpass attachments.
In this case, a dummy attachment with a dummy MTLTexture is created
whenever the subpass begins, but was not being correctly used.
Move the creation, retaining, and releasing of the dummy MTLTexture to
MVKFramebuffer, where the extent and layer count is known and can be reused.
Pass framebuffer to MVKCommandEncoder::beginRenderpass() and remember
current framebuffer in MVKCommandEncoder.
Add getFramebufferExtent() and getFramebufferLayerCount() to MVKCommandEncoder.
Pass framebuffer to MVKRenderSubpass:populateMTLRenderPassDescriptor() and
retrieve dummy MTLTexture from framebuffer.
Do not use MTLEvent for VkSemaphore under Rosetta2.
Remove compile test for MVK_MACOS_APPLE_SILICON and MVK_APPLE_SILICON when testing
for Apple GPU families, to allow x86 builds to test for Apple GPU under Rosetta2.
Simplify identifying M1 GPU. All M1 SoCs currently support the A14 (Apple7) GPU.
Support compiling MSL 2.4 in runtime pipelines and MoltenVKShaderConverterTool.
Fix issue where MSL 2.3 only available on Apple Silicon, even on macOS.
Update to latest SPIRV-Cross (unrelated to Rosetta2).
Add build environment variable MVK_HIDE_VULKAN_SYMBOLS. to allow MoltenVK
to be built with static Vulkan API symbols hidden, to avoid library linking
conflicts when bound to a Vulkan Loader that also exports identical symbols.
The default value of MVK_HIDE_VULKAN_SYMBOLS is 0,
meaning Vulkan static symbols are exposed by default.
Add MVK_PUBLIC_VULKAN_SYMBOL directive to mark each Vulkan call symbols
for exporting or hiding.
Update the MoltenVK Xcode project to add the MVK_HIDE_VULKAN_SYMBOLS build
setting, and set the ENABLE_TESTABILITY build setting to NO, because it
conflicts with stripping symbols.
Update MoltenVK version to 1.1.7.
Metal does not provide direct support for BC1_RGB formats
(VK_FORMAT_BC1_RGB_UNORM_BLOCK & VK_FORMAT_BC1_RGB_SRGB_BLOCK).
We have been faking it by mapping these Vulkan formats to Metal
formats containing alpha (MTLPixelFormatBC7_RGBAUnorm &
MTLPixelFormatBC7_RGBAUnorm_sRGB, respectively),
and advertising support for BC1_RGB formats.
However, this triggers CTS failures, because the BC1_RGBA formats can return
an alpha value of 0.0 when constructed that way, whereas the BC1_RGB formats
always expect 1.0 (opaque) to be returned.
This change moves to indirect support for BC1_RGB formats. They will still
be covered by MTLPixelFormatBC7_RGBAUnorm & MTLPixelFormatBC7_RGBAUnorm_sRGB,
and will effectively work (except transparency), but are no longer advertised
through physical device format and image format queries.
Dynamic pipeline state set before the pipeline is set was reading
dynamic flags from previous pipeline. This is fixed here by accepting
the dynamic state, but deferring the decision to use either dynamic
or static state until the pipeline is encoded.
An MVKImageView that renders to only one layer of a multilayer MVKImage
is not performing multilayer-rendering. Only validate multilayer-rendering
when it is definitely requested in an MVKImageView, instead of presuming
when a multilayer MVKImage is marked for rendering.
Check that appropriate GPU counter set is supported on
the device before creating GPU counter sample buffer.
Don't attempt to timestamp using GPU counters unless
a GPU sample counter buffer has been created.
Support maximum point primitive size of 511.
Update to latest SPIRV-Cross version to add support
for OpSpecConstantOp ops OpQuantizeToF16 and OpSRem.
Update MoltenVK version to 1.1.6.
MSL: Support row-major transpose when storing matrix from constant RHS matrix.
MSL: Fix casting in constant expressions with different sizes.
MSL: Fix duplicate gl_Position outputs when gl_Position defined but unused.
Apple GPUs do not support rendering/writing to an attachment and then reading
from that attachment within a single Metal renderpass. On Apple Silicon, restart
the Metal renderpass if an input attachment is cleared inside renderpass.
Don't clear render area when restarting Metal renderpass, as it should not occur,
and itself causes a recursive loop restarting the renderpass as a result.
Add MVKCommandUse::kMVKCommandUseRestartSubpass.
MVKCommandEncoder::beginMetalRenderPass() pass MVKCommandUse to help determine
Metal renderpass attachment load and clearing options.
Rename MVKRenderPassAttachment::shouldUseClearAttachment() to
shouldClearAttachment(), pass whether testing for stencil clearing,
and check stencil clearing distinct from depth clearing.
Refactor MVKRenderSubpass::populateClearAttachments() to work with this.
Remove MVKRenderPassAttachment::getAttachmentStencilLoadOp() as obsolete.
Disable MVK_ALLOW_METAL_FENCES by default.
Disable use of MTLEvent on NVIDIA.
By default, use MTLEvent for VkSemaphore everywhere except NVIDIA.
By default, use CPU synchronization on NVIDIA.
These changes fix a large number of CTS synchronization test failures.
Prefer MTLEvent over MTLFence for VkSemaphore, because MTLEvent handles
sync across MTLCommandBuffers and MTLCommandQueues, except on NVIDIA GPUs,
which have demonstrated trouble with MTLEvents, prefer MTLFence.
Add MVKDevice::VkSemaphoreStyle enum.
Metal does not support resolving all formats that support MSAA, whereas Vulkan
assumes any MSAA format can be resolved. We fix that by running an optional
post-renderpass compute shader that resolves such textures by simply taking the
first sample as the resolved sample. This works to fix all failing CTS tests,
because such formats are all integer formats, and Vulkan allows an arbitrary
single sample value to be selected.
If we need to resolve, but the Metal format doesn't support it,
cause the Metal renderpass to store the MSAA attachment results.
MVKRenderSubpass don't establish Metal resolve attachment textures if format
is not natively resolvable, and encode Metal renderpass store actions accordingly.
MVKCommandEncodingPool add MTLComputePipelineStates to run simple resolve
compute shaders on attachments that cannot be resolved in Metal renderpass.
Add MVKRenderSubpass::resolveUnresolvableAttachments() and call from
MVKCommandEncoder::endMetalRenderEncoding(), before subpass index is updated.
Rename MVKCommandEncodingPool::getClearStateIndex() to
getRenderpassLoadStoreStateIndex() and remove MVK_MACOS restriction on
clearing shaders to allow compatibility with resolve shader handling.
MVKRenderPassAttachment remove validation of whether a format can be resolved.
MVKPixelFormats::getMTLTextureUsage() add read and write usage as appropriate
to allow compute shader to run to resolve formats not natively resolvable.
MVKPixelFormats remove obsolete unit test code.
MVKImageView clean up access functions and obsolete constructor
use of MVKConfiguration.
On Apple GPUs, MVKCmdPipelineBarrier restarts Metal renderpass when encountered
inside self-dependent Vulkan subpass where the same attachment acts as both
input attachment and render attachment.
Move update of MVKSwapchainImageAvailability::acquisitionID to the acquisition
time instead of the become available again time, so other images will be preferred
if either all images are available or no images are available.
Add MVKPhysicalDeviceMetalFeatures::counterSamplingPoints
to track platform availability of GPU counters.
MVKPhysicalDevice creates and manages MTLCounterSets and checks for and enables
flags within MVKPhysicalDeviceMetalFeatures::counterSamplingPoints.
Add abstract MVKGPUCounterQueryPool class as parent of MVKTimestampQueryPool
and MVKPipelineStatisticsQueryPool concrete classes and refactor access to host
and command copy tracking data to allow extraction from MTLCounterSampleBuffer.
MVKTimestampQueryPool uses MTLCounterSampleBuffer if supported, otherwise reverts
to using host data for timestamps.
MVKCommandEncoder encodes Vulkan timestamp commands either as Metal staged or
command timestamps, depending on whether the GPU is tile-based or immediate-mode.
For Metal stage counters, we use a light-weight dummy BLIT encoder to mark
timestamp commands executed in the previous Metal encoding pass.
Add MVKDevice::getDummyBlitMTLBuffer() to supply a dummy single-byte buffer that
can be used by a stand-alone MTLBlitCommandEncoder as dummy work to mark timestamps.
If alpha-to-coverage is enabled, we must enable the fragment shader first color output,
even without a color attachment present or in use, so that coverage can be calculated.
VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 on macOS Apple Silicon.
On Apple Silicon (iOS/tvOs/macOS M1), format VK_FORMAT_E5B9G9R9_UFLOAT_PACK32
is fully supported as a color attachment except that format components cannot
be individually write-enabled. All components must either be write-enabled or
write-disabled together. This is causing several hundred Vulkan CTS blending
tests to fail on M1. The least intrusive behavioural change to allow the CTS
tests to report Not Supported instead, is to disable blending for this format.
The same set of CTS tests either fails or passes on different GPUs
based on whether or not we adjust float clear colors by one ULP.
Add MVKFloatRounding enum.
Add MVKPhysicalDeviceMetalFeatures::clearColorFloatRounding.
Disable ULP adjustment for clear colors on Apple Silicon.
For consistency and to simplify bookkeepping, calculate
clear color ULP adjustment from bit width of format component.
Update MoltenVK version to 1.1.5.
Update VK_MVK_MOLTENVK_SPEC_VERSION to 32.
across separate render encoders within a single Metal command buffer (Vulkan submit).
Add MVKCommandEncodingContext to track information across multiple
MVKCommandEncoders, and use it to track temporary visibility buffer and offset.
Add support for more than one temporary visibility buffer per MTLCommandBuffer
when current temporary visibility buffer is exhausted.