Moved debug functions to vks namespace (Refs #260)
This commit is contained in:
parent
b31d773b93
commit
132c2be990
5 changed files with 130 additions and 126 deletions
|
|
@ -8,11 +8,13 @@
|
||||||
* 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>
|
||||||
|
|
||||||
namespace vkDebug
|
namespace vks
|
||||||
{
|
{
|
||||||
|
namespace debug
|
||||||
|
{
|
||||||
int validationLayerCount = 1;
|
int validationLayerCount = 1;
|
||||||
const char *validationLayerNames[] =
|
const char *validationLayerNames[] =
|
||||||
{
|
{
|
||||||
|
|
@ -109,8 +111,9 @@ namespace vkDebug
|
||||||
DestroyDebugReportCallback(instance, msgCallback, nullptr);
|
DestroyDebugReportCallback(instance, msgCallback, nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace DebugMarker
|
namespace debugmarker
|
||||||
{
|
{
|
||||||
bool active = false;
|
bool active = false;
|
||||||
|
|
||||||
|
|
@ -277,6 +280,5 @@ namespace vkDebug
|
||||||
setObjectName(device, (uint64_t)_event, VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT, name);
|
setObjectName(device, (uint64_t)_event, VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT, name);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -21,8 +21,10 @@
|
||||||
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
namespace vkDebug
|
namespace vks
|
||||||
{
|
{
|
||||||
|
namespace debug
|
||||||
|
{
|
||||||
// Default validation layers
|
// Default validation layers
|
||||||
extern int validationLayerCount;
|
extern int validationLayerCount;
|
||||||
extern const char *validationLayerNames[];
|
extern const char *validationLayerNames[];
|
||||||
|
|
@ -46,13 +48,14 @@ namespace vkDebug
|
||||||
VkDebugReportCallbackEXT callBack);
|
VkDebugReportCallbackEXT callBack);
|
||||||
// Clear debug callback
|
// Clear debug callback
|
||||||
void freeDebugCallback(VkInstance instance);
|
void freeDebugCallback(VkInstance instance);
|
||||||
|
}
|
||||||
|
|
||||||
// Setup and functions for the VK_EXT_debug_marker_extension
|
// Setup and functions for the VK_EXT_debug_marker_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
|
// 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
|
||||||
// Note that the extension will only be present if run from an offline debugging application
|
// Note that the extension will only be present if run from an offline debugging application
|
||||||
// The actual check for extension presence and enabling it on the device is done in the example base class
|
// 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)
|
// See VulkanExampleBase::createInstance and VulkanExampleBase::createDevice (base/vulkanexamplebase.cpp)
|
||||||
namespace DebugMarker
|
namespace debugmarker
|
||||||
{
|
{
|
||||||
// Set to true if function pointer for the debug marker are available
|
// Set to true if function pointer for the debug marker are available
|
||||||
extern bool active;
|
extern bool active;
|
||||||
|
|
@ -95,5 +98,4 @@ namespace vkDebug
|
||||||
void setFenceName(VkDevice device, VkFence fence, const char * name);
|
void setFenceName(VkDevice device, VkFence fence, const char * name);
|
||||||
void setEventName(VkDevice device, VkEvent _event, const char * name);
|
void setEventName(VkDevice device, VkEvent _event, const char * name);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -50,8 +50,8 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
|
||||||
}
|
}
|
||||||
if (settings.validation)
|
if (settings.validation)
|
||||||
{
|
{
|
||||||
instanceCreateInfo.enabledLayerCount = vkDebug::validationLayerCount;
|
instanceCreateInfo.enabledLayerCount = vks::debug::validationLayerCount;
|
||||||
instanceCreateInfo.ppEnabledLayerNames = vkDebug::validationLayerNames;
|
instanceCreateInfo.ppEnabledLayerNames = vks::debug::validationLayerNames;
|
||||||
}
|
}
|
||||||
return vkCreateInstance(&instanceCreateInfo, nullptr, &instance);
|
return vkCreateInstance(&instanceCreateInfo, nullptr, &instance);
|
||||||
}
|
}
|
||||||
|
|
@ -164,7 +164,7 @@ void VulkanExampleBase::prepare()
|
||||||
{
|
{
|
||||||
if (vulkanDevice->enableDebugMarkers)
|
if (vulkanDevice->enableDebugMarkers)
|
||||||
{
|
{
|
||||||
vkDebug::DebugMarker::setup(device);
|
vks::debugmarker::setup(device);
|
||||||
}
|
}
|
||||||
createCommandPool();
|
createCommandPool();
|
||||||
setupSwapChain();
|
setupSwapChain();
|
||||||
|
|
@ -684,7 +684,7 @@ VulkanExampleBase::~VulkanExampleBase()
|
||||||
|
|
||||||
if (settings.validation)
|
if (settings.validation)
|
||||||
{
|
{
|
||||||
vkDebug::freeDebugCallback(instance);
|
vks::debug::freeDebugCallback(instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
vkDestroyInstance(instance, nullptr);
|
vkDestroyInstance(instance, nullptr);
|
||||||
|
|
@ -735,7 +735,7 @@ void VulkanExampleBase::initVulkan()
|
||||||
// For validating (debugging) an appplication the error and warning bits should suffice
|
// For validating (debugging) an appplication the error and warning bits should suffice
|
||||||
VkDebugReportFlagsEXT debugReportFlags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
|
VkDebugReportFlagsEXT debugReportFlags = VK_DEBUG_REPORT_ERROR_BIT_EXT | VK_DEBUG_REPORT_WARNING_BIT_EXT | VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT;
|
||||||
// Additional flags include performance info, loader and layer debug messages, etc.
|
// Additional flags include performance info, loader and layer debug messages, etc.
|
||||||
vkDebug::setupDebugging(instance, debugReportFlags, VK_NULL_HANDLE);
|
vks::debug::setupDebugging(instance, debugReportFlags, VK_NULL_HANDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Physical device
|
// Physical device
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
#include "keycodes.hpp"
|
#include "keycodes.hpp"
|
||||||
#include "vulkantools.h"
|
#include "vulkantools.h"
|
||||||
#include "vulkandebug.h"
|
#include "VulkanDebug.h"
|
||||||
|
|
||||||
#include "VulkanInitializers.hpp"
|
#include "VulkanInitializers.hpp"
|
||||||
#include "VulkanDevice.hpp"
|
#include "VulkanDevice.hpp"
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include "vulkantools.h"
|
#include "vulkantools.h"
|
||||||
#include "vulkandebug.h"
|
#include "VulkanDebug.h"
|
||||||
#include "VulkanBuffer.hpp"
|
#include "VulkanBuffer.hpp"
|
||||||
#include "VulkanDevice.hpp"
|
#include "VulkanDevice.hpp"
|
||||||
|
|
||||||
|
|
@ -643,9 +643,9 @@ public:
|
||||||
|
|
||||||
VK_CHECK_RESULT(vkBeginCommandBuffer(cmdBuffers[i], &cmdBufInfo));
|
VK_CHECK_RESULT(vkBeginCommandBuffer(cmdBuffers[i], &cmdBufInfo));
|
||||||
|
|
||||||
if (vkDebug::DebugMarker::active)
|
if (vks::debugmarker::active)
|
||||||
{
|
{
|
||||||
vkDebug::DebugMarker::beginRegion(cmdBuffers[i], "Text overlay", glm::vec4(1.0f, 0.94f, 0.3f, 1.0f));
|
vks::debugmarker::beginRegion(cmdBuffers[i], "Text overlay", glm::vec4(1.0f, 0.94f, 0.3f, 1.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
vkCmdBeginRenderPass(cmdBuffers[i], &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
|
vkCmdBeginRenderPass(cmdBuffers[i], &renderPassBeginInfo, VK_SUBPASS_CONTENTS_INLINE);
|
||||||
|
|
@ -669,9 +669,9 @@ public:
|
||||||
|
|
||||||
vkCmdEndRenderPass(cmdBuffers[i]);
|
vkCmdEndRenderPass(cmdBuffers[i]);
|
||||||
|
|
||||||
if (vkDebug::DebugMarker::active)
|
if (vks::debugmarker::active)
|
||||||
{
|
{
|
||||||
vkDebug::DebugMarker::endRegion(cmdBuffers[i]);
|
vks::debugmarker::endRegion(cmdBuffers[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
VK_CHECK_RESULT(vkEndCommandBuffer(cmdBuffers[i]));
|
VK_CHECK_RESULT(vkEndCommandBuffer(cmdBuffers[i]));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue