Browse Source

Vk: Rename Context to Instance to match Vulkan naming

Signed-off-by: Squareys <squareys@googlemail.com>
pull/202/head
Squareys 10 years ago committed by Squareys
parent
commit
cac8f8552c
  1. 4
      src/Magnum/Platform/GlfwApplication.cpp
  2. 4
      src/Magnum/Vk/CMakeLists.txt
  3. 2
      src/Magnum/Vk/CommandBuffer.h
  4. 2
      src/Magnum/Vk/Device.h
  5. 59
      src/Magnum/Vk/Instance.cpp
  6. 59
      src/Magnum/Vk/Instance.h
  7. 4
      src/Magnum/Vk/Queue.h
  8. 4
      src/Magnum/Vk/Swapchain.cpp
  9. 2
      src/Magnum/Vk/Swapchain.h
  10. 4
      src/Magnum/Vk/Test/CommandTest.cpp
  11. 28
      src/Magnum/Vk/Test/ContextTest.cpp
  12. 44
      src/Magnum/Vk/Test/ContextVkTest.cpp

4
src/Magnum/Platform/GlfwApplication.cpp

@ -34,7 +34,7 @@
#include "Magnum/Platform/ScreenedApplication.hpp" #include "Magnum/Platform/ScreenedApplication.hpp"
#ifdef MAGNUM_TARGET_VULKAN #ifdef MAGNUM_TARGET_VULKAN
#include "Magnum/Vk/Context.h" #include "Magnum/Vk/Instance.h"
#endif #endif
namespace Magnum { namespace Platform { namespace Magnum { namespace Platform {
@ -247,7 +247,7 @@ void GlfwApplication::mouseScrollEvent(MouseScrollEvent&) {}
VkSurfaceKHR GlfwApplication::createVkSurface() { VkSurfaceKHR GlfwApplication::createVkSurface() {
VkSurfaceKHR surface; VkSurfaceKHR surface;
VkResult res = glfwCreateWindowSurface(Magnum::Vk::Context::current().vkInstance(), _window, nullptr, &surface); VkResult res = glfwCreateWindowSurface(Magnum::Vk::Instance::current(), _window, nullptr, &surface);
if(res != VK_SUCCESS) { if(res != VK_SUCCESS) {
Error() << "Vulkan Surface creation failed."; Error() << "Vulkan Surface creation failed.";
} }

4
src/Magnum/Vk/CMakeLists.txt

@ -31,7 +31,7 @@ set(MagnumVk_SRCS
Buffer.cpp Buffer.cpp
CommandBuffer.cpp CommandBuffer.cpp
CommandPool.cpp CommandPool.cpp
Context.cpp Instance.cpp
DescriptorPool.cpp DescriptorPool.cpp
DescriptorSet.cpp DescriptorSet.cpp
Device.cpp Device.cpp
@ -52,7 +52,7 @@ set(MagnumVk_HEADERS
Command.h Command.h
CommandBuffer.h CommandBuffer.h
CommandPool.h CommandPool.h
Context.h Instance.h
DescriptorPool.h DescriptorPool.h
DescriptorSet.h DescriptorSet.h
Device.h Device.h

2
src/Magnum/Vk/CommandBuffer.h

@ -32,7 +32,7 @@
#include "Magnum/Magnum.h" #include "Magnum/Magnum.h"
#include "Magnum/Math/Range.h" #include "Magnum/Math/Range.h"
#include "Magnum/Vk/Context.h" #include "Magnum/Vk/Instance.h"
#include "Magnum/Vk/RenderPass.h" #include "Magnum/Vk/RenderPass.h"
#include "Magnum/Vk/Framebuffer.h" #include "Magnum/Vk/Framebuffer.h"
#include "Magnum/Vk/visibility.h" #include "Magnum/Vk/visibility.h"

2
src/Magnum/Vk/Device.h

@ -33,7 +33,7 @@
#include <memory> #include <memory>
#include "Magnum/Magnum.h" #include "Magnum/Magnum.h"
#include "Magnum/Vk/Context.h" #include "Magnum/Vk/Instance.h"
#include "Magnum/Vk/PhysicalDevice.h" #include "Magnum/Vk/PhysicalDevice.h"
#include "Magnum/Vk/visibility.h" #include "Magnum/Vk/visibility.h"

59
src/Magnum/Vk/Context.cpp → src/Magnum/Vk/Instance.cpp

@ -23,13 +23,12 @@
DEALINGS IN THE SOFTWARE. DEALINGS IN THE SOFTWARE.
*/ */
#include "Context.h" #include "Instance.h"
#include <Corrade/Utility/Arguments.h> #include <Corrade/Utility/Arguments.h>
#include <Corrade/Utility/Assert.h> #include <Corrade/Utility/Assert.h>
#include <Corrade/Utility/String.h> #include <Corrade/Utility/String.h>
#include "vulkan.h" #include <Corrade/Containers/Array.h>
namespace Magnum { namespace Vk { namespace Magnum { namespace Vk {
@ -47,29 +46,29 @@ const char *validationLayerNames[] =
"VK_LAYER_LUNARG_api_dump" "VK_LAYER_LUNARG_api_dump"
}; };
Context* Context::_current = nullptr; Instance* Instance::_current = nullptr;
bool Context::hasCurrent() { return _current; } bool Instance::hasCurrent() { return _current; }
Context& Context::current() { Instance& Instance::current() {
CORRADE_ASSERT(_current, "Context::current(): no current context", *_current); CORRADE_ASSERT(_current, "Instance::current(): no current Instance", *_current);
return *_current; return *_current;
} }
Context::Context(): Context{Flags{}} {} Instance::Instance(): Instance{Flags{}} {}
Context::Context(Flags flags): _functionLoader{nullptr}, _version{Version::None}, _flags(flags) { Instance::Instance(Flags flags): _functionLoader{nullptr}, _version{Version::None}, _flags(flags) {
create(); create();
} }
Context::Context(Context&& other): _version{std::move(other._version)}, Instance::Instance(Instance&& other): _version{std::move(other._version)},
_flags{std::move(other._flags)} _flags{std::move(other._flags)}
{ {
if(_current == &other) _current = this; if(_current == &other) _current = this;
} }
Context::~Context() { Instance::~Instance() {
if(_current == this) _current = nullptr; if(_current == this) _current = nullptr;
if(_instance == nullptr) { if(_instance == nullptr) {
@ -83,8 +82,8 @@ Context::~Context() {
vkDestroyInstance(_instance, nullptr); vkDestroyInstance(_instance, nullptr);
} }
void Context::create() { void Instance::create() {
/* Hard exit if the context cannot be created */ /* Hard exit if the Instance cannot be created */
if(!tryCreate()) std::exit(1); if(!tryCreate()) std::exit(1);
} }
@ -111,7 +110,7 @@ VKAPI_ATTR VkBool32 VKAPI_CALL MyDebugReportCallback(
return VK_FALSE; return VK_FALSE;
} }
bool Context::tryCreate() { bool Instance::tryCreate() {
_version = Version::Vulkan_1_0; _version = Version::Vulkan_1_0;
VkApplicationInfo appInfo = {}; VkApplicationInfo appInfo = {};
@ -183,10 +182,34 @@ bool Context::tryCreate() {
return true; return true;
} }
bool Context::isVersionSupported(Version) const { bool Instance::isVersionSupported(Version) const {
return true; return true;
} }
Containers::Array<PhysicalDevice> Instance::enumeratePhysicalDevices() {
// Physical device
UnsignedInt gpuCount = 0;
// Get number of available physical devices
VkResult err = vkEnumeratePhysicalDevices(*this, &gpuCount, nullptr);
MAGNUM_VK_ASSERT_ERROR(err);
if(gpuCount <= 0) {
Error() << "No GPU with Vulkan support found.";
return {};
}
std::vector<VkPhysicalDevice> physicalDevicesVk(gpuCount);
err = vkEnumeratePhysicalDevices(*this, &gpuCount, physicalDevicesVk.data());
MAGNUM_VK_ASSERT_ERROR(err);
Containers::Array<PhysicalDevice> physicalDevices{Containers::NoInit, physicalDevicesVk.size()};
for(int i = 0; i < physicalDevices.size(); ++i) {
new(&physicalDevices[i]) PhysicalDevice{physicalDevicesVk[i]};
}
return physicalDevices;
}
Debug& operator<<(Debug& debug, Result value) { Debug& operator<<(Debug& debug, Result value) {
switch(value) { switch(value) {
#define _c(value) case Result::value: return debug << "Vk::Result::" #value; #define _c(value) case Result::value: return debug << "Vk::Result::" #value;
@ -222,14 +245,14 @@ Debug& operator<<(Debug& debug, Result value) {
return debug << "Vk::Result::(invalid)"; return debug << "Vk::Result::(invalid)";
} }
Debug& operator<<(Debug& debug, Context::Flag value) { Debug& operator<<(Debug& debug, Instance::Flag value) {
switch(value) { switch(value) {
#define _c(value) case Context::Flag::value: return debug << "Context::Flag::" #value; #define _c(value) case Instance::Flag::value: return debug << "Instance::Flag::" #value;
_c(EnableValidation) _c(EnableValidation)
#undef _c #undef _c
} }
return debug << "Context::Flag::(invalid)"; return debug << "Instance::Flag::(invalid)";
} }
Debug& operator<<(Debug& debug, Version value) { Debug& operator<<(Debug& debug, Version value) {

59
src/Magnum/Vk/Context.h → src/Magnum/Vk/Instance.h

@ -1,5 +1,5 @@
#ifndef Magnum_Vk_Context_h #ifndef Magnum_Vk_Instance_h
#define Magnum_Vk_Context_h #define Magnum_Vk_Instance_h
/* /*
This file is part of Magnum. This file is part of Magnum.
@ -27,7 +27,7 @@
*/ */
/** @file /** @file
* @brief Class @ref Magnum::Vk::Context * @brief Class @ref Magnum::Vk::Instance
*/ */
#include "vulkan.h" #include "vulkan.h"
@ -41,6 +41,7 @@
#include "Magnum/Tags.h" #include "Magnum/Tags.h"
#include "Magnum/Magnum.h" #include "Magnum/Magnum.h"
#include "Magnum/Vk/PhysicalDevice.h"
#include "Magnum/Vk/visibility.h" #include "Magnum/Vk/visibility.h"
#include "MagnumExternal/Optional/optional.hpp" #include "MagnumExternal/Optional/optional.hpp"
@ -94,20 +95,20 @@ enum class Result: Int {
}; };
/** /**
@brief Magnum context @brief Magnum Instance
Provides access to version and extension information. Instance available Provides access to version and extension information. Instance available
through @ref Context::current() is automatically created during construction of through @ref Instance::current() is automatically created during construction of
`*Application` classes in @ref Platform namespace. You can safely assume that `*Application` classes in @ref Platform namespace. You can safely assume that
the instance is available during whole lifetime of `*Application` object. It's the instance is available during whole lifetime of `*Application` object. It's
also possible to create the context without using any `*Application` class also possible to create the Instance without using any `*Application` class
using @ref Platform::Context subclass, see @ref platform documentation for more using @ref Platform::Instance subclass, see @ref platform documentation for more
information. information.
## Command-line options ## Command-line options
The context is configurable through command-line options, that are passed The Instance is configurable through command-line options, that are passed
either from the `Platform::*Application` classes or from the @ref Platform::Context either from the `Platform::*Application` classes or from the @ref Platform::Instance
class. Usage: class. Usage:
<application> [--magnum-help] ... <application> [--magnum-help] ...
@ -117,10 +118,10 @@ Arguments:
- `...` -- main application arguments (see `-h` or `--help` for details) - `...` -- main application arguments (see `-h` or `--help` for details)
- `--magnum-help` -- display this help message and exit - `--magnum-help` -- display this help message and exit
*/ */
class MAGNUM_VK_EXPORT Context { class MAGNUM_VK_EXPORT Instance {
public: public:
/** /**
* @brief Context flag * @brief Instance flag
* *
* @see @ref Flags, @ref flags(), * @see @ref Flags, @ref flags(),
* @ref Platform::Sdl2Application::Configuration::setFlags() "Platform::*Application::Configuration::setFlags()" * @ref Platform::Sdl2Application::Configuration::setFlags() "Platform::*Application::Configuration::setFlags()"
@ -130,58 +131,58 @@ class MAGNUM_VK_EXPORT Context {
}; };
/** /**
* @brief Context flags * @brief Instance flags
* *
* @see @ref flags() * @see @ref flags()
*/ */
typedef Containers::EnumSet<Flag> Flags; typedef Containers::EnumSet<Flag> Flags;
/** /**
* @brief Whether there is any current context * @brief Whether there is any current Instance
* *
* @see @ref current() * @see @ref current()
*/ */
static bool hasCurrent(); static bool hasCurrent();
/** /**
* @brief Current context * @brief Current Instance
* *
* Expect that there is current context. * Expect that there is current Instance.
* @see @ref hasCurrent() * @see @ref hasCurrent()
*/ */
static Context& current(); static Instance& current();
/** @brief Constructor */ /** @brief Constructor */
Context(); Instance();
/** /**
* @brief Constructor with flags * @brief Constructor with flags
*/ */
Context(Flags flags); Instance(Flags flags);
/** @brief Copying is not allowed */ /** @brief Copying is not allowed */
Context(const Context&) = delete; Instance(const Instance&) = delete;
/** @brief Move constructor */ /** @brief Move constructor */
Context(Context&& other); Instance(Instance&& other);
/** /**
* @brief Destructor * @brief Destructor
* *
* @see @fn_vk{DestroyInstance} * @see @fn_vk{DestroyInstance}
*/ */
~Context(); ~Instance();
/** @brief Copying is not allowed */ /** @brief Copying is not allowed */
Context& operator=(const Context&) = delete; Instance& operator=(const Instance&) = delete;
/** @brief Move assignment is not allowed */ /** @brief Move assignment is not allowed */
Context& operator=(Context&&) = delete; Instance& operator=(Instance&&) = delete;
/** @brief Vulkan version */ /** @brief Vulkan version */
Version version() const { return _version; } Version version() const { return _version; }
/** @brief Context flags */ /** @brief Instance flags */
Flags flags() const { return _flags; } Flags flags() const { return _flags; }
/** /**
@ -191,14 +192,16 @@ class MAGNUM_VK_EXPORT Context {
*/ */
bool isVersionSupported(Version version) const; bool isVersionSupported(Version version) const;
VkInstance vkInstance() { operator VkInstance() {
return _instance; return _instance;
} }
Containers::Array<PhysicalDevice> enumeratePhysicalDevices();
private: private:
MAGNUM_VK_LOCAL static Context* _current; MAGNUM_VK_LOCAL static Instance* _current;
explicit Context(NoCreateT, Int argc, char** argv, void functionLoader()); explicit Instance(NoCreateT, Int argc, char** argv, void functionLoader());
bool tryCreate(); bool tryCreate();
void create(); void create();
@ -212,7 +215,7 @@ class MAGNUM_VK_EXPORT Context {
}; };
MAGNUM_VK_EXPORT Debug& operator<<(Debug& debug, Result value); 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, Instance::Flag value);
MAGNUM_VK_EXPORT Debug& operator<<(Debug& debug, Version value); MAGNUM_VK_EXPORT Debug& operator<<(Debug& debug, Version value);
}} }}

4
src/Magnum/Vk/Queue.h

@ -32,7 +32,7 @@
#include "Magnum/Magnum.h" #include "Magnum/Magnum.h"
#include "Magnum/Vk/CommandBuffer.h" #include "Magnum/Vk/CommandBuffer.h"
#include "Magnum/Vk/Context.h" #include "Magnum/Vk/Instance.h"
#include "Magnum/Vk/Device.h" #include "Magnum/Vk/Device.h"
#include "Magnum/Vk/Semaphore.h" #include "Magnum/Vk/Semaphore.h"
#include "Magnum/Vk/visibility.h" #include "Magnum/Vk/visibility.h"
@ -44,7 +44,7 @@ class MAGNUM_VK_EXPORT Queue {
public: public:
/** @brief Copying is not allowed */ /** @brief Copying is not allowed */
Queue(const Context&) = delete; Queue(const Queue&) = delete;
/** @brief Move constructor */ /** @brief Move constructor */
Queue(Queue&& other); Queue(Queue&& other);

4
src/Magnum/Vk/Swapchain.cpp

@ -42,7 +42,7 @@ Swapchain::Swapchain(Device& device, CommandBuffer& cb, VkSurfaceKHR surface):
VkDevice vkDevice = _device.vkDevice(); VkDevice vkDevice = _device.vkDevice();
VkPhysicalDevice vkPhysicalDevice = _device.physicalDevice().vkPhysicalDevice(); VkPhysicalDevice vkPhysicalDevice = _device.physicalDevice().vkPhysicalDevice();
#define GET_INSTANCE_PROC_ADDR(entrypoint) vk##entrypoint = PFN_vk##entrypoint(vkGetInstanceProcAddr(Vk::Context::current().vkInstance(), "vk"#entrypoint)); do{if(vk##entrypoint == nullptr) { Error() << "Failed to get function pointer.";} }while(false) #define GET_INSTANCE_PROC_ADDR(entrypoint) vk##entrypoint = PFN_vk##entrypoint(vkGetInstanceProcAddr(Vk::Instance::current(), "vk"#entrypoint)); do{if(vk##entrypoint == nullptr) { Error() << "Failed to get function pointer.";} }while(false)
#define GET_DEVICE_PROC_ADDR(entrypoint) vk##entrypoint = PFN_vk##entrypoint(vkGetDeviceProcAddr(vkDevice, "vk"#entrypoint)); do{ if(vk##entrypoint == nullptr) { Error() << "Failed to get function pointer.";} }while(false) #define GET_DEVICE_PROC_ADDR(entrypoint) vk##entrypoint = PFN_vk##entrypoint(vkGetDeviceProcAddr(vkDevice, "vk"#entrypoint)); do{ if(vk##entrypoint == nullptr) { Error() << "Failed to get function pointer.";} }while(false)
GET_INSTANCE_PROC_ADDR(GetPhysicalDeviceSurfaceSupportKHR); GET_INSTANCE_PROC_ADDR(GetPhysicalDeviceSurfaceSupportKHR);
@ -281,7 +281,7 @@ Swapchain::Swapchain(Device& device, CommandBuffer& cb, VkSurfaceKHR surface):
Swapchain::~Swapchain() { Swapchain::~Swapchain() {
vkDestroySwapchainKHR(_device, _swapchain, nullptr); vkDestroySwapchainKHR(_device, _swapchain, nullptr);
vkDestroySurfaceKHR(Vk::Context::current().vkInstance(), _surface, nullptr); vkDestroySurfaceKHR(Vk::Instance::current(), _surface, nullptr);
} }
Swapchain& Swapchain::queuePresent(VkQueue queue, UnsignedInt currentBuffer) { Swapchain& Swapchain::queuePresent(VkQueue queue, UnsignedInt currentBuffer) {

2
src/Magnum/Vk/Swapchain.h

@ -32,7 +32,7 @@
#include "Magnum/Magnum.h" #include "Magnum/Magnum.h"
#include "Magnum/Vk/CommandBuffer.h" #include "Magnum/Vk/CommandBuffer.h"
#include "Magnum/Vk/Context.h" #include "Magnum/Vk/Instance.h"
#include "Magnum/Vk/Device.h" #include "Magnum/Vk/Device.h"
#include "Magnum/Vk/ImageView.h" #include "Magnum/Vk/ImageView.h"
#include "Magnum/Vk/Semaphore.h" #include "Magnum/Vk/Semaphore.h"

4
src/Magnum/Vk/Test/CommandTest.cpp

@ -29,7 +29,7 @@
#include <algorithm> #include <algorithm>
#include "Magnum/Vk/Command.h" #include "Magnum/Vk/Command.h"
#include "Magnum/Vk/Context.h" #include "Magnum/Vk/Instance.h"
#include "Magnum/Vk/Device.h" #include "Magnum/Vk/Device.h"
#include "Magnum/Vk/PhysicalDevice.h" #include "Magnum/Vk/PhysicalDevice.h"
#include "AbstractVulkanTester.h" #include "AbstractVulkanTester.h"
@ -48,7 +48,7 @@ CommandVkTest::CommandVkTest() {
} }
void CommandVkTest::doTheLambdasWork() { void CommandVkTest::doTheLambdasWork() {
Vk::Context context{}; Vk::Instance instance{};
//CommandBuffer buffer; //CommandBuffer buffer;
//buffer << Cmd::setScissor(0, {Range2Di{{0, 0}, {0, 0}}); //buffer << Cmd::setScissor(0, {Range2Di{{0, 0}, {0, 0}});

28
src/Magnum/Vk/Test/ContextTest.cpp

@ -27,36 +27,36 @@
#include <sstream> #include <sstream>
#include <Corrade/TestSuite/Tester.h> #include <Corrade/TestSuite/Tester.h>
#include "Magnum/Vk/Context.h" #include "Magnum/Vk/Instance.h"
namespace Magnum { namespace Test { namespace Magnum { namespace Test {
struct ContextTest: TestSuite::Tester { struct InstanceTest: TestSuite::Tester {
explicit ContextTest(); explicit InstanceTest();
void createAndDestroy(); void createAndDestroy();
void flag(); void flag();
void result(); void result();
}; };
ContextTest::ContextTest() { InstanceTest::InstanceTest() {
addTests({&ContextTest::createAndDestroy, addTests({&InstanceTest::createAndDestroy,
&ContextTest::flag, &InstanceTest::flag,
&ContextTest::result}); &InstanceTest::result});
} }
void ContextTest::createAndDestroy() { void InstanceTest::createAndDestroy() {
Vk::Context c{{}}; Vk::Instance c{{}};
CORRADE_COMPARE(c.version(), Vk::Version::Vulkan_1_0); CORRADE_COMPARE(c.version(), Vk::Version::Vulkan_1_0);
} }
void ContextTest::flag() { void InstanceTest::flag() {
std::ostringstream out; std::ostringstream out;
Debug(&out) << Vk::Context::Flag::EnableValidation; Debug(&out) << Vk::Instance::Flag::EnableValidation;
CORRADE_COMPARE(out.str(), "Context::Flag::EnableValidation\n"); CORRADE_COMPARE(out.str(), "Instance::Flag::EnableValidation\n");
} }
void ContextTest::result() { void InstanceTest::result() {
std::ostringstream out; std::ostringstream out;
Debug(&out) << Vk::Result::ErrorLayerNotPresent; Debug(&out) << Vk::Result::ErrorLayerNotPresent;
CORRADE_COMPARE(out.str(), "Vk::Result::ErrorLayerNotPresent\n"); CORRADE_COMPARE(out.str(), "Vk::Result::ErrorLayerNotPresent\n");
@ -64,4 +64,4 @@ void ContextTest::result() {
}} }}
CORRADE_TEST_MAIN(Magnum::Test::ContextTest) CORRADE_TEST_MAIN(Magnum::Test::InstanceTest)

44
src/Magnum/Vk/Test/ContextVkTest.cpp

@ -28,14 +28,14 @@
#include <sstream> #include <sstream>
#include <algorithm> #include <algorithm>
#include "Magnum/Vk/Context.h" #include "Magnum/Vk/Instance.h"
#include "AbstractVulkanTester.h" #include "AbstractVulkanTester.h"
namespace Magnum { namespace Vk { namespace Test { namespace Magnum { namespace Vk { namespace Test {
struct ContextVkTest: AbstractVulkanTester { struct InstanceVkTest: AbstractVulkanTester {
explicit ContextVkTest(); explicit InstanceVkTest();
void constructCopyMove(); void constructCopyMove();
@ -43,34 +43,34 @@ struct ContextVkTest: AbstractVulkanTester {
void createWithValidation(); void createWithValidation();
}; };
ContextVkTest::ContextVkTest() { InstanceVkTest::InstanceVkTest() {
addTests({&ContextVkTest::constructCopyMove, addTests({&InstanceVkTest::constructCopyMove,
&ContextVkTest::createInstance, &InstanceVkTest::createInstance,
&ContextVkTest::createWithValidation}); &InstanceVkTest::createWithValidation});
} }
void ContextVkTest::constructCopyMove() { void InstanceVkTest::constructCopyMove() {
/* Only move-construction allowed */ /* Only move-construction allowed */
CORRADE_VERIFY(!(std::is_constructible<Context, const Context&>{})); CORRADE_VERIFY(!(std::is_constructible<Instance, const Instance&>{}));
CORRADE_VERIFY((std::is_constructible<Context, Context&&>{})); CORRADE_VERIFY((std::is_constructible<Instance, Instance&&>{}));
CORRADE_VERIFY(!(std::is_assignable<Context, const Context&>{})); CORRADE_VERIFY(!(std::is_assignable<Instance, const Instance&>{}));
CORRADE_VERIFY(!(std::is_assignable<Context, Context&&>{})); CORRADE_VERIFY(!(std::is_assignable<Instance, Instance&&>{}));
} }
void ContextVkTest::createInstance() { void InstanceVkTest::createInstance() {
Vk::Context context; Vk::Instance Instance;
CORRADE_VERIFY(&Vk::Context::current() != nullptr); CORRADE_VERIFY(&Vk::Instance::current() != nullptr);
CORRADE_VERIFY(Vk::Context::hasCurrent()); CORRADE_VERIFY(Vk::Instance::hasCurrent());
CORRADE_COMPARE(context.version(), Vk::Version::Vulkan_1_0); CORRADE_COMPARE(Instance.version(), Vk::Version::Vulkan_1_0);
} }
void ContextVkTest::createWithValidation() { void InstanceVkTest::createWithValidation() {
Vk::Context context{Vk::Context::Flag::EnableValidation}; Vk::Instance Instance{Vk::Instance::Flag::EnableValidation};
CORRADE_VERIFY(Vk::Context::hasCurrent()); CORRADE_VERIFY(Vk::Instance::hasCurrent());
CORRADE_COMPARE(context.version(), Vk::Version::Vulkan_1_0); CORRADE_COMPARE(Instance.version(), Vk::Version::Vulkan_1_0);
} }
}}} }}}
MAGNUM_VK_TEST_MAIN(Magnum::Vk::Test::ContextVkTest) MAGNUM_VK_TEST_MAIN(Magnum::Vk::Test::InstanceVkTest)

Loading…
Cancel
Save