Swapchain是一系列最终会展示给用户的图像的集合。

/*
* Set up swapchain:
* - Get supported uses for all queues
* - Try to find a queue that supports both graphics and present
* - If no queue supports both, find a present queue and make sure we have a
* graphics queue
* - Get a list of supported formats and use the first one
* - Get surface properties and present modes and use them to create a swap
* chain
* - Create swap chain buffers
* - For each buffer, create a color attachment view and set its layout to
* color attachment
*/

Vulkan and the Windowing System

1、跟其他图形API不同,vulkan 将window相关的操作和图形核心的API隔离;窗口使用对应的扩展,KHR 代表了这是一种Khronos Extension.

VK_USE_PLATFORM_ANDROID_KHR - Android
VK_USE_PLATFORM_WAYLAND_KHR - Wayland
VK_USE_PLATFORM_WIN32_KHR - Microsoft Windows
VK_USE_PLATFORM_XCB_KHR - X Window System, using the XCB library
VK_USE_PLATFORM_XLIB_KHR - X Window System, using the Xlib library

2、VkSurfaceKHR 是对原生平台设备表面或者窗口的一种抽象;

Revisiting Instance and Device Extensions

Instance Extensions

Device Extensions

1、swapchain只是一系列需要展示的图片,具体要将这些图片显示到显示器上,需要硬件进行操作,这个时候需要用到 VK_KHR_SWAPCHAIN_EXTENSION_NAME;

Queue Family and Present

1、vkQueuePresentKHR()  需要找到一个同时指出graphics和present的famaliy;

Device Surface Formats

1、 VkSurfaceFormatKHR  能获取当前显示设备指出的VkFormat;

Surface Capabilities

1、Swapchain的创建需要提供一些额外的信息,可以通过vkGetPhysicalDeviceSurfaceCapabilitiesKHR() 和 vkGetPhysicalDeviceSurfacePresentModesKHR()获取;

2、 minImageCount用来决定当前使用的是双缓冲还是三缓冲区。 双缓冲区一个render,一个present; 三缓冲区一个用来present,其他两个用来render;

Different Queue Families for Graphics and Present

1、如果graphics queue和 present queue family是不同的,需要做一些额外的工作可以让imagine在各个queue之间进行共享;

swapchain_ci.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
swapchain_ci.queueFamilyIndexCount = ;
swapchain_ci.pQueueFamilyIndices = NULL;
uint32_t queueFamilyIndices[] = {
(uint32_t)info.graphics_queue_family_index,
(uint32_t)info.present_queue_family_index};
if (info.graphics_queue_family_index != info.present_queue_family_index) {
// If the graphics and present queues are from different queue families,
// we either have to explicitly transfer ownership of images between the
// queues, or we have to create the swapchain with imageSharingMode
// as VK_SHARING_MODE_CONCURRENT
swapchain_ci.imageSharingMode = VK_SHARING_MODE_CONCURRENT;
swapchain_ci.queueFamilyIndexCount = ;
swapchain_ci.pQueueFamilyIndices = queueFamilyIndices;
}

Create Swapchain

1、vkCreateSwapchainKHR 创建了一系列的图像来组成swapchain,但在实际使用的过程中,我们需要告诉GPU当前使用的是哪个image,这个时候就用到如下的接口 vkGetSwapchainImagesKHR;通过这个接口你可以获得
一系列images的handle;

Create Image Views

1、swapchain是一系列的images,但是当我们需要使用这些image的时候,我们就需要为image创建imagin view。 “view”用来告诉vulkan如何使用这些imagin。

2、VkImageViewCreateInfo 用来创建所需的imageview;

 

Vulkan SDK之 Swapchain的更多相关文章

  1. Vulkan SDK Demo 之一 熟悉

    DiligentEngine的API是D3d11和D3D12风格的,vulkan也被封装成了这种风格的API. 在了解Diligent Engine是如何对vulkan进行封装之前,我准备先学习下Vu ...

  2. Vulkan SDK 之 Instance

    上一篇 Vulkan SDK Demo 熟悉 粗略的了解了下,一个app是如何调用vulkan的api来展示一个立方体的,但是对其中的每一个api了解并不深刻,后面的系列会根据sample的tutor ...

  3. Vulkan SDK 之 Depth Buffer

    深度缓冲是可选的,比如渲染一个3D的立方体的时候,就需要用到深度缓冲.Swapchain就算有多个images,此时深度缓冲区也只需要一个.vkCreateSwapchainKHR 会创建所有需要的i ...

  4. Vulkan SDK 之 DrawCube

    Waiting for a Swapchain Buffer Beginning the Render Pass Bind the Pipeline Bind the Descriptor Sets ...

  5. Vulkan SDK之 FrameBuffer

    The Vulkan Framebuffer Framebuffers represent a collection of memory attachments that are used by a ...

  6. Vulkan SDK 之 Shaders

    Compiling GLSL Shaders into SPIR-V 1.SPIR-V 是vulkan的底层shader语言.GLSL可以通过相关接口转换为SPIR-V. Creating Vulka ...

  7. Vulkan SDK 之Render Pass

    Create a Render Pass A render pass describes the scope of a rendering operation by specifying the co ...

  8. Vulkan SDK 之 Descriptor Set Layouts and Pipeline Layouts

    当我们有了一个uniform buff之后,vulkan 还不知道这个信息,需要通过descriptor进行描述. Descriptors and Descriptor Sets A descript ...

  9. Vulkan SDK 之 Device

     Enumerate Physical Devices Vulkan instance创建完成之后,vulkan loader是知道你有几个物理设备(显卡),但是程序不知道,需要通过 相关接口获取设备 ...

随机推荐

  1. (实例)Linux 内核添加exfat驱动

    背景: 由于exfat是常用的文件系统格式,而Linux由于版权的问题,没有在官方中添加有关的驱动. 但是 微软也同意开源了,所以比较新的 Linux 会支持这一块. 为了支持exfat的驱动,我们需 ...

  2. shell-Startup-Files

    shell-Startup-Files 1. 相关阅读 2. 主流shell 3. shell实例类型 4. Shell启动文件的必要元素 4.1 路径: 命令路径, 4.2 提示符 5. 主流she ...

  3. 最近学习总结 Nodejs express 获取url参数,post参数的三种方式

    express获取参数有三种方法:官网实例: Checks route params (req.params), ex: /user/:id Checks query string params (r ...

  4. 【C】揭秘rand()函数;

    原文地址:http://www.cnblogs.com/ngnetboy/archive/2012/11/23/2784078.html 相信只要是程序猿都会知道rand()函数是用来取随机数的一个库 ...

  5. [Codeforces]1263D Secret Passwords

    题目 One unknown hacker wants to get the admin's password of AtForces testing system, to get problems ...

  6. 019.CI4框架CodeIgniter辅助函数类之:Array数组查询

    01. 数组辅助函数,可以方便的查看数组内部的成员,用法如下图所示: <?php namespace App\Controllers; class Hello extends BaseContr ...

  7. Java 的 String.split 函数,消除空字符串

    代码: String str = "the music made it hard to concentrate"; String delims = "[ ]+" ...

  8. uniapp属性插值报错Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead.

    解决方法: 因为vue 2.x不支持对属性使用插值{{}}的方式赋值,所以要使用v-bind指令(或简写“:”)来指定属性. v-bind指令 v-bind:id="item.id" ...

  9. Golang的循环结构-for语句

    Golang的循环结构-for语句 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 一.for循环语法 循环结构在生活中的场景也非常的多,比如: ()上班族们每天朝九晚五的生活; ( ...

  10. Web系统测试的常用方法总结-18《转载》

    Web系统测试的常用方法归纳 --- 知识记录 1.页面链接检查 每一个链接是否都有对应的页面,并且页面之间切换正确.可以依靠一些工具,如:LinkBotPro.File-AIDCS.HTML Lin ...