Vulkan SDK之 Swapchain
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的更多相关文章
- Vulkan SDK Demo 之一 熟悉
DiligentEngine的API是D3d11和D3D12风格的,vulkan也被封装成了这种风格的API. 在了解Diligent Engine是如何对vulkan进行封装之前,我准备先学习下Vu ...
- Vulkan SDK 之 Instance
上一篇 Vulkan SDK Demo 熟悉 粗略的了解了下,一个app是如何调用vulkan的api来展示一个立方体的,但是对其中的每一个api了解并不深刻,后面的系列会根据sample的tutor ...
- Vulkan SDK 之 Depth Buffer
深度缓冲是可选的,比如渲染一个3D的立方体的时候,就需要用到深度缓冲.Swapchain就算有多个images,此时深度缓冲区也只需要一个.vkCreateSwapchainKHR 会创建所有需要的i ...
- Vulkan SDK 之 DrawCube
Waiting for a Swapchain Buffer Beginning the Render Pass Bind the Pipeline Bind the Descriptor Sets ...
- Vulkan SDK之 FrameBuffer
The Vulkan Framebuffer Framebuffers represent a collection of memory attachments that are used by a ...
- Vulkan SDK 之 Shaders
Compiling GLSL Shaders into SPIR-V 1.SPIR-V 是vulkan的底层shader语言.GLSL可以通过相关接口转换为SPIR-V. Creating Vulka ...
- Vulkan SDK 之Render Pass
Create a Render Pass A render pass describes the scope of a rendering operation by specifying the co ...
- Vulkan SDK 之 Descriptor Set Layouts and Pipeline Layouts
当我们有了一个uniform buff之后,vulkan 还不知道这个信息,需要通过descriptor进行描述. Descriptors and Descriptor Sets A descript ...
- Vulkan SDK 之 Device
Enumerate Physical Devices Vulkan instance创建完成之后,vulkan loader是知道你有几个物理设备(显卡),但是程序不知道,需要通过 相关接口获取设备 ...
随机推荐
- css常用设置
距离左边和上边 style="margin-left:100px;margin-top:10px" 设置相对位置 position:absolute; position:relat ...
- zookeeper加Kafka集群配置
官方 https://zookeeper.apache.org/doc/r3.5.6/zookeeperStarted.html#sc_Prerequisites https://www.cnblog ...
- sklearn中实现多分类任务(OVR和OVO)
sklearn中实现多分类任务(OVR和OVO) 1.OVR和OVO是针对一些二分类算法(比如典型的逻辑回归算法)来实现多分类任务的两种最为常用的方式,sklearn中专门有其调用的函数,其调用过程如 ...
- 记一次菜鸡的低级折腾--WordPress get Webshell(后台文件编辑插马)
挺简单的一个测试站,开始思路错了,一直去网上找WordPress的漏洞,看有没有什么能利用的,未果,因为这个测试站有些地方并不完善,有的漏洞利用不了,菜鸡的我连弱口令都没猜对,没知识就是这么悲哀. 下 ...
- JavaScript 字符编码
JavaScript 字符编码 JavaScript 遵循 Unicode 字符编码规则.Unicode 字符集中每个字符使用 2 个字节来表示,这意味着用户可以使用中文来命名 Java)Script ...
- NO34 awk
- docker-compose 修改zabbix images 添加微信报警插件 时间同步 中文乱码 添加grafana美化zabbix
我们先来看一下我们要修改得 zabbix.yaml github https://github.com/bboysoulcn/awesome-dockercompose ve ...
- robot_framework + selenium + 上传本地文件+win7 32位
1.下载与安装AutoIt v3 地址链接:http://pan.baidu.com/s/1hqsDFBA,我自己是32位的系统,用这个运行可以 2.安装完成后,如下图所示 3. AutoIt Wi ...
- java实现下划线转驼峰
废话少说,直接上代码 import java.util.regex.Matcher; import java.util.regex.Pattern; public class Temp { publi ...
- lsof(查看端口)
简介 简介 lsof(list open files)是一个列出当前系统打开文件的工具.在linux环境下,任何事物都以文件的形式存在,通过文件不仅仅可以访问常规数据,还可以访问网络连接和硬件.所以如 ...