Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ****************************************************************************************************************** */
- /* */
- /* Vulkan Renderer */
- /* */
- /* Copyright (C) 2019 - Ognjen "Daemes" Robovic */
- /* */
- /* ****************************************************************************************************************** */
- /* ****************************************************************************************************************** */
- /* */
- /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public */
- /* License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any */
- /* later version. */
- /* */
- /* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied */
- /* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more */
- /* details. */
- /* */
- /* You should have received a copy of the GNU General Public License along with this program; if not, write to the */
- /* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
- /* */
- /* ****************************************************************************************************************** */
- extern void Create_Swapchain
- (
- struct Window_Data * Window,
- struct Physical_Device_Data * Physical,
- struct Queue_Data * Queue,
- struct Logical_Device_Data * Logical,
- struct Surface_Data * Surface,
- struct Swapchain_Data * Swapchain
- );
- extern void Delete_Swapchain
- (
- struct Logical_Device_Data * Logical,
- struct Swapchain_Data * Swapchain
- );
- /* ****************************************************************************************************************** */
- extern void Create_Swapchain
- (
- struct Window_Data * Window,
- struct Physical_Device_Data * Physical,
- struct Queue_Data * Queue,
- struct Logical_Device_Data * Logical,
- struct Surface_Data * Surface,
- struct Swapchain_Data * Swapchain
- )
- /* ****************************************************** */
- /* */
- /* Create swapchain that'll be connected with surface. */
- /* Count of swapchain images and image views is hardcoded */
- /* and should be carefully chosen. */
- /* */
- /* ****************************************************** */
- {
- unsigned int Counter_I = 0;
- char Indicator = '\0';
- /* ****************************************************** */
- switch (vkGetPhysicalDeviceSurfaceCapabilitiesKHR (Physical -> Device, Surface -> Data, & Surface -> Capabilities))
- {
- case VK_SUCCESS:
- (void) fprintf (_Output, ":: Found physical device surface capabilities.\n");
- break;
- case VK_ERROR_OUT_OF_HOST_MEMORY:
- (void) fprintf (_Output, ";; Failed to find physical device surface capabilities, out of host memory.\n");
- exit (EXIT_FAILURE);
- case VK_ERROR_OUT_OF_DEVICE_MEMORY:
- (void) fprintf (_Output, ";; Failed to find physical device surface capabilities, out of device memory.\n");
- exit (EXIT_FAILURE);
- case VK_ERROR_SURFACE_LOST_KHR:
- (void) fprintf (_Output, ";; Failed to find physical device surface capabilities, surface lost.\n");
- exit (EXIT_FAILURE);
- default:
- (void) fprintf (_Output, ";; Unrecognized return value while finding physical device surface capabilities.\n");
- exit (EXIT_FAILURE);
- }
- if ((unsigned int) Surface -> Capabilities. minImageCount <= _Swapchain_Images)
- {
- Swapchain -> Image_Count = _Swapchain_Images;
- }
- else
- {
- Swapchain -> Image_Count = (unsigned int) Surface -> Capabilities. minImageCount;
- }
- (void) fprintf (_Output, " Selected %u images for swapchain image count.\n", Swapchain -> Image_Count);
- if (Surface -> Capabilities. currentExtent. width == 0xFFFFFFFF)
- {
- Swapchain -> Extent. width = Window -> Width;
- Swapchain -> Extent. height = Window -> Height;
- if (Swapchain -> Extent. width < Surface -> Capabilities. minImageExtent. width)
- {
- Swapchain -> Extent. width = Surface -> Capabilities. minImageExtent. width;
- }
- if (Swapchain -> Extent. width > Surface -> Capabilities. maxImageExtent. width)
- {
- Swapchain -> Extent. width = Surface -> Capabilities. maxImageExtent. width;
- }
- if (Swapchain -> Extent. height < Surface -> Capabilities. minImageExtent. height)
- {
- Swapchain -> Extent. height = Surface -> Capabilities. minImageExtent. height;
- }
- if (Swapchain -> Extent. height > Surface -> Capabilities. maxImageExtent. height)
- {
- Swapchain -> Extent. height = Surface -> Capabilities. maxImageExtent. height;
- }
- }
- else
- {
- Swapchain -> Extent = Surface -> Capabilities. currentExtent;
- }
- /* ****************************************************** */
- (void) vkGetPhysicalDeviceSurfaceFormatsKHR (Physical -> Device, Surface -> Data, & Surface -> Format_Count, NULL);
- if (Surface -> Format_Count == 0)
- {
- (void) fprintf (_Output, ";; No surface formats found.\n");
- exit (EXIT_FAILURE);
- }
- switch (vkGetPhysicalDeviceSurfaceFormatsKHR (Physical -> Device, Surface -> Data, & Surface -> Format_Count, Surface -> Formats))
- {
- case VK_SUCCESS:
- (void) fprintf (_Output, ":: Found physical device surface formats.\n");
- break;
- case VK_INCOMPLETE:
- (void) fprintf (_Output, ":: Incompletely found physical device surface formats.\n");
- break;
- case VK_ERROR_OUT_OF_HOST_MEMORY:
- (void) fprintf (_Output, ";; Failed to find physical device surface formats, out of host memory.\n");
- exit (EXIT_FAILURE);
- case VK_ERROR_OUT_OF_DEVICE_MEMORY:
- (void) fprintf (_Output, ";; Failed to find physical device surface formats, out of device memory.\n");
- exit (EXIT_FAILURE);
- case VK_ERROR_SURFACE_LOST_KHR:
- (void) fprintf (_Output, ";; Failed to find physical device surface formats, surface lost.\n");
- exit (EXIT_FAILURE);
- default:
- (void) fprintf (_Output, ";; Unrecognized return value while finding physical device surface formats.\n");
- exit (EXIT_FAILURE);
- }
- if ((Surface -> Format_Count == 1) && (Surface -> Formats [0]. format == VK_FORMAT_UNDEFINED))
- {
- Surface -> Format = VK_FORMAT_B8G8R8A8_UNORM;
- Surface -> Format_Index [VK_FORMAT_UNDEFINED] = (unsigned int) 1;
- Surface -> Format_Index [VK_FORMAT_B8G8R8A8_UNORM] = (unsigned int) 1;
- }
- else
- {
- Surface -> Format = Surface -> Formats [0]. format;
- Surface -> Format_Index [Surface -> Formats [0]. format] = (unsigned int) 1;
- }
- /* ****************************************************** */
- (void) fprintf (_Output, " Available formats: %u\n", Surface -> Format_Count);
- while (Counter_I != Surface -> Format_Count)
- {
- Indicator = (Surface -> Format_Index [Surface -> Formats [Counter_I]. format] != (unsigned int) 0) ? '+' : '-';
- switch (Surface -> Formats [Counter_I]. format)
- {
- case VK_FORMAT_UNDEFINED:
- (void) fprintf (_Output, " [%c] Undefined\n", Indicator);
- break;
- case VK_FORMAT_R4G4_UNORM_PACK8:
- (void) fprintf (_Output, " [%c] R4G4 unsigned normalized 8\n", Indicator);
- break;
- case VK_FORMAT_R4G4B4A4_UNORM_PACK16:
- (void) fprintf (_Output, " [%c] R4G4B4A4 unsigned normalized 16\n", Indicator);
- break;
- case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
- (void) fprintf (_Output, " [%c] B4G4R4A4 unsigned normalized 16\n", Indicator);
- break;
- case VK_FORMAT_R5G6B5_UNORM_PACK16:
- (void) fprintf (_Output, " [%c] R5G6B5 unsigned normalized 16\n", Indicator);
- break;
- case VK_FORMAT_B5G6R5_UNORM_PACK16:
- (void) fprintf (_Output, " [%c] B5G6R5 unsigned normalized 16\n", Indicator);
- break;
- case VK_FORMAT_R5G5B5A1_UNORM_PACK16:
- (void) fprintf (_Output, " [%c] R5G5B5A1 unsigned normalized 16\n", Indicator);
- break;
- case VK_FORMAT_B5G5R5A1_UNORM_PACK16:
- (void) fprintf (_Output, " [%c] B5G5R5A1 unsigned normalized 16\n", Indicator);
- break;
- case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
- (void) fprintf (_Output, " [%c] A1R5G5B5 unsigned normalized 16\n", Indicator);
- break;
- case VK_FORMAT_R8_UNORM:
- (void) fprintf (_Output, " [%c] R8 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_R8_SNORM:
- (void) fprintf (_Output, " [%c] R8 signed normalized\n", Indicator);
- break;
- case VK_FORMAT_R8_USCALED:
- (void) fprintf (_Output, " [%c] R8 unsigned scaled integer\n", Indicator);
- break;
- case VK_FORMAT_R8_SSCALED:
- (void) fprintf (_Output, " [%c] R8 signed scaled integer\n", Indicator);
- break;
- case VK_FORMAT_R8_UINT:
- (void) fprintf (_Output, " [%c] R8 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_R8_SINT:
- (void) fprintf (_Output, " [%c] R8 signed integer\n", Indicator);
- break;
- case VK_FORMAT_R8_SRGB:
- (void) fprintf (_Output, " [%c] R8 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_R8G8_UNORM:
- (void) fprintf (_Output, " [%c] R8G8 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_R8G8_SNORM:
- (void) fprintf (_Output, " [%c] R8G8 signed normalized\n", Indicator);
- break;
- case VK_FORMAT_R8G8_USCALED:
- (void) fprintf (_Output, " [%c] R8G8 unsigned scaled integer\n", Indicator);
- break;
- case VK_FORMAT_R8G8_SSCALED:
- (void) fprintf (_Output, " [%c] R8G8 signed scaled integer\n", Indicator);
- break;
- case VK_FORMAT_R8G8_UINT:
- (void) fprintf (_Output, " [%c] R8G8 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_R8G8_SINT:
- (void) fprintf (_Output, " [%c] R8G8 signed integer\n", Indicator);
- break;
- case VK_FORMAT_R8G8_SRGB:
- (void) fprintf (_Output, " [%c] R8G8 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_R8G8B8_UNORM:
- (void) fprintf (_Output, " [%c] R8G8B8 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_R8G8B8_SNORM:
- (void) fprintf (_Output, " [%c] R8G8B8 signed normalized\n", Indicator);
- break;
- case VK_FORMAT_R8G8B8_USCALED:
- (void) fprintf (_Output, " [%c] R8G8B8 unsigned scaled integer\n", Indicator);
- break;
- case VK_FORMAT_R8G8B8_SSCALED:
- (void) fprintf (_Output, " [%c] R8G8B8 signed scaled integer\n", Indicator);
- break;
- case VK_FORMAT_R8G8B8_UINT:
- (void) fprintf (_Output, " [%c] R8G8B8 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_R8G8B8_SINT:
- (void) fprintf (_Output, " [%c] R8G8B8 signed integer\n", Indicator);
- break;
- case VK_FORMAT_R8G8B8_SRGB:
- (void) fprintf (_Output, " [%c] R8G8B8 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_B8G8R8_UNORM:
- (void) fprintf (_Output, " [%c] B8G8R8 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_B8G8R8_SNORM:
- (void) fprintf (_Output, " [%c] B8G8R8 signed normalized\n", Indicator);
- break;
- case VK_FORMAT_B8G8R8_USCALED:
- (void) fprintf (_Output, " [%c] B8G8R8 unsigned scaled integer\n", Indicator);
- break;
- case VK_FORMAT_B8G8R8_SSCALED:
- (void) fprintf (_Output, " [%c] B8G8R8 signed scaled integer\n", Indicator);
- break;
- case VK_FORMAT_B8G8R8_UINT:
- (void) fprintf (_Output, " [%c] B8G8R8 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_B8G8R8_SINT:
- (void) fprintf (_Output, " [%c] B8G8R8 signed integer\n", Indicator);
- break;
- case VK_FORMAT_B8G8R8_SRGB:
- (void) fprintf (_Output, " [%c] B8G8R8 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_R8G8B8A8_UNORM:
- (void) fprintf (_Output, " [%c] R8G8B8A8 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_R8G8B8A8_SNORM:
- (void) fprintf (_Output, " [%c] R8G8B8A8 signed normalized\n", Indicator);
- break;
- case VK_FORMAT_R8G8B8A8_USCALED:
- (void) fprintf (_Output, " [%c] R8G8B8A8 unsigned scaled integer\n", Indicator);
- break;
- case VK_FORMAT_R8G8B8A8_SSCALED:
- (void) fprintf (_Output, " [%c] R8G8B8A8 signed scaled integer\n", Indicator);
- break;
- case VK_FORMAT_R8G8B8A8_UINT:
- (void) fprintf (_Output, " [%c] R8G8B8A8 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_R8G8B8A8_SINT:
- (void) fprintf (_Output, " [%c] R8G8B8A8 signed integer\n", Indicator);
- break;
- case VK_FORMAT_R8G8B8A8_SRGB:
- (void) fprintf (_Output, " [%c] R8G8B8A8 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_B8G8R8A8_UNORM:
- (void) fprintf (_Output, " [%c] B8G8R8A8 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_B8G8R8A8_SNORM:
- (void) fprintf (_Output, " [%c] B8G8R8A8 signed normalized\n", Indicator);
- break;
- case VK_FORMAT_B8G8R8A8_USCALED:
- (void) fprintf (_Output, " [%c] B8G8R8A8 unsigned scaled integer\n", Indicator);
- break;
- case VK_FORMAT_B8G8R8A8_SSCALED:
- (void) fprintf (_Output, " [%c] B8G8R8A8 signed scaled integer\n", Indicator);
- break;
- case VK_FORMAT_B8G8R8A8_UINT:
- (void) fprintf (_Output, " [%c] B8G8R8A8 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_B8G8R8A8_SINT:
- (void) fprintf (_Output, " [%c] B8G8R8A8 signed integer\n", Indicator);
- break;
- case VK_FORMAT_B8G8R8A8_SRGB:
- (void) fprintf (_Output, " [%c] B8G8R8A8 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
- (void) fprintf (_Output, " [%c] A8B8G8R8 unsigned normalized 32\n", Indicator);
- break;
- case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
- (void) fprintf (_Output, " [%c] A8B8G8R8 signed normalized 32\n", Indicator);
- break;
- case VK_FORMAT_A8B8G8R8_USCALED_PACK32:
- (void) fprintf (_Output, " [%c] A8B8G8R8 unsigned scaled integer 32\n", Indicator);
- break;
- case VK_FORMAT_A8B8G8R8_SSCALED_PACK32:
- (void) fprintf (_Output, " [%c] A8B8G8R8 signed scaled integer 32\n", Indicator);
- break;
- case VK_FORMAT_A8B8G8R8_UINT_PACK32:
- (void) fprintf (_Output, " [%c] A8B8G8R8 unsigned integer 32\n", Indicator);
- break;
- case VK_FORMAT_A8B8G8R8_SINT_PACK32:
- (void) fprintf (_Output, " [%c] A8B8G8R8 signed integer 32\n", Indicator);
- break;
- case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
- (void) fprintf (_Output, " [%c] A8B8G8R8 sRGB non-linear 32\n", Indicator);
- break;
- case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
- (void) fprintf (_Output, " [%c] A2R10G10B10 unsigned normalized 32\n", Indicator);
- break;
- case VK_FORMAT_A2R10G10B10_SNORM_PACK32:
- (void) fprintf (_Output, " [%c] A2R10G10B10 signed normalized 32\n", Indicator);
- break;
- case VK_FORMAT_A2R10G10B10_USCALED_PACK32:
- (void) fprintf (_Output, " [%c] A2R10G10B10 unsigned scaled integer 32\n", Indicator);
- break;
- case VK_FORMAT_A2R10G10B10_SSCALED_PACK32:
- (void) fprintf (_Output, " [%c] A2R10G10B10 signed scaled integer 32\n", Indicator);
- break;
- case VK_FORMAT_A2R10G10B10_UINT_PACK32:
- (void) fprintf (_Output, " [%c] A2R10G10B10 unsigned integer 32\n", Indicator);
- break;
- case VK_FORMAT_A2R10G10B10_SINT_PACK32:
- (void) fprintf (_Output, " [%c] A2R10G10B10 signed integer 32\n", Indicator);
- break;
- case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
- (void) fprintf (_Output, " [%c] A2B10G10R10 unsigned normalized 32\n", Indicator);
- break;
- case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
- (void) fprintf (_Output, " [%c] A2B10G10R10 signed normalized 32\n", Indicator);
- break;
- case VK_FORMAT_A2B10G10R10_USCALED_PACK32:
- (void) fprintf (_Output, " [%c] A2B10G10R10 unsigned scaled integer 32\n", Indicator);
- break;
- case VK_FORMAT_A2B10G10R10_SSCALED_PACK32:
- (void) fprintf (_Output, " [%c] A2B10G10R10 signed scaled integer 32\n", Indicator);
- break;
- case VK_FORMAT_A2B10G10R10_UINT_PACK32:
- (void) fprintf (_Output, " [%c] A2B10G10R10 unsigned integer 32\n", Indicator);
- break;
- case VK_FORMAT_A2B10G10R10_SINT_PACK32:
- (void) fprintf (_Output, " [%c] A2B10G10R10 signed integer 32\n", Indicator);
- break;
- case VK_FORMAT_R16_UNORM:
- (void) fprintf (_Output, " [%c] R16 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_R16_SNORM:
- (void) fprintf (_Output, " [%c] R16 signed normalized\n", Indicator);
- break;
- case VK_FORMAT_R16_USCALED:
- (void) fprintf (_Output, " [%c] R16 unsigned scaled integer\n", Indicator);
- break;
- case VK_FORMAT_R16_SSCALED:
- (void) fprintf (_Output, " [%c] R16 signed scaled integer\n", Indicator);
- break;
- case VK_FORMAT_R16_UINT:
- (void) fprintf (_Output, " [%c] R16 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_R16_SINT:
- (void) fprintf (_Output, " [%c] R16 signed integer\n", Indicator);
- break;
- case VK_FORMAT_R16_SFLOAT:
- (void) fprintf (_Output, " [%c] R16 signed float\n", Indicator);
- break;
- case VK_FORMAT_R16G16_UNORM:
- (void) fprintf (_Output, " [%c] R16G16 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_R16G16_SNORM:
- (void) fprintf (_Output, " [%c] R16G16 signed normalized\n", Indicator);
- break;
- case VK_FORMAT_R16G16_USCALED:
- (void) fprintf (_Output, " [%c] R16G16 unsigned scaled integer\n", Indicator);
- break;
- case VK_FORMAT_R16G16_SSCALED:
- (void) fprintf (_Output, " [%c] R16G16 signed scaled integer\n", Indicator);
- break;
- case VK_FORMAT_R16G16_UINT:
- (void) fprintf (_Output, " [%c] R16G16 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_R16G16_SINT:
- (void) fprintf (_Output, " [%c] R16G16 signed integer\n", Indicator);
- break;
- case VK_FORMAT_R16G16_SFLOAT:
- (void) fprintf (_Output, " [%c] R16G16 signed float\n", Indicator);
- break;
- case VK_FORMAT_R16G16B16_UNORM:
- (void) fprintf (_Output, " [%c] R16G16B16 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_R16G16B16_SNORM:
- (void) fprintf (_Output, " [%c] R16G16B16 signed normalized\n", Indicator);
- break;
- case VK_FORMAT_R16G16B16_USCALED:
- (void) fprintf (_Output, " [%c] R16G16B16 unsigned scaled integer\n", Indicator);
- break;
- case VK_FORMAT_R16G16B16_SSCALED:
- (void) fprintf (_Output, " [%c] R16G16B16 signed scaled integer\n", Indicator);
- break;
- case VK_FORMAT_R16G16B16_UINT:
- (void) fprintf (_Output, " [%c] R16G16B16 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_R16G16B16_SINT:
- (void) fprintf (_Output, " [%c] R16G16B16 signed integer\n", Indicator);
- break;
- case VK_FORMAT_R16G16B16_SFLOAT:
- (void) fprintf (_Output, " [%c] R16G16B16 signed float\n", Indicator);
- break;
- case VK_FORMAT_R16G16B16A16_UNORM:
- (void) fprintf (_Output, " [%c] R16G16B16A16 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_R16G16B16A16_SNORM:
- (void) fprintf (_Output, " [%c] R16G16B16A16 signed normalized\n", Indicator);
- break;
- case VK_FORMAT_R16G16B16A16_USCALED:
- (void) fprintf (_Output, " [%c] R16G16B16A16 unsigned scaled integer\n", Indicator);
- break;
- case VK_FORMAT_R16G16B16A16_SSCALED:
- (void) fprintf (_Output, " [%c] R16G16B16A16 signed scaled integer\n", Indicator);
- break;
- case VK_FORMAT_R16G16B16A16_UINT:
- (void) fprintf (_Output, " [%c] R16G16B16A16 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_R16G16B16A16_SINT:
- (void) fprintf (_Output, " [%c] R16G16B16A16 signed integer\n", Indicator);
- break;
- case VK_FORMAT_R16G16B16A16_SFLOAT:
- (void) fprintf (_Output, " [%c] R16G16B16A16 signed float\n", Indicator);
- break;
- case VK_FORMAT_R32_UINT:
- (void) fprintf (_Output, " [%c] R32 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_R32_SINT:
- (void) fprintf (_Output, " [%c] R32 signed integer\n", Indicator);
- break;
- case VK_FORMAT_R32_SFLOAT:
- (void) fprintf (_Output, " [%c] R32 signed float\n", Indicator);
- break;
- case VK_FORMAT_R32G32_UINT:
- (void) fprintf (_Output, " [%c] R32G32 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_R32G32_SINT:
- (void) fprintf (_Output, " [%c] R32G32 signed integer\n", Indicator);
- break;
- case VK_FORMAT_R32G32_SFLOAT:
- (void) fprintf (_Output, " [%c] R32G32 signed float\n", Indicator);
- break;
- case VK_FORMAT_R32G32B32_UINT:
- (void) fprintf (_Output, " [%c] R32G32B32 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_R32G32B32_SINT:
- (void) fprintf (_Output, " [%c] R32G32B32 signed integer\n", Indicator);
- break;
- case VK_FORMAT_R32G32B32_SFLOAT:
- (void) fprintf (_Output, " [%c] R32G32B32 signed float\n", Indicator);
- break;
- case VK_FORMAT_R32G32B32A32_UINT:
- (void) fprintf (_Output, " [%c] R32G32B32A32 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_R32G32B32A32_SINT:
- (void) fprintf (_Output, " [%c] R32G32B32A32 signed integer\n", Indicator);
- break;
- case VK_FORMAT_R32G32B32A32_SFLOAT:
- (void) fprintf (_Output, " [%c] R32G32B32A32 signed float\n", Indicator);
- break;
- case VK_FORMAT_R64_UINT:
- (void) fprintf (_Output, " [%c] R64 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_R64_SINT:
- (void) fprintf (_Output, " [%c] R64 signed integer\n", Indicator);
- break;
- case VK_FORMAT_R64_SFLOAT:
- (void) fprintf (_Output, " [%c] R64 signed float\n", Indicator);
- break;
- case VK_FORMAT_R64G64_UINT:
- (void) fprintf (_Output, " [%c] R64G64 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_R64G64_SINT:
- (void) fprintf (_Output, " [%c] R64G64 signed integer\n", Indicator);
- break;
- case VK_FORMAT_R64G64_SFLOAT:
- (void) fprintf (_Output, " [%c] R64G64 signed float\n", Indicator);
- break;
- case VK_FORMAT_R64G64B64_UINT:
- (void) fprintf (_Output, " [%c] R64G64B64 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_R64G64B64_SINT:
- (void) fprintf (_Output, " [%c] R64G64B64 signed integer\n", Indicator);
- break;
- case VK_FORMAT_R64G64B64_SFLOAT:
- (void) fprintf (_Output, " [%c] R64G64B64 signed float\n", Indicator);
- break;
- case VK_FORMAT_R64G64B64A64_UINT:
- (void) fprintf (_Output, " [%c] R64G64B64A64 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_R64G64B64A64_SINT:
- (void) fprintf (_Output, " [%c] R64G64B64A64 signed integer\n", Indicator);
- break;
- case VK_FORMAT_R64G64B64A64_SFLOAT:
- (void) fprintf (_Output, " [%c] R64G64B64A64 signed float\n", Indicator);
- break;
- case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
- (void) fprintf (_Output, " [%c] B10G11R11 unsigned float 32\n", Indicator);
- break;
- case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
- (void) fprintf (_Output, " [%c] E5B9G9R9 unsigned float 32\n", Indicator);
- break;
- case VK_FORMAT_D16_UNORM:
- (void) fprintf (_Output, " [%c] D16 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_X8_D24_UNORM_PACK32:
- (void) fprintf (_Output, " [%c] Unused 8 / D24 unsigned normalized 32\n", Indicator);
- break;
- case VK_FORMAT_D32_SFLOAT:
- (void) fprintf (_Output, " [%c] D32 signed float 32\n", Indicator);
- break;
- case VK_FORMAT_S8_UINT:
- (void) fprintf (_Output, " [%c] S8 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_D16_UNORM_S8_UINT:
- (void) fprintf (_Output, " [%c] D16 unsigned normalized / S8 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_D24_UNORM_S8_UINT:
- (void) fprintf (_Output, " [%c] D24 unsigned normalized / S8 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_D32_SFLOAT_S8_UINT:
- (void) fprintf (_Output, " [%c] D32 signed float / S8 unsigned integer\n", Indicator);
- break;
- case VK_FORMAT_BC1_RGB_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] BC1 RGB unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_BC1_RGB_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] BC1 RGB sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_BC1_RGBA_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] BC1 RGBA unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_BC1_RGBA_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] BC1 RGBA sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_BC2_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] BC2 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_BC2_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] BC2 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_BC3_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] BC3 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_BC3_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] BC3 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_BC4_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] BC4 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_BC4_SNORM_BLOCK:
- (void) fprintf (_Output, " [%c] BC4 signed normalized\n", Indicator);
- break;
- case VK_FORMAT_BC5_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] BC5 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_BC5_SNORM_BLOCK:
- (void) fprintf (_Output, " [%c] BC5 signed normalized\n", Indicator);
- break;
- case VK_FORMAT_BC6H_UFLOAT_BLOCK:
- (void) fprintf (_Output, " [%c] BC6H unsigned float\n", Indicator);
- break;
- case VK_FORMAT_BC6H_SFLOAT_BLOCK:
- (void) fprintf (_Output, " [%c] BC6H signed float\n", Indicator);
- break;
- case VK_FORMAT_BC7_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] BC7 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_BC7_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] BC7 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] ETC2 R8G8B8 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] ETC R8G8B82 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] ETC2 R8G8B8A1 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] ETC2 R8G8B8A1 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] ETC2 R8G8B8A8 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] ETC2 R8G8B8A8 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_EAC_R11_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] EAC R11 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_EAC_R11_SNORM_BLOCK:
- (void) fprintf (_Output, " [%c] EAC R11 signed normalized\n", Indicator);
- break;
- case VK_FORMAT_EAC_R11G11_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] EAC R11G11 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_EAC_R11G11_SNORM_BLOCK:
- (void) fprintf (_Output, " [%c] EAC R11G11 signed normalized\n", Indicator);
- break;
- case VK_FORMAT_ASTC_4x4_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 4x4 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_ASTC_4x4_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 4x4 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_ASTC_5x4_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 5x4 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_ASTC_5x4_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 5x4 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_ASTC_5x5_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 5x5 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_ASTC_5x5_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 5x5 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_ASTC_6x5_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 6x5 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_ASTC_6x5_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 6x5 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_ASTC_6x6_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 6x6 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_ASTC_6x6_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 6x6 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_ASTC_8x5_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 8x5 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_ASTC_8x5_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 8x5 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_ASTC_8x6_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 8x6 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_ASTC_8x6_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 8x6 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_ASTC_8x8_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 8x8 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_ASTC_8x8_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 8x8 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_ASTC_10x5_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 10x5 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_ASTC_10x5_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 10x5 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_ASTC_10x6_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 10x6 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_ASTC_10x6_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 10x6 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_ASTC_10x8_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 10x8 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_ASTC_10x8_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 10x8 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_ASTC_10x10_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 10x10 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_ASTC_10x10_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 10x10 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_ASTC_12x10_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 12x10 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_ASTC_12x10_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 12x10 sRGB non-linear\n", Indicator);
- break;
- case VK_FORMAT_ASTC_12x12_UNORM_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 12x12 unsigned normalized\n", Indicator);
- break;
- case VK_FORMAT_ASTC_12x12_SRGB_BLOCK:
- (void) fprintf (_Output, " [%c] ASTC 12x12 sRGB non-linear\n", Indicator);
- break;
- default:
- (void) fprintf (_Output, " [?] Unrecognized format\n");
- break;
- }
- Counter_I++;
- }
- Counter_I = 0;
- /* ****************************************************** */
- (void) vkGetPhysicalDeviceSurfacePresentModesKHR (Physical -> Device, Surface -> Data, & Surface -> Present_Mode_Count, NULL);
- if (Surface -> Present_Mode_Count == 0)
- {
- (void) fprintf (_Output, ";; No surface present modes found.\n");
- exit (EXIT_FAILURE);
- }
- switch (vkGetPhysicalDeviceSurfacePresentModesKHR (Physical -> Device, Surface -> Data, & Surface -> Present_Mode_Count, Surface -> Present_Modes))
- {
- case VK_SUCCESS:
- (void) fprintf (_Output, ":: Found physical device surface present modes.\n");
- break;
- case VK_INCOMPLETE:
- (void) fprintf (_Output, ":: Incompletely find physical device surface present modes.\n");
- break;
- case VK_ERROR_OUT_OF_HOST_MEMORY:
- (void) fprintf (_Output, ";; Failed to find physical device surface present modes, out of host memory.\n");
- exit (EXIT_FAILURE);
- case VK_ERROR_OUT_OF_DEVICE_MEMORY:
- (void) fprintf (_Output, ";; Failed to find physical device surface present modes, out of device memory.\n");
- exit (EXIT_FAILURE);
- case VK_ERROR_SURFACE_LOST_KHR:
- (void) fprintf (_Output, ";; Failed to find physical device surface present modes, surface lost.\n");
- exit (EXIT_FAILURE);
- default:
- (void) fprintf (_Output, ";; Unrecognized return value while finding physical device surface present modes.\n");
- exit (EXIT_FAILURE);
- }
- Surface -> Present_Mode = VK_PRESENT_MODE_FIFO_KHR;
- Surface -> Present_Mode_Index [VK_PRESENT_MODE_FIFO_KHR] = (unsigned int) 1;
- /* ****************************************************** */
- (void) fprintf (_Output, " Available present modes: %u\n", Surface -> Present_Mode_Count);
- while (Counter_I != Surface -> Present_Mode_Count)
- {
- Indicator = (Surface -> Present_Mode_Index [Surface -> Present_Modes [Counter_I]] != (unsigned int) 0) ? '+' : '-';
- switch (Surface -> Present_Modes [Counter_I])
- {
- case VK_PRESENT_MODE_IMMEDIATE_KHR:
- (void) fprintf (_Output, " [%c] Immediate\n", Indicator);
- break;
- case VK_PRESENT_MODE_MAILBOX_KHR:
- (void) fprintf (_Output, " [%c] Mailbox\n", Indicator);
- break;
- case VK_PRESENT_MODE_FIFO_KHR:
- (void) fprintf (_Output, " [%c] FIFO\n", Indicator);
- break;
- case VK_PRESENT_MODE_FIFO_RELAXED_KHR:
- (void) fprintf (_Output, " [%c] FIFO relaxed\n", Indicator);
- break;
- default:
- (void) fprintf (_Output, " [?] Unrecognized format\n");
- break;
- }
- Counter_I++;
- }
- Counter_I = 0;
- /* ****************************************************** */
- unsigned int Queue_Family_Indices [1] =
- {
- Queue -> Family_Index
- };
- const VkSwapchainCreateInfoKHR Swapchain_Information =
- {
- .sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
- .pNext = NULL,
- .flags = 0,
- .surface = Surface -> Data,
- .minImageCount = Swapchain -> Image_Count,
- .imageFormat = Surface -> Format,
- .imageColorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR,
- .imageExtent.width = Swapchain -> Extent. width,
- .imageExtent.height = Swapchain -> Extent. height,
- .imageArrayLayers = 1,
- .imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
- .imageSharingMode = VK_SHARING_MODE_EXCLUSIVE,
- .queueFamilyIndexCount = 1,
- .pQueueFamilyIndices = Queue_Family_Indices,
- .preTransform = Surface -> Capabilities. supportedTransforms,
- .compositeAlpha = Surface -> Capabilities. supportedCompositeAlpha,
- .presentMode = Surface -> Present_Mode,
- .clipped = VK_TRUE,
- .oldSwapchain = VK_NULL_HANDLE
- };
- switch (vkCreateSwapchainKHR (Logical -> Device, & Swapchain_Information, NULL, & Swapchain -> Data))
- {
- case VK_SUCCESS:
- (void) fprintf (_Output, ":: Created swapchain.\n");
- break;
- case VK_ERROR_OUT_OF_HOST_MEMORY:
- (void) fprintf (_Output, ";; Failed to create swapchain, out of host memory.\n");
- exit (EXIT_FAILURE);
- case VK_ERROR_OUT_OF_DEVICE_MEMORY:
- (void) fprintf (_Output, ";; Failed to create swapchain, out of device memory.\n");
- exit (EXIT_FAILURE);
- case VK_ERROR_DEVICE_LOST:
- (void) fprintf (_Output, ";; Failed to create swapchain, device lost.\n");
- exit (EXIT_FAILURE);
- case VK_ERROR_SURFACE_LOST_KHR:
- (void) fprintf (_Output, ";; Failed to create swapchain, surface lost.\n");
- exit (EXIT_FAILURE);
- case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
- (void) fprintf (_Output, ";; Failed to create swapchain, native window in use.\n");
- exit (EXIT_FAILURE);
- case VK_ERROR_INITIALIZATION_FAILED:
- (void) fprintf (_Output, ";; Failed to create swapchain, initialization failed.\n");
- exit (EXIT_FAILURE);
- default:
- (void) fprintf (_Output, ";; Unrecognized return value while creating swapchain.\n");
- exit (EXIT_FAILURE);
- }
- /* ****************************************************** */
- (void) vkGetSwapchainImagesKHR (Logical -> Device, Swapchain -> Data, & Swapchain -> Image_Count, NULL);
- VkImage Swapchain_Image_Buffer [_Swapchain_Images];
- switch (vkGetSwapchainImagesKHR (Logical -> Device, Swapchain -> Data, & Swapchain -> Image_Count, Swapchain_Image_Buffer))
- {
- case VK_SUCCESS:
- (void) fprintf (_Output, ":: Found swapchain images.\n");
- break;
- case VK_INCOMPLETE:
- (void) fprintf (_Output, ":: Incompletely found swapchain images.\n");
- break;
- case VK_ERROR_OUT_OF_HOST_MEMORY:
- (void) fprintf (_Output, ";; Failed to find swapchain images, out of host memory.\n");
- exit (EXIT_FAILURE);
- case VK_ERROR_OUT_OF_DEVICE_MEMORY:
- (void) fprintf (_Output, ";; Failed to find swapchain images, out of device memory.\n");
- exit (EXIT_FAILURE);
- default:
- (void) fprintf (_Output, ";; Unrecognized return value while finding swapchain images.\n");
- exit (EXIT_FAILURE);
- }
- Counter_I = 0;
- while (Counter_I != Swapchain -> Image_Count)
- {
- Swapchain -> Images [Counter_I] = Swapchain_Image_Buffer [Counter_I];
- Counter_I++;
- }
- Counter_I = 0;
- /* ****************************************************** */
- while (Counter_I != Swapchain -> Image_Count)
- {
- const VkImageViewCreateInfo Image_View_Information =
- {
- . sType = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
- . pNext = NULL,
- . flags = 0,
- . image = Swapchain -> Images [Counter_I],
- . viewType = VK_IMAGE_VIEW_TYPE_2D,
- . format = Surface -> Format,
- . components. r = VK_COMPONENT_SWIZZLE_R,
- . components. g = VK_COMPONENT_SWIZZLE_G,
- . components. b = VK_COMPONENT_SWIZZLE_B,
- . components. a = VK_COMPONENT_SWIZZLE_A,
- . subresourceRange. aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
- . subresourceRange. baseMipLevel = 0,
- . subresourceRange. levelCount = 1,
- . subresourceRange. baseArrayLayer = 0,
- . subresourceRange. layerCount = 1
- };
- switch (vkCreateImageView (Logical -> Device, & Image_View_Information, NULL, & Swapchain -> Image_Views [Counter_I]))
- {
- case VK_SUCCESS:
- break;
- case VK_ERROR_OUT_OF_HOST_MEMORY:
- (void) fprintf (_Output, ";; Failed to create swapchain image views, out of host memory.\n");
- exit (EXIT_FAILURE);
- case VK_ERROR_OUT_OF_DEVICE_MEMORY:
- (void) fprintf (_Output, ";; Failed to create swapchain image views, out of device memory.\n");
- exit (EXIT_FAILURE);
- default:
- (void) fprintf (_Output, ";; Unrecognized return value while creating swapchain image views.\n");
- exit (EXIT_FAILURE);
- }
- Counter_I++;
- }
- (void) fprintf (_Output, ":: Created swapchain image views.\n");
- }
- /* ****************************************************************************************************************** */
- extern void Delete_Swapchain
- (
- struct Logical_Device_Data * Logical,
- struct Swapchain_Data * Swapchain
- )
- /* ****************************************************** */
- /* */
- /* Delete swapchain image views, and then swapchain. */
- /* */
- /* ****************************************************** */
- {
- unsigned int Counter_I = 0;
- /* ****************************************************** */
- while (Counter_I != Swapchain -> Image_Count)
- {
- vkDestroyImageView (Logical -> Device, Swapchain -> Image_Views [Counter_I], NULL);
- Counter_I++;
- }
- /* ****************************************************** */
- vkDestroySwapchainKHR (Logical -> Device, Swapchain -> Data, NULL);
- (void) fprintf (_Output, ":: Deleted swapchain image views.\n");
- (void) fprintf (_Output, ":: Deleted swapchain.\n");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement