From a8dbbb3a0897eab8530a605ac33911da21ecc05f Mon Sep 17 00:00:00 2001
From: Alexander Gauggel <agauggel@uni-koblenz.de>
Date: Mon, 26 Apr 2021 15:33:19 +0200
Subject: [PATCH] added getters for device and instance to context

---
 projects/first_triangle/src/main.cpp | 15 ++++++++++++++-
 src/vkcv/Context.cpp                 | 11 +++++++++++
 src/vkcv/Context.hpp                 |  4 ++++
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/projects/first_triangle/src/main.cpp b/projects/first_triangle/src/main.cpp
index 25e26a68..6b99b0e2 100644
--- a/projects/first_triangle/src/main.cpp
+++ b/projects/first_triangle/src/main.cpp
@@ -8,7 +8,20 @@ int main(int argc, const char** argv) {
 			VK_MAKE_VERSION(0, 0, 1)
 	);
 
-	std::cout << "Hello world" << std::endl;
+	const vk::Instance instance = context.getInstance();
+	const vk::PhysicalDevice physicalDevice = context.getPhysicalDevice();
+	const vk::Device device = context.getDevice();
+
+	std::cout << "Physical device: " << physicalDevice.getProperties().deviceName << std::endl;
+
+	switch (physicalDevice.getProperties().vendorID) {
+		case 0x1002: std::cout << "Running AMD huh? You like underdogs, are you a Linux user?" << std::endl; break;
+		case 0x10DE: std::cout << "An NVidia GPU, how predictable..." << std::endl; break;
+		case 0x8086: std::cout << "Poor child, running on an Intel GPU, probably integrated..."
+			"or perhaps you are from the future with a dedicated one?" << std::endl; break;
+		case 0x13B5: std::cout << "ARM? What the hell are you running on, next thing I know you're trying to run Vulkan on a leg..." << std::endl; break;
+		default: std::cout << "Unknown GPU vendor?! Either you're on an exotic system or your driver is broken..." << std::endl;
+	}
 
 	return 0;
 }
diff --git a/src/vkcv/Context.cpp b/src/vkcv/Context.cpp
index bfad8c96..e77bae20 100644
--- a/src/vkcv/Context.cpp
+++ b/src/vkcv/Context.cpp
@@ -53,4 +53,15 @@ namespace vkcv {
 		return Context(instance, physicalDevice, device);
 	}
 
+	vk::Instance Context::getInstance() {
+		return m_instance;
+	}
+
+	vk::PhysicalDevice Context::getPhysicalDevice() {
+		return m_physicalDevice;
+	}
+
+	vk::Device Context::getDevice() {
+		return m_device;
+	}
 }
diff --git a/src/vkcv/Context.hpp b/src/vkcv/Context.hpp
index f3736276..116d5f5a 100644
--- a/src/vkcv/Context.hpp
+++ b/src/vkcv/Context.hpp
@@ -16,6 +16,10 @@ namespace vkcv {
 		Context(const Context &other) = delete;
 		Context(Context &&other) = default;
 
+		vk::Instance getInstance();
+		vk::PhysicalDevice getPhysicalDevice();
+		vk::Device getDevice();
+
 		virtual ~Context();
 
 		Context& operator=(const Context &other) = delete;
-- 
GitLab