1941 Commits

Author SHA1 Message Date
Chip Davis
5c8a472a1b Add support for uploading 3D S3TC-compressed images.
This allows clients to initialize 3D image objects with data in a BC1,
BC2, or BC3 (aka DXTn, aka S3TC) format. Since Metal doesn't support
this natively, DXTn-compressed image data are manually decompressed
prior to upload or copying. This particular algorithm was derived from
Wine, from code originally authored by Connor McAdams. It's somewhat
primitive, and could probably stand some vectorization, but it's a good
first start.

The meat of the algorithm is pulled into a header, "MVKDXTnCodec.def",
intended to be used by both CPU and shader code. CPU uploads, which in
MoltenVK happen when binding a `VkDeviceMemory` object to an image, run
the code normally. GPU uploads, i.e. copying from a buffer to a texture,
run the algorithm as a compute shader, possibly storing the results to
an intermediate buffer to then copy directly to the texture.
Intermediate buffers are used when uploading to mip levels higher than
0, since desktop Metal doesn't support directly writing to higher mip
levels from a shader.

Only uploads are supported. Downloads are not implemented yet.

Theoretically, this could be extended to other compressed formats as
well, allowing MoltenVK to support all texture compression formats on
all platforms.
2018-12-31 15:51:06 -06:00
Bill Hollings
d5c91a9578 Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2018-12-31 16:47:16 -05:00
Bill Hollings
66a407dcc6 Support iOS builds for arm64e architecture. 2018-12-31 16:46:45 -05:00
Bill Hollings
3549d13ad8
Merge pull request #433 from billhollings/master
Fix issues #429 & #430.
2018-12-31 16:18:06 -05:00
Chip Davis
0f7525bf13 Remove needless disablement of the fragment aux buffer. 2018-12-31 13:48:53 -06:00
Bill Hollings
b74cb7b947 Swapchain supports both double and triple buffering.
Decrease minimum swapchain images to 2.
Add MVKPhysicalDeviceMetalFeatures::minSwapchainImageCount & maxSwapchainImageCount.
Minor refactoring of mvkClamp() & MVKPhysicalDevice::getSurfacePresentModes().
Update VK_MVK_MOLTENVK_SPEC_VERSION to 15.
Update MoltenVK version to 1.0.30.
2018-12-31 13:17:00 -05:00
Bill Hollings
a1ac6d9b63 Return VK_TIMEOUT even on zero wait if fences not signaled. 2018-12-30 14:32:48 -05:00
Bill Hollings
33a7ad2f85 Increase max swapchain images to 3. 2018-12-29 17:14:07 -05:00
aerofly
50c55ed49b fix merge errors 2018-12-22 22:00:08 +01:00
aerofly
2fdee5c2e3
Merge branch 'master' into master 2018-12-22 21:39:54 +01:00
aerofly
d1a6c3cf32 Update aerofly fork to latest MoltenVK 2018-12-21 10:32:35 +01:00
Bill Hollings
a01b99514e
Merge pull request #420 from mlfarrell/bugfix/default-device-graphics-switching-macos
If user requests system default device curing vkCreateDevice, call …
2018-12-20 17:01:59 -05:00
Bill Hollings
0ac27b087e
Merge pull request #423 from cdavis5e/compressed-format-type
Use a specific format type for compressed formats.
2018-12-20 09:14:40 -05:00
Bill Hollings
e2bcd175bc
Merge pull request #422 from cdavis5e/aux-buffer-inline
Use an inline constant buffer for the auxiliary buffer.
2018-12-20 08:17:28 -05:00
Bill Hollings
7152633db8
Merge pull request #412 from cdavis5e/forbid-uncompressed-views
MVKImage: Make BLOCK_TEXEL_VIEW a hard error.
2018-12-20 08:08:01 -05:00
Chip Davis
7c2ce795bb Use a specific format type for compressed formats.
Instead of assuming that `kMVKFormatNone` means the format is
compressed. This makes the code doing these checks more obvious and
self-documenting.

Since I changed the public MoltenVK-specific API, I also bumped the
`VK_MVK_moltenvk` spec revision.
2018-12-19 12:25:03 -07:00
Chip Davis
d973602edb Use an inline constant buffer for the auxiliary buffer.
Since a pipeline might be shared between multiple draws, but those draws
could use different textures, it isn't tenable to have a single aux
buffer shared between those draws. Instead, we'll set up constant
buffers using the `setXxxBytes()` method on the command encoder. That
way, separate draws using the same pipeline won't interfere with each
other.

This change also uses separate buffers for the vertex and fragment
shaders, since they may have different sets of textures.
2018-12-19 11:34:03 -07:00
Chip Davis
94fc4de563 Also claim the BLOCK_TEXEL_VIEW_COMPATIBLE bit is unsupported. 2018-12-19 11:32:25 -07:00
Bill Hollings
c3838c15de
Merge pull request #414 from cdavis5e/vertex-attr-offset-stride
MVKPipeline: Forbid vertex attribute offsets >= stride.
2018-12-19 12:23:56 -05:00
Bill Hollings
6aa4ddbffc
Merge pull request #413 from cdavis5e/immutable-sampler-lifetime
MVKDescriptorSet: Fix handling of immutable samplers.
2018-12-19 12:22:14 -05:00
Bill Hollings
4049518683
Merge pull request #411 from cdavis5e/copy-image-compat-format-2
vkCmdCopyImage: Cast source image to the destination format.
2018-12-19 12:05:10 -05:00
Bill Hollings
7b0630290f
Merge pull request #410 from cdavis5e/format-props-2-match-core
MVKDevice: Make result of extended getFormatProperties() match the core API.
2018-12-19 11:49:45 -05:00
Mike Farrell
e658f9d1c4 - if user requests system default device curing vkCreateDevice, call required trigger method MTLCreateSystemDefaultDevice() to ensure proper graphics switching occurs on macos 2018-12-19 01:32:18 -08:00
aerofly
d87b71887e Reduce heap allocations during rendering 2018-12-18 15:59:49 +01:00
Chip Davis
6ff8a46a3c Actually check the vertex binding I meant to check. 2018-12-17 11:05:37 -06:00
Chip Davis
288211d81f Fix handling of case where vertex bindings and binding indices don't match up. 2018-12-17 10:35:36 -06:00
Chip Davis
8e6b2e3e11 MVKPipeline: Forbid vertex attribute offsets >= stride.
Metal validates that this is so.
2018-12-17 09:36:45 -06:00
Chip Davis
972ba0e148 MVKDescriptorSet: Fix handling of immutable samplers.
Null the `sampler` field of the stored `VkDescriptorImageInfo` if the
descriptor uses an immutable sampler. That way, we won't try to
double-free a sampler.

Retain immutable samplers when the set is created. Release them when the
set is destroyed.
2018-12-17 09:32:55 -06:00
Chip Davis
9c9d23f621 MVKImage: Make BLOCK_TEXEL_VIEW a hard error.
As I feared. It's impossible to create an uncompressed view from a
compressed texture.
2018-12-17 09:32:11 -06:00
Chip Davis
79f0b175fc vkCmdCopyImage: Cast source image to the destination format.
In which I am proved wrong again. While Metal indeed won't assert if the
pixel formats don't match, the results of attempting such a copy are...
mixed, to say the least. Sometimes, nothing is copied at all. Other
times, pixels are copied in weird ways that don't seem to conform at all
to expectation. (This is most apparent in the output of the CTS's image
copying tests.) It's best, then, to ensure that the source and
destination have the same format.

Unfortunately, in the process of writing this, my fears regarding not
being able to make uncompressed views of compressed images were
confirmed. So we can't do this for compressed images.
2018-12-17 09:29:27 -06:00
Chip Davis
9f58016c35 MVKDevice: Make result of extended getFormatProperties() match the core API. 2018-12-17 09:25:31 -06:00
Chip Davis
2bfa7b47d6 vkCmdPushDescriptorSetWithTemplate: Initialize data pointer to null.
The command object assumes it is null if it hasn't been used yet. Let's
ensure this is so.
2018-12-17 09:23:46 -06:00
aerofly
febeb9d738 Merge fork with master MoltenVK again 2018-12-15 18:59:58 +01:00
aerofly
ef21f2488a Merge fork with master MoltenVK again 2018-12-15 18:36:07 +01:00
aerofly
fba2eefa5e Modify MVKVector with feedback from cdavis5e 2018-12-14 14:19:30 +01:00
aerofly
6aad9dc0ba fix conflicts 2018-12-12 20:57:11 +01:00
aerofly
2b19954d11
Merge branch 'master' into master 2018-12-12 20:11:18 +01:00
aerofly
5811ae5811 fix conflicts 2018-12-12 20:09:24 +01:00
aerofly
8c1581f247 Update fork to latest MoltenVK 2018-12-12 16:08:22 +01:00
Bill Hollings
da598c0061
Merge pull request #392 from billhollings/master
MSL don't emit memory_scope after MSL 2.0.
2018-12-12 08:33:41 -05:00
Bill Hollings
b804fd536c
Merge pull request #391 from cdavis5e/format-features
Add new formats and fix existing ones
2018-12-12 08:33:12 -05:00
Chip Davis
3d424679f3 Add support for VK_FORMAT_A2R10G10B10_UNORM_PACK32.
This format was added in Metal 2 (iOS 11, macOS 10.13), and is intended
for rendering to wide-color (10bpc) displays.
2018-12-11 17:40:21 -06:00
Chip Davis
e9158463a6 On macOS, VK_FORMAT_E5B9G9R9_UFLOAT_PACK32 can only be filtered. 2018-12-11 17:40:21 -06:00
Chip Davis
15b67b4311 On macOS, linear textures cannot be blitted to.
Since they cannot be render targets.

I wonder if we could work around that using a shader.
2018-12-11 17:40:21 -06:00
Chip Davis
35573832dc Give every image format we support the BLIT_SRC feature.
All that is required is that we can either read the format
(`TRANSFER_SRC`) or sample from it (`SAMPLED_IMAGE`). Every image format
that Metal supports supports those two features.

This marks the depth/stencil formats as able to be the source of a
blit. The spec requires in particular that `D16_UNORM` and `D32_SFLOAT`
support that.
2018-12-11 17:40:21 -06:00
Chip Davis
282699d755 Depth formats cannot be used for a VkBufferView.
It is not possible to create a linear texture from a depth/stencil
format. Therefore, we can't support buffer views in these formats.
2018-12-11 17:40:21 -06:00
Chip Davis
a1d8de5da2 Correct supported features of compressed formats.
Compressed formats only support reading and filtering. They also can't
be used to create linear textures, so they can't be used for buffer
views, either.
2018-12-11 17:40:21 -06:00
Chip Davis
5c65330e50 Add some more vertex formats.
Use `MTLVertexFormatChar`, `UChar`, `Short`, `UShort`, and `Half` when
available. Add `MTLVertexFormatUChar4Normalized_BGRA` for
`VK_FORMAT_B8G8R8A8_UNORM`.

These are only available on Metal 2.0 (iOS 11, macOS 10.13) and up, so
this adds what MoltenVK was using before as a fallback, similar to how
some `MTLPixelFormat`s have substitutes.
2018-12-11 17:40:21 -06:00
Chip Davis
4bbbbbd783 MVKImage: Round up byte alignment to the nearest power of 2. 2018-12-11 17:38:47 -06:00
Bill Hollings
98dd858d82 Merge branch 'master' of https://github.com/KhronosGroup/MoltenVK 2018-12-11 18:27:40 -05:00