From: Mikko Rasa Date: Sat, 4 May 2024 16:52:21 +0000 (+0300) Subject: Access VulkanContext's private members through VulkanDevice X-Git-Url: https://git.tdb.fi/?a=commitdiff_plain;h=fd2dca20ba26dd2086e680b7e43aec248abbd5b7;p=libs%2Fgl.git Access VulkanContext's private members through VulkanDevice Windows.h has some #defines which conflict with datatype.h here, so I need to limit the exposure. --- diff --git a/source/backends/vulkan/commands_backend.cpp b/source/backends/vulkan/commands_backend.cpp index 643c57db..3bfd1b1b 100644 --- a/source/backends/vulkan/commands_backend.cpp +++ b/source/backends/vulkan/commands_backend.cpp @@ -1,5 +1,4 @@ #include -#include #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); } diff --git a/source/backends/vulkan/device_backend.cpp b/source/backends/vulkan/device_backend.cpp index 81941c8e..13909ef2 100644 --- a/source/backends/vulkan/device_backend.cpp +++ b/source/backends/vulkan/device_backend.cpp @@ -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(context.get_private().surface); +} + +VkPhysicalDevice VulkanDevice::get_physical_device() const +{ + return handle_cast(context.get_private().physical_device); +} + } // namespace GL } // namespace Msp diff --git a/source/backends/vulkan/device_backend.h b/source/backends/vulkan/device_backend.h index 4f9b17d0..07a1f495 100644 --- a/source/backends/vulkan/device_backend.h +++ b/source/backends/vulkan/device_backend.h @@ -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; } diff --git a/source/backends/vulkan/memoryallocator.cpp b/source/backends/vulkan/memoryallocator.cpp index cd776577..1a52e62e 100644 --- a/source/backends/vulkan/memoryallocator.cpp +++ b/source/backends/vulkan/memoryallocator.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include "device.h" @@ -15,7 +14,7 @@ namespace GL { MemoryAllocator::MemoryAllocator(Device &d): device(d), - phys_device(handle_cast(device.get_context().get_private().physical_device)) + phys_device(device.get_physical_device()) { const VulkanFunctions &vk = device.get_functions(); diff --git a/source/backends/vulkan/swapchain.cpp b/source/backends/vulkan/swapchain.cpp index b04dbdc2..9311c2ff 100644 --- a/source/backends/vulkan/swapchain.cpp +++ b/source/backends/vulkan/swapchain.cpp @@ -1,7 +1,6 @@ #include #include #include -#include #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(device.get_context().get_private().surface)), + surface(device.get_surface()), width(w), height(h) {