253 Commits

Author SHA1 Message Date
Bill Hollings
480d5b239a Support polygonMode VK_POLYGON_MODE_POINT.
Support MTLPrimitiveTopologyClass on iOS in addition to macOS.
2018-10-24 17:06:19 -04:00
Bill Hollings
ac61f9185f vkCreateInstance returns VK_ERROR_INCOMPATIBLE_DRIVER if Metal not available. 2018-10-22 17:21:55 -04:00
Bill Hollings
af0c1a08f1 Update shader caching for compatibility with texture swizzling.
MVKPipelineLayout set auxiliary buffer MSL index relative to already-calculated
push constant buffer MSL index.
MVKPipeline destructor release auxiliary buffer MTLBuffer instance.
Nudge MVK_VERSION_PATCH.
2018-10-17 16:57:21 -07:00
Bill Hollings
6c0ab0f4c2
Merge pull request #304 from cdavis5e/wolf2-packed-pixels
Correct MTLPixelFormats for a couple of formats.
2018-10-16 14:55:44 -04:00
Chip Davis
e7af5bed64 Correct MTLPixelFormats for a couple of formats.
Set `MTLPixelFormatRG11B10Float` for `VK_FORMAT_B10G11R11_UFLOAT_PACK32`
and `MTLPixelFormatRGB9E5Float` for `VK_FORMAT_E5B9R9G9_UFLOAT_PACK32`.

This should fix the rest of #302.
2018-10-16 11:41:46 -05:00
Chip Davis
082d282b28 Support arbitrary swizzles of image data.
The swizzles are passed to shaders that need them using an "auxiliary
buffer", for which there must be room in the function argument table.
Code is inserted into the shaders to swizzle reads from sampled
textures--per the Vulkan spec, component mappings must only be applied
to sampled images.

Update SPIRV-Cross to pull in some fixes for handling swizzled image
data. Bump MoltenVK version.
2018-10-16 11:33:13 -05:00
Bill Hollings
7dd143411a
Merge pull request #298 from francoisbertelatschrodinger/whitespaces
Make PhaseScriptExecution works when SRCROOT path has whitespaces.
2018-10-15 13:54:07 -04:00
Bill Hollings
aad51f82f2 Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2018-10-09 11:56:42 -04:00
Bill Hollings
2adc450c62 Include struct size parameter in VK_MVK_moltenvk extension functions
that pass structs that might change size across extension versions
2018-10-08 20:22:12 -04:00
François Bertel
014b936c4e Make PhaseScriptExecution works when SRCROOT path has whitespaces. 2018-10-08 14:11:39 -04:00
Bill Hollings
4640d273af
Merge pull request #296 from cdavis5e/copy-image-compat-format
vkCmdCopyImage: Allow copies between compatible formats.
2018-10-03 13:14:35 -04:00
Chip Davis
b8202e7b65 Forbid copying between 3D texture and a 2D array texture.
Metal doesn't support that yet.
2018-10-03 11:24:49 -05:00
Bill Hollings
2204113b86
Merge pull request #295 from cdavis5e/blend-state-unused
MVKPipeline: Don't set blend state for unused attachments.
2018-10-03 12:00:07 -04:00
Bill Hollings
2444dfee37
Merge pull request #294 from cdavis5e/vertex-rgb10a2-unorm
Map VK_FORMAT_A2B10G10R10_UNORM_PACKED to an MTLVertexFormat.
2018-10-03 11:59:49 -04:00
Bill Hollings
b173ea5964
Merge pull request #293 from cdavis5e/linear-tiled-props
MVKDevice: Correct properties of linear-tiled images.
2018-10-03 10:50:11 -04:00
Bill Hollings
d0b111ef46
Merge pull request #292 from cdavis5e/dedicated-free
MVKDeviceMemory: Allow dedicated allocations to forget their resources.
2018-10-03 10:44:14 -04:00
Chip Davis
44c9aaa957 vkCmdCopyImage: Allow copies between compatible formats.
The docs for the `MTLBlitCommandEncoder`'s `copyFromTexture:...` method
state that the source and destination textures must have the same
format.

This was true when it was written in the iOS 8 timeframe for Metal 1.0.
But, I suspect it was changed in Metal 1.1 when support was added for
texture views of differing formats. Like with texture views, the two
formats now need only be compatible. This is the same behavior that
Vulkan prescribes.
2018-10-03 09:42:31 -05:00
Chip Davis
a0a93e0cdb MVKPipeline: Don't set blend state for unused attachments.
Some clients always set blend state for all eight attachments, even if
the attachments are unused. Since the attachments are unused, the
expectation is that the corresponding blend states won't matter. But in
Metal, there's no way to tell if an attachment won't be used. So, if you
enable blending on an unused attachment, its pixel format will be
`MTLPixelFormatInvalid`, which doesn't support blending; Metal will
assert on this.
2018-10-03 09:39:42 -05:00
Chip Davis
0171fd46c5 Set the VERTEX_BUFFER feature bit on VK_FORMAT_A2B10G10R10_UNORM_PACK32.
Since we can use it in a vertex buffer now.
2018-10-03 09:37:31 -05:00
Bill Hollings
4fba647123 Optimize scheme configuration and make consistent. 2018-10-03 10:09:47 -04:00
Chip Davis
230ec2569e Map VK_FORMAT_A2B10G10R10_UNORM_PACKED to an MTLVertexFormat.
Use `MTLVertexFormatUInt1010102Normalized`. This is the unsigned
equivalent to the signed `MTLVertexFormatInt1010102Normalized`, which we
already use for `VK_FORMAT_A2B10G10R10_SNORM_PACKED`.
2018-10-02 18:24:49 -05:00
Chip Davis
b86e6b2be3 MVKDevice: Correct properties of linear-tiled images.
According to the Vulkan spec, linear-tiled images *may* not be supported
unless certain restrictions are satisfied. That means that
implementations may support features--or restrictions--above and beyond
the restrictions given in the Vulkan spec.

Metal places these limitations on linear textures:
* They must be 2D.
* They may only have one mip level.
* They may only have one array layer.
* They may not be multisampled--sample count must be one.
* On macOS, they may not be used as attachments.
* They may not be depth/stencil textures.
* They may not have a compressed format.

Have `vkGetPhysicalDeviceFormatProperties()` and
`vkGetPhysicalDeviceImageFormatProperties()` return results consistent
with these constraints. Also, allow creation of linear textures with
usages other than `VK_IMAGE_USAGE_TRANSFER_{SRC,DST}_BIT`.
2018-10-02 18:14:33 -05:00
Chip Davis
6da32e55b0 MVKDeviceMemory: Allow dedicated allocations to forget their resources.
Otherwise, if the resource is destroyed first (which it almost always
will be), then when the `VkDeviceMemory` is freed, it will access a
freed resource, at which point it will then proceed to fandango on core.
2018-10-02 18:00:38 -05:00
Chip Davis
9490e96164 MVKPipeline: Fix getting the vertex attribute divisor struct.
Bah. I read the spec wrong. It's hung off the vertex input state, not
the top-level create info.
2018-10-02 18:00:13 -05:00
Bill Hollings
a3f571e89b Include version number in VK_MVK_moltenvk extension functions that pass structs that might change. 2018-10-02 12:48:51 -04:00
Bill Hollings
c933330406 Allocate MVKDescriptorSets from a pool within MVKDescriptorPool,
keyed by MVKDescriptorSetLayout reference.

Add MVKObjectPool subclass MVKDeviceObjectPool.
Enlarge window dimensions on macOS Cube demo.
2018-09-30 18:07:13 -04:00
Bill Hollings
cded63b008 Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2018-09-27 18:21:05 -04:00
Bill Hollings
9f28854a2a Update glslang version and What's New document. 2018-09-27 18:20:20 -04:00
Chip Davis
6f1c97966c Use the passed render area to set the render target extent.
Use the smaller of the render area and the framebuffer area.
2018-09-27 16:29:37 -05:00
Bill Hollings
7ffc5bd806
Merge pull request #286 from cdavis5e/resource-array-dynamic-indexing
Support the shader{Sampled,Storage}ImageArrayDynamicIndexing feature.
2018-09-27 17:27:11 -04:00
Bill Hollings
dfcc815c82
Merge pull request #285 from cdavis5e/tsan-build
Build the dylib with -fsanitize=thread when tsan is enabled.
2018-09-27 17:25:50 -04:00
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