Replaced debug marker with debug utils in framework
This commit is contained in:
parent
3c9aca3fcb
commit
ed8be7e92d
7 changed files with 107 additions and 277 deletions
|
|
@ -1,10 +1,10 @@
|
||||||
/*
|
/*
|
||||||
* Vulkan examples debug wrapper
|
* Vulkan examples debug wrapper
|
||||||
*
|
*
|
||||||
* Copyright (C) by Sascha Willems - www.saschawillems.de
|
* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de
|
||||||
*
|
*
|
||||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "VulkanDebug.h"
|
#include "VulkanDebug.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
@ -90,172 +90,39 @@ namespace vks
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace debugmarker
|
namespace debugutils
|
||||||
{
|
{
|
||||||
bool active = false;
|
PFN_vkCmdBeginDebugUtilsLabelEXT vkCmdBeginDebugUtilsLabelEXT{ nullptr };
|
||||||
|
PFN_vkCmdEndDebugUtilsLabelEXT vkCmdEndDebugUtilsLabelEXT{ nullptr };
|
||||||
|
PFN_vkCmdInsertDebugUtilsLabelEXT vkCmdInsertDebugUtilsLabelEXT{ nullptr };
|
||||||
|
|
||||||
PFN_vkDebugMarkerSetObjectTagEXT pfnDebugMarkerSetObjectTag = VK_NULL_HANDLE;
|
void setup(VkInstance instance)
|
||||||
PFN_vkDebugMarkerSetObjectNameEXT pfnDebugMarkerSetObjectName = VK_NULL_HANDLE;
|
|
||||||
PFN_vkCmdDebugMarkerBeginEXT pfnCmdDebugMarkerBegin = VK_NULL_HANDLE;
|
|
||||||
PFN_vkCmdDebugMarkerEndEXT pfnCmdDebugMarkerEnd = VK_NULL_HANDLE;
|
|
||||||
PFN_vkCmdDebugMarkerInsertEXT pfnCmdDebugMarkerInsert = VK_NULL_HANDLE;
|
|
||||||
|
|
||||||
void setup(VkDevice device)
|
|
||||||
{
|
{
|
||||||
pfnDebugMarkerSetObjectTag = reinterpret_cast<PFN_vkDebugMarkerSetObjectTagEXT>(vkGetDeviceProcAddr(device, "vkDebugMarkerSetObjectTagEXT"));
|
vkCmdBeginDebugUtilsLabelEXT = reinterpret_cast<PFN_vkCmdBeginDebugUtilsLabelEXT>(vkGetInstanceProcAddr(instance, "vkCmdBeginDebugUtilsLabelEXT"));
|
||||||
pfnDebugMarkerSetObjectName = reinterpret_cast<PFN_vkDebugMarkerSetObjectNameEXT>(vkGetDeviceProcAddr(device, "vkDebugMarkerSetObjectNameEXT"));
|
vkCmdEndDebugUtilsLabelEXT = reinterpret_cast<PFN_vkCmdEndDebugUtilsLabelEXT>(vkGetInstanceProcAddr(instance, "vkCmdEndDebugUtilsLabelEXT"));
|
||||||
pfnCmdDebugMarkerBegin = reinterpret_cast<PFN_vkCmdDebugMarkerBeginEXT>(vkGetDeviceProcAddr(device, "vkCmdDebugMarkerBeginEXT"));
|
vkCmdInsertDebugUtilsLabelEXT = reinterpret_cast<PFN_vkCmdInsertDebugUtilsLabelEXT>(vkGetInstanceProcAddr(instance, "vkCmdInsertDebugUtilsLabelEXT"));
|
||||||
pfnCmdDebugMarkerEnd = reinterpret_cast<PFN_vkCmdDebugMarkerEndEXT>(vkGetDeviceProcAddr(device, "vkCmdDebugMarkerEndEXT"));
|
|
||||||
pfnCmdDebugMarkerInsert = reinterpret_cast<PFN_vkCmdDebugMarkerInsertEXT>(vkGetDeviceProcAddr(device, "vkCmdDebugMarkerInsertEXT"));
|
|
||||||
|
|
||||||
// Set flag if at least one function pointer is present
|
|
||||||
active = (pfnDebugMarkerSetObjectName != VK_NULL_HANDLE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void setObjectName(VkDevice device, uint64_t object, VkDebugReportObjectTypeEXT objectType, const char *name)
|
void cmdBeginLabel(VkCommandBuffer cmdbuffer, std::string caption, glm::vec4 color)
|
||||||
{
|
{
|
||||||
// Check for valid function pointer (may not be present if not running in a debugging application)
|
if (!vkCmdBeginDebugUtilsLabelEXT) {
|
||||||
if (pfnDebugMarkerSetObjectName)
|
return;
|
||||||
{
|
|
||||||
VkDebugMarkerObjectNameInfoEXT nameInfo = {};
|
|
||||||
nameInfo.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT;
|
|
||||||
nameInfo.objectType = objectType;
|
|
||||||
nameInfo.object = object;
|
|
||||||
nameInfo.pObjectName = name;
|
|
||||||
pfnDebugMarkerSetObjectName(device, &nameInfo);
|
|
||||||
}
|
}
|
||||||
|
VkDebugUtilsLabelEXT labelInfo{};
|
||||||
|
labelInfo.sType = VK_STRUCTURE_TYPE_DEBUG_UTILS_LABEL_EXT;
|
||||||
|
labelInfo.pLabelName = caption.c_str();
|
||||||
|
memcpy(labelInfo.color, &color[0], sizeof(float) * 4);
|
||||||
|
vkCmdBeginDebugUtilsLabelEXT(cmdbuffer, &labelInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setObjectTag(VkDevice device, uint64_t object, VkDebugReportObjectTypeEXT objectType, uint64_t name, size_t tagSize, const void* tag)
|
void cmdEndLabel(VkCommandBuffer cmdbuffer)
|
||||||
{
|
{
|
||||||
// Check for valid function pointer (may not be present if not running in a debugging application)
|
if (!vkCmdEndDebugUtilsLabelEXT) {
|
||||||
if (pfnDebugMarkerSetObjectTag)
|
return;
|
||||||
{
|
|
||||||
VkDebugMarkerObjectTagInfoEXT tagInfo = {};
|
|
||||||
tagInfo.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_TAG_INFO_EXT;
|
|
||||||
tagInfo.objectType = objectType;
|
|
||||||
tagInfo.object = object;
|
|
||||||
tagInfo.tagName = name;
|
|
||||||
tagInfo.tagSize = tagSize;
|
|
||||||
tagInfo.pTag = tag;
|
|
||||||
pfnDebugMarkerSetObjectTag(device, &tagInfo);
|
|
||||||
}
|
}
|
||||||
|
vkCmdEndDebugUtilsLabelEXT(cmdbuffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void beginRegion(VkCommandBuffer cmdbuffer, const char* pMarkerName, glm::vec4 color)
|
|
||||||
{
|
|
||||||
// Check for valid function pointer (may not be present if not running in a debugging application)
|
|
||||||
if (pfnCmdDebugMarkerBegin)
|
|
||||||
{
|
|
||||||
VkDebugMarkerMarkerInfoEXT markerInfo = {};
|
|
||||||
markerInfo.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT;
|
|
||||||
memcpy(markerInfo.color, &color[0], sizeof(float) * 4);
|
|
||||||
markerInfo.pMarkerName = pMarkerName;
|
|
||||||
pfnCmdDebugMarkerBegin(cmdbuffer, &markerInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void insert(VkCommandBuffer cmdbuffer, std::string markerName, glm::vec4 color)
|
|
||||||
{
|
|
||||||
// Check for valid function pointer (may not be present if not running in a debugging application)
|
|
||||||
if (pfnCmdDebugMarkerInsert)
|
|
||||||
{
|
|
||||||
VkDebugMarkerMarkerInfoEXT markerInfo = {};
|
|
||||||
markerInfo.sType = VK_STRUCTURE_TYPE_DEBUG_MARKER_MARKER_INFO_EXT;
|
|
||||||
memcpy(markerInfo.color, &color[0], sizeof(float) * 4);
|
|
||||||
markerInfo.pMarkerName = markerName.c_str();
|
|
||||||
pfnCmdDebugMarkerInsert(cmdbuffer, &markerInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void endRegion(VkCommandBuffer cmdBuffer)
|
|
||||||
{
|
|
||||||
// Check for valid function (may not be present if not running in a debugging application)
|
|
||||||
if (pfnCmdDebugMarkerEnd)
|
|
||||||
{
|
|
||||||
pfnCmdDebugMarkerEnd(cmdBuffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void setCommandBufferName(VkDevice device, VkCommandBuffer cmdBuffer, const char * name)
|
|
||||||
{
|
|
||||||
setObjectName(device, (uint64_t)cmdBuffer, VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setQueueName(VkDevice device, VkQueue queue, const char * name)
|
|
||||||
{
|
|
||||||
setObjectName(device, (uint64_t)queue, VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setImageName(VkDevice device, VkImage image, const char * name)
|
|
||||||
{
|
|
||||||
setObjectName(device, (uint64_t)image, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setSamplerName(VkDevice device, VkSampler sampler, const char * name)
|
|
||||||
{
|
|
||||||
setObjectName(device, (uint64_t)sampler, VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setBufferName(VkDevice device, VkBuffer buffer, const char * name)
|
|
||||||
{
|
|
||||||
setObjectName(device, (uint64_t)buffer, VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setDeviceMemoryName(VkDevice device, VkDeviceMemory memory, const char * name)
|
|
||||||
{
|
|
||||||
setObjectName(device, (uint64_t)memory, VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setShaderModuleName(VkDevice device, VkShaderModule shaderModule, const char * name)
|
|
||||||
{
|
|
||||||
setObjectName(device, (uint64_t)shaderModule, VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPipelineName(VkDevice device, VkPipeline pipeline, const char * name)
|
|
||||||
{
|
|
||||||
setObjectName(device, (uint64_t)pipeline, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setPipelineLayoutName(VkDevice device, VkPipelineLayout pipelineLayout, const char * name)
|
|
||||||
{
|
|
||||||
setObjectName(device, (uint64_t)pipelineLayout, VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setRenderPassName(VkDevice device, VkRenderPass renderPass, const char * name)
|
|
||||||
{
|
|
||||||
setObjectName(device, (uint64_t)renderPass, VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setFramebufferName(VkDevice device, VkFramebuffer framebuffer, const char * name)
|
|
||||||
{
|
|
||||||
setObjectName(device, (uint64_t)framebuffer, VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setDescriptorSetLayoutName(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const char * name)
|
|
||||||
{
|
|
||||||
setObjectName(device, (uint64_t)descriptorSetLayout, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setDescriptorSetName(VkDevice device, VkDescriptorSet descriptorSet, const char * name)
|
|
||||||
{
|
|
||||||
setObjectName(device, (uint64_t)descriptorSet, VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setSemaphoreName(VkDevice device, VkSemaphore semaphore, const char * name)
|
|
||||||
{
|
|
||||||
setObjectName(device, (uint64_t)semaphore, VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setFenceName(VkDevice device, VkFence fence, const char * name)
|
|
||||||
{
|
|
||||||
setObjectName(device, (uint64_t)fence, VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setEventName(VkDevice device, VkEvent _event, const char * name)
|
|
||||||
{
|
|
||||||
setObjectName(device, (uint64_t)_event, VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT, name);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,11 @@
|
||||||
|
/*
|
||||||
|
* Vulkan examples debug wrapper
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de
|
||||||
|
*
|
||||||
|
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||||
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "vulkan/vulkan.h"
|
#include "vulkan/vulkan.h"
|
||||||
|
|
||||||
|
|
@ -43,52 +51,12 @@ namespace vks
|
||||||
void freeDebugCallback(VkInstance instance);
|
void freeDebugCallback(VkInstance instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Setup and functions for the VK_EXT_debug_marker_extension
|
// Wrapper for the VK_EXT_debug_utils extension
|
||||||
// Extension spec can be found at https://github.com/KhronosGroup/Vulkan-Docs/blob/1.0-VK_EXT_debug_marker/doc/specs/vulkan/appendices/VK_EXT_debug_marker.txt
|
// These can be used to name Vulkan objects for debugging tools like RenderDoc
|
||||||
// Note that the extension will only be present if run from an offline debugging application
|
namespace debugutils
|
||||||
// The actual check for extension presence and enabling it on the device is done in the example base class
|
|
||||||
// See VulkanExampleBase::createInstance and VulkanExampleBase::createDevice (base/vulkanexamplebase.cpp)
|
|
||||||
namespace debugmarker
|
|
||||||
{
|
{
|
||||||
// Set to true if function pointer for the debug marker are available
|
void setup(VkInstance instance);
|
||||||
extern bool active;
|
void cmdBeginLabel(VkCommandBuffer cmdbuffer, std::string caption, glm::vec4 color);
|
||||||
|
void cmdEndLabel(VkCommandBuffer cmdbuffer);
|
||||||
// Get function pointers for the debug report extensions from the device
|
}
|
||||||
void setup(VkDevice device);
|
|
||||||
|
|
||||||
// Sets the debug name of an object
|
|
||||||
// All Objects in Vulkan are represented by their 64-bit handles which are passed into this function
|
|
||||||
// along with the object type
|
|
||||||
void setObjectName(VkDevice device, uint64_t object, VkDebugReportObjectTypeEXT objectType, const char *name);
|
|
||||||
|
|
||||||
// Set the tag for an object
|
|
||||||
void setObjectTag(VkDevice device, uint64_t object, VkDebugReportObjectTypeEXT objectType, uint64_t name, size_t tagSize, const void* tag);
|
|
||||||
|
|
||||||
// Start a new debug marker region
|
|
||||||
void beginRegion(VkCommandBuffer cmdbuffer, const char* pMarkerName, glm::vec4 color);
|
|
||||||
|
|
||||||
// Insert a new debug marker into the command buffer
|
|
||||||
void insert(VkCommandBuffer cmdbuffer, std::string markerName, glm::vec4 color);
|
|
||||||
|
|
||||||
// End the current debug marker region
|
|
||||||
void endRegion(VkCommandBuffer cmdBuffer);
|
|
||||||
|
|
||||||
// Object specific naming functions
|
|
||||||
void setCommandBufferName(VkDevice device, VkCommandBuffer cmdBuffer, const char * name);
|
|
||||||
void setQueueName(VkDevice device, VkQueue queue, const char * name);
|
|
||||||
void setImageName(VkDevice device, VkImage image, const char * name);
|
|
||||||
void setSamplerName(VkDevice device, VkSampler sampler, const char * name);
|
|
||||||
void setBufferName(VkDevice device, VkBuffer buffer, const char * name);
|
|
||||||
void setDeviceMemoryName(VkDevice device, VkDeviceMemory memory, const char * name);
|
|
||||||
void setShaderModuleName(VkDevice device, VkShaderModule shaderModule, const char * name);
|
|
||||||
void setPipelineName(VkDevice device, VkPipeline pipeline, const char * name);
|
|
||||||
void setPipelineLayoutName(VkDevice device, VkPipelineLayout pipelineLayout, const char * name);
|
|
||||||
void setRenderPassName(VkDevice device, VkRenderPass renderPass, const char * name);
|
|
||||||
void setFramebufferName(VkDevice device, VkFramebuffer framebuffer, const char * name);
|
|
||||||
void setDescriptorSetLayoutName(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const char * name);
|
|
||||||
void setDescriptorSetName(VkDevice device, VkDescriptorSet descriptorSet, const char * name);
|
|
||||||
void setSemaphoreName(VkDevice device, VkSemaphore semaphore, const char * name);
|
|
||||||
void setFenceName(VkDevice device, VkFence fence, const char * name);
|
|
||||||
void setEventName(VkDevice device, VkEvent _event, const char * name);
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Vulkan device class
|
* Vulkan device class
|
||||||
*
|
*
|
||||||
* Encapsulates a physical Vulkan device and its logical representation
|
* Encapsulates a physical Vulkan device and its logical representation
|
||||||
*
|
*
|
||||||
* Copyright (C) by Sascha Willems - www.saschawillems.de
|
* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de
|
||||||
*
|
*
|
||||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK))
|
#if (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK))
|
||||||
// SRS - Enable beta extensions and make VK_KHR_portability_subset visible
|
// SRS - Enable beta extensions and make VK_KHR_portability_subset visible
|
||||||
|
|
@ -269,13 +269,6 @@ namespace vks
|
||||||
deviceCreateInfo.pNext = &physicalDeviceFeatures2;
|
deviceCreateInfo.pNext = &physicalDeviceFeatures2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Enable the debug marker extension if it is present (likely meaning a debugging tool is present)
|
|
||||||
if (extensionSupported(VK_EXT_DEBUG_MARKER_EXTENSION_NAME))
|
|
||||||
{
|
|
||||||
deviceExtensions.push_back(VK_EXT_DEBUG_MARKER_EXTENSION_NAME);
|
|
||||||
enableDebugMarkers = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK)) && defined(VK_KHR_portability_subset)
|
#if (defined(VK_USE_PLATFORM_IOS_MVK) || defined(VK_USE_PLATFORM_MACOS_MVK)) && defined(VK_KHR_portability_subset)
|
||||||
// SRS - When running on iOS/macOS with MoltenVK and VK_KHR_portability_subset is defined and supported by the device, enable the extension
|
// SRS - When running on iOS/macOS with MoltenVK and VK_KHR_portability_subset is defined and supported by the device, enable the extension
|
||||||
if (extensionSupported(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME))
|
if (extensionSupported(VK_KHR_PORTABILITY_SUBSET_EXTENSION_NAME))
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
/*
|
/*
|
||||||
* Vulkan device class
|
* Vulkan device class
|
||||||
*
|
*
|
||||||
* Encapsulates a physical Vulkan device and its logical representation
|
* Encapsulates a physical Vulkan device and its logical representation
|
||||||
*
|
*
|
||||||
* Copyright (C) by Sascha Willems - www.saschawillems.de
|
* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de
|
||||||
*
|
*
|
||||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
|
@ -39,8 +39,6 @@ struct VulkanDevice
|
||||||
std::vector<std::string> supportedExtensions;
|
std::vector<std::string> supportedExtensions;
|
||||||
/** @brief Default command pool for the graphics queue family index */
|
/** @brief Default command pool for the graphics queue family index */
|
||||||
VkCommandPool commandPool = VK_NULL_HANDLE;
|
VkCommandPool commandPool = VK_NULL_HANDLE;
|
||||||
/** @brief Set to true when the debug marker extension is detected */
|
|
||||||
bool enableDebugMarkers = false;
|
|
||||||
/** @brief Contains queue family indices */
|
/** @brief Contains queue family indices */
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -105,13 +105,13 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Enable the debug utils extension if available (e.g. when debugging tools are present)
|
||||||
|
if (settings.validation || std::find(supportedInstanceExtensions.begin(), supportedInstanceExtensions.end(), VK_EXT_DEBUG_UTILS_EXTENSION_NAME) != supportedInstanceExtensions.end()) {
|
||||||
|
instanceExtensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
if (instanceExtensions.size() > 0)
|
if (instanceExtensions.size() > 0)
|
||||||
{
|
{
|
||||||
if (settings.validation)
|
|
||||||
{
|
|
||||||
instanceExtensions.push_back(VK_EXT_DEBUG_REPORT_EXTENSION_NAME); // SRS - Dependency when VK_EXT_DEBUG_MARKER is enabled
|
|
||||||
instanceExtensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
|
|
||||||
}
|
|
||||||
instanceCreateInfo.enabledExtensionCount = (uint32_t)instanceExtensions.size();
|
instanceCreateInfo.enabledExtensionCount = (uint32_t)instanceExtensions.size();
|
||||||
instanceCreateInfo.ppEnabledExtensionNames = instanceExtensions.data();
|
instanceCreateInfo.ppEnabledExtensionNames = instanceExtensions.data();
|
||||||
}
|
}
|
||||||
|
|
@ -140,7 +140,14 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
|
||||||
std::cerr << "Validation layer VK_LAYER_KHRONOS_validation not present, validation is disabled";
|
std::cerr << "Validation layer VK_LAYER_KHRONOS_validation not present, validation is disabled";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return vkCreateInstance(&instanceCreateInfo, nullptr, &instance);
|
VkResult result = vkCreateInstance(&instanceCreateInfo, nullptr, &instance);
|
||||||
|
|
||||||
|
// If the debug utils extension is present we set up debug functions, so samples an label objects for debugging
|
||||||
|
if (std::find(supportedInstanceExtensions.begin(), supportedInstanceExtensions.end(), VK_EXT_DEBUG_UTILS_EXTENSION_NAME) != supportedInstanceExtensions.end()) {
|
||||||
|
vks::debugutils::setup(instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanExampleBase::renderFrame()
|
void VulkanExampleBase::renderFrame()
|
||||||
|
|
@ -196,9 +203,6 @@ void VulkanExampleBase::createPipelineCache()
|
||||||
|
|
||||||
void VulkanExampleBase::prepare()
|
void VulkanExampleBase::prepare()
|
||||||
{
|
{
|
||||||
if (vulkanDevice->enableDebugMarkers) {
|
|
||||||
vks::debugmarker::setup(device);
|
|
||||||
}
|
|
||||||
initSwapchain();
|
initSwapchain();
|
||||||
createCommandPool();
|
createCommandPool();
|
||||||
setupSwapChain();
|
setupSwapChain();
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
/*
|
/*
|
||||||
* Vulkan Example - Using input attachments
|
* Vulkan Example - Using input attachments
|
||||||
*
|
*
|
||||||
* Copyright (C) 2018-2021 by Sascha Willems - www.saschawillems.de
|
* Copyright (C) 2018-2023 by Sascha Willems - www.saschawillems.de
|
||||||
*
|
*
|
||||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||||
*
|
*
|
||||||
* Summary:
|
* Summary:
|
||||||
* Input attachments can be used to read attachment contents from a previous sub pass
|
* Input attachments can be used to read attachment contents from a previous sub pass
|
||||||
* at the same pixel position within a single render pass
|
* at the same pixel position within a single render pass
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "vulkanexamplebase.h"
|
#include "vulkanexamplebase.h"
|
||||||
#include "VulkanglTFModel.h"
|
#include "VulkanglTFModel.h"
|
||||||
|
|
@ -379,13 +379,13 @@ public:
|
||||||
Fills the attachments
|
Fills the attachments
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
vks::debugmarker::beginRegion(drawCmdBuffers[i], "Subpass 0: Writing attachments", glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
vks::debugutils::cmdBeginLabel(drawCmdBuffers[i], "Subpass 0: Writing attachments", { 1.0f, 0.78f, 0.05f, 1.0f });
|
||||||
|
|
||||||
vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.attachmentWrite);
|
vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.attachmentWrite);
|
||||||
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayouts.attachmentWrite, 0, 1, &descriptorSets.attachmentWrite, 0, NULL);
|
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayouts.attachmentWrite, 0, 1, &descriptorSets.attachmentWrite, 0, NULL);
|
||||||
scene.draw(drawCmdBuffers[i]);
|
scene.draw(drawCmdBuffers[i]);
|
||||||
|
|
||||||
vks::debugmarker::endRegion(drawCmdBuffers[i]);
|
vks::debugutils::cmdEndLabel(drawCmdBuffers[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -393,7 +393,7 @@ public:
|
||||||
Render a full screen quad, reading from the previously written attachments via input attachments
|
Render a full screen quad, reading from the previously written attachments via input attachments
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
vks::debugmarker::beginRegion(drawCmdBuffers[i], "Subpass 1: Reading attachments", glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
vks::debugutils::cmdBeginLabel(drawCmdBuffers[i], "Subpass 1: Reading attachments", { 0.0f, 0.5f, 1.0f, 1.0f });
|
||||||
|
|
||||||
vkCmdNextSubpass(drawCmdBuffers[i], VK_SUBPASS_CONTENTS_INLINE);
|
vkCmdNextSubpass(drawCmdBuffers[i], VK_SUBPASS_CONTENTS_INLINE);
|
||||||
|
|
||||||
|
|
@ -401,7 +401,7 @@ public:
|
||||||
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayouts.attachmentRead, 0, 1, &descriptorSets.attachmentRead[i], 0, NULL);
|
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayouts.attachmentRead, 0, 1, &descriptorSets.attachmentRead[i], 0, NULL);
|
||||||
vkCmdDraw(drawCmdBuffers[i], 3, 1, 0, 0);
|
vkCmdDraw(drawCmdBuffers[i], 3, 1, 0, 0);
|
||||||
|
|
||||||
vks::debugmarker::endRegion(drawCmdBuffers[i]);
|
vks::debugutils::cmdEndLabel(drawCmdBuffers[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawUI(drawCmdBuffers[i]);
|
drawUI(drawCmdBuffers[i]);
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,20 @@
|
||||||
/*
|
/*
|
||||||
* Vulkan Example - Using subpasses for G-Buffer compositing
|
* Vulkan Example - Using subpasses for G-Buffer compositing
|
||||||
*
|
*
|
||||||
* Copyright (C) 2016-2022 by Sascha Willems - www.saschawillems.de
|
* Copyright (C) 2016-2023 by Sascha Willems - www.saschawillems.de
|
||||||
*
|
*
|
||||||
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
|
||||||
*
|
*
|
||||||
* Summary:
|
* Summary:
|
||||||
* Implements a deferred rendering setup with a forward transparency pass using sub passes
|
* Implements a deferred rendering setup with a forward transparency pass using sub passes
|
||||||
*
|
*
|
||||||
* Sub passes allow reading from the previous framebuffer (in the same render pass) at
|
* Sub passes allow reading from the previous framebuffer (in the same render pass) at
|
||||||
* the same pixel position.
|
* the same pixel position.
|
||||||
*
|
*
|
||||||
* This is a feature that was especially designed for tile-based-renderers
|
* This is a feature that was especially designed for tile-based-renderers
|
||||||
* (mostly mobile GPUs) and is a new optimization feature in Vulkan for those GPU types.
|
* (mostly mobile GPUs) and is a new optimization feature in Vulkan for those GPU types.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "vulkanexamplebase.h"
|
#include "vulkanexamplebase.h"
|
||||||
#include "VulkanglTFModel.h"
|
#include "VulkanglTFModel.h"
|
||||||
|
|
@ -474,19 +474,19 @@ public:
|
||||||
// First sub pass
|
// First sub pass
|
||||||
// Renders the components of the scene to the G-Buffer attachments
|
// Renders the components of the scene to the G-Buffer attachments
|
||||||
{
|
{
|
||||||
vks::debugmarker::beginRegion(drawCmdBuffers[i], "Subpass 0: Deferred G-Buffer creation", glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
vks::debugutils::cmdBeginLabel(drawCmdBuffers[i], "Subpass 0: Deferred G-Buffer creation", { 1.0f, 0.78f, 0.05f, 1.0f });
|
||||||
|
|
||||||
vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.offscreen);
|
vkCmdBindPipeline(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelines.offscreen);
|
||||||
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayouts.offscreen, 0, 1, &descriptorSets.scene, 0, NULL);
|
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayouts.offscreen, 0, 1, &descriptorSets.scene, 0, NULL);
|
||||||
models.scene.draw(drawCmdBuffers[i]);
|
models.scene.draw(drawCmdBuffers[i]);
|
||||||
|
|
||||||
vks::debugmarker::endRegion(drawCmdBuffers[i]);
|
vks::debugutils::cmdEndLabel(drawCmdBuffers[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Second sub pass
|
// Second sub pass
|
||||||
// This subpass will use the G-Buffer components that have been filled in the first subpass as input attachment for the final compositing
|
// This subpass will use the G-Buffer components that have been filled in the first subpass as input attachment for the final compositing
|
||||||
{
|
{
|
||||||
vks::debugmarker::beginRegion(drawCmdBuffers[i], "Subpass 1: Deferred composition", glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
vks::debugutils::cmdBeginLabel(drawCmdBuffers[i], "Subpass 1: Deferred composition", { 0.0f, 0.5f, 1.0f, 1.0f });
|
||||||
|
|
||||||
vkCmdNextSubpass(drawCmdBuffers[i], VK_SUBPASS_CONTENTS_INLINE);
|
vkCmdNextSubpass(drawCmdBuffers[i], VK_SUBPASS_CONTENTS_INLINE);
|
||||||
|
|
||||||
|
|
@ -494,13 +494,13 @@ public:
|
||||||
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayouts.composition, 0, 1, &descriptorSets.composition, 0, NULL);
|
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayouts.composition, 0, 1, &descriptorSets.composition, 0, NULL);
|
||||||
vkCmdDraw(drawCmdBuffers[i], 3, 1, 0, 0);
|
vkCmdDraw(drawCmdBuffers[i], 3, 1, 0, 0);
|
||||||
|
|
||||||
vks::debugmarker::endRegion(drawCmdBuffers[i]);
|
vks::debugutils::cmdEndLabel(drawCmdBuffers[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Third subpass
|
// Third subpass
|
||||||
// Render transparent geometry using a forward pass that compares against depth generated during G-Buffer fill
|
// Render transparent geometry using a forward pass that compares against depth generated during G-Buffer fill
|
||||||
{
|
{
|
||||||
vks::debugmarker::beginRegion(drawCmdBuffers[i], "Subpass 2: Forward transparency", glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
|
vks::debugutils::cmdBeginLabel(drawCmdBuffers[i], "Subpass 2: Forward transparency", { 0.5f, 0.76f, 0.34f, 1.0f });
|
||||||
|
|
||||||
vkCmdNextSubpass(drawCmdBuffers[i], VK_SUBPASS_CONTENTS_INLINE);
|
vkCmdNextSubpass(drawCmdBuffers[i], VK_SUBPASS_CONTENTS_INLINE);
|
||||||
|
|
||||||
|
|
@ -508,7 +508,7 @@ public:
|
||||||
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayouts.transparent, 0, 1, &descriptorSets.transparent, 0, NULL);
|
vkCmdBindDescriptorSets(drawCmdBuffers[i], VK_PIPELINE_BIND_POINT_GRAPHICS, pipelineLayouts.transparent, 0, 1, &descriptorSets.transparent, 0, NULL);
|
||||||
models.transparent.draw(drawCmdBuffers[i]);
|
models.transparent.draw(drawCmdBuffers[i]);
|
||||||
|
|
||||||
vks::debugmarker::endRegion(drawCmdBuffers[i]);
|
vks::debugutils::cmdEndLabel(drawCmdBuffers[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawUI(drawCmdBuffers[i]);
|
drawUI(drawCmdBuffers[i]);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue