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. img标签无法显示src中名字中带有中文的图片的问题

    img: <img src="/upload/${good.photo}" style="width: 120px;height: 120px;" alt ...

  2. JVM性能调优指南

    1.JVM的参数类型 1.1 标准参数:在各jdk版本中较稳定 -help -server -client -version -showversion -cp -classpath 1.2 X参数 1 ...

  3. JAVA虚拟机:内存各个区介绍

    概述:java应用程序由java虚拟机自动管理程序执行期间内存管理. 优势:1.不再需要程序员去为使用的内存在程序中手动编写释放内存代码. 2.由虚拟机管理内存不容易出现内存泄漏和内存溢出的问题. 缺 ...

  4. gitlab实现webhook触发jenkins 自动,构建,测试,push webhook构子 总结

    最新一直在学习 工作 + 学习 去掉 90%   所以blog  一直没更 真是很不好!  exsi ceph gitlab jenkins harbor k8s  docker-compose ap ...

  5. springboot的maven多模块项目架构微服务搭建——依赖方式的多模块演化为微服务项目

    在上一篇依赖方式多模块的基础上对项目进行改造.主要改造user-service项目,service要配置mapper.mybatis及数据库相关的东西,后面的接口消费方user就不再需要了 注意:以下 ...

  6. Day6 - H - Balanced Lineup POJ - 3264

    For the daily milking, Farmer John's N cows (1 ≤ N ≤ 50,000) always line up in the same order. One d ...

  7. MapReduce On Yarn的执行流程

    1.概述 Yarn是一个资源调度平台,负责为运算程序提供服务器运算资源,相当于一个分布式的操作系统平台,而MapReduce等运算程序则相当于运行于操作系统之上的应用程序. Yarn的架构如下图所示: ...

  8. 洛谷 P3205 [HNOI2010]合唱队(区间dp)

    传送门 解题思路 观察队形的组成方式可以得出,最后一名加入区间i...j的人要么是在i位置上,要么是在j位置上,所以我们可以用dp[i][j][0]表示区间i...j最后一个加入的人站在i位置上的方案 ...

  9. 学校算法作业X——(日期问题)

    最近一直在忙项目,难得有时间写一下作业,所以断了,现在赶紧续上 题目如下: 日历问题 问题描述 在我们现在使用的日历中, 闰年被定义为能被4整除的年份,但是能被100整除而不能被400整除的年是例外, ...

  10. HDU - 1698 Just a Hook (线段树---区间修改)

    题意:n个棍子,初始值全为1,给定Q个区间,分别赋值,问n个棍子的总值. 分析:lazy标记主要体现在update上. 当l <= L && R <= r时,该结点的子结点 ...