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

Skip to content

Commit 5032f89

Browse files
committed
Update object creation code with VDeleter in chapters
1 parent 18dfdf2 commit 5032f89

20 files changed

Lines changed: 27 additions & 27 deletions

03_Drawing_a_triangle/00_Setup/01_Instance.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ We've now specified everything Vulkan needs to create an instance and we can
9090
finally issue the `vkCreateInstance` call:
9191

9292
```c++
93-
VkResult result = vkCreateInstance(&createInfo, nullptr, &instance);
93+
VkResult result = vkCreateInstance(&createInfo, nullptr, instance.replace());
9494
```
9595

9696
As you'll see, the general pattern that object creation function parameters in
@@ -106,7 +106,7 @@ type `VkResult` that is either `VK_SUCCESS` or an error code. To check if the
106106
instance was created successfully, simply add a check for the success value:
107107

108108
```c++
109-
if (vkCreateInstance(&createInfo, nullptr, &instance) != VK_SUCCESS) {
109+
if (vkCreateInstance(&createInfo, nullptr, instance.replace()) != VK_SUCCESS) {
110110
throw std::runtime_error("failed to create instance!");
111111
}
112112
```

03_Drawing_a_triangle/00_Setup/02_Validation_layers.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ couldn't be loaded. We can now call this function to create the extension
315315
object if it's available:
316316
317317
```c++
318-
if (CreateDebugReportCallbackEXT(instance, &createInfo, nullptr, &callback) != VK_SUCCESS) {
318+
if (CreateDebugReportCallbackEXT(instance, &createInfo, nullptr, callback.replace()) != VK_SUCCESS) {
319319
throw std::runtime_error("failed to set up debug callback!");
320320
}
321321
```

03_Drawing_a_triangle/00_Setup/04_Logical_device_and_queues.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ That's it, we're now ready to instantiate the logical device with a call to the
122122
appropriately named `vkCreateDevice` function.
123123

124124
```c++
125-
if (vkCreateDevice(physicalDevice, &createInfo, nullptr, &device) != VK_SUCCESS) {
125+
if (vkCreateDevice(physicalDevice, &createInfo, nullptr, device.replace()) != VK_SUCCESS) {
126126
throw std::runtime_error("failed to create logical device!");
127127
}
128128
```

03_Drawing_a_triangle/01_Presentation/00_Window_surface.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ allocators and the variable for the surface handle to be stored in.
6868
auto CreateWin32SurfaceKHR = (PFN_vkCreateWin32SurfaceKHR) vkGetInstanceProcAddr(instance, "vkCreateWin32SurfaceKHR");
6969

7070
if (!CreateWin32SurfaceKHR || CreateWin32SurfaceKHR(instance, &createInfo,
71-
nullptr, &surface) != VK_SUCCESS) {
71+
nullptr, surface.replace()) != VK_SUCCESS) {
7272
throw std::runtime_error("failed to create window surface!");
7373
}
7474
```
@@ -101,7 +101,7 @@ implementation of the function very straightforward:
101101

102102
```c++
103103
void createSurface() {
104-
if (glfwCreateWindowSurface(instance, window, nullptr, &surface) != VK_SUCCESS) {
104+
if (glfwCreateWindowSurface(instance, window, nullptr, surface.replace()) != VK_SUCCESS) {
105105
throw std::runtime_error("failed to create window surface!");
106106
}
107107
}

03_Drawing_a_triangle/01_Presentation/01_Swap_chain.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ VDeleter<VkSwapchainKHR> swapChain{device, vkDestroySwapchainKHR};
519519
Now creating the swap chain is as simple as calling `vkCreateSwapchainKHR`:
520520
521521
```c++
522-
if (vkCreateSwapchainKHR(device, &createInfo, nullptr, &swapChain) != VK_SUCCESS) {
522+
if (vkCreateSwapchainKHR(device, &createInfo, nullptr, swapChain.replace()) != VK_SUCCESS) {
523523
throw std::runtime_error("failed to create swap chain!");
524524
}
525525
```

03_Drawing_a_triangle/01_Presentation/02_Image_views.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ different layers.
105105
Creating the image view is now a matter of calling `vkCreateImageView`:
106106

107107
```c++
108-
if (vkCreateImageView(device, &createInfo, nullptr, &swapChainImageViews[i]) != VK_SUCCESS) {
108+
if (vkCreateImageView(device, &createInfo, nullptr, swapChainImageViews[i].replace()) != VK_SUCCESS) {
109109
throw std::runtime_error("failed to create image views!");
110110
}
111111
```

03_Drawing_a_triangle/02_Graphics_pipeline_basics/01_Shader_modules.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ createInfo.pCode = (uint32_t*) code.data();
374374
The `VkShaderModule` can then be created with a call to `vkCreateShaderModule`:
375375

376376
```c++
377-
if (vkCreateShaderModule(device, &createInfo, nullptr, &shaderModule) != VK_SUCCESS) {
377+
if (vkCreateShaderModule(device, &createInfo, nullptr, shaderModule.replace()) != VK_SUCCESS) {
378378
throw std::runtime_error("failed to create shader module!");
379379
}
380380
```

03_Drawing_a_triangle/02_Graphics_pipeline_basics/02_Fixed_functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ pipelineLayoutInfo.pushConstantRangeCount = 0; // Optional
379379
pipelineLayoutInfo.pPushConstantRanges = 0; // Optional
380380
381381
if (vkCreatePipelineLayout(device, &pipelineLayoutInfo, nullptr,
382-
&pipelineLayout) != VK_SUCCESS) {
382+
pipelineLayout.replace()) != VK_SUCCESS) {
383383
throw std::runtime_error("failed to create pipeline layout!");
384384
}
385385
```

03_Drawing_a_triangle/02_Graphics_pipeline_basics/03_Render_passes.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ renderPassInfo.pAttachments = &colorAttachment;
189189
renderPassInfo.subpassCount = 1;
190190
renderPassInfo.pSubpasses = &subPass;
191191
192-
if (vkCreateRenderPass(device, &renderPassInfo, nullptr, &renderPass) != VK_SUCCESS) {
192+
if (vkCreateRenderPass(device, &renderPassInfo, nullptr, renderPass.replace()) != VK_SUCCESS) {
193193
throw std::runtime_error("failed to create render pass!");
194194
}
195195
```

03_Drawing_a_triangle/02_Graphics_pipeline_basics/04_Conclusion.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ VDeleter<VkPipeline> graphicsPipeline{device, vkDestroyPipeline};
7575
And finally create the graphics pipeline:
7676
7777
```c++
78-
if (vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, &graphicsPipeline) != VK_SUCCESS) {
78+
if (vkCreateGraphicsPipelines(device, VK_NULL_HANDLE, 1, &pipelineInfo, nullptr, graphicsPipeline.replace()) != VK_SUCCESS) {
7979
throw std::runtime_error("failed to create graphics pipeline!");
8080
}
8181
```

0 commit comments

Comments
 (0)