1972 Commits

Author SHA1 Message Date
Chip Davis
fcbbdc1948 Support the shader{Sampled,Storage}ImageArrayDynamicIndexing feature.
Update SPIRV-Cross to support dynamic indexing on iOS 10... and to
actually support arrays of input buffers (which should've been present
before I flipped the `shader{Uniform,Storage}BufferArrayDynamicIndexing`
switch).

Bump patch version.

Fixes #96.
2018-09-27 13:11:55 -05:00
Chip Davis
522793e680 Build the dylib with -fsanitize=thread when tsan is enabled. 2018-09-27 11:27:36 -05:00
Chip Davis
f9022614bb Add a dummy attachment in case no attachments were specified.
Metal currently requires at least one attachment, in order to define the
size of the render target area (and thus, how many times to run the
fragment shader). Vulkan, however, allows specifying no attachments. In
that case, the size of the render target area comes from the extent and
layer count of the framebuffer object. Since Metal doesn't let you (at
least on macOS) define the render target area without an attachment, we
have to supply a dummy attachment that will be discarded once rendering
is complete.

When possible, the render target uses the memoryless storage mode,
falling back to private when that isn't supported. It is marked as
volatile, and its load and store actions are set to "don't care." The
texture is retained for the lifetime of the subpass.
2018-09-26 21:00:07 -05:00
Bill Hollings
99a242e167 Allocate MVKCommandBuffers from a pool within MVKCommandPool.
Add support for trimming command pools.
2018-09-26 18:31:31 -04:00
Bill Hollings
1f7bd607d1
Merge pull request #280 from cdavis5e/fix-dedicated-alloc-segfault
MVKResource: Check that a VkDeviceMemory is nonnull before using it.
2018-09-25 12:01:26 -04:00
Chip Davis
f1888dff95 MVKResource: Check that a VkDeviceMemory is nonnull before using it. 2018-09-25 10:21:08 -05:00
Chip Davis
d667f570f6 Support the VK_EXT_vertex_attribute_divisor extension. 2018-09-25 10:19:05 -05:00
Bill Hollings
1533fdda39
Merge pull request #278 from cdavis5e/fix-query-deadlock
MVKQueryPool: Shunt copying results off to another thread.
2018-09-25 10:56:29 -04:00
Bill Hollings
ec32a16971
Merge pull request #276 from cdavis5e/fence-sitter-race
MVKFenceSitter: Put a hash table read behind the lock.
2018-09-25 10:51:07 -04:00
Bill Hollings
873bceabe5
Merge pull request #275 from cdavis5e/3d-subviews
Better support subviews of 3D textures.
2018-09-25 10:48:11 -04:00
Bill Hollings
21cb79df09
Merge pull request #274 from cdavis5e/render-target-size
vkRenderPass: Set renderTargetWidth and renderTargetHeight when possible.
2018-09-25 10:47:48 -04:00
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
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
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
Chip Davis
ecddc6a539 Log failures to use dedicated allocs with the wrong objects. 2018-09-20 16:13:19 -05: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
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
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
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
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
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
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
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
Bill Hollings
5dac8dc645 Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2018-09-11 16:34:19 -04:00
Bill Hollings
774d4a4040 Remove flushing of command buffer during query commands.
MVKCommandBuffer refactor reset and begin operations.
2018-09-11 16:33:32 -04:00
Chip Davis
9fa8e8c57c Bump extension spec version again after merge. 2018-09-11 12:15:28 -05:00
Chip Davis
ad057e3478 Merge remote-tracking branch 'origin/master' into stencil-image-views 2018-09-11 12:14:38 -05:00
Chip Davis
6947fdf57e Only set MTLTextureUsagePixelFormatView on depth/stencil views...
...and only if the device supports stencil views.
2018-09-11 11:34:46 -05:00
Bill Hollings
26058daba3 Simplify and improve performance of MTLCommandBuffer completion handling.
Manage MTLCommandBuffer in MVKQueueCommandBufferSubmission instead of MVKQueue.
Remove MVKMTLCommandBufferCountdown and its use in MVKQueue.
2018-09-11 10:54:21 -04:00
Chip Davis
1f33a311ae Support views of the stencil aspect of depth/stencil images.
This requires Metal 1.2 (for the `MTLPixelFormatX24_Stencil8` and
`MTLPixelFormatX32_Stencil8` formats). Since Vulkan doesn't actually
have a corresponding format for that, add a new Metal feature for this.
Bump extension spec version.
2018-09-10 17:26:02 -05:00
Bill Hollings
f2cd295b18 Fix configuration access compilation error. 2018-09-10 17:22:21 -04:00