1125 Commits

Author SHA1 Message Date
Bill Hollings
6ebb20ebf5
Merge pull request #1064 from cdavis5e/layered-copies
MVKCmdCopyImage: Use the method to copy multiple slices when possible.
2020-09-23 13:54:43 -04:00
Chip Davis
ef6848165a Really fix tvOS build. 2020-09-23 12:15:25 -05:00
Chip Davis
9334fe8f15 MVKCmdCopyImage: Use the method to copy multiple slices when possible.
When the extent covers both the source and destination images
completely, we can use the copy method on `MTLBlitCommandEncoder` which
can copy multiple slices at once. This should hopefully reduce CPU
overhead and command buffer memory usage.
2020-09-23 12:02:35 -05:00
Bill Hollings
cf3379fea9
Merge pull request #1062 from cdavis5e/layered-resolve
MVKCmdResolveImage: Use layered rendering where possible.
2020-09-23 12:36:56 -04:00
Chip Davis
0fc93afafd Fix build errors on tvOS. 2020-09-23 10:51:25 -05:00
Chip Davis
0ae3dc2041 MVKCmdResolveImage: Use layered rendering where possible. 2020-09-23 09:32:35 -05:00
Chip Davis
35fbda1cae MVKCmdClearAttachments: Account for the renderArea.
When calculating the vertices, we need to use the render area's
extent--but only if the implementation supports constraining the render
area using `renderTargetWidth` and `renderTargetHeight`. Otherwise, the
quad will be stretched and/or squashed because of the render area
constraint.
2020-09-23 02:45:11 -05:00
Chip Davis
656935b559 MVKCmdClearImage: Use layered rendering when possible. 2020-09-22 16:04:06 -05:00
Chip Davis
61de11b370 MVKImage: Correct offset for texel buffers and heaps.
For planes other than 0, we must add the offset of the first
subresource, so the plane is at the correct place in memory.
2020-09-22 13:15:40 -05:00
Bill Hollings
c312fb37a7
Merge pull request #1057 from cdavis5e/fix-1d-props
MVKDevice: Fix reported image format properties for 1D images as 2D.
2020-09-22 13:51:58 -04:00
Bill Hollings
38e0793c90
Merge pull request #1056 from cdavis5e/read-stencil-view
MVKImage: Only create a stencil view for reading.
2020-09-22 13:49:51 -04:00
Chip Davis
f4065f8a72 MVKDevice: Fix reported image format properties for 1D images as 2D.
Fall through to the 2D case, so all the special handling for 2D is used
for 1D as well. Also, make sure 1D doesn't report multisampling or
support for 420 subsampled formats. There is no
`MTLTextureType1DMultisample` anyway.

Also, clear the `VkImageFormatProperties` struct if the format is not
supported with the given parameters. Some tests seem to expect this.
2020-09-22 10:47:42 -05:00
Chip Davis
41b787dc8b MVKImage: Only create a stencil view for reading.
We don't want to do this for stencil attachment views, because we use
the original packed depth/stencil format in render pipelines, and
Metal's validation layer for some reason doesn't consider packed formats
and their corresponding stencil view formats to match. So only do this
if the image view usage includes `SAMPLED` or `INPUT_ATTACHMENT`.
2020-09-22 10:46:19 -05:00
Chip Davis
4b4e5e912b MVKImage: Always use a texel buffer for atomic linear storage images.
If the image has a format that supports atomic access, or can be cast to
a format which supports atomic access, then use a texel buffer,
regardless of the memory type. If we can't use the `MTLBuffer` from the
device memory, then create our own.

For #1027.
2020-09-22 10:44:16 -05:00
Bill Hollings
e5cf11fcbf
Merge pull request #1052 from cdavis5e/image-mutable-format
MVKImage: Handle VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT.
2020-09-22 11:25:55 -04:00
Bill Hollings
b04720d8a6
Merge pull request #1053 from cdavis5e/max-inline-uniform-blocks
MVKDevice: Limit the maximum number of inline uniform blocks on Mac.
2020-09-22 10:51:58 -04:00
Chip Davis
e4a5910f3b MVKImageView: Get the plane from the aspect mask for single-plane formats.
This is the case where we might be getting a view for a single plane
from a multiplanar image.
2020-09-21 16:20:57 -05:00
Chip Davis
400781e950 MVKImage: Use the plane's MTLPixelFormat to calculate memory sizes.
We really don't want to use the `VkFormat` for the whole image. That has
a block size set on it, which causes the size to be reduced by a factor
of two or even four, in the case of a 420 format whose pitch exceeds the
required alignment. If instead we use the plane `MTLPixelFormat`, we can
sidestep that.
2020-09-21 16:20:57 -05:00
Chip Davis
f3eda6218e MVKDevice: Fix getting the required alignment for multiplanar textures.
In that case, use the format for plane 1. In a two-plane format, that
will have two components and thus will have stricter alignment
requirements.
2020-09-21 16:20:57 -05:00
Chip Davis
4b592be2d2 Correct features and image properties of chroma subsampled formats.
Under Metal, `GBGR422` and `BGRG422` formats don't support linear
textures, mipmapping, or multisampled, arrayed, 1D, 3D, or cube
images. Many of these don't make sense for multiplanar images, either,
so I've disabled them there as well. Vulkan also forbids creating buffer
views in a chroma subsampled format, which we can't do on Metal anyway
due to linear textures not supporting this. Finally, Vulkan forbids
blitting between chroma subsampled formats.

Don't advertise GBGR/BGRG formats greater than 8 bits. Metal has no
corresponding public pixel format.

Make sure `samplerYcbcrProperties.combinedImageSamplerDescriptorCount`
is at least 1. According to the Vulkan spec:

> `combinedImageSamplerDescriptorCount` is a number between 1 and the
> number of planes in the format.

For single-plane formats, use the directly mapped `MTLPixelFormat`
instead of trying to guess the correct format. This is important for
`G8B8G8R8_422_UNORM` and `B8G8R8G8_422_UNORM`, since these shouldn't map
to `RGBA8Unorm`.

Don't adjust the extent for plane 0. Plane 0 is never subsampled, even
with GBGR/BGRG formats. The subsampled R/B components are instead
interleaved in these formats with the fully sampled G. This fixes a
validation error creating a GBGR/BGRG texture with an odd size.

Don't warn when there's no `MTLPixelFormat` for a multiplanar format.
These deliberately have no `MTLPixelFormat`, because there is no single
`MTLTexture` corresponding to the entire image.

The extra checks in `MVKImage` are to ensure that the
`dEQP-VK.api.invariance.random` test doesn't crash.
2020-09-21 16:20:52 -05:00
Chip Davis
c37f17647c MVKDevice: Limit the maximum number of inline uniform blocks on Mac.
Mac GPUs only support 14 dynamic buffers. One of those is used for push
constants, leaving 13 for inline uniform blocks.
2020-09-21 16:04:56 -05:00
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
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
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
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
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
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
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