1418 Commits

Author SHA1 Message Date
Chip Davis
a63861c732
Merge pull request #1146 from TheSpydog/dont-cull-clears
Disable culling for the duration of vkCmdClearAttachments
2020-11-14 18:17:41 -06:00
Caleb Cornett
2c33c69e22 Set viewport and scissor rect to the framebuffer extents before clearing. And minor style fixes. 2020-11-14 16:27:39 -05:00
Caleb Cornett
85c6e453b2 Set fill mode, depth bias, viewport, and scissor states before clearing attachments 2020-11-14 15:32:37 -05:00
Chip Davis
6a00362b7b MVKPhysicalDevice: Enable Apple family 7 features on macOS.
The M1 chip supports up to GPU family 7. The enum for this was added to
the SDK in the final version of Xcode 12.2; now we can use it.
2020-11-13 18:10:02 -06:00
Caleb Cornett
d8bded2637 Disable culling for the duration of the vkCmdClearAttachments call 2020-11-11 15:27:11 -05:00
Chip Davis
3e699e4650 MVKCommandEncoder: Don't set renderTargetArrayLength for mixed 2D/3D renders.
Metal's validation layer doesn't like it when we render to both a 2D and
a 3D texture with layered rendering. Work around this by not setting the
`renderTargetArrayLength` if it would be one and we are rendering to
mixed 2D and 3D textures.

If the pipeline sets `[[render_target_array_index]]`, we're hosed either
way. Perhaps this is why Vulkan has a special flag,
`VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT`, intended for rendering to 3D
textures.
2020-11-09 11:14:00 -06:00
Chip Davis
e6d1f3cc67 MVKPhysicalDevice: Expose support for interpolation functions.
This is now supported in MSL 2.3. Support varies by device; devices that
support this return `YES` from `supportsPullModelInterpolation`. Based
on my testing, AMD devices do not yet support this, and Intel devices
do. Apple GPUs probably also support this, in order to support OpenGL on
top.

Update SPIRV-Cross to pull in the changes needed for this.
2020-11-07 12:05:12 -06:00
Bill Hollings
c593983ae0
Merge pull request #1142 from MarnixKuijs/master
Device fallback and fixed typo
2020-11-06 15:11:27 -05:00
Bill Hollings
bf65caa7e4
Merge pull request #1141 from billhollings/desc-set-cleanups
Descriptor code cleanups
2020-11-06 11:30:49 -05:00
MarnixKuijs
ac968db0b5 Device fallback and fixed typo 2020-11-05 23:39:29 +01:00
Bill Hollings
163e8e5b20 Merge branch 'master' of https://github.com/billhollings/MoltenVK into desc-set-cleanups 2020-11-05 15:14:02 -05:00
Chip Davis
415ad30bea Allow linear images on Apple GPUs in Blit and Clear commands.
They can now be used as blit destinations and be cleared with a render
pass.

This also fixes a bug where we were incorrectly validating that the
format supported shader writes if the image were linear, even on
iOS/tvOS.
2020-11-05 13:45:53 -06:00
Bill Hollings
3261d69be8
Merge pull request #1139 from billhollings/tvos-build-fixes
Fix tvOS builds and fix supportsGPUFamily: typo.
2020-11-05 14:28:16 -05:00
Bill Hollings
223a1f4d30 Fix build warnings.
Replace use of MTLDevice::supportsGPUFamily: with supportsFamily:.
Wrap unused variable of tvOS with conditional compile macro.
2020-11-05 13:58:30 -05:00
Bill Hollings
779ae2aa45 Fix tvOS builds.
Add macros to set MTLPixelFormatASTC_*_HDR to MTLPixelFormatInvalid on tvOS.
Use MTLRenderPipelineDescriptor::inputPrimitiveTopologyMVK instead of native method.
2020-11-05 13:41:55 -05:00
Chip Davis
8cb48464b4 MVKPhysicalDevice: Set max visibility buffer size to 256 kiB where supported.
Starting in macOS 10.15, all desktop GPUs support 256 kiB offsets. Apple
GPUs, however, do not support this until family 7. It isn't clear which
one is the supported limit on Apple Silicon Macs with family 5 or 6
GPUs, so I have left the Apple Silicon limit at 64 kiB for now.
2020-11-05 12:04:09 -06:00
Bill Hollings
426b699703
Merge pull request #1137 from cdavis5e/layered-blits
MVKCmdBlitImage: Use layered draws when possible.
2020-11-05 12:30:37 -05:00
Bill Hollings
6defcea596 Simplify MVKDescriptor subclass implementations.
Don't pass descriptor type to MVKDescriptor functions, which already know their
descriptor type, and remove redundant switch tests in each subclass.
Move sanity tests for correct descriptor type to callers.
2020-11-05 11:31:50 -05:00
Chip Davis
b1e304bf91 MVKCmdBlitImage: Use layered draws when possible.
I wanted to do this in the last release, but I ran out of time.

It doesn't seem to provide much speed up.
2020-11-05 10:28:00 -06:00
Chip Davis
75129b849b Support the VK_EXT_texture_compression_astc_hdr extension.
Requires Apple family 6.

This adds one too many `MTLPixelFormats`, so I bumped the
`_mtlPixelFormatCount`.

Fixes #738.
2020-11-05 10:17:42 -06:00
Bill Hollings
a941ace5de
Merge pull request #1135 from cdavis5e/tsan-pipeline-layout-config
MVKPipelineLayout: Only set configuration result if validating.
2020-11-05 09:36:34 -05:00
Bill Hollings
cdd5b458da Fix Metal validation error when unused elements in
an array of sampler are not populated by descriptors.

Populate a default MTLSampler in unused sampler descriptors.
2020-11-04 22:16:04 -05:00
Chip Davis
23f113f1cd MVKPipelineLayout: Only set configuration result if validating.
Fixes a race condition picked up by `tsan`.
2020-11-04 16:25:39 -06:00
Bill Hollings
8cff884624 MVKDescriptorSetLayout sort and hold bindings by binding number.
MVKBufferDescriptor increment dynamic offset index as consumed during binding.
Remove need to track dynamic offset indexes in MVKDescriptorSetLayoutBinding.
2020-11-04 17:25:24 -05:00
Chip Davis
8bb9db2dce Enable VK_EXT_post_depth_coverage for Apple Silicon on Mac. 2020-11-04 16:23:33 -06:00
Chip Davis
51afe4745e Enable VK_AMD_shader_image_load_store_lod for Apple Silicon on Mac. 2020-11-04 16:23:33 -06:00
Bill Hollings
53fd0b3640 Fix crash in vkUpdateDescriptorSets() when copying inline block descriptors.
Use temporary buffer to hold inline block data between
read and write stages while copying between descriptor sets.
2020-11-04 14:01:08 -05:00
Bill Hollings
e23ead807e Fix typo. 2020-11-04 13:00:49 -05:00
Bill Hollings
6e5984832f Sync VK_EXT_descriptor_indexing branch with master. 2020-11-04 11:07:27 -05:00
Bill Hollings
77dc97631e
Merge pull request #1132 from cdavis5e/tvos-supported-extensions
MVKExtensions: Add missing tvOS case for unsupported extensions.
2020-11-04 10:58:41 -05:00
Chip Davis
abf2cba022 MVKExtensions: Add missing tvOS case for unsupported extensions. 2020-11-03 16:24:09 -06:00
Chip Davis
d635d19de4 Support Apple GPU pixel formats with Apple Silicon on Mac.
Also, enable rendering caps on linear textures. This is supported on
Apple GPUs.

Conversely, disable capabilities supported by desktop GPUs that are not
supported on Apple GPUs.

Sadly, no support for 16-bit packed pixel formats on non-Apple GPUs.
2020-11-03 16:23:36 -06:00
Bill Hollings
3910f09b6f Sync VK_EXT_descriptor_indexing branch with master. 2020-11-03 12:10:00 -05:00
Bill Hollings
d3155bd811 VK_EXT_descriptor_indexing add support for update after binding.
MVKDevice track enabled VkPhysicalDeviceInlineUniformBlockFeaturesEXT features.
Disable prefilled MTLCommandBuffers if update after binding enabled.
Update to latest SPIRV-Cross that includes support for unsized arrays.
2020-11-03 11:40:10 -05:00
Bill Hollings
3d952d5ed4 Support setting sizes of SPIR-V unsized arrays.
Set SPIRV-Cross MSLResourceBinding::size value
from MVKDescriptorSetLayoutBinding descriptor count.
2020-10-31 17:50:08 -04:00
Chip Davis
387763797d Expose MTLStorageTypeMemoryless for Apple Silicon on Mac. 2020-10-29 12:39:34 -05:00
Bill Hollings
4055d84a22 Use variable descriptor count when determining descriptor binding count.
MVKDescriptorSetLayoutBinding::getDescriptorCount() considers descriptor set
it is being applied to if it has a variable descriptor count.
Consolidate descriptor creation for inline uniform block with other types.
Don't track dynamic offsets consumed by the descriptor set layout. Instead,
during descriptor binding, track dynamic offsets consumed by each binding and set.
2020-10-28 22:36:59 -04:00
Chip Davis
d73017f4db MVKDevice: Set properties for Apple Silicon GPUs on macOS. 2020-10-28 19:35:24 -05:00
Bill Hollings
0098e94668 Set VK_EXT_descriptor_indexing features and properties.
Increase per-stage texture count to 96 for A11 SoC's and above.
Report VkPhysicalDeviceLimits::maxPerStageDescriptorStorageImages as Metal limit of 8.
Add MVKPhysicalDeviceMetalFeatures::maxPerStageStorageTextureCount and set to 8.
Update VK_MVK_MOLTENVK_SPEC_VERSION to 29.
2020-10-28 19:36:33 -04:00
Chip Davis
2b7f9aee43 Support the VK_KHR_timeline_semaphore extension.
This implementation uses `MTLSharedEvent` where possible, and emulates
it on the host otherwise. Unlike binary semaphores, `MTLSharedEvent`s
map well to timeline semaphores; there should be no problems using them
when they're available.

I'm extremely confident in the `MTLSharedEvent`-based implementation. It
passes nearly all the synchronization tests. I'm less confident in the
emulated implementation.
2020-10-27 18:56:00 -05:00
Bill Hollings
794edc5ec1 Initial support for handling VK_EXT_descriptor_indexing structures.
VK_EXT_descriptor_indexing adds no new functions, but does add six structures to
existing pNext chains. This initial commit processes these structs, but does not
yet perform any operational functionality for this extension.
2020-10-27 11:32:06 -04:00
Bill Hollings
dd08daa478
Merge pull request #1123 from cdavis5e/intel-nv-strictlines
MVKPhysicalDevice: Enable strictLines for Intel and NVIDIA.
2020-10-27 10:20:45 -04:00
Chip Davis
1aad3c3659 MVKPhysicalDevice: Enable strictLines for Intel and NVIDIA.
Both Intel and NV Vulkan drivers enable `strictLines`. My testing shows
in fact that AMD and Apple Silicon exhibit the non-strict-line behavior,
while Intel shows the strict-line behavior.
2020-10-26 17:53:27 -05:00
Chip Davis
9cf3a21b40 MVKCmdBlitImage: Add 0.5 to layer index before interpolating.
This is why the 3D blit tests failed.
2020-10-23 19:05:29 -05:00
Jan Sikorski
e7c49d4e7f MVKPipeline: shorten vertex attribute format's length when stride < size
Metal currently does not support overlapping attribute loads and asserts on
them. Prevent it by shortening format's vector length to fit within the stride,
but print a cautionary message.

An example of affected program is Kingdom Come: Deliverance, which sets
attribute format to RGBA32 in IA and binding stride to 12, while the shader
input is just a float3.
2020-10-22 18:37:41 +02:00
Jan Sikorski
9ee50b526a MVKPixelFormats: Add getName() for MTLVertexFormat 2020-10-22 18:37:41 +02:00
Bill Hollings
a71267797d Upgrade to Xcode 12.2 build settings. 2020-10-21 23:01:33 -04:00
Chip Davis
b052600404 MVKImage: Always set the depth plane when rendering to a 3D image.
Even if we used a texture view. We can't constrain the depth planes in a
3D texture using a texture view, so we need to set the render depth
plane in that case.
2020-10-21 18:04:20 -05:00
Bill Hollings
59ab58484a
Merge pull request #1117 from billhollings/master
Allow binding descriptor set using layout different than it was created with.
2020-10-21 18:06:42 -04:00
Bill Hollings
eb81f2b5be Streamline binding access in MVKDescriptorSetLayout.
Use temporary MVKSmallVector of bindings to sort dynamic offset indices.
Use getDescriptor() where in read/write functions.
2020-10-21 15:34:10 -04:00