mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-03-01 16:13:23 +00:00
vulkan: precompute memory type mapping.
This commit is contained in:
parent
93b06f2a39
commit
da2caa0881
@ -167,6 +167,8 @@ VKGSRender::VKGSRender() : GSRender(frame_type::Vulkan)
|
|||||||
|
|
||||||
m_device = (vk::render_device *)(&m_swap_chain->get_device());
|
m_device = (vk::render_device *)(&m_swap_chain->get_device());
|
||||||
|
|
||||||
|
m_memory_type_mapping = get_memory_mapping(m_device->gpu());
|
||||||
|
|
||||||
m_optimal_tiling_supported_formats = vk::get_optimal_tiling_supported_formats(m_device->gpu());
|
m_optimal_tiling_supported_formats = vk::get_optimal_tiling_supported_formats(m_device->gpu());
|
||||||
|
|
||||||
vk::set_current_thread_ctx(m_thread_context);
|
vk::set_current_thread_ctx(m_thread_context);
|
||||||
|
@ -29,6 +29,7 @@ private:
|
|||||||
rsx::vk_render_targets m_rtts;
|
rsx::vk_render_targets m_rtts;
|
||||||
|
|
||||||
vk::gpu_formats_support m_optimal_tiling_supported_formats;
|
vk::gpu_formats_support m_optimal_tiling_supported_formats;
|
||||||
|
vk::memory_type_mapping m_memory_type_mapping;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
//vk::fbo draw_fbo;
|
//vk::fbo draw_fbo;
|
||||||
|
@ -35,6 +35,31 @@ namespace vk
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
memory_type_mapping get_memory_mapping(VkPhysicalDevice pdev)
|
||||||
|
{
|
||||||
|
VkPhysicalDeviceMemoryProperties memory_properties;
|
||||||
|
vkGetPhysicalDeviceMemoryProperties(pdev, &memory_properties);
|
||||||
|
|
||||||
|
memory_type_mapping result;
|
||||||
|
result.device_local = VK_MAX_MEMORY_TYPES;
|
||||||
|
result.host_visible_coherent = VK_MAX_MEMORY_TYPES;
|
||||||
|
|
||||||
|
for (int i = 0; i < VK_MAX_MEMORY_TYPES; i++)
|
||||||
|
{
|
||||||
|
bool is_device_local = !!(memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||||
|
if (is_device_local)
|
||||||
|
result.device_local = i;
|
||||||
|
bool is_host_visible = !!(memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT);
|
||||||
|
bool is_host_coherent = !!(memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
|
||||||
|
if (is_host_coherent && is_host_visible)
|
||||||
|
result.host_visible_coherent = i;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (result.device_local == VK_MAX_MEMORY_TYPES) throw EXCEPTION("GPU doesn't support device local memory");
|
||||||
|
if (result.host_visible_coherent == VK_MAX_MEMORY_TYPES) throw EXCEPTION("GPU doesn't support host coherent device local memory");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
VkFormat get_compatible_sampler_format(u32 format, VkComponentMapping& swizzle, u8 swizzle_mask)
|
VkFormat get_compatible_sampler_format(u32 format, VkComponentMapping& swizzle, u8 swizzle_mask)
|
||||||
{
|
{
|
||||||
u8 remap_a = swizzle_mask & 0x3;
|
u8 remap_a = swizzle_mask & 0x3;
|
||||||
|
@ -69,6 +69,14 @@ namespace vk
|
|||||||
VkFormat get_compatible_sampler_format(u32 format, VkComponentMapping& mapping, u8 swizzle_mask=0);
|
VkFormat get_compatible_sampler_format(u32 format, VkComponentMapping& mapping, u8 swizzle_mask=0);
|
||||||
VkFormat get_compatible_surface_format(rsx::surface_color_format color_format);
|
VkFormat get_compatible_surface_format(rsx::surface_color_format color_format);
|
||||||
|
|
||||||
|
struct memory_type_mapping
|
||||||
|
{
|
||||||
|
uint32_t host_visible_coherent;
|
||||||
|
uint32_t device_local;
|
||||||
|
};
|
||||||
|
|
||||||
|
memory_type_mapping get_memory_mapping(VkPhysicalDevice pdev);
|
||||||
|
|
||||||
class physical_device
|
class physical_device
|
||||||
{
|
{
|
||||||
VkPhysicalDevice dev = nullptr;
|
VkPhysicalDevice dev = nullptr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user