Compare commits
No commits in common. "main" and "vulkan_api_wrapper" have entirely different histories.
main
...
vulkan_api
5 changed files with 78 additions and 72 deletions
|
|
@ -172,7 +172,7 @@ private:
|
|||
{
|
||||
// I know this makes the tests too verbose...
|
||||
// but makes it easier to figure out what the problem is when things fail on ci
|
||||
lt::log::trace("vulkan: {}", std::string { data.message });
|
||||
lt::log::debug("vulkan: {}", data.message);
|
||||
std::ignore = data;
|
||||
std::ignore = type;
|
||||
|
||||
|
|
@ -221,6 +221,10 @@ public:
|
|||
return m_system;
|
||||
}
|
||||
|
||||
auto device() -> lt::renderer::IDevice &
|
||||
{
|
||||
}
|
||||
|
||||
[[nodiscard]] auto has_any_messages() const -> bool
|
||||
{
|
||||
return m_user_data->m_has_any_messages;
|
||||
|
|
@ -242,7 +246,7 @@ private:
|
|||
{
|
||||
// I know this makes the tests too verbose...
|
||||
// but makes it easier to figure out what the problem is when things fail on ci
|
||||
lt::log::trace("vulkan: {}", std::string { data.message });
|
||||
lt::log::trace("vulkan: {}", data.message);
|
||||
|
||||
std::ignore = data;
|
||||
std::ignore = type;
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public:
|
|||
|
||||
System(CreateInfo info);
|
||||
|
||||
~System() override = default;
|
||||
~System() override;
|
||||
|
||||
System(System &&) = default;
|
||||
|
||||
|
|
@ -152,6 +152,8 @@ System::System(CreateInfo info)
|
|||
) };
|
||||
}
|
||||
|
||||
System::~System() = default;
|
||||
|
||||
void System::on_register()
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1306,8 +1306,10 @@ public:
|
|||
/** de-allocation functions */
|
||||
void free_memory(VkDeviceMemory memory) const;
|
||||
|
||||
void free_descriptor_set(VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set)
|
||||
const;
|
||||
void free_descriptor_set(
|
||||
VkDescriptorPool descriptor_pool,
|
||||
VkDescriptorSet descriptor_set
|
||||
) const;
|
||||
|
||||
/** destroy functions */
|
||||
void destroy_swapchain(VkSwapchainKHR swapchain) const;
|
||||
|
|
@ -3069,7 +3071,7 @@ Instance::Instance(CreateInfo info)
|
|||
layer_names.emplace_back(layer.name.c_str());
|
||||
for (const auto &setting : layer.settings)
|
||||
{
|
||||
const auto *values = static_cast<void *>(nullptr);
|
||||
const auto *values = (void *) { nullptr };
|
||||
|
||||
if (setting.values.index() == 0)
|
||||
{
|
||||
|
|
@ -3086,13 +3088,15 @@ Instance::Instance(CreateInfo info)
|
|||
|
||||
debug::ensure(values, "Failed to get variant from setting.values");
|
||||
|
||||
layer_settings.emplace_back(VkLayerSettingEXT {
|
||||
.pLayerName = layer.name.c_str(),
|
||||
.pSettingName = setting.name.c_str(),
|
||||
.type = std::visit(layer_setting_type_visitor, setting.values),
|
||||
.valueCount = 1u,
|
||||
.pValues = values,
|
||||
});
|
||||
layer_settings.emplace_back(
|
||||
VkLayerSettingEXT {
|
||||
.pLayerName = layer.name.c_str(),
|
||||
.pSettingName = setting.name.c_str(),
|
||||
.type = std::visit(layer_setting_type_visitor, setting.values),
|
||||
.valueCount = 1u,
|
||||
.pValues = values,
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -3104,8 +3108,8 @@ Instance::Instance(CreateInfo info)
|
|||
|
||||
auto app_info = VkApplicationInfo {
|
||||
.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
|
||||
.pApplicationName = constants::engine_name,
|
||||
.applicationVersion = constants::application_version,
|
||||
.pApplicationName = constants::engine_name,
|
||||
.pEngineName = constants::app_name,
|
||||
.apiVersion = constants::api_version,
|
||||
};
|
||||
|
|
@ -3114,11 +3118,11 @@ Instance::Instance(CreateInfo info)
|
|||
.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
|
||||
.pNext = &layer_settings_create_info,
|
||||
.flags = {},
|
||||
.pApplicationInfo = &app_info,
|
||||
.enabledLayerCount = static_cast<uint32_t>(info.layers.size()),
|
||||
.ppEnabledLayerNames = layer_names.data(),
|
||||
.enabledExtensionCount = static_cast<uint32_t>(extension_names.size()),
|
||||
.ppEnabledExtensionNames = extension_names.data(),
|
||||
.pApplicationInfo = &app_info,
|
||||
};
|
||||
|
||||
vkc(api::create_instance(&vk_info, nullptr, &m_instance));
|
||||
|
|
@ -3291,7 +3295,7 @@ Surface::~Surface()
|
|||
.shader_sampled_image_array_non_uniform_indexing =true,
|
||||
.shader_storage_buffer_array_non_uniform_indexing =true,
|
||||
.shader_storage_image_array_non_uniform_indexing =true,
|
||||
.shader_input_attachment_array_non_uniform_indexing =false,
|
||||
.shader_input_attachment_array_non_uniform_indexing =true,
|
||||
.shader_uniform_texel_buffer_array_non_uniform_indexing =true,
|
||||
.shader_storage_texel_buffer_array_non_uniform_indexing =true,
|
||||
.descriptor_binding_uniform_buffer_update_after_bind =true,
|
||||
|
|
@ -3581,10 +3585,12 @@ Surface::~Surface()
|
|||
auto formats = std::vector<Surface::Format> {};
|
||||
for (auto &vk_format : vk_formats)
|
||||
{
|
||||
formats.emplace_back(Surface::Format {
|
||||
.format = static_cast<Format>(vk_format.format),
|
||||
.color_space = static_cast<ColorSpace>(vk_format.colorSpace),
|
||||
});
|
||||
formats.emplace_back(
|
||||
Surface::Format {
|
||||
.format = static_cast<Format>(vk_format.format),
|
||||
.color_space = static_cast<ColorSpace>(vk_format.colorSpace),
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
return formats;
|
||||
|
|
@ -3641,12 +3647,14 @@ Device::Device(const Gpu &gpu, CreateInfo info)
|
|||
auto vk_queue_infos = std::vector<VkDeviceQueueCreateInfo> {};
|
||||
for (auto queue_family : info.queue_indices)
|
||||
{
|
||||
vk_queue_infos.emplace_back(VkDeviceQueueCreateInfo {
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
|
||||
.queueFamilyIndex = queue_family,
|
||||
.queueCount = 1u,
|
||||
.pQueuePriorities = &priorities,
|
||||
});
|
||||
vk_queue_infos.emplace_back(
|
||||
VkDeviceQueueCreateInfo {
|
||||
.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO,
|
||||
.queueFamilyIndex = queue_family,
|
||||
.queueCount = 1u,
|
||||
.pQueuePriorities = &priorities,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
auto vk_extension_names = std::vector<const char *> {};
|
||||
|
|
@ -4039,8 +4047,10 @@ void Device::free_memory(VkDeviceMemory memory) const
|
|||
api::free_memory(m_device, memory, nullptr);
|
||||
}
|
||||
|
||||
void Device::free_descriptor_set(VkDescriptorPool descriptor_pool, VkDescriptorSet descriptor_set)
|
||||
const
|
||||
void Device::free_descriptor_set(
|
||||
VkDescriptorPool descriptor_pool,
|
||||
VkDescriptorSet descriptor_set
|
||||
) const
|
||||
{
|
||||
vkc(api::free_descriptor_sets(m_device, descriptor_pool, 1, &descriptor_set));
|
||||
}
|
||||
|
|
@ -4444,8 +4454,8 @@ CommandPool::CommandPool(Device &device, CreateInfo info): m_device(device.get_v
|
|||
{
|
||||
auto vk_info = VkCommandPoolCreateInfo {
|
||||
.sType = VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO,
|
||||
.pNext = {},
|
||||
.flags = info.flags,
|
||||
.pNext = {},
|
||||
.queueFamilyIndex = {},
|
||||
};
|
||||
|
||||
|
|
@ -4669,13 +4679,15 @@ DescriptorSetLayout::DescriptorSetLayout(Device &device, CreateInfo info)
|
|||
vk_binding_flag_values.reserve(info.bindings.size());
|
||||
for (auto &binding_info : info.bindings)
|
||||
{
|
||||
vk_bindings.emplace_back(VkDescriptorSetLayoutBinding {
|
||||
.binding = binding_info.idx,
|
||||
.descriptorType = static_cast<VkDescriptorType>(binding_info.type),
|
||||
.descriptorCount = binding_info.count,
|
||||
.stageFlags = binding_info.shader_stages,
|
||||
.pImmutableSamplers = {},
|
||||
});
|
||||
vk_bindings.emplace_back(
|
||||
VkDescriptorSetLayoutBinding {
|
||||
.binding = binding_info.idx,
|
||||
.descriptorType = static_cast<VkDescriptorType>(binding_info.type),
|
||||
.descriptorCount = binding_info.count,
|
||||
.stageFlags = binding_info.shader_stages,
|
||||
.pImmutableSamplers = {},
|
||||
}
|
||||
);
|
||||
|
||||
vk_binding_flag_values.emplace_back(binding_info.flags);
|
||||
}
|
||||
|
|
@ -4717,10 +4729,12 @@ DescriptorPool::DescriptorPool(Device &device, CreateInfo info): m_device(device
|
|||
vk_sizes.reserve(info.sizes.size());
|
||||
for (auto &size : info.sizes)
|
||||
{
|
||||
vk_sizes.emplace_back(VkDescriptorPoolSize {
|
||||
.type = static_cast<VkDescriptorType>(size.type),
|
||||
.descriptorCount = size.count,
|
||||
});
|
||||
vk_sizes.emplace_back(
|
||||
VkDescriptorPoolSize {
|
||||
.type = static_cast<VkDescriptorType>(size.type),
|
||||
.descriptorCount = size.count,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
auto vk_info = VkDescriptorPoolCreateInfo {
|
||||
|
|
@ -4774,12 +4788,14 @@ Pipeline::Pipeline(Device &device, PipelineLayout &layout, CreateInfo info)
|
|||
auto shader_stages = std::vector<VkPipelineShaderStageCreateInfo> {};
|
||||
for (auto &[shader, stage] : info.shaders)
|
||||
{
|
||||
shader_stages.emplace_back(VkPipelineShaderStageCreateInfo {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
||||
.stage = static_cast<VkShaderStageFlagBits>(stage),
|
||||
.module = shader.get_vk_handle(),
|
||||
.pName = "main",
|
||||
});
|
||||
shader_stages.emplace_back(
|
||||
VkPipelineShaderStageCreateInfo {
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO,
|
||||
.stage = static_cast<VkShaderStageFlagBits>(stage),
|
||||
.module = shader.get_vk_handle(),
|
||||
.pName = "main",
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
auto dynamic_states = std::array<VkDynamicState, 2> {
|
||||
|
|
@ -4862,7 +4878,8 @@ Pipeline::Pipeline(Device &device, PipelineLayout &layout, CreateInfo info)
|
|||
.colorAttachmentCount = static_cast<uint32_t>(color_attachment_formats.size()),
|
||||
.pColorAttachmentFormats = std::bit_cast<VkFormat *>(color_attachment_formats.data()),
|
||||
.depthAttachmentFormat = info.attachment_state.depth_attachment ?
|
||||
static_cast<VkFormat>(*info.attachment_state.depth_attachment
|
||||
static_cast<VkFormat>(
|
||||
*info.attachment_state.depth_attachment
|
||||
) :
|
||||
VK_FORMAT_UNDEFINED,
|
||||
|
||||
|
|
@ -4914,11 +4931,13 @@ PipelineLayout::PipelineLayout(Device &device, CreateInfo info): m_device(device
|
|||
|
||||
for (const auto &range : info.push_constant_ranges)
|
||||
{
|
||||
vk_push_constant_ranges.emplace_back(VkPushConstantRange {
|
||||
.stageFlags = range.shader_stages,
|
||||
.offset = range.offset,
|
||||
.size = range.size,
|
||||
});
|
||||
vk_push_constant_ranges.emplace_back(
|
||||
VkPushConstantRange {
|
||||
.stageFlags = range.shader_stages,
|
||||
.offset = range.offset,
|
||||
.size = range.size,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
for (const auto &layout : info.descriptor_set_layouts)
|
||||
|
|
|
|||
|
|
@ -105,9 +105,9 @@ void Device::initialize_logical_device()
|
|||
|
||||
.features = {
|
||||
.geometry_shader = true,
|
||||
.sampler_anisotropy = true,
|
||||
.multi_draw_indirect = true,
|
||||
.draw_indirect_first_instance = true,
|
||||
.sampler_anisotropy = true,
|
||||
},
|
||||
|
||||
.dynamic_rendering_features = m_gpu->vk().get_supported_dynamic_rendering_features(),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
export module renderer.vk.gpu;
|
||||
import renderer.vk.api_wrapper;
|
||||
import logger;
|
||||
import debug.assertions;
|
||||
import renderer.frontend;
|
||||
import renderer.vk.instance;
|
||||
|
|
@ -76,30 +75,12 @@ Gpu::Gpu(IInstance *instance)
|
|||
auto properties = gpu.get_properties();
|
||||
auto features = gpu.get_features();
|
||||
|
||||
// GPU is dedicated, a great success!
|
||||
if (properties.device_type == vk::Gpu::Type::discrete_gpu && features.geometry_shader)
|
||||
{
|
||||
m_gpu = gpu;
|
||||
}
|
||||
}
|
||||
|
||||
if (!m_gpu)
|
||||
{
|
||||
for (auto &gpu : gpus)
|
||||
{
|
||||
auto properties = gpu.get_properties();
|
||||
auto features = gpu.get_features();
|
||||
|
||||
// GPU is integrated, fall back to anything with geometry shader support...
|
||||
if (features.geometry_shader)
|
||||
{
|
||||
m_gpu = gpu;
|
||||
log::warn("Using integrated GPU");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// No suitable GPU is fonud...
|
||||
debug::ensure(m_gpu, "Failed to find any suitable Vulkan physical device");
|
||||
|
||||
m_memory_properties = m_gpu.get_memory_properties();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue