1825 Commits

Author SHA1 Message Date
Bill Hollings
18dd6fa7aa
Merge pull request #1068 from cdavis5e/zero-divisor-base-instance
Offset vertex buffers for attribute bindings with zero divisors.
2020-09-24 17:37:19 -04:00
Chip Davis
c377de9748 Offset vertex buffers for attribute bindings with zero divisors.
One aspect of the `VK_EXT_vertex_attribute_divisor` spec that I
apparently missed is that, for a vertex buffer binding with a divisor of
0, the base instance determines where the attributes are read from. This
cannot be expressed in Metal, but we can emulate it by offseting the
buffer by `firstInstance * stride`.

Unfortunately, we can't do this for indirect draws. If a program tries
this, we're hosed.
2020-09-24 10:21:05 -05:00
Bill Hollings
dea8fd4fd1
Merge pull request #1066 from billhollings/kill-opts
fetchDependencies builds serially by default.
2020-09-23 15:34:22 -04:00
Bill Hollings
92336c597a
Merge pull request #1067 from billhollings/setmtltex
vkSetMTLTextureMVK() Fix crash if incoming MTLTexture does not have an IOSurface.
2020-09-23 15:34:01 -04:00
Bill Hollings
eb706ea40c Update What's New document. 2020-09-23 15:04:52 -04:00
Bill Hollings
00f7535f32 fetchDependencies builds serially by default.
Building in parallel does not significantly improve performance, and makes it
more difficult to integrate calling fetchDependencies from a larger build script,
because of the need to trap and kill child processes on an error.
2020-09-23 14:55:13 -04:00
Bill Hollings
f58da7675c
Merge pull request #1054 from billhollings/master
Merge xcode12 branch into master.
2020-09-23 14:40:18 -04:00
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
4b7111d650
Merge pull request #1065 from cdavis5e/tvos-fixes
Really fix tvOS build.
2020-09-23 12:44:53 -05:00
Chip Davis
ef6848165a Really fix tvOS build. 2020-09-23 12:15:25 -05:00
Bill Hollings
4097089f1c vkSetMTLTextureMVK() Fix crash if incoming MTLTexture does not have an IOSurface. 2020-09-23 13:06:25 -04: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
37fb85f1d7 Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2020-09-23 12:40:39 -04: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
a56cfd7fb1
Merge pull request #1063 from cdavis5e/tvos-fixes
Fix build errors on tvOS.
2020-09-23 11:25:28 -05:00
Chip Davis
0fc93afafd Fix build errors on tvOS. 2020-09-23 10:51:25 -05:00
Bill Hollings
3f58a8f805 Merge branch 'master' of https://github.com/billhollings/MoltenVK into xcode12 2020-09-23 11:11:34 -04:00
Bill Hollings
a23f99c3e5 Refactor MoltenVKShaderConverter frameworks.
Combine MoltenVKSPIRVToMSLConverter and MoltenVKGLSLToSPIRVConverter
frameworks into a single MoltenVKShaderConverter framework.

Update corresponding directory structures, symlinks, scripts, and build paths.
Update MoltenVK code to use new framework name for headers.
Add symlinks in API-Samples demo to support legacy
MoltenVKGLSLToSPIRVConverter header paths.

In addition to simplifying shader converter code and build management, the
use of only one shader converter framework fixes a race condition within Xcode,
prior to Xcode 12, when multiple targets use the same dependency XCFramework.
2020-09-23 11:09:46 -04:00
Bill Hollings
f175750042 Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2020-09-23 10:50:30 -04:00
Chip Davis
0ae3dc2041 MVKCmdResolveImage: Use layered rendering where possible. 2020-09-23 09:32:35 -05:00
Bill Hollings
7394860d92
Merge pull request #1061 from cdavis5e/clear-atts-render-area
MVKCmdClearAttachments: Account for the renderArea.
2020-09-23 08:05:48 -04: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
Bill Hollings
6cfe8cdd36
Merge pull request #1060 from cdavis5e/layered-clears
MVKCmdClearImage: Use layered rendering when possible.
2020-09-22 17:47:47 -04:00
Chip Davis
656935b559 MVKCmdClearImage: Use layered rendering when possible. 2020-09-22 16:04:06 -05:00
Bill Hollings
a48da300ed
Merge pull request #1059 from cdavis5e/fix-image-memory-offset
MVKImage: Correct offset for texel buffers and heaps.
2020-09-22 16:27:34 -04:00
Bill Hollings
0e495490ab Remove obsolete library paths in MoltenVKShaderConverter.xcodeproj. 2020-09-22 16:15:34 -04: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
f3b6b9c582 Merge branch 'master' of https://github.com/billhollings/MoltenVK into xcode12 2020-09-22 13:57:47 -04:00
Bill Hollings
fde690aabc Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2020-09-22 13:54:29 -04: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
Bill Hollings
a8cb88d6c4
Merge pull request #1055 from cdavis5e/atomic-linear-texel-buffer
MVKImage: Always use a texel buffer for atomic linear storage images.
2020-09-22 13:44:47 -04:00
Bill Hollings
f4f6c06d33 Conditionally compile MTLLanguageVersion2_3 based on available SDK. 2020-09-22 13:40:02 -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
Bill Hollings
8dc26c3ef9
Merge pull request #1051 from cdavis5e/ycbcr-fixes
Y'CbCr fixes
2020-09-22 10:45:37 -04:00
Bill Hollings
6fba50bba5 Update What's New document with new linking options. 2020-09-21 18:08:54 -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
8a9c708ec7 Disable MTLLanguageVersion2_3 on macOS for Xcode 12.0. 2020-09-21 16:58:42 -04:00
Bill Hollings
9af7d1670d Merge branch 'master' of https://github.com/billhollings/MoltenVK into xcode12 2020-09-21 16:49:46 -04: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