Advertisement
Guest User

Vulkan swapchain

a guest
Jan 27th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 42.01 KB | None | 0 0
  1. /* ****************************************************************************************************************** */
  2. /*                                                                                                                    */
  3. /* Vulkan Renderer                                                                                                    */
  4. /*                                                                                                                    */
  5. /* Copyright (C) 2019 - Ognjen "Daemes" Robovic                                                                       */
  6. /*                                                                                                                    */
  7. /* ****************************************************************************************************************** */
  8.  
  9. /* ****************************************************************************************************************** */
  10. /*                                                                                                                    */
  11. /* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public  */
  12. /* License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any     */
  13. /* later version.                                                                                                     */
  14. /*                                                                                                                    */
  15. /* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied */
  16. /* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more       */
  17. /* details.                                                                                                           */
  18. /*                                                                                                                    */
  19. /* You should have received a copy of the GNU General Public License along with this program; if not, write to the    */
  20. /* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.                       */
  21. /*                                                                                                                    */
  22. /* ****************************************************************************************************************** */
  23.  
  24. extern void Create_Swapchain
  25. (
  26.     struct Window_Data          * Window,
  27.     struct Physical_Device_Data * Physical,
  28.     struct Queue_Data           * Queue,
  29.     struct Logical_Device_Data  * Logical,
  30.     struct Surface_Data         * Surface,
  31.     struct Swapchain_Data       * Swapchain
  32. );
  33.  
  34. extern void Delete_Swapchain
  35. (
  36.     struct Logical_Device_Data * Logical,
  37.     struct Swapchain_Data      * Swapchain
  38. );
  39.  
  40. /* ****************************************************************************************************************** */
  41.  
  42. extern void Create_Swapchain
  43. (
  44.     struct Window_Data          * Window,
  45.     struct Physical_Device_Data * Physical,
  46.     struct Queue_Data           * Queue,
  47.     struct Logical_Device_Data  * Logical,
  48.     struct Surface_Data         * Surface,
  49.     struct Swapchain_Data       * Swapchain
  50. )
  51. /* ****************************************************** */
  52. /*                                                        */
  53. /* Create swapchain that'll be connected with surface.    */
  54. /* Count of swapchain images and image views is hardcoded */
  55. /* and should be carefully chosen.                        */
  56. /*                                                        */
  57. /* ****************************************************** */
  58. {
  59.     unsigned int Counter_I = 0;
  60.  
  61.     char Indicator = '\0';
  62.  
  63. /*                               ******************************************************                               */
  64.  
  65.     switch (vkGetPhysicalDeviceSurfaceCapabilitiesKHR (Physical -> Device, Surface -> Data, & Surface -> Capabilities))
  66.     {
  67.         case VK_SUCCESS:
  68.             (void) fprintf (_Output, ":: Found physical device surface capabilities.\n");
  69.             break;
  70.         case VK_ERROR_OUT_OF_HOST_MEMORY:
  71.             (void) fprintf (_Output, ";; Failed to find physical device surface capabilities, out of host memory.\n");
  72.             exit (EXIT_FAILURE);
  73.         case VK_ERROR_OUT_OF_DEVICE_MEMORY:
  74.             (void) fprintf (_Output, ";; Failed to find physical device surface capabilities, out of device memory.\n");
  75.             exit (EXIT_FAILURE);
  76.         case VK_ERROR_SURFACE_LOST_KHR:
  77.             (void) fprintf (_Output, ";; Failed to find physical device surface capabilities, surface lost.\n");
  78.             exit (EXIT_FAILURE);
  79.         default:
  80.             (void) fprintf (_Output, ";; Unrecognized return value while finding physical device surface capabilities.\n");
  81.             exit (EXIT_FAILURE);
  82.     }
  83.  
  84.     if ((unsigned int) Surface -> Capabilities. minImageCount <= _Swapchain_Images)
  85.     {
  86.         Swapchain -> Image_Count = _Swapchain_Images;
  87.     }
  88.     else
  89.     {
  90.         Swapchain -> Image_Count = (unsigned int) Surface -> Capabilities. minImageCount;
  91.     }
  92.  
  93.     (void) fprintf (_Output, "   Selected %u images for swapchain image count.\n", Swapchain -> Image_Count);
  94.  
  95.     if (Surface -> Capabilities. currentExtent. width == 0xFFFFFFFF)
  96.     {
  97.         Swapchain -> Extent. width  = Window -> Width;
  98.         Swapchain -> Extent. height = Window -> Height;
  99.         if (Swapchain -> Extent. width  < Surface -> Capabilities. minImageExtent. width)
  100.         {
  101.              Swapchain -> Extent. width  = Surface -> Capabilities. minImageExtent. width;
  102.         }
  103.         if (Swapchain -> Extent. width  > Surface -> Capabilities. maxImageExtent. width)
  104.         {
  105.              Swapchain -> Extent. width  = Surface -> Capabilities. maxImageExtent. width;
  106.         }
  107.         if (Swapchain -> Extent. height < Surface -> Capabilities. minImageExtent. height)
  108.         {
  109.              Swapchain -> Extent. height = Surface -> Capabilities. minImageExtent. height;
  110.         }
  111.         if (Swapchain -> Extent. height > Surface -> Capabilities. maxImageExtent. height)
  112.         {
  113.             Swapchain -> Extent. height = Surface -> Capabilities. maxImageExtent. height;
  114.         }
  115.     }
  116.     else
  117.     {
  118.         Swapchain -> Extent = Surface -> Capabilities. currentExtent;
  119.     }
  120.  
  121. /*                               ******************************************************                               */
  122.  
  123.     (void) vkGetPhysicalDeviceSurfaceFormatsKHR (Physical -> Device, Surface -> Data, & Surface -> Format_Count, NULL);
  124.  
  125.     if (Surface -> Format_Count == 0)
  126.     {
  127.         (void) fprintf (_Output, ";; No surface formats found.\n");
  128.         exit (EXIT_FAILURE);
  129.     }
  130.  
  131.     switch (vkGetPhysicalDeviceSurfaceFormatsKHR (Physical -> Device, Surface -> Data, & Surface -> Format_Count, Surface -> Formats))
  132.     {
  133.         case VK_SUCCESS:
  134.             (void) fprintf (_Output, ":: Found physical device surface formats.\n");
  135.             break;
  136.         case VK_INCOMPLETE:
  137.             (void) fprintf (_Output, ":: Incompletely found physical device surface formats.\n");
  138.             break;
  139.         case VK_ERROR_OUT_OF_HOST_MEMORY:
  140.             (void) fprintf (_Output, ";; Failed to find physical device surface formats, out of host memory.\n");
  141.             exit (EXIT_FAILURE);
  142.         case VK_ERROR_OUT_OF_DEVICE_MEMORY:
  143.             (void) fprintf (_Output, ";; Failed to find physical device surface formats, out of device memory.\n");
  144.             exit (EXIT_FAILURE);
  145.         case VK_ERROR_SURFACE_LOST_KHR:
  146.             (void) fprintf (_Output, ";; Failed to find physical device surface formats, surface lost.\n");
  147.             exit (EXIT_FAILURE);
  148.         default:
  149.             (void) fprintf (_Output, ";; Unrecognized return value while finding physical device surface formats.\n");
  150.             exit (EXIT_FAILURE);
  151.     }
  152.  
  153.     if ((Surface -> Format_Count == 1) && (Surface -> Formats [0]. format == VK_FORMAT_UNDEFINED))
  154.     {
  155.         Surface -> Format                                  = VK_FORMAT_B8G8R8A8_UNORM;
  156.         Surface -> Format_Index [VK_FORMAT_UNDEFINED]      = (unsigned int) 1;
  157.         Surface -> Format_Index [VK_FORMAT_B8G8R8A8_UNORM] = (unsigned int) 1;
  158.     }
  159.     else
  160.     {
  161.         Surface -> Format                                        = Surface -> Formats [0]. format;
  162.         Surface -> Format_Index [Surface -> Formats [0]. format] = (unsigned int) 1;
  163.     }
  164.  
  165. /*                               ******************************************************                               */
  166.  
  167.     (void) fprintf (_Output, "   Available formats: %u\n", Surface -> Format_Count);
  168.  
  169.     while (Counter_I != Surface -> Format_Count)
  170.     {
  171.         Indicator = (Surface -> Format_Index [Surface -> Formats [Counter_I]. format] != (unsigned int) 0) ? '+' : '-';
  172.         switch (Surface -> Formats [Counter_I]. format)
  173.         {
  174.             case VK_FORMAT_UNDEFINED:
  175.                 (void) fprintf (_Output, "      [%c] Undefined\n", Indicator);
  176.                 break;
  177.             case VK_FORMAT_R4G4_UNORM_PACK8:
  178.                 (void) fprintf (_Output, "      [%c] R4G4 unsigned normalized 8\n", Indicator);
  179.                 break;
  180.             case VK_FORMAT_R4G4B4A4_UNORM_PACK16:
  181.                 (void) fprintf (_Output, "      [%c] R4G4B4A4 unsigned normalized 16\n", Indicator);
  182.                 break;
  183.             case VK_FORMAT_B4G4R4A4_UNORM_PACK16:
  184.                 (void) fprintf (_Output, "      [%c] B4G4R4A4 unsigned normalized 16\n", Indicator);
  185.                 break;
  186.             case VK_FORMAT_R5G6B5_UNORM_PACK16:
  187.                 (void) fprintf (_Output, "      [%c] R5G6B5 unsigned normalized 16\n", Indicator);
  188.                 break;
  189.             case VK_FORMAT_B5G6R5_UNORM_PACK16:
  190.                 (void) fprintf (_Output, "      [%c] B5G6R5 unsigned normalized 16\n", Indicator);
  191.                 break;
  192.             case VK_FORMAT_R5G5B5A1_UNORM_PACK16:
  193.                 (void) fprintf (_Output, "      [%c] R5G5B5A1 unsigned normalized 16\n", Indicator);
  194.                 break;
  195.             case VK_FORMAT_B5G5R5A1_UNORM_PACK16:
  196.                 (void) fprintf (_Output, "      [%c] B5G5R5A1 unsigned normalized 16\n", Indicator);
  197.                 break;
  198.             case VK_FORMAT_A1R5G5B5_UNORM_PACK16:
  199.                 (void) fprintf (_Output, "      [%c] A1R5G5B5 unsigned normalized 16\n", Indicator);
  200.                 break;
  201.             case VK_FORMAT_R8_UNORM:
  202.                 (void) fprintf (_Output, "      [%c] R8 unsigned normalized\n", Indicator);
  203.                 break;
  204.             case VK_FORMAT_R8_SNORM:
  205.                 (void) fprintf (_Output, "      [%c] R8 signed normalized\n", Indicator);
  206.                 break;
  207.             case VK_FORMAT_R8_USCALED:
  208.                 (void) fprintf (_Output, "      [%c] R8 unsigned scaled integer\n", Indicator);
  209.                 break;
  210.             case VK_FORMAT_R8_SSCALED:
  211.                 (void) fprintf (_Output, "      [%c] R8 signed scaled integer\n", Indicator);
  212.                 break;
  213.             case VK_FORMAT_R8_UINT:
  214.                 (void) fprintf (_Output, "      [%c] R8 unsigned integer\n", Indicator);
  215.                 break;
  216.             case VK_FORMAT_R8_SINT:
  217.                 (void) fprintf (_Output, "      [%c] R8 signed integer\n", Indicator);
  218.                 break;
  219.             case VK_FORMAT_R8_SRGB:
  220.                 (void) fprintf (_Output, "      [%c] R8 sRGB non-linear\n", Indicator);
  221.                 break;
  222.             case VK_FORMAT_R8G8_UNORM:
  223.                 (void) fprintf (_Output, "      [%c] R8G8 unsigned normalized\n", Indicator);
  224.                 break;
  225.             case VK_FORMAT_R8G8_SNORM:
  226.                 (void) fprintf (_Output, "      [%c] R8G8 signed normalized\n", Indicator);
  227.                 break;
  228.             case VK_FORMAT_R8G8_USCALED:
  229.                 (void) fprintf (_Output, "      [%c] R8G8 unsigned scaled integer\n", Indicator);
  230.                 break;
  231.             case VK_FORMAT_R8G8_SSCALED:
  232.                 (void) fprintf (_Output, "      [%c] R8G8 signed scaled integer\n", Indicator);
  233.                 break;
  234.             case VK_FORMAT_R8G8_UINT:
  235.                 (void) fprintf (_Output, "      [%c] R8G8 unsigned integer\n", Indicator);
  236.                 break;
  237.             case VK_FORMAT_R8G8_SINT:
  238.                 (void) fprintf (_Output, "      [%c] R8G8 signed integer\n", Indicator);
  239.                 break;
  240.             case VK_FORMAT_R8G8_SRGB:
  241.                 (void) fprintf (_Output, "      [%c] R8G8 sRGB non-linear\n", Indicator);
  242.                 break;
  243.             case VK_FORMAT_R8G8B8_UNORM:
  244.                 (void) fprintf (_Output, "      [%c] R8G8B8 unsigned normalized\n", Indicator);
  245.                 break;
  246.             case VK_FORMAT_R8G8B8_SNORM:
  247.                 (void) fprintf (_Output, "      [%c] R8G8B8 signed normalized\n", Indicator);
  248.                 break;
  249.             case VK_FORMAT_R8G8B8_USCALED:
  250.                 (void) fprintf (_Output, "      [%c] R8G8B8 unsigned scaled integer\n", Indicator);
  251.                 break;
  252.             case VK_FORMAT_R8G8B8_SSCALED:
  253.                 (void) fprintf (_Output, "      [%c] R8G8B8 signed scaled integer\n", Indicator);
  254.                 break;
  255.             case VK_FORMAT_R8G8B8_UINT:
  256.                 (void) fprintf (_Output, "      [%c] R8G8B8 unsigned integer\n", Indicator);
  257.                 break;
  258.             case VK_FORMAT_R8G8B8_SINT:
  259.                 (void) fprintf (_Output, "      [%c] R8G8B8 signed integer\n", Indicator);
  260.                 break;
  261.             case VK_FORMAT_R8G8B8_SRGB:
  262.                 (void) fprintf (_Output, "      [%c] R8G8B8 sRGB non-linear\n", Indicator);
  263.                 break;
  264.             case VK_FORMAT_B8G8R8_UNORM:
  265.                 (void) fprintf (_Output, "      [%c] B8G8R8 unsigned normalized\n", Indicator);
  266.                 break;
  267.             case VK_FORMAT_B8G8R8_SNORM:
  268.                 (void) fprintf (_Output, "      [%c] B8G8R8 signed normalized\n", Indicator);
  269.                 break;
  270.             case VK_FORMAT_B8G8R8_USCALED:
  271.                 (void) fprintf (_Output, "      [%c] B8G8R8 unsigned scaled integer\n", Indicator);
  272.                 break;
  273.             case VK_FORMAT_B8G8R8_SSCALED:
  274.                 (void) fprintf (_Output, "      [%c] B8G8R8 signed scaled integer\n", Indicator);
  275.                 break;
  276.             case VK_FORMAT_B8G8R8_UINT:
  277.                 (void) fprintf (_Output, "      [%c] B8G8R8 unsigned integer\n", Indicator);
  278.                 break;
  279.             case VK_FORMAT_B8G8R8_SINT:
  280.                 (void) fprintf (_Output, "      [%c] B8G8R8 signed integer\n", Indicator);
  281.                 break;
  282.             case VK_FORMAT_B8G8R8_SRGB:
  283.                 (void) fprintf (_Output, "      [%c] B8G8R8 sRGB non-linear\n", Indicator);
  284.                 break;
  285.             case VK_FORMAT_R8G8B8A8_UNORM:
  286.                 (void) fprintf (_Output, "      [%c] R8G8B8A8 unsigned normalized\n", Indicator);
  287.                 break;
  288.             case VK_FORMAT_R8G8B8A8_SNORM:
  289.                 (void) fprintf (_Output, "      [%c] R8G8B8A8 signed normalized\n", Indicator);
  290.                 break;
  291.             case VK_FORMAT_R8G8B8A8_USCALED:
  292.                 (void) fprintf (_Output, "      [%c] R8G8B8A8 unsigned scaled integer\n", Indicator);
  293.                 break;
  294.             case VK_FORMAT_R8G8B8A8_SSCALED:
  295.                 (void) fprintf (_Output, "      [%c] R8G8B8A8 signed scaled integer\n", Indicator);
  296.                 break;
  297.             case VK_FORMAT_R8G8B8A8_UINT:
  298.                 (void) fprintf (_Output, "      [%c] R8G8B8A8 unsigned integer\n", Indicator);
  299.                 break;
  300.             case VK_FORMAT_R8G8B8A8_SINT:
  301.                 (void) fprintf (_Output, "      [%c] R8G8B8A8 signed integer\n", Indicator);
  302.                 break;
  303.             case VK_FORMAT_R8G8B8A8_SRGB:
  304.                 (void) fprintf (_Output, "      [%c] R8G8B8A8 sRGB non-linear\n", Indicator);
  305.                 break;
  306.             case VK_FORMAT_B8G8R8A8_UNORM:
  307.                 (void) fprintf (_Output, "      [%c] B8G8R8A8 unsigned normalized\n", Indicator);
  308.                 break;
  309.             case VK_FORMAT_B8G8R8A8_SNORM:
  310.                 (void) fprintf (_Output, "      [%c] B8G8R8A8 signed normalized\n", Indicator);
  311.                 break;
  312.             case VK_FORMAT_B8G8R8A8_USCALED:
  313.                 (void) fprintf (_Output, "      [%c] B8G8R8A8 unsigned scaled integer\n", Indicator);
  314.                 break;
  315.             case VK_FORMAT_B8G8R8A8_SSCALED:
  316.                 (void) fprintf (_Output, "      [%c] B8G8R8A8 signed scaled integer\n", Indicator);
  317.                 break;
  318.             case VK_FORMAT_B8G8R8A8_UINT:
  319.                 (void) fprintf (_Output, "      [%c] B8G8R8A8 unsigned integer\n", Indicator);
  320.                 break;
  321.             case VK_FORMAT_B8G8R8A8_SINT:
  322.                 (void) fprintf (_Output, "      [%c] B8G8R8A8 signed integer\n", Indicator);
  323.                 break;
  324.             case VK_FORMAT_B8G8R8A8_SRGB:
  325.                 (void) fprintf (_Output, "      [%c] B8G8R8A8 sRGB non-linear\n", Indicator);
  326.                 break;
  327.             case VK_FORMAT_A8B8G8R8_UNORM_PACK32:
  328.                 (void) fprintf (_Output, "      [%c] A8B8G8R8 unsigned normalized 32\n", Indicator);
  329.                 break;
  330.             case VK_FORMAT_A8B8G8R8_SNORM_PACK32:
  331.                 (void) fprintf (_Output, "      [%c] A8B8G8R8 signed normalized 32\n", Indicator);
  332.                 break;
  333.             case VK_FORMAT_A8B8G8R8_USCALED_PACK32:
  334.                 (void) fprintf (_Output, "      [%c] A8B8G8R8 unsigned scaled integer 32\n", Indicator);
  335.                 break;
  336.             case VK_FORMAT_A8B8G8R8_SSCALED_PACK32:
  337.                 (void) fprintf (_Output, "      [%c] A8B8G8R8 signed scaled integer 32\n", Indicator);
  338.                 break;
  339.             case VK_FORMAT_A8B8G8R8_UINT_PACK32:
  340.                 (void) fprintf (_Output, "      [%c] A8B8G8R8 unsigned integer 32\n", Indicator);
  341.                 break;
  342.             case VK_FORMAT_A8B8G8R8_SINT_PACK32:
  343.                 (void) fprintf (_Output, "      [%c] A8B8G8R8 signed integer 32\n", Indicator);
  344.                 break;
  345.             case VK_FORMAT_A8B8G8R8_SRGB_PACK32:
  346.                 (void) fprintf (_Output, "      [%c] A8B8G8R8 sRGB non-linear 32\n", Indicator);
  347.                 break;
  348.             case VK_FORMAT_A2R10G10B10_UNORM_PACK32:
  349.                 (void) fprintf (_Output, "      [%c] A2R10G10B10 unsigned normalized 32\n", Indicator);
  350.                 break;
  351.             case VK_FORMAT_A2R10G10B10_SNORM_PACK32:
  352.                 (void) fprintf (_Output, "      [%c] A2R10G10B10 signed normalized 32\n", Indicator);
  353.                 break;
  354.             case VK_FORMAT_A2R10G10B10_USCALED_PACK32:
  355.                 (void) fprintf (_Output, "      [%c] A2R10G10B10 unsigned scaled integer 32\n", Indicator);
  356.                 break;
  357.             case VK_FORMAT_A2R10G10B10_SSCALED_PACK32:
  358.                 (void) fprintf (_Output, "      [%c] A2R10G10B10 signed scaled integer 32\n", Indicator);
  359.                 break;
  360.             case VK_FORMAT_A2R10G10B10_UINT_PACK32:
  361.                 (void) fprintf (_Output, "      [%c] A2R10G10B10 unsigned integer 32\n", Indicator);
  362.                 break;
  363.             case VK_FORMAT_A2R10G10B10_SINT_PACK32:
  364.                 (void) fprintf (_Output, "      [%c] A2R10G10B10 signed integer 32\n", Indicator);
  365.                 break;
  366.             case VK_FORMAT_A2B10G10R10_UNORM_PACK32:
  367.                 (void) fprintf (_Output, "      [%c] A2B10G10R10 unsigned normalized 32\n", Indicator);
  368.                 break;
  369.             case VK_FORMAT_A2B10G10R10_SNORM_PACK32:
  370.                 (void) fprintf (_Output, "      [%c] A2B10G10R10 signed normalized 32\n", Indicator);
  371.                 break;
  372.             case VK_FORMAT_A2B10G10R10_USCALED_PACK32:
  373.                 (void) fprintf (_Output, "      [%c] A2B10G10R10 unsigned scaled integer 32\n", Indicator);
  374.                 break;
  375.             case VK_FORMAT_A2B10G10R10_SSCALED_PACK32:
  376.                 (void) fprintf (_Output, "      [%c] A2B10G10R10 signed scaled integer 32\n", Indicator);
  377.                 break;
  378.             case VK_FORMAT_A2B10G10R10_UINT_PACK32:
  379.                 (void) fprintf (_Output, "      [%c] A2B10G10R10 unsigned integer 32\n", Indicator);
  380.                 break;
  381.             case VK_FORMAT_A2B10G10R10_SINT_PACK32:
  382.                 (void) fprintf (_Output, "      [%c] A2B10G10R10 signed integer 32\n", Indicator);
  383.                 break;
  384.             case VK_FORMAT_R16_UNORM:
  385.                 (void) fprintf (_Output, "      [%c] R16 unsigned normalized\n", Indicator);
  386.                 break;
  387.             case VK_FORMAT_R16_SNORM:
  388.                 (void) fprintf (_Output, "      [%c] R16 signed normalized\n", Indicator);
  389.                 break;
  390.             case VK_FORMAT_R16_USCALED:
  391.                 (void) fprintf (_Output, "      [%c] R16 unsigned scaled integer\n", Indicator);
  392.                 break;
  393.             case VK_FORMAT_R16_SSCALED:
  394.                 (void) fprintf (_Output, "      [%c] R16 signed scaled integer\n", Indicator);
  395.                 break;
  396.             case VK_FORMAT_R16_UINT:
  397.                 (void) fprintf (_Output, "      [%c] R16 unsigned integer\n", Indicator);
  398.                 break;
  399.             case VK_FORMAT_R16_SINT:
  400.                 (void) fprintf (_Output, "      [%c] R16 signed integer\n", Indicator);
  401.                 break;
  402.             case VK_FORMAT_R16_SFLOAT:
  403.                 (void) fprintf (_Output, "      [%c] R16 signed float\n", Indicator);
  404.                 break;
  405.             case VK_FORMAT_R16G16_UNORM:
  406.                 (void) fprintf (_Output, "      [%c] R16G16 unsigned normalized\n", Indicator);
  407.                 break;
  408.             case VK_FORMAT_R16G16_SNORM:
  409.                 (void) fprintf (_Output, "      [%c] R16G16 signed normalized\n", Indicator);
  410.                 break;
  411.             case VK_FORMAT_R16G16_USCALED:
  412.                 (void) fprintf (_Output, "      [%c] R16G16 unsigned scaled integer\n", Indicator);
  413.                 break;
  414.             case VK_FORMAT_R16G16_SSCALED:
  415.                 (void) fprintf (_Output, "      [%c] R16G16 signed scaled integer\n", Indicator);
  416.                 break;
  417.             case VK_FORMAT_R16G16_UINT:
  418.                 (void) fprintf (_Output, "      [%c] R16G16 unsigned integer\n", Indicator);
  419.                 break;
  420.             case VK_FORMAT_R16G16_SINT:
  421.                 (void) fprintf (_Output, "      [%c] R16G16 signed integer\n", Indicator);
  422.                 break;
  423.             case VK_FORMAT_R16G16_SFLOAT:
  424.                 (void) fprintf (_Output, "      [%c] R16G16 signed float\n", Indicator);
  425.                 break;
  426.             case VK_FORMAT_R16G16B16_UNORM:
  427.                 (void) fprintf (_Output, "      [%c] R16G16B16 unsigned normalized\n", Indicator);
  428.                 break;
  429.             case VK_FORMAT_R16G16B16_SNORM:
  430.                 (void) fprintf (_Output, "      [%c] R16G16B16 signed normalized\n", Indicator);
  431.                 break;
  432.             case VK_FORMAT_R16G16B16_USCALED:
  433.                 (void) fprintf (_Output, "      [%c] R16G16B16 unsigned scaled integer\n", Indicator);
  434.                 break;
  435.             case VK_FORMAT_R16G16B16_SSCALED:
  436.                 (void) fprintf (_Output, "      [%c] R16G16B16 signed scaled integer\n", Indicator);
  437.                 break;
  438.             case VK_FORMAT_R16G16B16_UINT:
  439.                 (void) fprintf (_Output, "      [%c] R16G16B16 unsigned integer\n", Indicator);
  440.                 break;
  441.             case VK_FORMAT_R16G16B16_SINT:
  442.                 (void) fprintf (_Output, "      [%c] R16G16B16 signed integer\n", Indicator);
  443.                 break;
  444.             case VK_FORMAT_R16G16B16_SFLOAT:
  445.                 (void) fprintf (_Output, "      [%c] R16G16B16 signed float\n", Indicator);
  446.                 break;
  447.             case VK_FORMAT_R16G16B16A16_UNORM:
  448.                 (void) fprintf (_Output, "      [%c] R16G16B16A16 unsigned normalized\n", Indicator);
  449.                 break;
  450.             case VK_FORMAT_R16G16B16A16_SNORM:
  451.                 (void) fprintf (_Output, "      [%c] R16G16B16A16 signed normalized\n", Indicator);
  452.                 break;
  453.             case VK_FORMAT_R16G16B16A16_USCALED:
  454.                 (void) fprintf (_Output, "      [%c] R16G16B16A16 unsigned scaled integer\n", Indicator);
  455.                 break;
  456.             case VK_FORMAT_R16G16B16A16_SSCALED:
  457.                 (void) fprintf (_Output, "      [%c] R16G16B16A16 signed scaled integer\n", Indicator);
  458.                 break;
  459.             case VK_FORMAT_R16G16B16A16_UINT:
  460.                 (void) fprintf (_Output, "      [%c] R16G16B16A16 unsigned integer\n", Indicator);
  461.                 break;
  462.             case VK_FORMAT_R16G16B16A16_SINT:
  463.                 (void) fprintf (_Output, "      [%c] R16G16B16A16 signed integer\n", Indicator);
  464.                 break;
  465.             case VK_FORMAT_R16G16B16A16_SFLOAT:
  466.                 (void) fprintf (_Output, "      [%c] R16G16B16A16 signed float\n", Indicator);
  467.                 break;
  468.             case VK_FORMAT_R32_UINT:
  469.                 (void) fprintf (_Output, "      [%c] R32 unsigned integer\n", Indicator);
  470.                 break;
  471.             case VK_FORMAT_R32_SINT:
  472.                 (void) fprintf (_Output, "      [%c] R32 signed integer\n", Indicator);
  473.                 break;
  474.             case VK_FORMAT_R32_SFLOAT:
  475.                 (void) fprintf (_Output, "      [%c] R32 signed float\n", Indicator);
  476.                 break;
  477.             case VK_FORMAT_R32G32_UINT:
  478.                 (void) fprintf (_Output, "      [%c] R32G32 unsigned integer\n", Indicator);
  479.                 break;
  480.             case VK_FORMAT_R32G32_SINT:
  481.                 (void) fprintf (_Output, "      [%c] R32G32 signed integer\n", Indicator);
  482.                 break;
  483.             case VK_FORMAT_R32G32_SFLOAT:
  484.                 (void) fprintf (_Output, "      [%c] R32G32 signed float\n", Indicator);
  485.                 break;
  486.             case VK_FORMAT_R32G32B32_UINT:
  487.                 (void) fprintf (_Output, "      [%c] R32G32B32 unsigned integer\n", Indicator);
  488.                 break;
  489.             case VK_FORMAT_R32G32B32_SINT:
  490.                 (void) fprintf (_Output, "      [%c] R32G32B32 signed integer\n", Indicator);
  491.                 break;
  492.             case VK_FORMAT_R32G32B32_SFLOAT:
  493.                 (void) fprintf (_Output, "      [%c] R32G32B32 signed float\n", Indicator);
  494.                 break;
  495.             case VK_FORMAT_R32G32B32A32_UINT:
  496.                 (void) fprintf (_Output, "      [%c] R32G32B32A32 unsigned integer\n", Indicator);
  497.                 break;
  498.             case VK_FORMAT_R32G32B32A32_SINT:
  499.                 (void) fprintf (_Output, "      [%c] R32G32B32A32 signed integer\n", Indicator);
  500.                 break;
  501.             case VK_FORMAT_R32G32B32A32_SFLOAT:
  502.                 (void) fprintf (_Output, "      [%c] R32G32B32A32 signed float\n", Indicator);
  503.                 break;
  504.             case VK_FORMAT_R64_UINT:
  505.                 (void) fprintf (_Output, "      [%c] R64 unsigned integer\n", Indicator);
  506.                 break;
  507.             case VK_FORMAT_R64_SINT:
  508.                 (void) fprintf (_Output, "      [%c] R64 signed integer\n", Indicator);
  509.                 break;
  510.             case VK_FORMAT_R64_SFLOAT:
  511.                 (void) fprintf (_Output, "      [%c] R64 signed float\n", Indicator);
  512.                 break;
  513.             case VK_FORMAT_R64G64_UINT:
  514.                 (void) fprintf (_Output, "      [%c] R64G64 unsigned integer\n", Indicator);
  515.                 break;
  516.             case VK_FORMAT_R64G64_SINT:
  517.                 (void) fprintf (_Output, "      [%c] R64G64 signed integer\n", Indicator);
  518.                 break;
  519.             case VK_FORMAT_R64G64_SFLOAT:
  520.                 (void) fprintf (_Output, "      [%c] R64G64 signed float\n", Indicator);
  521.                 break;
  522.             case VK_FORMAT_R64G64B64_UINT:
  523.                 (void) fprintf (_Output, "      [%c] R64G64B64 unsigned integer\n", Indicator);
  524.                 break;
  525.             case VK_FORMAT_R64G64B64_SINT:
  526.                 (void) fprintf (_Output, "      [%c] R64G64B64 signed integer\n", Indicator);
  527.                 break;
  528.             case VK_FORMAT_R64G64B64_SFLOAT:
  529.                 (void) fprintf (_Output, "      [%c] R64G64B64 signed float\n", Indicator);
  530.                 break;
  531.             case VK_FORMAT_R64G64B64A64_UINT:
  532.                 (void) fprintf (_Output, "      [%c] R64G64B64A64 unsigned integer\n", Indicator);
  533.                 break;
  534.             case VK_FORMAT_R64G64B64A64_SINT:
  535.                 (void) fprintf (_Output, "      [%c] R64G64B64A64 signed integer\n", Indicator);
  536.                 break;
  537.             case VK_FORMAT_R64G64B64A64_SFLOAT:
  538.                 (void) fprintf (_Output, "      [%c] R64G64B64A64 signed float\n", Indicator);
  539.                 break;
  540.             case VK_FORMAT_B10G11R11_UFLOAT_PACK32:
  541.                 (void) fprintf (_Output, "      [%c] B10G11R11 unsigned float 32\n", Indicator);
  542.                 break;
  543.             case VK_FORMAT_E5B9G9R9_UFLOAT_PACK32:
  544.                 (void) fprintf (_Output, "      [%c] E5B9G9R9 unsigned float 32\n", Indicator);
  545.                 break;
  546.             case VK_FORMAT_D16_UNORM:
  547.                 (void) fprintf (_Output, "      [%c] D16 unsigned normalized\n", Indicator);
  548.                 break;
  549.             case VK_FORMAT_X8_D24_UNORM_PACK32:
  550.                 (void) fprintf (_Output, "      [%c] Unused 8 / D24 unsigned normalized 32\n", Indicator);
  551.                 break;
  552.             case VK_FORMAT_D32_SFLOAT:
  553.                 (void) fprintf (_Output, "      [%c] D32 signed float 32\n", Indicator);
  554.                 break;
  555.             case VK_FORMAT_S8_UINT:
  556.                 (void) fprintf (_Output, "      [%c] S8 unsigned integer\n", Indicator);
  557.                 break;
  558.             case VK_FORMAT_D16_UNORM_S8_UINT:
  559.                 (void) fprintf (_Output, "      [%c] D16 unsigned normalized / S8 unsigned integer\n", Indicator);
  560.                 break;
  561.             case VK_FORMAT_D24_UNORM_S8_UINT:
  562.                 (void) fprintf (_Output, "      [%c] D24 unsigned normalized / S8 unsigned integer\n", Indicator);
  563.                 break;
  564.             case VK_FORMAT_D32_SFLOAT_S8_UINT:
  565.                 (void) fprintf (_Output, "      [%c] D32 signed float / S8 unsigned integer\n", Indicator);
  566.                 break;
  567.             case VK_FORMAT_BC1_RGB_UNORM_BLOCK:
  568.                 (void) fprintf (_Output, "      [%c] BC1 RGB unsigned normalized\n", Indicator);
  569.                 break;
  570.             case VK_FORMAT_BC1_RGB_SRGB_BLOCK:
  571.                 (void) fprintf (_Output, "      [%c] BC1 RGB sRGB non-linear\n", Indicator);
  572.                 break;
  573.             case VK_FORMAT_BC1_RGBA_UNORM_BLOCK:
  574.                 (void) fprintf (_Output, "      [%c] BC1 RGBA unsigned normalized\n", Indicator);
  575.                 break;
  576.             case VK_FORMAT_BC1_RGBA_SRGB_BLOCK:
  577.                 (void) fprintf (_Output, "      [%c] BC1 RGBA sRGB non-linear\n", Indicator);
  578.                 break;
  579.             case VK_FORMAT_BC2_UNORM_BLOCK:
  580.                 (void) fprintf (_Output, "      [%c] BC2 unsigned normalized\n", Indicator);
  581.                 break;
  582.             case VK_FORMAT_BC2_SRGB_BLOCK:
  583.                 (void) fprintf (_Output, "      [%c] BC2 sRGB non-linear\n", Indicator);
  584.                 break;
  585.             case VK_FORMAT_BC3_UNORM_BLOCK:
  586.                 (void) fprintf (_Output, "      [%c] BC3 unsigned normalized\n", Indicator);
  587.                 break;
  588.             case VK_FORMAT_BC3_SRGB_BLOCK:
  589.                 (void) fprintf (_Output, "      [%c] BC3 sRGB non-linear\n", Indicator);
  590.                 break;
  591.             case VK_FORMAT_BC4_UNORM_BLOCK:
  592.                 (void) fprintf (_Output, "      [%c] BC4 unsigned normalized\n", Indicator);
  593.                 break;
  594.             case VK_FORMAT_BC4_SNORM_BLOCK:
  595.                 (void) fprintf (_Output, "      [%c] BC4 signed normalized\n", Indicator);
  596.                 break;
  597.             case VK_FORMAT_BC5_UNORM_BLOCK:
  598.                 (void) fprintf (_Output, "      [%c] BC5 unsigned normalized\n", Indicator);
  599.                 break;
  600.             case VK_FORMAT_BC5_SNORM_BLOCK:
  601.                 (void) fprintf (_Output, "      [%c] BC5 signed normalized\n", Indicator);
  602.                 break;
  603.             case VK_FORMAT_BC6H_UFLOAT_BLOCK:
  604.                 (void) fprintf (_Output, "      [%c] BC6H unsigned float\n", Indicator);
  605.                 break;
  606.             case VK_FORMAT_BC6H_SFLOAT_BLOCK:
  607.                 (void) fprintf (_Output, "      [%c] BC6H signed float\n", Indicator);
  608.                 break;
  609.             case VK_FORMAT_BC7_UNORM_BLOCK:
  610.                 (void) fprintf (_Output, "      [%c] BC7 unsigned normalized\n", Indicator);
  611.                 break;
  612.             case VK_FORMAT_BC7_SRGB_BLOCK:
  613.                 (void) fprintf (_Output, "      [%c] BC7 sRGB non-linear\n", Indicator);
  614.                 break;
  615.             case VK_FORMAT_ETC2_R8G8B8_UNORM_BLOCK:
  616.                 (void) fprintf (_Output, "      [%c] ETC2 R8G8B8 unsigned normalized\n", Indicator);
  617.                 break;
  618.             case VK_FORMAT_ETC2_R8G8B8_SRGB_BLOCK:
  619.                 (void) fprintf (_Output, "      [%c] ETC R8G8B82 sRGB non-linear\n", Indicator);
  620.                 break;
  621.             case VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK:
  622.                 (void) fprintf (_Output, "      [%c] ETC2 R8G8B8A1 unsigned normalized\n", Indicator);
  623.                 break;
  624.             case VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK:
  625.                 (void) fprintf (_Output, "      [%c] ETC2 R8G8B8A1 sRGB non-linear\n", Indicator);
  626.                 break;
  627.             case VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK:
  628.                 (void) fprintf (_Output, "      [%c] ETC2 R8G8B8A8 unsigned normalized\n", Indicator);
  629.                 break;
  630.             case VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK:
  631.                 (void) fprintf (_Output, "      [%c] ETC2 R8G8B8A8 sRGB non-linear\n", Indicator);
  632.                 break;
  633.             case VK_FORMAT_EAC_R11_UNORM_BLOCK:
  634.                 (void) fprintf (_Output, "      [%c] EAC R11 unsigned normalized\n", Indicator);
  635.                 break;
  636.             case VK_FORMAT_EAC_R11_SNORM_BLOCK:
  637.                 (void) fprintf (_Output, "      [%c] EAC R11 signed normalized\n", Indicator);
  638.                 break;
  639.             case VK_FORMAT_EAC_R11G11_UNORM_BLOCK:
  640.                 (void) fprintf (_Output, "      [%c] EAC R11G11 unsigned normalized\n", Indicator);
  641.                 break;
  642.             case VK_FORMAT_EAC_R11G11_SNORM_BLOCK:
  643.                 (void) fprintf (_Output, "      [%c] EAC R11G11 signed normalized\n", Indicator);
  644.                 break;
  645.             case VK_FORMAT_ASTC_4x4_UNORM_BLOCK:
  646.                 (void) fprintf (_Output, "      [%c] ASTC 4x4 unsigned normalized\n", Indicator);
  647.                 break;
  648.             case VK_FORMAT_ASTC_4x4_SRGB_BLOCK:
  649.                 (void) fprintf (_Output, "      [%c] ASTC 4x4 sRGB non-linear\n", Indicator);
  650.                 break;
  651.             case VK_FORMAT_ASTC_5x4_UNORM_BLOCK:
  652.                 (void) fprintf (_Output, "      [%c] ASTC 5x4 unsigned normalized\n", Indicator);
  653.                 break;
  654.             case VK_FORMAT_ASTC_5x4_SRGB_BLOCK:
  655.                 (void) fprintf (_Output, "      [%c] ASTC 5x4 sRGB non-linear\n", Indicator);
  656.                 break;
  657.             case VK_FORMAT_ASTC_5x5_UNORM_BLOCK:
  658.                 (void) fprintf (_Output, "      [%c] ASTC 5x5 unsigned normalized\n", Indicator);
  659.                 break;
  660.             case VK_FORMAT_ASTC_5x5_SRGB_BLOCK:
  661.                 (void) fprintf (_Output, "      [%c] ASTC 5x5 sRGB non-linear\n", Indicator);
  662.                 break;
  663.             case VK_FORMAT_ASTC_6x5_UNORM_BLOCK:
  664.                 (void) fprintf (_Output, "      [%c] ASTC 6x5 unsigned normalized\n", Indicator);
  665.                 break;
  666.             case VK_FORMAT_ASTC_6x5_SRGB_BLOCK:
  667.                 (void) fprintf (_Output, "      [%c] ASTC 6x5 sRGB non-linear\n", Indicator);
  668.                 break;
  669.             case VK_FORMAT_ASTC_6x6_UNORM_BLOCK:
  670.                 (void) fprintf (_Output, "      [%c] ASTC 6x6 unsigned normalized\n", Indicator);
  671.                 break;
  672.             case VK_FORMAT_ASTC_6x6_SRGB_BLOCK:
  673.                 (void) fprintf (_Output, "      [%c] ASTC 6x6 sRGB non-linear\n", Indicator);
  674.                 break;
  675.             case VK_FORMAT_ASTC_8x5_UNORM_BLOCK:
  676.                 (void) fprintf (_Output, "      [%c] ASTC 8x5 unsigned normalized\n", Indicator);
  677.                 break;
  678.             case VK_FORMAT_ASTC_8x5_SRGB_BLOCK:
  679.                 (void) fprintf (_Output, "      [%c] ASTC 8x5 sRGB non-linear\n", Indicator);
  680.                 break;
  681.             case VK_FORMAT_ASTC_8x6_UNORM_BLOCK:
  682.                 (void) fprintf (_Output, "      [%c] ASTC 8x6 unsigned normalized\n", Indicator);
  683.                 break;
  684.             case VK_FORMAT_ASTC_8x6_SRGB_BLOCK:
  685.                 (void) fprintf (_Output, "      [%c] ASTC 8x6 sRGB non-linear\n", Indicator);
  686.                 break;
  687.             case VK_FORMAT_ASTC_8x8_UNORM_BLOCK:
  688.                 (void) fprintf (_Output, "      [%c] ASTC 8x8 unsigned normalized\n", Indicator);
  689.                 break;
  690.             case VK_FORMAT_ASTC_8x8_SRGB_BLOCK:
  691.                 (void) fprintf (_Output, "      [%c] ASTC 8x8 sRGB non-linear\n", Indicator);
  692.                 break;
  693.             case VK_FORMAT_ASTC_10x5_UNORM_BLOCK:
  694.                 (void) fprintf (_Output, "      [%c] ASTC 10x5 unsigned normalized\n", Indicator);
  695.                 break;
  696.             case VK_FORMAT_ASTC_10x5_SRGB_BLOCK:
  697.                 (void) fprintf (_Output, "      [%c] ASTC 10x5 sRGB non-linear\n", Indicator);
  698.                 break;
  699.             case VK_FORMAT_ASTC_10x6_UNORM_BLOCK:
  700.                 (void) fprintf (_Output, "      [%c] ASTC 10x6 unsigned normalized\n", Indicator);
  701.                 break;
  702.             case VK_FORMAT_ASTC_10x6_SRGB_BLOCK:
  703.                 (void) fprintf (_Output, "      [%c] ASTC 10x6 sRGB non-linear\n", Indicator);
  704.                 break;
  705.             case VK_FORMAT_ASTC_10x8_UNORM_BLOCK:
  706.                 (void) fprintf (_Output, "      [%c] ASTC 10x8 unsigned normalized\n", Indicator);
  707.                 break;
  708.             case VK_FORMAT_ASTC_10x8_SRGB_BLOCK:
  709.                 (void) fprintf (_Output, "      [%c] ASTC 10x8 sRGB non-linear\n", Indicator);
  710.                 break;
  711.             case VK_FORMAT_ASTC_10x10_UNORM_BLOCK:
  712.                 (void) fprintf (_Output, "      [%c] ASTC 10x10 unsigned normalized\n", Indicator);
  713.                 break;
  714.             case VK_FORMAT_ASTC_10x10_SRGB_BLOCK:
  715.                 (void) fprintf (_Output, "      [%c] ASTC 10x10 sRGB non-linear\n", Indicator);
  716.                 break;
  717.             case VK_FORMAT_ASTC_12x10_UNORM_BLOCK:
  718.                 (void) fprintf (_Output, "      [%c] ASTC 12x10 unsigned normalized\n", Indicator);
  719.                 break;
  720.             case VK_FORMAT_ASTC_12x10_SRGB_BLOCK:
  721.                 (void) fprintf (_Output, "      [%c] ASTC 12x10 sRGB non-linear\n", Indicator);
  722.                 break;
  723.             case VK_FORMAT_ASTC_12x12_UNORM_BLOCK:
  724.                 (void) fprintf (_Output, "      [%c] ASTC 12x12 unsigned normalized\n", Indicator);
  725.                 break;
  726.             case VK_FORMAT_ASTC_12x12_SRGB_BLOCK:
  727.                 (void) fprintf (_Output, "      [%c] ASTC 12x12 sRGB non-linear\n", Indicator);
  728.                 break;
  729.             default:
  730.                 (void) fprintf (_Output, "      [?] Unrecognized format\n");
  731.                 break;
  732.         }
  733.         Counter_I++;
  734.     }
  735.  
  736.     Counter_I = 0;
  737.  
  738. /*                               ******************************************************                               */
  739.  
  740.     (void) vkGetPhysicalDeviceSurfacePresentModesKHR (Physical -> Device, Surface -> Data, & Surface -> Present_Mode_Count, NULL);
  741.  
  742.     if (Surface -> Present_Mode_Count == 0)
  743.     {
  744.         (void) fprintf (_Output, ";; No surface present modes found.\n");
  745.         exit (EXIT_FAILURE);
  746.     }
  747.  
  748.     switch (vkGetPhysicalDeviceSurfacePresentModesKHR (Physical -> Device, Surface -> Data, & Surface -> Present_Mode_Count, Surface -> Present_Modes))
  749.     {
  750.         case VK_SUCCESS:
  751.             (void) fprintf (_Output, ":: Found physical device surface present modes.\n");
  752.             break;
  753.         case VK_INCOMPLETE:
  754.             (void) fprintf (_Output, ":: Incompletely find physical device surface present modes.\n");
  755.             break;
  756.         case VK_ERROR_OUT_OF_HOST_MEMORY:
  757.             (void) fprintf (_Output, ";; Failed to find physical device surface present modes, out of host memory.\n");
  758.             exit (EXIT_FAILURE);
  759.         case VK_ERROR_OUT_OF_DEVICE_MEMORY:
  760.             (void) fprintf (_Output, ";; Failed to find physical device surface present modes, out of device memory.\n");
  761.             exit (EXIT_FAILURE);
  762.         case VK_ERROR_SURFACE_LOST_KHR:
  763.             (void) fprintf (_Output, ";; Failed to find physical device surface present modes, surface lost.\n");
  764.             exit (EXIT_FAILURE);
  765.         default:
  766.             (void) fprintf (_Output, ";; Unrecognized return value while finding physical device surface present modes.\n");
  767.             exit (EXIT_FAILURE);
  768.     }
  769.  
  770.     Surface -> Present_Mode                                  = VK_PRESENT_MODE_FIFO_KHR;
  771.     Surface -> Present_Mode_Index [VK_PRESENT_MODE_FIFO_KHR] = (unsigned int) 1;
  772.  
  773. /*                               ******************************************************                               */
  774.  
  775.     (void) fprintf (_Output, "   Available present modes: %u\n", Surface -> Present_Mode_Count);
  776.  
  777.     while (Counter_I != Surface -> Present_Mode_Count)
  778.     {
  779.         Indicator = (Surface -> Present_Mode_Index [Surface -> Present_Modes [Counter_I]] != (unsigned int) 0) ? '+' : '-';
  780.         switch (Surface -> Present_Modes [Counter_I])
  781.         {
  782.             case VK_PRESENT_MODE_IMMEDIATE_KHR:
  783.                 (void) fprintf (_Output, "      [%c] Immediate\n", Indicator);
  784.                 break;
  785.             case VK_PRESENT_MODE_MAILBOX_KHR:
  786.                 (void) fprintf (_Output, "      [%c] Mailbox\n", Indicator);
  787.                 break;
  788.             case VK_PRESENT_MODE_FIFO_KHR:
  789.                 (void) fprintf (_Output, "      [%c] FIFO\n", Indicator);
  790.                 break;
  791.             case VK_PRESENT_MODE_FIFO_RELAXED_KHR:
  792.                 (void) fprintf (_Output, "      [%c] FIFO relaxed\n", Indicator);
  793.                 break;
  794.             default:
  795.                 (void) fprintf (_Output, "      [?] Unrecognized format\n");
  796.                 break;
  797.         }
  798.         Counter_I++;
  799.     }
  800.  
  801.     Counter_I = 0;
  802.  
  803. /*                               ******************************************************                               */
  804.  
  805.     unsigned int Queue_Family_Indices [1] =
  806.     {
  807.         Queue -> Family_Index
  808.     };
  809.  
  810.     const VkSwapchainCreateInfoKHR Swapchain_Information =
  811.     {
  812.         .sType                 = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR,
  813.         .pNext                 = NULL,
  814.         .flags                 = 0,
  815.         .surface               = Surface -> Data,
  816.         .minImageCount         = Swapchain -> Image_Count,
  817.         .imageFormat           = Surface -> Format,
  818.         .imageColorSpace       = VK_COLORSPACE_SRGB_NONLINEAR_KHR,
  819.         .imageExtent.width     = Swapchain -> Extent. width,
  820.         .imageExtent.height    = Swapchain -> Extent. height,
  821.         .imageArrayLayers      = 1,
  822.         .imageUsage            = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
  823.         .imageSharingMode      = VK_SHARING_MODE_EXCLUSIVE,
  824.         .queueFamilyIndexCount = 1,
  825.         .pQueueFamilyIndices   = Queue_Family_Indices,
  826.         .preTransform          = Surface -> Capabilities. supportedTransforms,
  827.         .compositeAlpha        = Surface -> Capabilities. supportedCompositeAlpha,
  828.         .presentMode           = Surface -> Present_Mode,
  829.         .clipped               = VK_TRUE,
  830.         .oldSwapchain          = VK_NULL_HANDLE
  831.     };
  832.  
  833.     switch (vkCreateSwapchainKHR (Logical -> Device, & Swapchain_Information, NULL, & Swapchain -> Data))
  834.     {
  835.         case VK_SUCCESS:
  836.             (void) fprintf (_Output, ":: Created swapchain.\n");
  837.             break;
  838.         case VK_ERROR_OUT_OF_HOST_MEMORY:
  839.             (void) fprintf (_Output, ";; Failed to create swapchain, out of host memory.\n");
  840.             exit (EXIT_FAILURE);
  841.         case VK_ERROR_OUT_OF_DEVICE_MEMORY:
  842.             (void) fprintf (_Output, ";; Failed to create swapchain, out of device memory.\n");
  843.             exit (EXIT_FAILURE);
  844.         case VK_ERROR_DEVICE_LOST:
  845.             (void) fprintf (_Output, ";; Failed to create swapchain, device lost.\n");
  846.             exit (EXIT_FAILURE);
  847.         case VK_ERROR_SURFACE_LOST_KHR:
  848.             (void) fprintf (_Output, ";; Failed to create swapchain, surface lost.\n");
  849.             exit (EXIT_FAILURE);
  850.         case VK_ERROR_NATIVE_WINDOW_IN_USE_KHR:
  851.             (void) fprintf (_Output, ";; Failed to create swapchain, native window in use.\n");
  852.             exit (EXIT_FAILURE);
  853.         case VK_ERROR_INITIALIZATION_FAILED:
  854.             (void) fprintf (_Output, ";; Failed to create swapchain, initialization failed.\n");
  855.             exit (EXIT_FAILURE);
  856.         default:
  857.             (void) fprintf (_Output, ";; Unrecognized return value while creating swapchain.\n");
  858.             exit (EXIT_FAILURE);
  859.     }
  860.  
  861. /*                               ******************************************************                               */
  862.  
  863.     (void) vkGetSwapchainImagesKHR (Logical -> Device, Swapchain -> Data, & Swapchain -> Image_Count, NULL);
  864.  
  865.     VkImage Swapchain_Image_Buffer [_Swapchain_Images];
  866.  
  867.     switch (vkGetSwapchainImagesKHR (Logical -> Device, Swapchain -> Data, & Swapchain -> Image_Count, Swapchain_Image_Buffer))
  868.     {
  869.         case VK_SUCCESS:
  870.             (void) fprintf (_Output, ":: Found swapchain images.\n");
  871.             break;
  872.         case VK_INCOMPLETE:
  873.             (void) fprintf (_Output, ":: Incompletely found swapchain images.\n");
  874.             break;
  875.         case VK_ERROR_OUT_OF_HOST_MEMORY:
  876.             (void) fprintf (_Output, ";; Failed to find swapchain images, out of host memory.\n");
  877.             exit (EXIT_FAILURE);
  878.         case VK_ERROR_OUT_OF_DEVICE_MEMORY:
  879.             (void) fprintf (_Output, ";; Failed to find swapchain images, out of device memory.\n");
  880.             exit (EXIT_FAILURE);
  881.         default:
  882.             (void) fprintf (_Output, ";; Unrecognized return value while finding swapchain images.\n");
  883.             exit (EXIT_FAILURE);
  884.     }
  885.  
  886.     Counter_I = 0;
  887.  
  888.     while (Counter_I != Swapchain -> Image_Count)
  889.     {
  890.         Swapchain -> Images [Counter_I] = Swapchain_Image_Buffer [Counter_I];
  891.         Counter_I++;
  892.     }
  893.  
  894.     Counter_I = 0;
  895.  
  896. /*                               ******************************************************                               */
  897.  
  898.     while (Counter_I != Swapchain -> Image_Count)
  899.     {
  900.         const VkImageViewCreateInfo Image_View_Information =
  901.         {
  902.             . sType                            = VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
  903.             . pNext                            = NULL,
  904.             . flags                            = 0,
  905.             . image                            = Swapchain -> Images [Counter_I],
  906.             . viewType                         = VK_IMAGE_VIEW_TYPE_2D,
  907.             . format                           = Surface -> Format,
  908.             . components.       r              = VK_COMPONENT_SWIZZLE_R,
  909.             . components.       g              = VK_COMPONENT_SWIZZLE_G,
  910.             . components.       b              = VK_COMPONENT_SWIZZLE_B,
  911.             . components.       a              = VK_COMPONENT_SWIZZLE_A,
  912.             . subresourceRange. aspectMask     = VK_IMAGE_ASPECT_COLOR_BIT,
  913.             . subresourceRange. baseMipLevel   = 0,
  914.             . subresourceRange. levelCount     = 1,
  915.             . subresourceRange. baseArrayLayer = 0,
  916.             . subresourceRange. layerCount     = 1
  917.         };
  918.         switch (vkCreateImageView (Logical -> Device, & Image_View_Information, NULL, & Swapchain -> Image_Views [Counter_I]))
  919.         {
  920.             case VK_SUCCESS:
  921.                 break;
  922.             case VK_ERROR_OUT_OF_HOST_MEMORY:
  923.                 (void) fprintf (_Output, ";; Failed to create swapchain image views, out of host memory.\n");
  924.                 exit (EXIT_FAILURE);
  925.             case VK_ERROR_OUT_OF_DEVICE_MEMORY:
  926.                 (void) fprintf (_Output, ";; Failed to create swapchain image views, out of device memory.\n");
  927.                 exit (EXIT_FAILURE);
  928.             default:
  929.                 (void) fprintf (_Output, ";; Unrecognized return value while creating swapchain image views.\n");
  930.                 exit (EXIT_FAILURE);
  931.         }
  932.         Counter_I++;
  933.     }
  934.  
  935.     (void) fprintf (_Output, ":: Created swapchain image views.\n");
  936. }
  937.  
  938. /* ****************************************************************************************************************** */
  939.  
  940. extern void Delete_Swapchain
  941. (
  942.     struct Logical_Device_Data * Logical,
  943.     struct Swapchain_Data      * Swapchain
  944. )
  945. /* ****************************************************** */
  946. /*                                                        */
  947. /* Delete swapchain image views, and then swapchain.      */
  948. /*                                                        */
  949. /* ****************************************************** */
  950. {
  951.     unsigned int Counter_I = 0;
  952.  
  953. /*                               ******************************************************                               */
  954.  
  955.     while (Counter_I != Swapchain -> Image_Count)
  956.     {
  957.         vkDestroyImageView (Logical -> Device, Swapchain -> Image_Views [Counter_I], NULL);
  958.         Counter_I++;
  959.     }
  960.  
  961. /*                               ******************************************************                               */
  962.  
  963.     vkDestroySwapchainKHR (Logical -> Device, Swapchain -> Data, NULL);
  964.  
  965.     (void) fprintf (_Output, ":: Deleted swapchain image views.\n");
  966.     (void) fprintf (_Output, ":: Deleted swapchain.\n");
  967. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement