1752 Commits

Author SHA1 Message Date
Chip Davis
278a7208ca MVKImage: Handle VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT.
Only set `MTLTextureUsagePixelFormatView` if this bit is set. This
should reduce the usage of this bit, which disables lossless compression
on Apple GPUs, in many cases.

We continue to set it anyway for `VK_IMAGE_USAGE_TRANSFER_SRC_BIT`; this
is because we create those texture views on the application's behalf, to
implement `vkCopyImage()` where the source and destination formats do
not agree. We also continue to set it for depth/stencil formats; Metal
requires it in order to use only the stencil aspect in a view.
2020-09-21 16:01:36 -05:00
Bill Hollings
cadc011c67
Merge pull request #1050 from cdavis5e/image-extended-usage
MVKImage: Handle VK_IMAGE_CREATE_EXTENDED_USAGE_BIT.
2020-09-21 16:43:22 -04:00
Chip Davis
3a97b1b810
Merge pull request #1049 from cdavis5e/mac-linear-images-ios-fix
Fix iOS build again.
2020-09-21 14:27:11 -05:00
Chip Davis
f5897fcc0c MVKImage: Handle VK_IMAGE_CREATE_EXTENDED_USAGE_BIT.
If this bit is set, add `MTLTextureUsage` bits for features supported by
all possible view formats, not just the image format. Happily, Metal's
API validator layer is OK with this.

This is needed for the mutable format tests, which use this bit with a
format that doesn't support writing, then casts the image to a format
which does.
2020-09-21 13:53:24 -05:00
Chip Davis
7b0f08ea1f Fix iOS build again.
Only do the managed-storage check on Mac.
2020-09-21 13:50:44 -05:00
Bill Hollings
1423930408
Merge pull request #1048 from cdavis5e/depth-stencil-resolve
Support the VK_KHR_depth_stencil_resolve extension.
2020-09-21 14:49:21 -04:00
Bill Hollings
cbcec7cff8
Merge pull request #1047 from cdavis5e/fix-image-memory-reqs-2
MVKImage: Fix broken getMemoryRequirements2().
2020-09-21 14:26:01 -04:00
Chip Davis
20217d0bf6 Support the VK_KHR_depth_stencil_resolve extension.
I've turned on the `Resolve` cap for stencil-only formats, even though
no version of the Metal Feature Set tables lists them as supporting
multisample resolve. Obviously, if they couldn't be resolve
destinations, the stencil-resolve filter that was introduced in Metal
2.1 wouldn't work. I don't know if the platforms and feature sets where
I've turned the bit on is accurate, though. Wider testing is needed.

Because Apple families 1 and 2 don't support depth/stencil resolve at
all, I've disabled the extension for those families. Since sample-zero
resolution is a required feature of Vulkan 1.2, this means we won't be
able to support 1.2 on those devices. If there's demand, we could
possibly have a compute pass which does sample-zero resolution.
2020-09-21 13:05:38 -05:00
Chip Davis
1f1726647e MVKImage: Fix broken getMemoryRequirements2().
We were looking in the wrong chain for the
`VkImagePlaneMemoryRequirementsInfo` struct. We were also failing to
call through to the `MVKImageMemoryBinding` to get dedicated
requirements, which broke dedicated memory.

Clearly, I failed to properly review the patch which refactored
`MVKImage` for `VK_KHR_sampler_ycbcr_conversion`.
2020-09-21 12:57:15 -05:00
Bill Hollings
a59a26816e
Merge pull request #1043 from cdavis5e/mac-linear-images
Support linear images and buffer views in shared memory on macOS 10.15.5+.
2020-09-21 13:41:31 -04:00
Chip Davis
e4dbb8044a Support linear images and buffer views in shared memory on macOS 10.15.5+.
Apple assured me that, starting in 10.15.5, linear textures and texture
buffers can be created from buffers with `Shared` storage. I have tested
this and can confirm that it works at least on Big Sur, and probably on
Catalina as well.
2020-09-21 12:13:13 -05:00
Bill Hollings
bfabb5f827
Merge pull request #1045 from cdavis5e/indirect-tess-draw-fix
MVKPipeline: Don't skip setting the vertex stage pipeline.
2020-09-21 12:57:11 -04:00
Bill Hollings
5cbd809d12
Merge pull request #1044 from cdavis5e/no-compressed-linear
MVKImage: Reject attempts to create compressed linear images.
2020-09-21 12:54:44 -04:00
Bill Hollings
f43e6c248f
Merge pull request #1046 from billhollings/master
Add support for VK_KHR_portability_subset extension.
2020-09-21 12:04:31 -04:00
Bill Hollings
76828818ce Add support for VK_KHR_portability_subset extension.
Remove support for VK_EXTX_portability_subset extension.
2020-09-21 11:33:29 -04:00
Bill Hollings
122c15b696 Update Vulkan-Headers to version 1.1.154 to include VK_KHR_portability_subset. 2020-09-21 09:43:51 -04:00
Chip Davis
fa7515ed08 MVKPipeline: Don't skip setting the vertex stage pipeline.
In an indirect draw, we wouldn't set the pipeline for the vertex stage
to the command encoder, because we had already switched encoders. This
caused havoc down the line, as we wound up running the "convert indirect
buffers" pipeline again, which smashed memory randomly--possibly causing
the GPU to crash, and bringing down the `WindowServer` with it!

Why is it so easy to bring down the `WindowServer` like this?
2020-09-20 23:27:55 -05:00
Chip Davis
ff25d46992 MVKImage: Reject attempts to create compressed linear images.
This doesn't sit well with Metal, which will immediately abort the
program on the attempt.
2020-09-20 22:43:39 -05:00
Bill Hollings
1d93650858
Merge pull request #1042 from cdavis5e/fix-instanced-divisors
MVKGraphicsPipeline: Fix applying divisors to instanced vertex attributes.
2020-09-18 12:07:26 -04:00
Chip Davis
69255e8122 MVKGraphicsPipeline: Fix applying divisors to instanced vertex attributes.
Use the Vulkan binding index to check that the binding is used.
Previously, we were erroneously using the Metal binding index. This
allows vertex binding divisor info to actually be used, and fixes some
tests in the CTS.

Fixes #1041.
2020-09-17 15:51:22 -05:00
Chip Davis
e4b8c67d51
Merge pull request #1040 from cdavis5e/fix-ios-build
Fix iOS/tvOS build.
2020-09-16 14:16:52 -05:00
Chip Davis
e768649c31 Fix iOS/tvOS build. 2020-09-16 13:33:18 -05:00
Bill Hollings
a8eff24d00
Merge pull request #1039 from cdavis5e/no-variable-ms-rate
Disable the variableMultisampleRate feature for now.
2020-09-16 12:12:38 -04:00
Bill Hollings
a0bdca1ec8
Merge pull request #1038 from cdavis5e/fail-tri-fan-pipelines
MVKGraphicsPipeline: Fail triangle fan pipelines.
2020-09-16 12:02:50 -04:00
Bill Hollings
a142455cf8
Merge pull request #1037 from cdavis5e/3d-clears
MVKCmdClearImage: Support clears of 3D images.
2020-09-16 11:51:57 -04:00
Chip Davis
68c8146729 Disable the variableMultisampleRate feature for now.
We actually can't support this. Metal's validation layer complains if
a pipeline has a different raster sample count from that of the
framebuffer, even in the no-attachment case. This means that the
`defaultRasterSampleCount` property must be set correctly if Metal
supports no-attachment rendering, and the sample count of the dummy
texture must be set properly otherwise.
2020-09-16 01:09:33 -05:00
Chip Davis
049fa3840d MVKGraphicsPipeline: Fail triangle fan pipelines.
Otherwise, when we try to draw with them, Metal's validation layer will
complain that the primitive type and primitive topology don't match.
2020-09-16 01:08:25 -05:00
Chip Davis
9f675b2e9d MVKCmdClearImage: Support clears of 3D images.
For these, we must use the `depthPlane` property to set the layer to
clear, and we must iterate over the image's depth, since the layer count
will be 1 in this case.
2020-09-16 01:07:20 -05:00
Bill Hollings
67d4b335be
Merge pull request #1036 from cdavis5e/ignore-sampler-address-w
MVKSampler: Ignore addressModeW with unnormalized coordinates.
2020-09-15 16:35:58 -04:00
Bill Hollings
afa536c8ea
Merge pull request #1035 from cdavis5e/3d-blits
MVKCmdBlitImage: Support blits with non-2D images.
2020-09-15 16:23:31 -04:00
Bill Hollings
5a9b8c8936
Merge pull request #1031 from cdavis5e/retain-descriptor-sets
MVKCmdBindDescriptorSets: Retain given objects.
2020-09-15 16:18:48 -04:00
Chip Davis
9c28064760 MVKSampler: Ignore addressModeW with unnormalized coordinates.
Some tests intentionally pass an invalid address mode here when
unnormalized coordinates are in use, ostensibly to test that it is
ignored. Metal's validation layer, however, complains if you set
`rAddressMode` to an invalid value, even if `normalizedCoordinates` is
`false`. To avoid this, don't set the `rAddressMode`, since it can't be
used with unnormalized coordinates anyway.
2020-09-15 13:13:32 -05:00
Chip Davis
3e1e029569 MVKCmdBlitImage: Support blits with non-2D images.
This is needed to get us past the 3D blit tests that were recently added
to the CTS. It *almost* passes all these new tests; the 3D format tests
fail for some reason.
2020-09-15 13:10:09 -05:00
Chip Davis
30113fc123 Retain pipeline layouts in bind/push descriptor commands.
Fixes a use-after-free bug when the pipeline layout is destroyed after
recording--e.g. in the
`dEQP-VK.api.pipeline_layout.lifetime.destroy_after_end` test.
2020-09-15 13:07:16 -05:00
Bill Hollings
a2734c3166
Merge pull request #1034 from cdavis5e/sampler-desc-autorelease
MVKSampler: Wrap MTLSamplerState creation in an autorelease pool.
2020-09-15 13:36:48 -04:00
Bill Hollings
7abb9f552a
Merge pull request #1033 from cdavis5e/3d-2d-copies
MVKCmdCopyImage: Support copies between 3D and 2D images.
2020-09-15 13:35:44 -04:00
Bill Hollings
0a20bb0cfb
Merge pull request #1032 from cdavis5e/free-failed-objects
Destroy/free objects when configuration fails.
2020-09-15 13:33:31 -04:00
Chip Davis
ef55ef6927 MVKSampler: Wrap MTLSamplerState creation in an autorelease pool.
Or the `MTLSamplerDescriptor` could be leaked.
2020-09-14 19:30:33 -05:00
Chip Davis
fa862c46a3 MVKCmdCopyImage: Support copies between 3D and 2D images.
This can be done by copying between each slice of the 2D image and each
plane of the 3D image individually.

This was actually quite simple to implement. I don't know why I punted
on this.
2020-09-14 19:28:09 -05:00
Chip Davis
86a1fbdb8f Destroy/free objects when configuration fails.
Prior to this, we were leaking objects after failing to configure them.
The sole exception was `VkDescriptorSet`; failed descriptor sets are
automatically returned to the pool. Now all objects are destroyed or
freed when creation fails.
2020-09-14 19:25:54 -05:00
Bill Hollings
061f4ee6c5
Merge pull request #1030 from cdavis5e/clear-linear-images-mac
MVKCmdClearColorImage: Clear linear images on Mac with a shader.
2020-09-14 14:39:33 -04:00
Chip Davis
544a4a88ef MVKCmdClearColorImage: Clear linear images on Mac with a shader.
Linear textures on Mac family GPUs aren't renderable, so we cannot use
a `Clear`/`Store` `MTLRenderPass` to clear them. Instead, use a compute
shader to clear them.

I haven't expanded this to all color images, because the
`MTLTextureUsageShaderWrite` usage disables lossless compression on
Apple GPUs, but `RenderTarget` usage does not. Also, multisample
textures do not yet support writing.
2020-09-14 12:37:17 -05:00
Bill Hollings
2cb385b04c
Merge pull request #1029 from cdavis5e/resolve-subregion-fix
MVKCmdResolveImage: Fix resolving sub-regions.
2020-09-14 13:31:16 -04:00
Chip Davis
a299ee6601 MVKCmdResolveImage: Fix resolving sub-regions.
When doing multisample resolution in Metal, the dimensions of the MSAA
RT and the resolve destination must be the same. Therefore, if the
resolve region does not cover the entire destination, we must use a
temporary transfer image. This fixes a validation error in the differing
image size tests from the CTS
(`dEQP-VK.api.copy_and_blit.*.resolve_image.diff_image_size.*`).

Because the temporary transfer image has the same dimensions as the
destination and is intended to be resolved to it, copies from the source
should use the destination's parameters for the temp image. That way,
the regions show up in the correct place in the destination. This fixes
the remaining resolve tests.

Don't do expansion blits if the resolve region covers the entire
destination. This should reduce the amount of needless work we do in
that case.
2020-09-14 11:28:18 -05:00
Bill Hollings
d135363277
Merge pull request #1024 from billhollings/master
Cleanup Vulkan 1.1 info & Support Xcode 11.7.
2020-09-11 12:15:32 -04:00
Bill Hollings
b7b1435d8b Support Xcode 11.7. 2020-09-11 11:35:44 -04:00
Bill Hollings
e9c4b4813b Cleanup Vulkan 1.1 info.
Update remaining documents to reference Vulkan 1.1 instead of 1.0.
Per Vulkan 1.1 spec, remove now-obsolete MVKInstance code
that emits error if app requests higher Vulkan version.
Upgrade MoltenVK version to 1.1.0.
2020-09-11 11:16:34 -04:00
Bill Hollings
c6af90ca5a
Merge pull request #1021 from cdavis5e/create-renderpass2
Support the VK_KHR_create_renderpass2 extension.
2020-09-11 10:42:06 -04:00
Bill Hollings
4181445688
Merge pull request #1022 from cdavis5e/arm64-alias-fix
Fix aliases on ARM64.
2020-09-11 10:34:00 -04:00
Chip Davis
2c40e39699 Fix aliases on ARM64.
The semicolon is the comment character in ARM64 assembly. Just put the
alias symbol definition on another line.
2020-09-10 20:21:02 -05:00