450 Commits

Author SHA1 Message Date
Chip Davis
6ec39da6b2 MVKQueryPool: Shunt copying results off to another thread.
Copying the results could block if the client said to wait. If this
completion handler runs before the one that actually finishes the
queries--and it will if it's scheduled first--it will block
indefinitely, causing a deadlock. Instead, run this on a different
dispatch queue; then the query will be allowed to finish.
2018-09-25 08:55:13 -05:00
Chip Davis
dd367fea0c MVKFenceSitter: Put a hash table read behind the lock.
To avoid a data race. Caught this with `ThreadSanitizer`.
2018-09-24 17:12:23 -05:00
Chip Davis
5f5f2243c2 Better support subviews of 3D textures.
Now when we set up the `MTLRenderPassAttachmentDescriptor` for the 3D
texture, we set the `depthPlane` property instead of the `slice`
property. Combined with an appropriate setting for
`renderTargetArrayLength` in the base descriptor, this allows rendering
to a subset of a 3D texture.
2018-09-24 16:35:19 -05:00
Chip Davis
74e0ce8962 vkRenderPass: Set renderTargetWidth and renderTargetHeight when possible.
These properties were introduced in Metal 2.0 on iOS. (They don't exist
yet on Mac.) Currently, they are only used to constrain the size of the
render target area. Perhaps someday, they may be used to support render
passes with no render target attachments. For now, though, Metal doesn't
support that.
2018-09-24 16:30:34 -05:00
Chip Davis
7e050d0584 Advertise the VK_KHR_sampler_mirror_clamp_to_edge extension.
We already support this extension. The enumerant added by this extension
is already mapped to its Metal equivalent. Only advertise the extension
on macOS, though. iOS doesn't support this.
2018-09-24 16:27:37 -05:00
Bill Hollings
ac10059a6b
Merge pull request #272 from cdavis5e/khr-maintenance2
Support the VK_KHR_maintenance2 extension.
2018-09-24 17:24:20 -04:00
Chip Davis
3b65e20936 Validate the image view config after setting the usage.
It's not convenient to get the usage out of the `pCreateInfo`, since
it's tucked away in an extension struct. (Unfortunately, I had assumed
we were already doing this...)
2018-09-24 15:50:03 -05:00
Chip Davis
32d4702265 Support the VK_KHR_maintenance2 extension.
We don't really restrict which usages you can request on an image, so
the `VK_IMAGE_CREATE_EXTENDED_USAGE_BIT` doesn't really apply to us.
Since we don't yet support tessellation, we don't support
`VkPipelineTessellationDomainOriginStateCreateInfo`, either. Finally,
as near as I can tell, we don't really do anything with input
attachments, so any `VkRenderPassInputAttachmentAspectCreateInfo` will
be ignored.

I'm not sure if creating image views of compressed images using an
uncompressed format will work. Metal's docs say texture views between
any two color formats of the same size will work, but they also
specifically call out converting between sRGB and non-sRGB compressed
formats, which implies that, say, creating an `RG32Uint` view on a
`BC1_RGBA` texture may not work. Thus, I've logged any uses of the
`VK_IMAGE_CREATE_BLOCK_TEXEL_VIEW_COMPATIBLE_BIT`.
2018-09-24 15:15:07 -05:00
Bill Hollings
aab8b9a798
Merge pull request #271 from cdavis5e/image-format-list
Advertise the VK_KHR_image_format_list extension.
2018-09-21 18:50:05 -04:00
Chip Davis
876ceeb269 Advertise the VK_KHR_image_format_list extension.
We don't actually do anything with the extension struct, but that's OK;
it's just an optimization hint anyway. I'm not sure what we'd do with
this information. It's intended to enable implementations to better
optimize image layouts, but that's under Metal's control in MoltenVK.
2018-09-20 21:24:55 -05:00
Bill Hollings
dd9408fa50
Merge pull request #270 from billhollings/master
Update library dependencies for Vulkan SDK.
2018-09-20 22:02:10 -04:00
Bill Hollings
7051582859 Update library dependencies for Vulkan SDK. 2018-09-20 21:02:39 -04:00
Bill Hollings
ccc534d583
Merge pull request #269 from cdavis5e/really-update-spirv-cross
Fix SPIRV-Cross update that I bungled.
2018-09-20 19:49:05 -04:00
Bill Hollings
57e361d95d
Merge pull request #267 from cdavis5e/dedicated-alloc
Support the VK_KHR_dedicated_allocation extension.
2018-09-20 19:27:41 -04:00
Bill Hollings
523f1571af
Merge pull request #268 from billhollings/master
Update travis to use Xcode 10.
2018-09-20 19:26:37 -04:00
Chip Davis
f0db0c746a Fix SPIRV-Cross update that I bungled.
(Do I have to bump the patch version again...?)
2018-09-20 18:19:25 -05:00
Chip Davis
ecddc6a539 Log failures to use dedicated allocs with the wrong objects. 2018-09-20 16:13:19 -05:00
Bill Hollings
d9cae70f85 Update travis to use Xcode 10. 2018-09-20 17:10:03 -04:00
Chip Davis
b9a42fe815 Support the VK_KHR_dedicated_allocation extension.
This is used to declare that a `VkDeviceMemory` object is for the sole
use of a particular buffer or image.

In fact, until Metal 1.2 on iOS (2.0 on Mac), Metal didn't really
support anything *but* dedicated allocations. MoltenVK hacks around this
limitation by manually syncing memory between buffers and images that
used the `VkDeviceMemory` object.

Maybe someday we can use the new `MTLHeap` object to support some sort
of sub-allocation scheme. But at this moment, it won't let you specify
the exact offset within the heap, nor can it be used for managed or (on
macOS) shared memory, nor will it let you directly map the heap memory
(something that could be worked around with an aliasable `MTLBuffer`
taking up the entire heap space), all of which makes it unsuitable for
implementing `VkDeviceMemory`. So, for now, we always prefer dedicated
allocation.
2018-09-20 15:46:04 -05:00
Bill Hollings
c329fa68ee
Merge pull request #266 from cdavis5e/get-memory-reqs-2
Support the VK_KHR_get_memory_requirements2 extension.
2018-09-20 16:45:00 -04:00
Chip Davis
77f935c265 Support the VK_KHR_get_memory_requirements2 extension.
In preparation for supporting `VK_KHR_dedicated_allocation`.
2018-09-20 14:21:12 -05:00
Bill Hollings
54b9f1364d
Merge pull request #265 from cdavis5e/more-easy-features
Advertise some more features we already support.
2018-09-20 15:18:26 -04:00
Bill Hollings
a63215f9c3
Merge pull request #264 from cdavis5e/shader-viewport-index-layer
Support the VK_EXT_shader_viewport_index_layer extension.
2018-09-20 14:53:46 -04:00
Chip Davis
544645de05 Advertise the shader{Uniform,Storage}BufferArrayDynamicIndexing features.
This means that arrays in the `Uniform` storage class decorated with
`Block` or `BufferBlock` (or in the `StorageBuffer` class with `Block`)
can be indexed with dynamically uniform constants. I see nothing in the
MSL spec which forbids this.
2018-09-20 13:36:30 -05:00
Chip Davis
5185ffc01f Advertise the shaderStorageImage{Read,Write}WithoutFormat features.
We really don't care about the `Format` specified on an `Image` type in
SPIR-V modules. MSL doesn't even have a place to specify it. (This is of
course referring to the pixel format, as opposed to the data type, which
we *do* care about.)
2018-09-20 10:10:35 -05:00
Chip Davis
6d4e95a7d7 Advertise the shaderStorageImageMultisample feature.
Metal supports read-only access from shaders to multisampled
textures--in fact, it's the only way they're supported. (Aside from as a
render target, of course.)
2018-09-20 10:10:35 -05:00
Chip Davis
801ce71108 Support the VK_EXT_shader_viewport_index_layer extension.
Update SPIRV-Cross to support the `ViewportIndex` builtin, and pull in a
fix for the `Layer` builtin. Bump `MVK_VERSION_PATCH`.
2018-09-20 10:00:21 -05:00
Bill Hollings
336b835906
Merge pull request #263 from cdavis5e/extension-cleanup
Pull extension definitions into a common file.
2018-09-20 10:31:31 -04:00
Bill Hollings
c756fa990b
Merge pull request #262 from cdavis5e/multi-viewport
Support the multiViewport feature.
2018-09-20 10:19:36 -04:00
Chip Davis
ec522f0168 Pull extension definitions into a common file.
`#include` this file to define the various bits and pieces needed to
support an extension. Now instead of having to change three places, we
now only need change one.

Also, sort the list of extensions. This list is starting to get a little
long and unruly, so before it gets completely out of hand, let's apply a
little semblance of order to it. The extensions are now arranged in the
following order: first, the Khronos-blessed extensions; then multivendor
extensions; then our (`MVK`) extensions; and finally other vendors'
extensions. These subgroups are sorted alphabetically, as Khronos'
master list is.

I'm not happy about the `MVK_EXTENSION_LAST` kluge. But, C++ apparently
doesn't let you stick a dangling comma on a constructor's initializer
list.
2018-09-19 20:57:29 -05:00
Chip Davis
09ef22d203 Fix coding style around if statements. 2018-09-19 20:46:48 -05:00
Bill Hollings
d2844d2578
Merge pull request #261 from billhollings/master
Support filling Metal command buffers on same thread as Vulkan command buffer.
2018-09-19 19:29:25 -04:00
Chip Davis
3b9e406573 Support the multiViewport feature.
Clients can now set multiple viewports and scissor rects, but without a
geometry shader, it won't be much use. For now, however, we can support
`VK_EXT_shader_viewport_index_layer`, which will make this feature more
useful despite us not having geometry shaders.
2018-09-19 16:35:10 -05:00
Bill Hollings
c3863dd495 Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2018-09-19 17:28:56 -04:00
Bill Hollings
799c429ace
Merge pull request #259 from cdavis5e/sample-rate-shading
Support the sampleRateShading feature.
2018-09-19 17:27:04 -04:00
Bill Hollings
ce4a41b90a Support filling Metal command buffers on same thread as Vulkan command buffer.
Add MVKConfiguration member prefillMetalCommandBuffers and build setting
MVK_CONFIG_PREFILL_METAL_COMMAND_BUFFERS.
Rename MVKConfiguration member maxActiveMetalCommandBuffersPerPool
to maxActiveMetalCommandBuffersPerQueue.
Support Xcode 10 build settings.
2018-09-19 16:58:43 -04:00
Chip Davis
eeca918c92 Support the sampleRateShading feature.
This is for fragment shaders that run per-sample instead of
per-fragment. It implies that the `SampleId`, `SampleMask`, and
`SamplePosition` builtins, as well as per-sample interpolation, are all
available--using any of these causes the frag shader to run once per
sample. (In Metal, reading the color buffers may also cause a frag
shader to run per-sample.)

Update SPIRV-Cross to pull in a change that properly translates the
`SamplePosition` builtin to a form that Metal can understand.
2018-09-18 09:58:56 -05:00
Bill Hollings
cfce1514f6 Replace use of MVKPhysicalDeviceMetalFeatures::depthClipMode with
existing Vulkan depthClamp feature flag.

Update VK_MVK_moltenvk spec version to 10.
2018-09-17 17:20:01 -04:00
Bill Hollings
13a950e1ec
Merge pull request #258 from billhollings/master
Accept CAMetalLayer in surface creation & fix docs.
2018-09-17 16:21:32 -04:00
Bill Hollings
8eaf767474 Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2018-09-17 14:16:00 -04:00
Bill Hollings
5d8d4d2440 Fixes to documentation for extensions and building.
Indicate both vk_KHR_maintenance1 & vk_AMD_negative_viewport_height extensions are available.
2018-09-16 14:46:01 -04:00
Bill Hollings
e546b83852 When creating a surface, accept either a CAMetalLayer or an
NSView/UIView in the pView member, and improve error logging.
2018-09-16 12:39:03 -04:00
Bill Hollings
2a1913ff19
Merge pull request #256 from danginsburg/spirv_cross_memory_leak
Fix memory leak not destroying spirv_cross objects.  When creating a …
2018-09-15 10:45:34 -04:00
Dan Ginsburg
9896403f9c Fix memory leak not destroying spirv_cross objects. When creating a lot of pipelines this was causing a large memory leak. 2018-09-14 14:01:22 -04:00
Bill Hollings
b543d08afe
Merge pull request #255 from cdavis5e/easy-features
Advertise some features we already support
2018-09-13 14:27:53 -04:00
Chip Davis
7633299a60 VkPhysicalDevice: Advertise the drawIndirectFirstInstance feature.
Only advertise it if the device supports both indirect drawing and
specifying the base vertex/instance.
2018-09-13 11:55:17 -05:00
Chip Davis
3b97980de0 VkPhysicalDevice: Advertise the fullDrawIndexUint32 feature.
This just means the maximum index for an indexed draw is 2**32 - 1.
2018-09-13 11:55:17 -05:00
Chip Davis
41dfeddc4c VkPhysicalDevice: Advertise the robustBufferAccess feature.
The spec requires all implementations of Vulkan to support this, so we
may as well turn it on. I haven't seen any ill effects from
out-of-bounds accesses, so I think we'll be OK.
2018-09-13 11:55:17 -05:00
Bill Hollings
48718dcaf0
Merge pull request #254 from billhollings/master
Command execution adjustments.
2018-09-12 15:03:42 -04:00
Bill Hollings
6e3574dc65 Command execution without queue submission.
MVKCommandEncoder encoding pass in only MTLCommandBuffer.
Make MVKCommandEncodingPool threadsafe and move from queue to command pool.
2018-09-12 14:09:12 -04:00