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.
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.
Use `MTLVertexFormatUInt1010102Normalized`. This is the unsigned
equivalent to the signed `MTLVertexFormatInt1010102Normalized`, which we
already use for `VK_FORMAT_A2B10G10R10_SNORM_PACKED`.
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`.
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.
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.
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.
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.