vk: Polishing and cleanup

Some spec violations fixes
Make the option dynamic
This commit is contained in:
kd-11 2021-01-11 21:51:53 +03:00 committed by kd-11
parent e1c0a917fa
commit 7de0ff337b
5 changed files with 24 additions and 4 deletions

View File

@ -280,8 +280,16 @@ namespace vk
void create_dma_block(std::unique_ptr<dma_block>& block)
{
// TODO
block.reset(new dma_block_EXT());
#ifdef _WIN32
if (g_render_device->get_external_memory_host_support())
{
block.reset(new dma_block_EXT());
}
else
#endif
{
block.reset(new dma_block());
}
}
std::pair<u32, vk::buffer*> map_dma(const command_buffer& cmd, u32 local_address, u32 length)

View File

@ -91,7 +91,7 @@ namespace vk
VkMemoryHostPointerPropertiesEXT memory_properties{};
memory_properties.sType = VK_STRUCTURE_TYPE_MEMORY_HOST_POINTER_PROPERTIES_EXT;
memory_map.getMemoryHostPointerPropertiesEXT(dev, VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT, host_pointer, &memory_properties);
CHECK_RESULT(memory_map.getMemoryHostPointerPropertiesEXT(dev, VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT, host_pointer, &memory_properties));
VkMemoryRequirements memory_reqs;
vkGetBufferMemoryRequirements(m_device, value, &memory_reqs);
@ -110,7 +110,7 @@ namespace vk
}
memory = std::make_unique<memory_block_host>(m_device, host_pointer, size, memory_type_index);
vkBindBufferMemory(dev, value, memory->get_vk_device_memory(), memory->get_vk_device_memory_offset());
CHECK_RESULT(vkBindBufferMemory(dev, value, memory->get_vk_device_memory(), memory->get_vk_device_memory_offset()));
}
buffer::~buffer()

View File

@ -265,6 +265,7 @@ namespace vk
if (pgpu->external_memory_host_support)
{
requested_extensions.push_back(VK_KHR_EXTERNAL_MEMORY_EXTENSION_NAME);
requested_extensions.push_back(VK_EXT_EXTERNAL_MEMORY_HOST_EXTENSION_NAME);
}
@ -484,6 +485,11 @@ namespace vk
return pgpu->unrestricted_depth_range_support;
}
bool render_device::get_external_memory_host_support() const
{
return pgpu->external_memory_host_support;
}
mem_allocator_base* render_device::get_allocator() const
{
return m_allocator.get();

View File

@ -115,6 +115,7 @@ namespace vk
bool get_alpha_to_one_support() const;
bool get_conditional_render_support() const;
bool get_unrestricted_depth_range_support() const;
bool get_external_memory_host_support() const;
mem_allocator_base* get_allocator() const;

View File

@ -149,6 +149,11 @@ namespace vk
{
extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
}
if (support.is_supported(VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME))
{
extensions.push_back(VK_KHR_EXTERNAL_MEMORY_CAPABILITIES_EXTENSION_NAME);
}
#ifdef _WIN32
extensions.push_back(VK_KHR_WIN32_SURFACE_EXTENSION_NAME);
#elif defined(__APPLE__)