]> git.tdb.fi Git - libs/gl.git/commitdiff
Access VulkanContext's private members through VulkanDevice
authorMikko Rasa <tdb@tdb.fi>
Sat, 4 May 2024 16:52:21 +0000 (19:52 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 4 May 2024 16:52:21 +0000 (19:52 +0300)
Windows.h has some #defines which conflict with datatype.h here, so I
need to limit the exposure.

source/backends/vulkan/commands_backend.cpp
source/backends/vulkan/device_backend.cpp
source/backends/vulkan/device_backend.h
source/backends/vulkan/memoryallocator.cpp
source/backends/vulkan/swapchain.cpp

index 643c57dbc736db82730ae06a6ee70d949e651286..3bfd1b1bf81ef9e33ce261df079efca0fd4416ee 100644 (file)
@@ -1,5 +1,4 @@
 #include <msp/core/hash.h>
-#include <msp/graphics/vulkancontext_private.h>
 #include "batch.h"
 #include "commands_backend.h"
 #include "device.h"
@@ -273,7 +272,7 @@ VulkanCommands::CommandPool::CommandPool(Device &d):
        VkCommandPoolCreateInfo pool_info = { };
        pool_info.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO;
        pool_info.flags = VK_COMMAND_POOL_CREATE_TRANSIENT_BIT;
-       pool_info.queueFamilyIndex = device.get_context().get_private().graphics_queue_family;
+       pool_info.queueFamilyIndex = device.get_graphics_queue_family();
 
        vk.CreateCommandPool(pool_info, pool);
 }
index 81941c8e60406d44ec52ce144030f5f80e9bda9b..13909ef22b30af0ec1c3cf2512989967d3fe78d7 100644 (file)
@@ -76,5 +76,20 @@ void VulkanDevice::fill_info()
        info.glsl_features = SL::Features::from_api_version(info.api, info.api_version);
 }
 
+uint32_t VulkanDevice::get_graphics_queue_family() const
+{
+       return context.get_private().graphics_queue_family;
+}
+
+VkSurface VulkanDevice::get_surface() const
+{
+       return handle_cast<VkSurface>(context.get_private().surface);
+}
+
+VkPhysicalDevice VulkanDevice::get_physical_device() const
+{
+       return handle_cast<VkPhysicalDevice>(context.get_private().physical_device);
+}
+
 } // namespace GL
 } // namespace Msp
index 4f9b17d0fa7c0820cd1a965d996ba1a9b1204d33..07a1f49563969f961fc59fdc6a4ec18b0c20c2c9 100644 (file)
@@ -45,6 +45,10 @@ protected:
        Graphics::VulkanContext &get_context() { return context; }
 
 public:
+       std::uint32_t get_graphics_queue_family() const;
+       VkPhysicalDevice get_physical_device() const;
+       VkSurface get_surface() const;
+
        const VulkanFunctions &get_functions() const { return *functions; }
        MemoryAllocator &get_allocator() { return allocator; }
        DestroyQueue &get_destroy_queue() { return destroy_queue; }
index cd77657763f941b89600561e7ebdf23bf73033a3..1a52e62ec2528e638b16030a6b76bafeb4aba2aa 100644 (file)
@@ -1,6 +1,5 @@
 #include <msp/core/algorithm.h>
 #include <msp/core/maputils.h>
-#include <msp/graphics/vulkancontext_private.h>
 #include <msp/stringcodec/utf8.h>
 #include <msp/strings/format.h>
 #include "device.h"
@@ -15,7 +14,7 @@ namespace GL {
 
 MemoryAllocator::MemoryAllocator(Device &d):
        device(d),
-       phys_device(handle_cast<VkPhysicalDevice>(device.get_context().get_private().physical_device))
+       phys_device(device.get_physical_device())
 {
        const VulkanFunctions &vk = device.get_functions();
 
index b04dbdc2602056ced4271810fba1583cd8098ab7..9311c2ff5ab53a861b2fdf86b3867bc0a4a3ba74 100644 (file)
@@ -1,7 +1,6 @@
 #include <limits>
 #include <vector>
 #include <msp/core/algorithm.h>
-#include <msp/graphics/vulkancontext_private.h>
 #include "device.h"
 #include "error.h"
 #include "pixelformat.h"
@@ -16,7 +15,7 @@ namespace GL {
 
 SwapChain::SwapChain(unsigned w, unsigned h, unsigned n_images_min):
        device(Device::get_current()),
-       surface(handle_cast<VkSurface>(device.get_context().get_private().surface)),
+       surface(device.get_surface()),
        width(w),
        height(h)
 {