wiki of vulkan

Prepare
Edit this section
1、Introduction

Vulkan is a new API of the Khronos group (known as OpenGL) that provides a better abstraction for modern graphics cards. The idea behind Vulkan is similar to that of Direct3D 12 and Metal,

Advantage:

Better performance and lower driver overhead,
Vulkan has the advantage of being completely cross-platform, allowing you to develop for Windows, Linux and Android at the same time.

Disadvantages:

A more verbose API must be used. Every detail related to the graphics API needs to be set up by your application from scratch, including initial frame buffer creation and memory management of objects such as buffers and texture images.
Very limited error checking and debugging capabilities. ( Allows extensive checks to be enabled through a function called the verification layer. The verification layer is a piece of code that can be inserted between the API and the graphics driver to perform operations such as running additional checks on function parameters and tracking memory management issues. )

Edit this section
2、Triangle process

Create a VkInstance
Select the supported graphics card (VkPhysicalDevice)
Create VkDevice and VkQueue for drawing and presentation
Create windows, window surfaces and swap chains
Pack the swap chain image into VkImageView
Create a rendering pass, specify the rendering target and purpose, create a frame buffer for the rendering pass
Set up graphics pipeline
Allocate and record the command buffer with drawing commands for each possible swap chain image
Draw the frame by acquiring the image, submitting the correct drawing command buffer and returning the image to the swap chain.

Edit this section
3. Coding Convention

All Vulkan functions, enumerations, and structures are defined in the vulkan.h header, which is included in the Vulkan SDK developed by LunarG.

Function: There is a lowercase vk prefix,
Enumerations and structures: Such types have a Vk prefix,
Enumeration value: There is a VK_ prefix.
The API makes extensive use of structures to provide parameters for functions.

Many structures in Vulkan require that the type of the structure be explicitly specified in the sType member.
Edit this section
Draw a triangle
Edit this section

  1. Configuration
    Edit this section
    1.1 General Architecture

The program itself is wrapped in a class, where we will store Vulkan objects as private class members and add functions to start each of them, which will be called from the initVulkan function. After everything is ready, we enter the main loop to start rendering frames. We will fill the mainLoop function to contain a loop that will continue to iterate until the window is closed later. Once the window is closed and mainLoop returns, we will make sure to release the resources we used in the cleanup function.

Vulkan 中的对象创建函数参数遵循的一般模式是:

指向带有创建信息的结构体的指针
指向自定义分配器回调的指针,在本教程中始终为 nullptr
指向存储新对象句柄的变量的指针 ### Resource Management

Vulkan objects are either created directly using functions such as vkCreateXXX, or allocated through another object using functions such as vkAllocateXXX. After ensuring that an object is no longer used anywhere, you need to use the corresponding vkDestroyXXX and vkFreeXXX to destroy it. The parameters of these functions are usually different for different types of objects, but they all share one parameter: pAllocator. This is an optional parameter that allows you to specify a callback for the custom memory allocator. We will ignore this parameter in the tutorial and always pass nullptr as a parameter.
Edit this section

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值