Add sample ValidationCache; slightly adjust vk::su::createInstance. (#357)

This commit is contained in:
Andreas Süßenbach 2019-07-09 09:25:48 +02:00 committed by Markus Tavenrath
parent b0bfcfdab5
commit 36691e4946
28 changed files with 42 additions and 63 deletions

View File

@ -26,7 +26,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -26,7 +26,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -30,7 +30,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -28,7 +28,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -26,7 +26,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -27,7 +27,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -30,7 +30,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -30,7 +30,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -54,7 +54,7 @@ int main(int /*argc*/, char ** /*argv*/)
(loader_major_version == desiredMajorVersion && loader_minor_version >= desiredMinorVersion)) (loader_major_version == desiredMajorVersion && loader_minor_version >= desiredMinorVersion))
{ {
// Create the instance // Create the instance
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions(), desiredVersion); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions(), desiredVersion);
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -25,7 +25,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -30,7 +30,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -30,7 +30,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -26,7 +26,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -30,7 +30,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -30,7 +30,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -58,7 +58,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -80,7 +80,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -30,7 +30,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -62,7 +62,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -22,37 +22,6 @@
#include "vulkan/vulkan.hpp" #include "vulkan/vulkan.hpp"
#include "SPIRV/GlslangToSpv.h" #include "SPIRV/GlslangToSpv.h"
// For timestamp code (getMilliseconds)
#ifdef WIN32
#include <Windows.h>
#else
#include <sys/time.h>
#endif
typedef unsigned long long timestamp_t;
timestamp_t getMilliseconds()
{
#ifdef WIN32
LARGE_INTEGER frequency;
BOOL useQPC = QueryPerformanceFrequency(&frequency);
if (useQPC)
{
LARGE_INTEGER now;
QueryPerformanceCounter(&now);
return (1000LL * now.QuadPart) / frequency.QuadPart;
}
else
{
return GetTickCount();
}
#else
struct timeval now;
gettimeofday(&now, NULL);
return (now.tv_usec / 1000) + (timestamp_t)now.tv_sec;
#endif
}
static char const* AppName = "PipelineDerivative"; static char const* AppName = "PipelineDerivative";
static char const* EngineName = "Vulkan.hpp"; static char const* EngineName = "Vulkan.hpp";
@ -60,7 +29,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -71,7 +71,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -43,7 +43,7 @@ int main(int /*argc*/, char ** /*argv*/)
std::vector<std::string> instanceExtensions = vk::su::getInstanceExtensions(); std::vector<std::string> instanceExtensions = vk::su::getInstanceExtensions();
instanceExtensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); instanceExtensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, instanceExtensions); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, instanceExtensions);
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -30,7 +30,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -60,7 +60,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -30,7 +30,7 @@ int main(int /*argc*/, char ** /*argv*/)
{ {
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -57,7 +57,7 @@ int main(int /*argc*/, char ** /*argv*/)
try try
{ {
vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, vk::su::getInstanceExtensions()); vk::UniqueInstance instance = vk::su::createInstance(AppName, EngineName, {}, vk::su::getInstanceExtensions());
#if !defined(NDEBUG) #if !defined(NDEBUG)
vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance); vk::UniqueDebugReportCallbackEXT debugReportCallback = vk::su::createDebugReportCallback(instance);
#endif #endif

View File

@ -169,12 +169,21 @@ namespace vk
return device->createGraphicsPipelineUnique(pipelineCache.get(), graphicsPipelineCreateInfo); return device->createGraphicsPipelineUnique(pipelineCache.get(), graphicsPipelineCreateInfo);
} }
vk::UniqueInstance createInstance(std::string const& appName, std::string const& engineName, std::vector<std::string> const& extensions, uint32_t apiVersion) vk::UniqueInstance createInstance(std::string const& appName, std::string const& engineName, std::vector<std::string> const& layers, std::vector<std::string> const& extensions,
uint32_t apiVersion)
{ {
std::vector<char const*> enabledLayers; std::vector<char const*> enabledLayers;
enabledLayers.reserve(layers.size());
for (auto const& layer : layers)
{
enabledLayers.push_back(layer.data());
}
#if !defined(NDEBUG) #if !defined(NDEBUG)
// Enable standard validation layer to find as much errors as possible! // Enable standard validation layer to find as much errors as possible!
if (std::find(layers.begin(), layers.end(), "VK_LAYER_KHRONOS_validation") == layers.end())
{
enabledLayers.push_back("VK_LAYER_KHRONOS_validation"); enabledLayers.push_back("VK_LAYER_KHRONOS_validation");
}
#endif #endif
std::vector<char const*> enabledExtensions; std::vector<char const*> enabledExtensions;
@ -823,15 +832,15 @@ namespace vk
std::ostream& operator<<(std::ostream& os, vk::su::UUID const& uuid) std::ostream& operator<<(std::ostream& os, vk::su::UUID const& uuid)
{ {
os << std::setfill('0'); os << std::setfill('0') << std::hex;
for (int j = 0; j < VK_UUID_SIZE; ++j) for (int j = 0; j < VK_UUID_SIZE; ++j)
{ {
os << std::hex << std::setw(2) << static_cast<uint32_t>(uuid.m_data[j]); os << std::setw(2) << static_cast<uint32_t>(uuid.m_data[j]);
if (j == 3 || j == 5 || j == 7 || j == 9) if (j == 3 || j == 5 || j == 7 || j == 9)
{ {
std::cout << '-'; std::cout << '-';
} }
} }
os << std::setfill(' '); os << std::setfill(' ') << std::dec;
return os; return os;
} }

View File

@ -262,7 +262,8 @@ namespace vk
std::pair<vk::ShaderModule, vk::SpecializationInfo const*> const& fragmentShaderData, uint32_t vertexStride, std::pair<vk::ShaderModule, vk::SpecializationInfo const*> const& fragmentShaderData, uint32_t vertexStride,
std::vector<std::pair<vk::Format, uint32_t>> const& vertexInputAttributeFormatOffset, vk::FrontFace frontFace, bool depthBuffered, std::vector<std::pair<vk::Format, uint32_t>> const& vertexInputAttributeFormatOffset, vk::FrontFace frontFace, bool depthBuffered,
vk::UniquePipelineLayout const& pipelineLayout, vk::UniqueRenderPass const& renderPass); vk::UniquePipelineLayout const& pipelineLayout, vk::UniqueRenderPass const& renderPass);
vk::UniqueInstance createInstance(std::string const& appName, std::string const& engineName, std::vector<std::string> const& extensions = {}, uint32_t apiVersion = VK_API_VERSION_1_0); vk::UniqueInstance createInstance(std::string const& appName, std::string const& engineName, std::vector<std::string> const& layers = {}, std::vector<std::string> const& extensions = {},
uint32_t apiVersion = VK_API_VERSION_1_0);
vk::UniqueRenderPass createRenderPass(vk::UniqueDevice &device, vk::Format colorFormat, vk::Format depthFormat, vk::AttachmentLoadOp loadOp = vk::AttachmentLoadOp::eClear, vk::ImageLayout colorFinalLayout = vk::ImageLayout::ePresentSrcKHR); vk::UniqueRenderPass createRenderPass(vk::UniqueDevice &device, vk::Format colorFormat, vk::Format depthFormat, vk::AttachmentLoadOp loadOp = vk::AttachmentLoadOp::eClear, vk::ImageLayout colorFinalLayout = vk::ImageLayout::ePresentSrcKHR);
VkBool32 debugReportCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData); VkBool32 debugReportCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objectType, uint64_t object, size_t location, int32_t messageCode, const char* pLayerPrefix, const char* pMessage, void* pUserData);
uint32_t findGraphicsQueueFamilyIndex(std::vector<vk::QueueFamilyProperties> const& queueFamilyProperties); uint32_t findGraphicsQueueFamilyIndex(std::vector<vk::QueueFamilyProperties> const& queueFamilyProperties);