1941 Commits

Author SHA1 Message Date
Bill Hollings
664296abd0 Fix small memory leak during swapchain creation.
Add ability to profile Cube demo on macOS.
2021-06-22 11:50:58 -04:00
Bill Hollings
53dde5718a Syntactically simplify tracking of outstanding occlusion queries.
Add MVKOcclusionQueryCommandEncoderState::OcclusionQueryLocation to
more directly track occlusion query locations in temp visibility buffer.
2021-06-21 12:37:46 -04:00
Bill Hollings
e72cd614e1 Fix issue where M1 GPU does not support reusing Metal visibility buffer offsets
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.
2021-06-21 11:17:40 -04:00
Bill Hollings
450feb0d30 Fix issue where M1 GPU does not support reusing Metal visibility buffer
offsets across separate render encoders within a single Vulkan command buffer.

Monotonically increase the offset into the temporary visibility buffer
after each query in a MVKCommandEncoder (ie- Vulkan command buffer).
2021-06-18 17:59:30 -04:00
Bill Hollings
adc43456bd
Merge pull request #1384 from billhollings/build-updates
Various build updates
2021-06-15 08:16:54 -04:00
Bill Hollings
6b502bcb60 Upgrade projects to Xcode 13 SDK APIs.
Add MVK_XCODE_13 code macro.
Support MTLLanguageVersion2_4 enum value.
MoltenVKPackaging project add DISABLE_MANUAL_TARGET_ORDER_BUILD_WARNING
build setting to suppress build warnings about using manual build orders.
2021-06-14 16:24:32 -04:00
Bill Hollings
a7a8a88904 Upgrade projects to Xcode 13 build settings. 2021-06-14 11:35:43 -04:00
Bill Hollings
269fca63ba Upgrade project builds to use C++17. 2021-06-14 10:39:42 -04:00
Jan Sikorski
c9d425a37b MVKMTLBufferAllocator: Make sure temporary buffer data is not discarded while in use.
e1ac50c0 marks temporary buffers as volatile, but it only mlocks() them for the duration
of memcpy() of initial data, leaving Metal runtime a window to snatch it before the buffer
is no longer in use. Simply putting the munlock() in a completion handler raises questions
about possible edge cases where multiple, non page-aligned allocations are live.
This patch fixes it by keeping the whole buffer non-volatile while is supports any active
allocations.

Fixes rendering issues in Sekiro: Shadows Die Twice menus.
2021-06-11 16:31:28 +02:00
Bill Hollings
ef34fb7f37 Set project build optimizations to -O2 for all Release mode builds. 2021-06-10 18:32:38 -04:00
Bill Hollings
a2d8cf1710 Reorganize coherent texture flushing on memory map and unmap.
MVKDeviceMemory track original Vulkan memory coherency request, not just Metal
coherency status.

MVKDeviceMemory map() and unmap() only triggers host flush if coherent Vulkan memory
was requested, not just when Metal memory is coherent, because this can be changed
for dedicated image resources.

Redesign MVKDeviceMemory flushToDevice() and pullFromDevice()
to be consistent operation with each other.

Don't trigger automatic texture flush during vkCmdCopyImage(), as it can
cause an unexpected update from mapped memory, resulting in a race condition.
2021-06-09 10:53:10 -04:00
Bill Hollings
db056e36f7 Pass attachments to MVKBeginRenderPass::setContents() as an MVKArrayRef.
MVKBeginRenderPass::setContents() use MVKSmallVector::assign()
to add attachments and clear colors.
MVKFramebuffer add getAttachments() and remove getAttachment()
and getAttachmentCount().
2021-06-01 12:40:26 -04:00
Bill Hollings
8eaf065aa0 Derive MVKCmdBeginRenderPass attachment count and imageless status once. 2021-05-31 22:30:54 -04:00
Bill Hollings
a73f10a35d Consolidate vkCmdBeginRenderPass() and vkCmdBeginRenderPass2KHR() handling.
Add mvkCmdBeginRenderPass() and call from both
vkCmdBeginRenderPass() and vkCmdBeginRenderPass2KHR().
MVKCmdBeginRenderPassBase and MVKCmdBeginRenderPassBase
constructors pass VkSubpassBeginInfo.
Remove overloaded MVKCmdBeginRenderPassBase::setContent().
2021-05-31 22:08:11 -04:00
Bill Hollings
51188ace2c Clear attachments in MVKCmdBeginRenderPass between invocations.
Fixes crash due to incorrect number of attachments.
Update What's New document with VK_KHR_imageless_framebuffer extension.
2021-05-31 21:31:30 -04:00
Bill Hollings
776719106c Fix crash using memoryless storage for input attachments on Apple Silicon.
Don't allow memoryless storage for VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT.
Memoryless storage for VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT descriptors
requires support for, and use of, shader framebuffer fetch.

Remove compile-time checking for MVK_APPLE_SILICON before disabling memoryless storage
for buffers and images, since the requirement exists for all platforms, and memoryless
storage will already otherwise be disabled on other platforms anyway.
2021-05-31 17:20:35 -04:00
Bill Hollings
e06eb3a892
Merge pull request #1370 from f32by/imageless_framebuffer
Support the VK_KHR_imageless_framebuffer extension.
2021-05-31 13:20:24 -04:00
UnsafeBy
6fe4cc5e13 Add MVKCmdBeginRenderPass template specializations for 2 framebuffer attachments. 2021-05-31 14:11:13 +08:00
UnsafeBy
d402a3265f Implement iterator-based assign() in pointer verion of MVKSmallVectorImpl. 2021-05-30 11:06:17 +08:00
UnsafeBy
703cdcf332 Update: support the VK_KHR_imageless_framebuffer extension.
Remove framebuffer reference in MVKCommandEncoder. Instead,
1) non-imageless: copy the attachment vector from
   VkFramebufferCreateInfo if it does not contain the
   VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR flag.
or
2) imageless: copy the attachment vector from
   VkRenderPassAttachmentBeginInfo when calling
   vkBeginRenderPass/vkBeginRenderPass2.
2021-05-29 11:59:42 +08:00
UnsafeBy
c49ad89ffa
Update MoltenVK/MoltenVK/Commands/MVKCommandBuffer.mm
Co-authored-by: Chip Davis <cdavis@codeweavers.com>
2021-05-29 10:00:27 +08:00
UnsafeBy
797b92e606
Update MoltenVK/MoltenVK/Commands/MVKCommandBuffer.h
Co-authored-by: Chip Davis <cdavis@codeweavers.com>
2021-05-29 10:00:19 +08:00
UnsafeBy
a723dc1f21 Support the VK_KHR_imageless_framebuffer extension.
I'm not sure this is the elegant way but it works in my own
project:)
2021-05-28 23:28:20 +08:00
Bill Hollings
5f4c4b257f Add label strings to MTLCommandBuffers, based on use type, for GPU Capture debugging.
Extend MVKCommandUse enum to identify additional command buffer uses.
MVKQueueCommandBufferSubmission track use type.
MVKQueue pass use type in functions that result in creation of a MTLCommandBuffer.
Add mvkMTLCommandBufferLabel() to map use types to label strings.
2021-05-27 18:15:27 -04:00
Bill Hollings
729dd5f7d4
Minor comment typo fix.
Co-authored-by: Chip Davis <cdavis@codeweavers.com>
2021-05-25 23:14:18 -04:00
Bill Hollings
9e5ff3a614 Changes to MVKConfiguration::resumeLostDevice behavior.
On command buffer submission failure, if MVKConfiguration::resumeLostDevice enabled,
do not release waits on VkDevice, and do not return VK_ERROR_DEVICE_LOST, unless
VkPhysicalDevice is also lost.
2021-05-25 12:14:14 -04:00
Bill Hollings
f4fbc1ec23 Fix race condition on MVKQueueCommandBufferSubmission fence during device loss.
MVKQueueCommandBufferSubmission retain() and release() fence and signal semaphores
to ensure they live long enough for the submission to finish using them.
2021-05-24 18:23:12 -04:00
Bill Hollings
d806530d7b
Fix syntactic typo in comment.
Co-authored-by: Chip Davis <cdavis@codeweavers.com>
2021-05-20 21:51:03 -04:00
Bill Hollings
4d2448db3f Fix inconsistent handling of linear attachment decisions on Apple Silicon. 2021-05-20 16:07:34 -04:00
Bill Hollings
378b5d5bc9 Fix synchronization issue with locking MTLArgumentEncoder.
Move mutex lock for using MTLArgumentEncoder to MVKMTLArgumentEncoder
to be tracked along with the MTLArgumentEncoder it guards.
2021-05-14 22:17:08 -04:00
Bill Hollings
1c9a918312 Revert to strict publishing of functions only from enabled extensions.
Previously we had loosened the behavior so that function proc addresses are returned
for an extension function even if that extension is disabled, if the API was artificially
restricted during testing, to bypass CTS tests that appeared to assume certain
extension functions were available.

This loosening in turn caused the dEQP-VK.api.version_check.entry_points test to fail,
so the restriction is reapplied and only functions from enabled extensions are published.
2021-05-13 20:54:12 -04:00
Bill Hollings
ea1d21a939 Cleanup handling of sampler border color and mirror edge clamp.
mvkMTLSamplerAddressModeFromVkSamplerAddressMode() support
MTLSamplerAddressModeClampToBorderColor and
MTLSamplerAddressModeMirrorClampToEdge if available.
Add MVKSampler::getMTLSamplerAddressMode() to test for device feature availability.
Remove special border color handling in MVKSampler::newMTLSamplerDescriptor().
2021-05-13 15:06:35 -04:00
Bill Hollings
e1bbe163d6 Revert pointSizeRange upper limit back to 64 as Metal has inconsistent docs on this. 2021-05-07 21:41:29 -04:00
Bill Hollings
8420988c73 Fixes for CTS dEQP-VK.info.device_properties failures.
Adjust VkPhysicalDeviceLimits values:
- minMemoryMapAlignment raised to MIN of 64 per Vulkan spec.
- pointSizeRange upper limit to 511 per Metal.
- lineWidthGranularity to 0 per Vulkan spec when wideLines disabled.
- maxSamplerLodBias set to 4 to cover setting in shader.
2021-05-07 21:28:56 -04:00
Bill Hollings
5de2e71619
Merge pull request #1355 from cdavis5e/new-amd-32-lane-devices
MVKDevice: Add new AMD devices supporting 32 lanes.
2021-05-06 08:22:20 -04:00
Chip Davis
78b04f4f6e MVKDevice: Add new AMD devices supporting 32 lanes.
These new cards are supported in the 11.4 beta.
2021-05-05 18:35:45 -05:00
Bill Hollings
19f02fac3d Merge from master and fix PR conflicts. 2021-05-05 16:46:45 -04:00
Bill Hollings
f781ee720a MVKImagePlane::getMTLTexture() protect against
crash when image has no device memory bound.
2021-05-05 16:37:16 -04:00
Bill Hollings
523342dd2f Fix crash when requesting MTLCommandBuffer logs in runtime debug mode on older OS versions. 2021-05-05 14:46:36 -04:00
Bill Hollings
26ff3e594a
Merge pull request #1352 from billhollings/shader-config
Improvements to SPIRVToMSLConversionConfiguration
2021-05-05 14:14:40 -04:00
Bill Hollings
650e8f3a46 To improve cache hits when matching SPIRVToMSLConversionConfiguration structs
to each other to find cached shader, only consider current shader stage resources.

Rename more references to ShaderConverterContext to ShaderConversionConfig.
2021-05-04 20:06:34 -04:00
Bill Hollings
64a69d0e51 Rename more references to ShaderConverterContext to ShaderConversionConfig. 2021-05-04 18:07:55 -04:00
Bill Hollings
577ec9a447 Rename references to ShaderConverterContext to ShaderConversionConfig
to align better with name of SPIRVToMSLConversionConfiguration structure.
2021-05-04 16:24:41 -04:00
Bill Hollings
91c5f58f7a Add class mixins for reference counting and configuration results.
Separate reference counting from MVKVulkanAPIObject into a new
MVKReferenceCountingMixin class, so reference counting can
potentially be used in other areas of the class hierarchy.
Replace MVKConfigurableObject with MVKConfigurableMixin for the same reason.
Remove some inline definitions as unnecessary in the files being revised here.
2021-05-04 15:26:28 -04:00
Bill Hollings
5b1f38fbb9 Miscellaneous non-functional maintainability updates.
Rename kMVKShaderStageMax to kMVKShaderStageCount
to clarify it's common use in array sizing and for loops.
Change mvkConfig() to return reference instead of pointer
to improve syntactic sugar to use . instead of ->.
Update MoltenVK version to 1.1.4.
Update What's New document.
2021-05-03 18:56:30 -04:00
Bill Hollings
2eba556084
Merge pull request #1345 from billhollings/xc-125
Support Xcode 12.5
2021-05-03 15:04:58 -04:00
Bill Hollings
f2eb8e60c8 Further fixes to Xcode 12.5 support.
Indicate that MacCatalyst does not support BC compression.
2021-05-03 13:49:41 -04:00
StarbucksDave
fea0eddcee
Update MVKDescriptor.mm
Fix space (from web commit).
2021-05-03 10:04:23 +02:00
StarbucksDave
1d480dbe63
Use SPIRV_CROSS_NAMESPACE define in MVKDescriptor.mm
I believe SPIRV_CROSS_NAMESPACE_OVERRIDE should be replaced by SPIRV_CROSS_NAMESPACE defined in SPIRV-Cross spirv_common.hpp. This ensures that SPIRV_CROSS_NAMESPACE_OVERRIDE usage in MVK is optional.
2021-05-03 09:57:12 +02:00
Bill Hollings
5fd821bb5d
Merge pull request #1344 from kleinerm/googledisplaytiming
Compliance fixes for VK_GOOGLE_display_timing extension implementation.
2021-05-01 16:19:58 -04:00