Compare commits
No commits in common. "604ee5e6a1f9ac19ebe84ee7fc5e56b686577af4" and "f50208653e03503cf8b8bc1a77bbe1e0d3c4ed5f" have entirely different histories.
604ee5e6a1
...
f50208653e
5 changed files with 27 additions and 98 deletions
|
|
@ -5,38 +5,35 @@
|
||||||
namespace lt::renderer::vk {
|
namespace lt::renderer::vk {
|
||||||
|
|
||||||
Gpu::Gpu(IInstance *instance)
|
Gpu::Gpu(IInstance *instance)
|
||||||
: m_descriptor_indexing_features(
|
|
||||||
{ .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES }
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
auto gpus = static_cast<Instance *>(instance)->enumerate_gpus();
|
auto gpus = static_cast<Instance *>(instance)->enumerate_gpus();
|
||||||
|
|
||||||
for (auto &gpu : gpus)
|
for (auto &gpu : gpus)
|
||||||
{
|
{
|
||||||
auto properties = VkPhysicalDeviceProperties {};
|
auto properties = VkPhysicalDeviceProperties {};
|
||||||
auto features = VkPhysicalDeviceFeatures2 {
|
auto features = VkPhysicalDeviceFeatures {};
|
||||||
.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2,
|
|
||||||
.pNext = &m_descriptor_indexing_features
|
|
||||||
};
|
|
||||||
|
|
||||||
vk_get_physical_device_properties(gpu, &properties);
|
vk_get_physical_device_properties(gpu, &properties);
|
||||||
vk_get_physical_device_features(gpu, &features);
|
vk_get_physical_device_features(gpu, &features);
|
||||||
|
|
||||||
if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
|
if (properties.deviceType == VK_PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
|
||||||
&& features.features.geometryShader)
|
&& features.geometryShader)
|
||||||
{
|
{
|
||||||
m_gpu = gpu;
|
m_gpu = gpu;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ensure(m_gpu, "Failed to find any suitable Vulkan physical device");
|
ensure(m_gpu, "Failed to find any suitable Vulkan physical device");
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto Gpu::get_queue_family_properties() const -> std::vector<VkQueueFamilyProperties>
|
||||||
vk_get_physical_device_memory_properties(m_gpu, &m_memory_properties);
|
{
|
||||||
|
|
||||||
auto count = uint32_t { 0u };
|
auto count = uint32_t { 0u };
|
||||||
vk_get_physical_device_queue_family_properties(m_gpu, &count, nullptr);
|
vk_get_physical_device_queue_family_properties(m_gpu, &count, nullptr);
|
||||||
m_queue_family_properties.resize(count);
|
|
||||||
vk_get_physical_device_queue_family_properties(m_gpu, &count, m_queue_family_properties.data());
|
auto properties = std::vector<VkQueueFamilyProperties>(count);
|
||||||
|
vk_get_physical_device_queue_family_properties(m_gpu, &count, properties.data());
|
||||||
|
|
||||||
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto Gpu::queue_family_supports_presentation(
|
[[nodiscard]] auto Gpu::queue_family_supports_presentation(
|
||||||
|
|
@ -70,11 +67,11 @@ Gpu::Gpu(IInstance *instance)
|
||||||
return formats;
|
return formats;
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] auto Gpu::create_device(VkDeviceCreateInfo info) const -> VkDevice
|
[[nodiscard]] auto Gpu::get_memory_properties() const -> VkPhysicalDeviceMemoryProperties
|
||||||
{
|
{
|
||||||
auto *device = VkDevice {};
|
auto memory_properties = VkPhysicalDeviceMemoryProperties {};
|
||||||
vkc(vk_create_device(m_gpu, &info, nullptr, &device));
|
vk_get_physical_device_memory_properties(m_gpu, &memory_properties);
|
||||||
return device;
|
return memory_properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace lt::renderer::vk
|
} // namespace lt::renderer::vk
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,13 @@ class Gpu: public IGpu
|
||||||
public:
|
public:
|
||||||
Gpu(IInstance *instance);
|
Gpu(IInstance *instance);
|
||||||
|
|
||||||
|
[[nodiscard]] auto vk() const -> VkPhysicalDevice
|
||||||
|
{
|
||||||
|
return m_gpu;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] auto get_queue_family_properties() const -> std::vector<VkQueueFamilyProperties>;
|
||||||
|
|
||||||
[[nodiscard]] auto queue_family_supports_presentation(
|
[[nodiscard]] auto queue_family_supports_presentation(
|
||||||
VkSurfaceKHR surface,
|
VkSurfaceKHR surface,
|
||||||
uint32_t queue_family_idx
|
uint32_t queue_family_idx
|
||||||
|
|
@ -23,39 +30,10 @@ public:
|
||||||
[[nodiscard]] auto get_surface_formats(VkSurfaceKHR surface) const
|
[[nodiscard]] auto get_surface_formats(VkSurfaceKHR surface) const
|
||||||
-> std::vector<VkSurfaceFormatKHR>;
|
-> std::vector<VkSurfaceFormatKHR>;
|
||||||
|
|
||||||
[[nodiscard]] auto create_device(VkDeviceCreateInfo info) const -> VkDevice;
|
[[nodiscard]] auto get_memory_properties() const -> VkPhysicalDeviceMemoryProperties;
|
||||||
|
|
||||||
[[nodiscard]] auto get_properties() const -> VkPhysicalDeviceProperties
|
|
||||||
{
|
|
||||||
return m_properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] auto get_descriptor_indexing_features() const
|
|
||||||
-> VkPhysicalDeviceDescriptorIndexingFeatures
|
|
||||||
{
|
|
||||||
return m_descriptor_indexing_features;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] auto get_memory_properties() const -> VkPhysicalDeviceMemoryProperties
|
|
||||||
{
|
|
||||||
return m_memory_properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] auto get_queue_family_properties() const -> std::vector<VkQueueFamilyProperties>
|
|
||||||
{
|
|
||||||
return m_queue_family_properties;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
memory::NullOnMove<VkPhysicalDevice> m_gpu = VK_NULL_HANDLE;
|
memory::NullOnMove<VkPhysicalDevice> m_gpu = VK_NULL_HANDLE;
|
||||||
|
|
||||||
VkPhysicalDeviceProperties m_properties {};
|
|
||||||
|
|
||||||
VkPhysicalDeviceDescriptorIndexingFeatures m_descriptor_indexing_features;
|
|
||||||
|
|
||||||
VkPhysicalDeviceMemoryProperties m_memory_properties {};
|
|
||||||
|
|
||||||
std::vector<VkQueueFamilyProperties> m_queue_family_properties;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace lt::renderer::vk
|
} // namespace lt::renderer::vk
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ PFN_vkGetPhysicalDeviceQueueFamilyProperties vk_get_physical_device_queue_family
|
||||||
PFN_vkCreateDevice vk_create_device {};
|
PFN_vkCreateDevice vk_create_device {};
|
||||||
PFN_vkGetDeviceProcAddr vk_get_device_proc_address {};
|
PFN_vkGetDeviceProcAddr vk_get_device_proc_address {};
|
||||||
PFN_vkDestroyDevice vk_destroy_device {};
|
PFN_vkDestroyDevice vk_destroy_device {};
|
||||||
PFN_vkGetPhysicalDeviceFeatures2 vk_get_physical_device_features {};
|
PFN_vkGetPhysicalDeviceFeatures vk_get_physical_device_features {};
|
||||||
PFN_vkEnumerateDeviceExtensionProperties vk_enumerate_device_extension_properties {};
|
PFN_vkEnumerateDeviceExtensionProperties vk_enumerate_device_extension_properties {};
|
||||||
PFN_vkGetPhysicalDeviceMemoryProperties vk_get_physical_device_memory_properties {};
|
PFN_vkGetPhysicalDeviceMemoryProperties vk_get_physical_device_memory_properties {};
|
||||||
|
|
||||||
|
|
@ -88,14 +88,6 @@ PFN_vkCmdDraw vk_cmd_draw {};
|
||||||
PFN_vkCmdSetViewport vk_cmd_set_viewport {};
|
PFN_vkCmdSetViewport vk_cmd_set_viewport {};
|
||||||
PFN_vkCmdSetScissor vk_cmd_set_scissors {};
|
PFN_vkCmdSetScissor vk_cmd_set_scissors {};
|
||||||
PFN_vkCmdPushConstants vk_cmd_push_constants {};
|
PFN_vkCmdPushConstants vk_cmd_push_constants {};
|
||||||
PFN_vkCmdCopyBuffer vk_cmd_copy_buffer {};
|
|
||||||
|
|
||||||
PFN_vkCreateDescriptorSetLayout vk_create_descriptor_set_layout {};
|
|
||||||
PFN_vkDestroyDescriptorSetLayout vk_destroy_descriptor_set_layout {};
|
|
||||||
PFN_vkCreateDescriptorPool vk_create_descriptor_pool {};
|
|
||||||
PFN_vkDestroyDescriptorPool vk_destroy_descriptor_pool {};
|
|
||||||
PFN_vkAllocateDescriptorSets vk_allocate_descriptor_sets {};
|
|
||||||
PFN_vkFreeDescriptorSets vk_free_descriptor_sets {};
|
|
||||||
|
|
||||||
PFN_vkCreateBuffer vk_create_buffer {};
|
PFN_vkCreateBuffer vk_create_buffer {};
|
||||||
PFN_vkDestroyBuffer vk_destroy_buffer {};
|
PFN_vkDestroyBuffer vk_destroy_buffer {};
|
||||||
|
|
@ -150,7 +142,6 @@ void Instance::initialize_instance()
|
||||||
VK_EXT_DEBUG_UTILS_EXTENSION_NAME,
|
VK_EXT_DEBUG_UTILS_EXTENSION_NAME,
|
||||||
VK_KHR_SURFACE_EXTENSION_NAME,
|
VK_KHR_SURFACE_EXTENSION_NAME,
|
||||||
VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
|
VK_KHR_XLIB_SURFACE_EXTENSION_NAME,
|
||||||
VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *layer_name = "VK_LAYER_KHRONOS_validation";
|
const char *layer_name = "VK_LAYER_KHRONOS_validation";
|
||||||
|
|
@ -396,13 +387,6 @@ void Instance::load_device_functions_impl(VkDevice device)
|
||||||
load_fn(vk_cmd_set_viewport, "vkCmdSetViewport");
|
load_fn(vk_cmd_set_viewport, "vkCmdSetViewport");
|
||||||
load_fn(vk_cmd_set_scissors, "vkCmdSetScissor");
|
load_fn(vk_cmd_set_scissors, "vkCmdSetScissor");
|
||||||
load_fn(vk_cmd_push_constants, "vkCmdPushConstants");
|
load_fn(vk_cmd_push_constants, "vkCmdPushConstants");
|
||||||
load_fn(vk_cmd_copy_buffer, "vkCmdCopyBuffer");
|
|
||||||
load_fn(vk_create_descriptor_set_layout, "vkCreateDescriptorSetLayout");
|
|
||||||
load_fn(vk_destroy_descriptor_set_layout, "vkDestroyDescriptorSetLayout");
|
|
||||||
load_fn(vk_create_descriptor_pool, "vkCreateDescriptorPool");
|
|
||||||
load_fn(vk_destroy_descriptor_pool, "vkDestroyDescriptorPool");
|
|
||||||
load_fn(vk_allocate_descriptor_sets, "vkAllocateDescriptorSets");
|
|
||||||
load_fn(vk_free_descriptor_sets, "vkFreeDescriptorSets");
|
|
||||||
load_fn(vk_create_buffer, "vkCreateBuffer");
|
load_fn(vk_create_buffer, "vkCreateBuffer");
|
||||||
load_fn(vk_destroy_buffer, "vkDestroyBuffer");
|
load_fn(vk_destroy_buffer, "vkDestroyBuffer");
|
||||||
load_fn(vk_allocate_memory, "vkAllocateMemory");
|
load_fn(vk_allocate_memory, "vkAllocateMemory");
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
#include <renderer/backend/vk/vulkan.hpp>
|
#include <renderer/backend/vk/vulkan.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace lt::renderer::vk::raii {
|
namespace lt::renderer::vk::raii { // NOLINTBEGIN(cppcoreguidelines-special-member-functions)
|
||||||
|
|
||||||
class DebugMessenger
|
class DebugMessenger
|
||||||
{
|
{
|
||||||
|
|
@ -23,20 +23,13 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DebugMessenger(DebugMessenger &&) = default;
|
|
||||||
|
|
||||||
DebugMessenger(const DebugMessenger &) = delete;
|
|
||||||
|
|
||||||
auto operator=(DebugMessenger &&) -> DebugMessenger & = default;
|
|
||||||
|
|
||||||
auto operator=(const DebugMessenger &) -> DebugMessenger & = delete;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
memory::NullOnMove<Instance *> m_instance {};
|
memory::NullOnMove<Instance *> m_instance {};
|
||||||
|
|
||||||
VkDebugUtilsMessengerEXT m_object;
|
VkDebugUtilsMessengerEXT m_object;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-special-member-functions)
|
||||||
class Buffer
|
class Buffer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
@ -54,14 +47,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Buffer(Buffer &&) = default;
|
|
||||||
|
|
||||||
Buffer(const Buffer &) = delete;
|
|
||||||
|
|
||||||
auto operator=(Buffer &&) -> Buffer & = default;
|
|
||||||
|
|
||||||
auto operator=(const Buffer &) -> Buffer & = delete;
|
|
||||||
|
|
||||||
[[nodiscard]] auto operator*() const -> VkBuffer
|
[[nodiscard]] auto operator*() const -> VkBuffer
|
||||||
{
|
{
|
||||||
return m_object;
|
return m_object;
|
||||||
|
|
@ -96,14 +81,6 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Memory(Memory &&) = default;
|
|
||||||
|
|
||||||
Memory(const Memory &) = delete;
|
|
||||||
|
|
||||||
auto operator=(Memory &&) -> Memory & = default;
|
|
||||||
|
|
||||||
auto operator=(const Memory &) -> Memory & = delete;
|
|
||||||
|
|
||||||
[[nodiscard]] auto operator*() const -> VkDeviceMemory
|
[[nodiscard]] auto operator*() const -> VkDeviceMemory
|
||||||
{
|
{
|
||||||
return m_object;
|
return m_object;
|
||||||
|
|
@ -121,4 +98,5 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// NOLINTEND(cppcoreguidelines-special-member-functions)
|
||||||
} // namespace lt::renderer::vk::raii
|
} // namespace lt::renderer::vk::raii
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ extern PFN_vkGetPhysicalDeviceQueueFamilyProperties vk_get_physical_device_queue
|
||||||
extern PFN_vkCreateDevice vk_create_device;
|
extern PFN_vkCreateDevice vk_create_device;
|
||||||
extern PFN_vkGetDeviceProcAddr vk_get_device_proc_address;
|
extern PFN_vkGetDeviceProcAddr vk_get_device_proc_address;
|
||||||
extern PFN_vkDestroyDevice vk_destroy_device;
|
extern PFN_vkDestroyDevice vk_destroy_device;
|
||||||
extern PFN_vkGetPhysicalDeviceFeatures2 vk_get_physical_device_features;
|
extern PFN_vkGetPhysicalDeviceFeatures vk_get_physical_device_features;
|
||||||
extern PFN_vkEnumerateDeviceExtensionProperties vk_enumerate_device_extension_properties;
|
extern PFN_vkEnumerateDeviceExtensionProperties vk_enumerate_device_extension_properties;
|
||||||
extern PFN_vkGetPhysicalDeviceMemoryProperties vk_get_physical_device_memory_properties;
|
extern PFN_vkGetPhysicalDeviceMemoryProperties vk_get_physical_device_memory_properties;
|
||||||
|
|
||||||
|
|
@ -77,14 +77,6 @@ extern PFN_vkCmdDraw vk_cmd_draw;
|
||||||
extern PFN_vkCmdSetViewport vk_cmd_set_viewport;
|
extern PFN_vkCmdSetViewport vk_cmd_set_viewport;
|
||||||
extern PFN_vkCmdSetScissor vk_cmd_set_scissors;
|
extern PFN_vkCmdSetScissor vk_cmd_set_scissors;
|
||||||
extern PFN_vkCmdPushConstants vk_cmd_push_constants;
|
extern PFN_vkCmdPushConstants vk_cmd_push_constants;
|
||||||
extern PFN_vkCmdCopyBuffer vk_cmd_copy_buffer;
|
|
||||||
|
|
||||||
extern PFN_vkCreateDescriptorSetLayout vk_create_descriptor_set_layout;
|
|
||||||
extern PFN_vkDestroyDescriptorSetLayout vk_destroy_descriptor_set_layout;
|
|
||||||
extern PFN_vkCreateDescriptorPool vk_create_descriptor_pool;
|
|
||||||
extern PFN_vkDestroyDescriptorPool vk_destroy_descriptor_pool;
|
|
||||||
extern PFN_vkAllocateDescriptorSets vk_allocate_descriptor_sets;
|
|
||||||
extern PFN_vkFreeDescriptorSets vk_free_descriptor_sets;
|
|
||||||
|
|
||||||
extern PFN_vkCreateBuffer vk_create_buffer;
|
extern PFN_vkCreateBuffer vk_create_buffer;
|
||||||
extern PFN_vkDestroyBuffer vk_destroy_buffer;
|
extern PFN_vkDestroyBuffer vk_destroy_buffer;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue