From 707f27736621a2394ebca4b24d0fc06606c5e3b0 Mon Sep 17 00:00:00 2001 From: Squareys Date: Tue, 26 Apr 2016 17:36:47 +0200 Subject: [PATCH] WIP --- src/Magnum/Test/ContextTest.cpp | 20 +++++++++++++------- src/Magnum/Vk/Context.cpp | 15 ++++++++++++++- src/Magnum/Vk/Context.h | 1 + 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/Magnum/Test/ContextTest.cpp b/src/Magnum/Test/ContextTest.cpp index bad9274ee..49744edde 100644 --- a/src/Magnum/Test/ContextTest.cpp +++ b/src/Magnum/Test/ContextTest.cpp @@ -3,6 +3,7 @@ Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 Vladimír Vondruš + Copyright © 2016 Jonathan Hale Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), @@ -33,21 +34,26 @@ namespace Magnum { namespace Test { struct ContextTest: TestSuite::Tester { explicit ContextTest(); - void debugFlag(); + void createAndDestroy(); + void flag(); + void result(); }; ContextTest::ContextTest() { - addTests({&ContextTest::debugFlag}); + addTests({&ContextTest::createAndDestroy, + &ContextTest::flag, + &ContextTest::result}); } -void ContextTest::debugFlag() { - #ifdef MAGNUM_TARGET_WEBGL - CORRADE_SKIP("No context flags on Emscripten yet."); - #else +void ContextTest::createAndDestroy() { + Vk::Context c{{}}; + CORRADE_COMPARE(c.version(), Vk::Version::Vulkan_1_0); +} + +void ContextTest::flag() { std::ostringstream out; Debug(&out) << Context::Flag::Debug << Context::Flag(0xdead); CORRADE_COMPARE(out.str(), "Context::Flag::Debug Context::Flag(0xdead)\n"); - #endif } }} diff --git a/src/Magnum/Vk/Context.cpp b/src/Magnum/Vk/Context.cpp index 6a63e3b6e..8704c00b4 100644 --- a/src/Magnum/Vk/Context.cpp +++ b/src/Magnum/Vk/Context.cpp @@ -102,11 +102,13 @@ VkBool32 messageCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT } bool Context::tryCreate() { + _version = Version::Vulkan_1_0; + VkApplicationInfo appInfo = {}; appInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; appInfo.pApplicationName = "Vulkan Example"; appInfo.pEngineName = "Magnum"; - appInfo.apiVersion = UnsignedInt(Version::Vulkan_1_0); + appInfo.apiVersion = UnsignedInt(_version); std::vector enabledExtensions = { VK_KHR_SURFACE_EXTENSION_NAME }; @@ -204,4 +206,15 @@ Debug& operator<<(Debug& debug, Context::Flag value) { return debug << "Context::Flag::(invalid)"; } +Debug& operator<<(Debug& debug, Version value) { + switch(value) { + #define _c(value) case Version::value: return debug << "Vk::Version::" #value; + _c(None) + _c(Vulkan_1_0) + #undef _c + } + + return debug << "Vk::Version::(invalid)"; +} + }} diff --git a/src/Magnum/Vk/Context.h b/src/Magnum/Vk/Context.h index 429054371..0d63b1b6e 100644 --- a/src/Magnum/Vk/Context.h +++ b/src/Magnum/Vk/Context.h @@ -185,6 +185,7 @@ class MAGNUM_VK_EXPORT Context { MAGNUM_VK_EXPORT Debug& operator<<(Debug& debug, Result value); MAGNUM_VK_EXPORT Debug& operator<<(Debug& debug, Context::Flag value); +MAGNUM_VK_EXPORT Debug& operator<<(Debug& debug, Version value); }}