Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e3d884f

Browse files
committed
Merge branch 'master' into daux-instructions
2 parents fa514fe + 840ee6b commit e3d884f

28 files changed

Lines changed: 159 additions & 37 deletions

02_Development_environment.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ chapter.
210210

211211
![](/images/vs_template.png)
212212

213-
You are now all set for [the real adventure](!Drawing_a_triangle).
213+
You are now all set for [the real adventure](!Drawing_a_triangle/Setup/Base_code).
214214

215215
## Linux
216216

@@ -500,4 +500,4 @@ The `Doc` directory contains useful information about the Vulkan SDK and an
500500
offline version of the entire Vulkan specification. Feel free to explore the
501501
other files, but we won't need them for this tutorial.
502502

503-
You are now all set for [the real adventure](!Drawing_a_triangle).
503+
You are now all set for [the real adventure](!Drawing_a_triangle/Setup/Base_code).

03_Drawing_a_triangle/02_Graphics_pipeline_basics/01_Shader_modules.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,13 +362,19 @@ easier to wrap it in a deleter variable when calling `createShaderModule`.
362362
363363
Creating a shader module is simple, we only need to specify a pointer to the
364364
buffer with the bytecode and the length of it. This information is specified in
365-
a `VkShaderModuleCreateInfo` structure.
365+
a `VkShaderModuleCreateInfo` structure. The one catch is that the size of the
366+
bytecode is specified in bytes, but the bytecode pointer is a `uint32_t` pointer
367+
rather than a `char` pointer. Therefore we need to temporarily copy the bytecode
368+
to a container that has the right alignment for `uint32_t`:
366369
367370
```c++
368371
VkShaderModuleCreateInfo createInfo = {};
369372
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
370373
createInfo.codeSize = code.size();
371-
createInfo.pCode = (uint32_t*) code.data();
374+
375+
std::vector<uint32_t> codeAligned(code.size() / sizeof(uint32_t) + 1);
376+
memcpy(codeAligned.data(), code.data(), code.size());
377+
createInfo.pCode = codeAligned.data();
372378
```
373379

374380
The `VkShaderModule` can then be created with a call to `vkCreateShaderModule`:

07_Depth_buffering.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -553,5 +553,5 @@ geometry and have it look right. We're going to try this out in the next chapter
553553
by drawing a textured model!
554554

555555
[C++ code](/code/depth_buffering.cpp) /
556-
[Vertex shader](/code/shader_textures.vert) /
557-
[Fragment shader](/code/shader_textures.frag)
556+
[Vertex shader](/code/shader_depth.vert) /
557+
[Fragment shader](/code/shader_depth.frag)

08_Loading_models.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -343,5 +343,5 @@ learn how these effects work from tutorials for other APIs, because despite
343343
Vulkan's explicitness, many concepts still work the same.
344344

345345
[C++ code](/code/model_loading.cpp) /
346-
[Vertex shader](/code/shader_textures.vert) /
347-
[Fragment shader](/code/shader_textures.frag)
346+
[Vertex shader](/code/shader_depth.vert) /
347+
[Fragment shader](/code/shader_depth.frag)

code/command_buffers.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,11 @@ class HelloTriangleApplication {
609609
VkShaderModuleCreateInfo createInfo = {};
610610
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
611611
createInfo.codeSize = code.size();
612-
createInfo.pCode = (uint32_t*) code.data();
612+
613+
std::vector<uint32_t> codeAligned(code.size() / 4 + 1);
614+
memcpy(codeAligned.data(), code.data(), code.size());
615+
616+
createInfo.pCode = codeAligned.data();
613617

614618
if (vkCreateShaderModule(device, &createInfo, nullptr, shaderModule.replace()) != VK_SUCCESS) {
615619
throw std::runtime_error("failed to create shader module!");

code/depth_buffering.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,11 @@ class HelloTriangleApplication {
13221322
VkShaderModuleCreateInfo createInfo = {};
13231323
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
13241324
createInfo.codeSize = code.size();
1325-
createInfo.pCode = (uint32_t*) code.data();
1325+
1326+
std::vector<uint32_t> codeAligned(code.size() / 4 + 1);
1327+
memcpy(codeAligned.data(), code.data(), code.size());
1328+
1329+
createInfo.pCode = codeAligned.data();
13261330

13271331
if (vkCreateShaderModule(device, &createInfo, nullptr, shaderModule.replace()) != VK_SUCCESS) {
13281332
throw std::runtime_error("failed to create shader module!");

code/descriptor_layout.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,7 +952,11 @@ class HelloTriangleApplication {
952952
VkShaderModuleCreateInfo createInfo = {};
953953
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
954954
createInfo.codeSize = code.size();
955-
createInfo.pCode = (uint32_t*) code.data();
955+
956+
std::vector<uint32_t> codeAligned(code.size() / 4 + 1);
957+
memcpy(codeAligned.data(), code.data(), code.size());
958+
959+
createInfo.pCode = codeAligned.data();
956960

957961
if (vkCreateShaderModule(device, &createInfo, nullptr, shaderModule.replace()) != VK_SUCCESS) {
958962
throw std::runtime_error("failed to create shader module!");

code/descriptor_set.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,11 @@ class HelloTriangleApplication {
10041004
VkShaderModuleCreateInfo createInfo = {};
10051005
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
10061006
createInfo.codeSize = code.size();
1007-
createInfo.pCode = (uint32_t*) code.data();
1007+
1008+
std::vector<uint32_t> codeAligned(code.size() / 4 + 1);
1009+
memcpy(codeAligned.data(), code.data(), code.size());
1010+
1011+
createInfo.pCode = codeAligned.data();
10081012

10091013
if (vkCreateShaderModule(device, &createInfo, nullptr, shaderModule.replace()) != VK_SUCCESS) {
10101014
throw std::runtime_error("failed to create shader module!");

code/fixed_functions.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,11 @@ class HelloTriangleApplication {
470470
VkShaderModuleCreateInfo createInfo = {};
471471
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
472472
createInfo.codeSize = code.size();
473-
createInfo.pCode = (uint32_t*) code.data();
473+
474+
std::vector<uint32_t> codeAligned(code.size() / 4 + 1);
475+
memcpy(codeAligned.data(), code.data(), code.size());
476+
477+
createInfo.pCode = codeAligned.data();
474478

475479
if (vkCreateShaderModule(device, &createInfo, nullptr, shaderModule.replace()) != VK_SUCCESS) {
476480
throw std::runtime_error("failed to create shader module!");

code/framebuffers.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,11 @@ class HelloTriangleApplication {
547547
VkShaderModuleCreateInfo createInfo = {};
548548
createInfo.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO;
549549
createInfo.codeSize = code.size();
550-
createInfo.pCode = (uint32_t*) code.data();
550+
551+
std::vector<uint32_t> codeAligned(code.size() / 4 + 1);
552+
memcpy(codeAligned.data(), code.data(), code.size());
553+
554+
createInfo.pCode = codeAligned.data();
551555

552556
if (vkCreateShaderModule(device, &createInfo, nullptr, shaderModule.replace()) != VK_SUCCESS) {
553557
throw std::runtime_error("failed to create shader module!");

0 commit comments

Comments
 (0)