Moved debug functions to vks namespace (Refs #260)

This commit is contained in:
saschawillems 2017-02-12 11:33:04 +01:00
parent b31d773b93
commit 132c2be990
5 changed files with 130 additions and 126 deletions

View file

@ -8,11 +8,13 @@
* This code is licensed under the MIT license (MIT) (http://opensource.org/licenses/MIT)
*/
#include "vulkandebug.h"
#include "VulkanDebug.h"
#include <iostream>
namespace vkDebug
namespace vks
{
namespace debug
{
int validationLayerCount = 1;
const char *validationLayerNames[] =
{
@ -109,8 +111,9 @@ namespace vkDebug
DestroyDebugReportCallback(instance, msgCallback, nullptr);
}
}
}
namespace DebugMarker
namespace debugmarker
{
bool active = false;
@ -277,6 +280,5 @@ namespace vkDebug
setObjectName(device, (uint64_t)_event, VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT, name);
}
};
}

View file

@ -21,8 +21,10 @@
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/glm.hpp>
namespace vkDebug
namespace vks
{
namespace debug
{
// Default validation layers
extern int validationLayerCount;
extern const char *validationLayerNames[];
@ -46,13 +48,14 @@ namespace vkDebug
VkDebugReportCallbackEXT callBack);
// Clear debug callback
void freeDebugCallback(VkInstance instance);
}
// 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
// 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
// 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
extern bool active;
@ -95,5 +98,4 @@ namespace vkDebug
void setFenceName(VkDevice device, VkFence fence, const char * name);
void setEventName(VkDevice device, VkEvent _event, const char * name);
};
}

View file

@ -50,8 +50,8 @@ VkResult VulkanExampleBase::createInstance(bool enableValidation)
}
if (settings.validation)
{
instanceCreateInfo.enabledLayerCount = vkDebug::validationLayerCount;
instanceCreateInfo.ppEnabledLayerNames = vkDebug::validationLayerNames;
instanceCreateInfo.enabledLayerCount = vks::debug::validationLayerCount;
instanceCreateInfo.ppEnabledLayerNames = vks::debug::validationLayerNames;
}
return vkCreateInstance(&instanceCreateInfo, nullptr, &instance);
}
@ -164,7 +164,7 @@ void VulkanExampleBase::prepare()
{
if (vulkanDevice->enableDebugMarkers)
{
vkDebug::DebugMarker::setup(device);
vks::debugmarker::setup(device);
}
createCommandPool();
setupSwapChain();
@ -684,7 +684,7 @@ VulkanExampleBase::~VulkanExampleBase()
if (settings.validation)
{
vkDebug::freeDebugCallback(instance);
vks::debug::freeDebugCallback(instance);
}
vkDestroyInstance(instance, nullptr);
@ -735,7 +735,7 @@ void VulkanExampleBase::initVulkan()
// 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;
// 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

View file

@ -39,7 +39,7 @@
#include "keycodes.hpp"
#include "vulkantools.h"
#include "vulkandebug.h"
#include "VulkanDebug.h"
#include "VulkanInitializers.hpp"
#include "VulkanDevice.hpp"

View file

@ -18,7 +18,7 @@
#include <vulkan/vulkan.h>
#include "vulkantools.h"
#include "vulkandebug.h"
#include "VulkanDebug.h"
#include "VulkanBuffer.hpp"
#include "VulkanDevice.hpp"
@ -643,9 +643,9 @@ public:
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);
@ -669,9 +669,9 @@ public:
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]));