Skip to content

Commit 9d7678b

Browse files
committed
Adjust documentation
1 parent 71054d6 commit 9d7678b

4 files changed

Lines changed: 33 additions & 33 deletions

File tree

en/04_Vertex_buffers/00_Vertex_input_description.adoc

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ Create a new structure called `Vertex` with the two attributes that we're going
5858

5959
[,c++]
6060
----
61-
struct Vertex {
61+
struct Vertex
62+
{
6263
glm::vec2 pos;
6364
glm::vec3 color;
6465
};
@@ -84,7 +85,7 @@ This is known as _interleaving_ vertex attributes.
8485
The next step is to tell Vulkan how to pass this data format to the vertex shader once it's been uploaded into GPU memory.
8586
There are two types of structures needed to convey this information.
8687

87-
The first structure is `VkVertexInputBindingDescription` and we'll add a member function to the `Vertex` struct to populate it with the right data.
88+
The first structure is `vk::VertexInputBindingDescription` and we'll add a member function to the `Vertex` struct to populate it with the right data.
8889

8990
[,c++]
9091
----
@@ -105,14 +106,14 @@ All of our per-vertex data is packed together in one array, so we're only going
105106
The `binding` parameter specifies the index of the binding in the array of bindings.
106107
The `stride` parameter specifies the number of bytes from one entry to the next, and the `inputRate` parameter can have one of the following values:
107108

108-
* `VK_VERTEX_INPUT_RATE_VERTEX`: Move to the next data entry after each vertex
109-
* `VK_VERTEX_INPUT_RATE_INSTANCE`: Move to the next data entry after each instance
109+
* `vk::VertexInputRate::eVertex` : Move to the next data entry after each vertex
110+
* `vk::VertexInputRate::eInstance`: Move to the next data entry after each instance
110111

111112
We're not going to use instanced rendering, so we'll stick to per-vertex data.
112113

113114
== Attribute descriptions
114115

115-
The second structure that describes how to handle vertex input is `VkVertexInputAttributeDescription`.
116+
The second structure that describes how to handle vertex input is `vk::VertexInputAttributeDescription`.
116117
We're going to add another helper function to `Vertex` to fill in these structs.
117118

118119
[,c++]
@@ -141,22 +142,20 @@ The `format` parameter describes the type of data for the attribute.
141142
A bit confusingly, the formats are specified using the same enumeration as color formats.
142143
The following shader types and formats are commonly used together:
143144

144-
* `float`: `VK_FORMAT_R32_SFLOAT`
145-
* `float2`: `VK_FORMAT_R32G32_SFLOAT`
146-
* `float3`: `VK_FORMAT_R32G32B32_SFLOAT`
147-
* `float4`: `VK_FORMAT_R32G32B32A32_SFLOAT`
145+
* `float` : `vk::Format::eR32Sfloat`
146+
* `float2`: `vk::Format::eR32G32Sfloat`
147+
* `float3`: `vk::Format::eR32G32B32Sfloat`
148+
* `float4`: `vk::Format::eR32G32B32A32Sfloat`
148149

149150
As you can see, you should use the format where the amount of color channels matches the number of components in the shader data type.
150151
It is allowed to use more channels than the number of components in the shader, but they will be silently discarded.
151152
If the number of channels is lower than the number of components, then the BGA components will use default values of `(0, 0, 1)`.
152-
The color type (`SFLOAT`, `UINT`, `SINT`) and bit width should also match the type of the shader input.
153+
The color type (`Sfloat`, `Uint`, `Sint`) and bit width should also match the type of the shader input.
153154
See the following examples:
154155

155-
* `int2`: `VK_FORMAT_R32G32_SINT`, a 2-component vector of 32-bit signed
156-
integers
157-
* `uint4`: `VK_FORMAT_R32G32B32A32_UINT`, a 4-component vector of 32-bit
158-
unsigned integers
159-
* `double`: `VK_FORMAT_R64_SFLOAT`, a double-precision (64-bit) float
156+
* `int2` : `vk::Format::eR32G32Sint`, a 2-component vector of 32-bit signed integers
157+
* `uint4` : `vk::Format::eR32G32B32A32Uint`, a 4-component vector of 32-bit unsigned integers
158+
* `double`: `vk::Format::eR64Sfloat`, a double-precision (64-bit) float
160159

161160
The `format` parameter implicitly defines the byte size of attribute data and the `offset` parameter has specified the number of bytes since the start of the per-vertex data to read from.
162161
The binding is loading one `Vertex` at a time and the position attribute (`pos`) is at an offset of `0` bytes from the beginning of this struct.
@@ -171,17 +170,18 @@ Find the `vertexInputInfo` struct and modify it to reference the two description
171170

172171
[,c++]
173172
----
174-
auto bindingDescription = Vertex::getBindingDescription();
175-
auto attributeDescriptions = Vertex::getAttributeDescriptions();
176-
vk::PipelineVertexInputStateCreateInfo vertexInputInfo { .vertexBindingDescriptionCount =1, .pVertexBindingDescriptions = &bindingDescription,
177-
.vertexAttributeDescriptionCount = attributeDescriptions.size(), .pVertexAttributeDescriptions = attributeDescriptions.data() };
173+
auto bindingDescription = Vertex::getBindingDescription();
174+
auto attributeDescriptions = Vertex::getAttributeDescriptions();
175+
vk::PipelineVertexInputStateCreateInfo vertexInputInfo{ .vertexBindingDescriptionCount = 1,
176+
.pVertexBindingDescriptions = &bindingDescription,
177+
.vertexAttributeDescriptionCount = static_cast<uint32_t>( attributeDescriptions.size() ),
178+
.pVertexAttributeDescriptions = attributeDescriptions.data() };
178179
----
179180

180181
The pipeline is now ready to accept vertex data in the format of the `vertices` container and pass it on to our vertex shader.
181-
If you run the program now with validation layers enabled, you'll see that it complains that there is no vertex buffer bound to the binding.
182182
The xref:./01_Vertex_buffer_creation.adoc[next step] is to create a vertex buffer and move the vertex data to it so the GPU is able to access it.
183183

184-
link:/attachments/18_vertex_input.cpp[C{pp} code] /
185-
link:/attachments/18_shader_vertexbuffer.slang[slang shader] /
186-
link:/attachments/18_shader_vertexbuffer.vert[GLSL Vertex shader] /
187-
link:/attachments/18_shader_vertexbuffer.frag[GLSL Fragment shader]
184+
link:/attachments/19_vertex_buffer.cpp[C{pp} code] /
185+
link:/attachments/19_shader_vertexbuffer.slang[slang shader] /
186+
link:/attachments/19_shader_vertexbuffer.vert[GLSL Vertex shader] /
187+
link:/attachments/19_shader_vertexbuffer.frag[GLSL Fragment shader]

en/04_Vertex_buffers/01_Vertex_buffer_creation.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,6 @@ image::/images/triangle_white.png[]
262262
In the xref:./02_Staging_buffer.adoc[next chapter,] we'll look at a different way to copy vertex data to a vertex buffer that results in better performance, but takes some more work.
263263

264264
link:/attachments/19_vertex_buffer.cpp[C{pp} code] /
265-
link:/attachments/18_shader_vertexbuffer.slang[slang shader] /
266-
link:/attachments/18_shader_vertexbuffer.vert[GLSL Vertex shader] /
267-
link:/attachments/18_shader_vertexbuffer.frag[GLSL Fragment shader]
265+
link:/attachments/19_shader_vertexbuffer.slang[slang shader] /
266+
link:/attachments/19_shader_vertexbuffer.vert[GLSL Vertex shader] /
267+
link:/attachments/19_shader_vertexbuffer.frag[GLSL Fragment shader]

en/04_Vertex_buffers/02_Staging_buffer.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,6 @@ However, for this tutorial, it's okay to use a separate allocation for every res
206206
In the xref:./03_Index_buffer.adoc[next chapter,] we'll learn about index buffers for vertex reuse.
207207

208208
link:/attachments/20_staging_buffer.cpp[C{pp} code] /
209-
link:/attachments/18_shader_vertexbuffer.slang[slang shader] /
210-
link:/attachments/18_shader_vertexbuffer.vert[GLSL Vertex shader] /
211-
link:/attachments/18_shader_vertexbuffer.frag[GLSL Fragment shader]
209+
link:/attachments/19_shader_vertexbuffer.slang[slang shader] /
210+
link:/attachments/19_shader_vertexbuffer.vert[GLSL Vertex shader] /
211+
link:/attachments/19_shader_vertexbuffer.frag[GLSL Fragment shader]

en/04_Vertex_buffers/03_Index_buffer.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,6 @@ This is known as _aliasing_ and some Vulkan functions have explicit flags to spe
141141
The xref:05_Uniform_buffers/00_Descriptor_set_layout_and_buffer.adoc[next chapter] we'll learn how to pass frequently changing parameters to the GPU.
142142

143143
link:/attachments/21_index_buffer.cpp[C{pp} code] /
144-
link:/attachments/18_shader_vertexbuffer.slang[slang shader] /
145-
link:/attachments/18_shader_vertexbuffer.vert[GLSL Vertex shader] /
146-
link:/attachments/18_shader_vertexbuffer.frag[GLSL Fragment shader]
144+
link:/attachments/19_shader_vertexbuffer.slang[slang shader] /
145+
link:/attachments/19_shader_vertexbuffer.vert[GLSL Vertex shader] /
146+
link:/attachments/19_shader_vertexbuffer.frag[GLSL Fragment shader]

0 commit comments

Comments
 (0)