@@ -28,7 +28,7 @@ VkResult vkCreateInstance(
2828 const VkInstanceCreateInfo* pCreateInfo,
2929 const VkAllocationCallbacks* pAllocator,
3030 VkInstance* instance) {
31-
31+
3232 if (pCreateInfo == nullptr || instance == nullptr) {
3333 log("Null pointer passed to required parameter!");
3434 return VK_ERROR_INITIALIZATION_FAILED;
@@ -147,7 +147,7 @@ void createInstance() {
147147Now run the program in debug mode and ensure that the error does not occur. If
148148it does, then make sure you have properly installed the Vulkan SDK. If none or
149149very few layers are being reported, then you may be dealing with
150- [ this issue] ( https://vulkan.lunarg.com/app/issues/578e8c8d5698c020d71580fc )
150+ [ this issue] ( https://vulkan.lunarg.com/app/issues/578e8c8d5698c020d71580fc )
151151(requires a LunarG account to view). See that page for help with fixing it.
152152
153153Finally, modify the ` VkInstanceCreateInfo ` struct instantiation to include the
@@ -191,7 +191,7 @@ std::vector<const char*> getRequiredExtensions() {
191191 if (enableValidationLayers) {
192192 extensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME);
193193 }
194-
194+
195195 return extensions;
196196}
197197```
@@ -216,10 +216,16 @@ the validation layers.
216216
217217Now let's see what a callback function looks like. Add a new static member
218218function called ` debugCallback ` with the ` PFN_vkDebugReportCallbackEXT `
219- prototype:
219+ prototype. It is required to have the ` stdcall ` calling convention on Windows.
220+ The calling convention does not have to be specified on Linux, because there is
221+ only one calling convention on that platform.
220222
221223``` c++
222- static VkBool32 debugCallback (
224+ #ifndef WIN32
225+ #define __ stdcall
226+ #endif
227+
228+ static VkBool32 __stdcall debugCallback (
223229 VkDebugReportFlagsEXT flags,
224230 VkDebugReportObjectTypeEXT objType,
225231 uint64_t obj,
@@ -230,7 +236,7 @@ static VkBool32 debugCallback(
230236 void* userData) {
231237
232238 std::cerr << "validation layer: " << msg << std::endl;
233-
239+
234240 return VK_FALSE;
235241}
236242```
@@ -282,7 +288,7 @@ We'll need to fill in a structure with details about the callback:
282288VkDebugReportCallbackCreateInfoEXT createInfo = {};
283289createInfo.sType = VK_STRUCTURE_TYPE_DEBUG_REPORT_CALLBACK_CREATE_INFO_EXT;
284290createInfo.flags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT;
285- createInfo.pfnCallback = (PFN_vkDebugReportCallbackEXT) debugCallback;
291+ createInfo.pfnCallback = debugCallback;
286292```
287293
288294The ` flags ` field allows you to filter which types of messages you would like to
@@ -293,7 +299,7 @@ to pass a pointer to the `HelloTriangleApplication` class, for example.
293299
294300This struct should be passed to the ` vkCreateDebugReportCallbackEXT ` function to
295301create the ` VkDebugReportCallbackEXT ` object. Unfortunately, because this
296- function is an extension function it is not automatically loaded. We have to
302+ function is an extension function, it is not automatically loaded. We have to
297303look up its address ourselves using ` vkGetInstanceProcAddr ` . We're going to
298304create our own proxy function that handles this in the background. I've added it
299305right above the ` VDeleter ` definition.
@@ -368,4 +374,4 @@ you how helpful the validation layers are with catching them and to teach you
368374how important it is to know exactly what you're doing with Vulkan. Now it's time
369375to look at [ Vulkan devices in the system] ( !Drawing_a_triangle/Setup/Physical_devices_and_queue_families ) .
370376
371- [ Full code listing] ( /code/validation_layers.cpp )
377+ [ Full code listing] ( /code/validation_layers.cpp )
0 commit comments