Support the VK_KHR_swapchain_mutable_format extension.

This allows clients to create views of a swapchain image with a
different format, just like a regular image created with the
`VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT` set. This extension also supports
the additional features provided by `VK_KHR_maintenance2` and
`VK_KHR_image_format_list` for swapchain images.

We... admittedly don't do much with any of this. There wasn't really
anything in Metal stopping clients from doing this to begin with. This
change does, however, set the `MUTABLE_FORMAT` and `EXTENDED_USAGE`
image bits on any swapchain created with the new
`VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR`.
This commit is contained in:
Chip Davis 2018-12-04 23:39:12 -06:00
parent 1518d0c5fe
commit 528d3daf2a
3 changed files with 7 additions and 1 deletions

View File

@ -239,6 +239,7 @@ In addition to the core *Vulkan* API, **MoltenVK** also supports the following
- `VK_KHR_storage_buffer_storage_class`
- `VK_KHR_surface`
- `VK_KHR_swapchain`
- `VK_KHR_swapchain_mutable_format`
- `VK_EXT_shader_viewport_index_layer`
- `VK_EXT_vertex_attribute_divisor`
- `VK_MVK_moltenvk`

View File

@ -214,7 +214,7 @@ void MVKSwapchain::initSurfaceImages(const VkSwapchainCreateInfoKHR* pCreateInfo
_mtlLayerOrigDrawSize = _mtlLayer.updatedDrawableSizeMVK;
VkExtent2D imgExtent = mvkVkExtent2DFromCGSize(_mtlLayerOrigDrawSize);
const VkImageCreateInfo imgInfo = {
VkImageCreateInfo imgInfo = {
.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO,
.pNext = VK_NULL_HANDLE,
.imageType = VK_IMAGE_TYPE_2D,
@ -228,6 +228,10 @@ void MVKSwapchain::initSurfaceImages(const VkSwapchainCreateInfoKHR* pCreateInfo
.flags = 0,
};
if (mvkAreFlagsEnabled(pCreateInfo->flags, VK_SWAPCHAIN_CREATE_MUTABLE_FORMAT_BIT_KHR)) {
mvkEnableFlag(imgInfo.flags, VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT|VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
}
VkSurfaceCapabilitiesKHR srfcProps;
MVKSurface* mvkSrfc = (MVKSurface*)pCreateInfo->surface;
_device->getPhysicalDevice()->getSurfaceCapabilities(mvkSrfc, &srfcProps);

View File

@ -48,6 +48,7 @@ MVK_EXTENSION(KHR_shader_float16_int8, KHR_SHADER_FLOAT16_INT8)
MVK_EXTENSION(KHR_storage_buffer_storage_class, KHR_STORAGE_BUFFER_STORAGE_CLASS)
MVK_EXTENSION(KHR_surface, KHR_SURFACE)
MVK_EXTENSION(KHR_swapchain, KHR_SWAPCHAIN)
MVK_EXTENSION(KHR_swapchain_mutable_format, KHR_SWAPCHAIN_MUTABLE_FORMAT)
MVK_EXTENSION(EXT_shader_viewport_index_layer, EXT_SHADER_VIEWPORT_INDEX_LAYER)
MVK_EXTENSION(EXT_vertex_attribute_divisor, EXT_VERTEX_ATTRIBUTE_DIVISOR)
MVK_EXTENSION(MVK_ios_surface, MVK_IOS_SURFACE)