Fixed-Function Vertex Processing


Vertex fetching is controlled via configurable state, as a logically distinct graphics pipeline stage.

Vertex Attributes

Vertex shaders can define input variables, which receive vertex attribute data transferred from one or more VkBuffer(s) by drawing commands. Vertex shader input variables are bound to buffers via an indirect binding where the vertex shader associates a vertex input attribute number with each variable, vertex input attributes are associated to vertex input bindings on a per-pipeline basis, and vertex input bindings are associated with specific buffers on a per-draw basis via the vkCmdBindVertexBuffers command. Vertex input attribute and vertex input binding descriptions also contain format information controlling how data is extracted from buffer memory and converted to the format expected by the vertex shader.

Applications can store multiple vertex input attributes interleaved in a single buffer, and use a single vertex input binding to access those attributes.

Attribute Location and Component Assignment

Vertex Input Description

typedef struct VkPipelineVertexInputStateCreateInfo { VkStructureType const void* VkPipelineVertexInputStateCreateFlags uint32_t const VkVertexInputBindingDescription* uint32_t const VkVertexInputAttributeDescription* } VkPipelineVertexInputStateCreateInfo;

typedef struct VkVertexInputBindingDescription { uint32_t uint32_t VkVertexInputRate binding; stride; inputRate; } VkVertexInputBindingDescription;

typedef enum VkVertexInputRate { VK_VERTEX_INPUT_RATE_VERTEX = 0, VK_VERTEX_INPUT_RATE_INSTANCE = 1, } VkVertexInputRate;

typedef struct VkVertexInputAttributeDescription { uint32_t uint32_t VkFormat uint32_t location; binding; format; offset; } VkVertexInputAttributeDescription;

void vkCmdBindVertexBuffers( VkCommandBuffer uint32_t uint32_t const VkBuffer* const VkDeviceSize* commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets);

void FVulkanPendingGfxState::PrepareForDraw(FVulkanCmdBuffer* CmdBuffer)

void vkCmdBindVertexBuffers2( VkCommandBuffer uint32_t uint32_t const VkBuffer* const VkDeviceSize* const VkDeviceSize* const VkDeviceSize* commandBuffer, firstBinding, bindingCount, pBuffers, pOffsets, pSizes, pStrides);

This command also dynamically sets the byte strides between consecutive elements within buffer pBuffers[i] to the corresponding pStrides[i] value when the graphics pipeline is created with VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE set in VkPipelineDynamicStateCreateInfo ::pDynamicStates. Otherwise, strides are specified by the VkVertexInputBindingDescription::stride values used to create the currently active pipeline.

Vertex Input Address Calculation

Vertex Input Extraction

本节教程就到此结束,希望大家继续阅读我之后的教程。

谢谢大家,再见!


原创技术文章,撰写不易,转载请注明出处:电子设备中的画家|王烁 于 2021 年 5 月 10 日发表,原文链接(http://geekfaner.com/shineengine/blog20_Vulkanv1.2_6.html)