1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 18:53:28 +01:00

vk: Reorganize handling of formats support

- Formats support is linked to the physical device and by extension the logical device derived from it
  It therefore makes no sense to track this as a separate object.
  Simplifies parameter passing and template specialization.
  Also avoids corner cases with AMD hardware (where D24S8 is not supported)
This commit is contained in:
kd-11 2018-04-22 14:22:40 +03:00 committed by kd-11
parent 291a828217
commit 7e32e7343a
9 changed files with 77 additions and 75 deletions

View File

@ -3,19 +3,19 @@
namespace vk
{
gpu_formats_support get_optimal_tiling_supported_formats(VkPhysicalDevice physical_device)
gpu_formats_support get_optimal_tiling_supported_formats(const physical_device& dev)
{
gpu_formats_support result = {};
VkFormatProperties props;
vkGetPhysicalDeviceFormatProperties(physical_device, VK_FORMAT_D24_UNORM_S8_UINT, &props);
vkGetPhysicalDeviceFormatProperties(dev, VK_FORMAT_D24_UNORM_S8_UINT, &props);
result.d24_unorm_s8 = !!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)
&& !!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)
&& !!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_SRC_BIT)
&& !!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT);
vkGetPhysicalDeviceFormatProperties(physical_device, VK_FORMAT_D32_SFLOAT_S8_UINT, &props);
vkGetPhysicalDeviceFormatProperties(dev, VK_FORMAT_D32_SFLOAT_S8_UINT, &props);
result.d32_sfloat_s8 = !!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)
&& !!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT)
&& !!(props.optimalTilingFeatures & VK_FORMAT_FEATURE_BLIT_SRC_BIT);
@ -211,7 +211,7 @@ namespace vk
return mapping;
}
VkFormat get_compatible_sampler_format(u32 format)
VkFormat get_compatible_sampler_format(const gpu_formats_support &support, u32 format)
{
switch (format)
{
@ -225,8 +225,8 @@ namespace vk
case CELL_GCM_TEXTURE_COMPRESSED_DXT45: return VK_FORMAT_BC3_UNORM_BLOCK;
case CELL_GCM_TEXTURE_G8B8: return VK_FORMAT_R8G8_UNORM;
case CELL_GCM_TEXTURE_R6G5B5: return VK_FORMAT_R5G6B5_UNORM_PACK16; // Expand, discard high bit?
case CELL_GCM_TEXTURE_DEPTH24_D8: return VK_FORMAT_D24_UNORM_S8_UINT; //TODO
case CELL_GCM_TEXTURE_DEPTH24_D8_FLOAT: return VK_FORMAT_D24_UNORM_S8_UINT; //TODO
case CELL_GCM_TEXTURE_DEPTH24_D8: return support.d24_unorm_s8? VK_FORMAT_D24_UNORM_S8_UINT : VK_FORMAT_D32_SFLOAT_S8_UINT;
case CELL_GCM_TEXTURE_DEPTH24_D8_FLOAT: return support.d24_unorm_s8 ? VK_FORMAT_D24_UNORM_S8_UINT : VK_FORMAT_D32_SFLOAT_S8_UINT;
case CELL_GCM_TEXTURE_DEPTH16: return VK_FORMAT_D16_UNORM;
case CELL_GCM_TEXTURE_DEPTH16_FLOAT: return VK_FORMAT_D16_UNORM;
case CELL_GCM_TEXTURE_X16: return VK_FORMAT_R16_UNORM;

View File

@ -4,17 +4,10 @@
namespace vk
{
struct gpu_formats_support
{
bool d24_unorm_s8 : 1;
bool d32_sfloat_s8 : 1;
};
gpu_formats_support get_optimal_tiling_supported_formats(VkPhysicalDevice physical_device);
VkBorderColor get_border_color(u32 color);
VkFormat get_compatible_depth_surface_format(const gpu_formats_support &support, rsx::surface_depth_format format);
VkFormat get_compatible_sampler_format(u32 format);
VkFormat get_compatible_sampler_format(const gpu_formats_support &support, u32 format);
VkFormat get_compatible_srgb_format(VkFormat rgb_format);
u8 get_format_texel_width(VkFormat format);
std::pair<u8, u8> get_format_element_size(VkFormat format);

View File

@ -544,10 +544,6 @@ VKGSRender::VKGSRender() : GSRender()
m_device = (vk::render_device*)(&m_swapchain->get_device());
m_memory_type_mapping = m_device->get_memory_mapping();
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_renderer(m_swapchain->get_device());
@ -573,7 +569,7 @@ VKGSRender::VKGSRender() : GSRender()
m_secondary_command_buffer.access_hint = vk::command_buffer::access_type_hint::all;
//Precalculated stuff
m_render_passes = get_precomputed_render_passes(*m_device, m_optimal_tiling_supported_formats);
m_render_passes = get_precomputed_render_passes(*m_device, m_device->get_formats_support());
std::tie(pipeline_layout, descriptor_layouts) = get_shared_pipeline_layout(*m_device);
//Occlusion
@ -592,14 +588,15 @@ VKGSRender::VKGSRender() : GSRender()
semaphore_info.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO;
//VRAM allocation
const auto& memory_map = m_device->get_memory_mapping();
m_attrib_ring_info.init(VK_ATTRIB_RING_BUFFER_SIZE_M * 0x100000, "attrib buffer", 0x400000);
m_attrib_ring_info.heap.reset(new vk::buffer(*m_device, VK_ATTRIB_RING_BUFFER_SIZE_M * 0x100000, m_memory_type_mapping.host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT, 0));
m_attrib_ring_info.heap.reset(new vk::buffer(*m_device, VK_ATTRIB_RING_BUFFER_SIZE_M * 0x100000, memory_map.host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT, 0));
m_uniform_buffer_ring_info.init(VK_UBO_RING_BUFFER_SIZE_M * 0x100000, "uniform buffer");
m_uniform_buffer_ring_info.heap.reset(new vk::buffer(*m_device, VK_UBO_RING_BUFFER_SIZE_M * 0x100000, m_memory_type_mapping.host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 0));
m_uniform_buffer_ring_info.heap.reset(new vk::buffer(*m_device, VK_UBO_RING_BUFFER_SIZE_M * 0x100000, memory_map.host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 0));
m_index_buffer_ring_info.init(VK_INDEX_RING_BUFFER_SIZE_M * 0x100000, "index buffer");
m_index_buffer_ring_info.heap.reset(new vk::buffer(*m_device, VK_INDEX_RING_BUFFER_SIZE_M * 0x100000, m_memory_type_mapping.host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, 0));
m_index_buffer_ring_info.heap.reset(new vk::buffer(*m_device, VK_INDEX_RING_BUFFER_SIZE_M * 0x100000, memory_map.host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_BUFFER_USAGE_INDEX_BUFFER_BIT, 0));
m_texture_upload_buffer_ring_info.init(VK_TEXTURE_UPLOAD_RING_BUFFER_SIZE_M * 0x100000, "texture upload buffer", 32 * 0x100000);
m_texture_upload_buffer_ring_info.heap.reset(new vk::buffer(*m_device, VK_TEXTURE_UPLOAD_RING_BUFFER_SIZE_M * 0x100000, m_memory_type_mapping.host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, 0));
m_texture_upload_buffer_ring_info.heap.reset(new vk::buffer(*m_device, VK_TEXTURE_UPLOAD_RING_BUFFER_SIZE_M * 0x100000, memory_map.host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_BUFFER_USAGE_TRANSFER_SRC_BIT, 0));
for (auto &ctx : frame_context_storage)
{
@ -607,7 +604,7 @@ VKGSRender::VKGSRender() : GSRender()
ctx.descriptor_pool.create(*m_device, sizes.data(), static_cast<uint32_t>(sizes.size()));
}
null_buffer = std::make_unique<vk::buffer>(*m_device, 32, m_memory_type_mapping.host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT, 0);
null_buffer = std::make_unique<vk::buffer>(*m_device, 32, memory_map.host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT, 0);
null_buffer_view = std::make_unique<vk::buffer_view>(*m_device, null_buffer->value, VK_FORMAT_R8_UINT, 0, 32);
vk::initialize_compiler_context();
@ -616,7 +613,7 @@ VKGSRender::VKGSRender() : GSRender()
{
size_t idx = vk::get_render_pass_location( m_swapchain->get_surface_format(), VK_FORMAT_UNDEFINED, 1);
m_text_writer.reset(new vk::text_writer());
m_text_writer->init(*m_device, m_memory_type_mapping, m_render_passes[idx]);
m_text_writer->init(*m_device, m_render_passes[idx]);
}
m_depth_converter.reset(new vk::depth_convert_pass());
@ -654,11 +651,11 @@ VKGSRender::VKGSRender() : GSRender()
m_current_frame = &frame_context_storage[0];
m_texture_cache.initialize((*m_device), m_memory_type_mapping, m_optimal_tiling_supported_formats, m_swapchain->get_graphics_queue(),
m_texture_cache.initialize((*m_device), m_swapchain->get_graphics_queue(),
m_texture_upload_buffer_ring_info);
m_ui_renderer.reset(new vk::ui_overlay_renderer());
m_ui_renderer->create(*m_current_command_buffer, m_memory_type_mapping, m_texture_upload_buffer_ring_info);
m_ui_renderer->create(*m_current_command_buffer, m_texture_upload_buffer_ring_info);
supports_multidraw = !g_cfg.video.strict_rendering_mode;
supports_native_ui = (bool)g_cfg.misc.use_native_interface;
@ -790,7 +787,7 @@ bool VKGSRender::on_access_violation(u32 address, bool is_writing)
vk::texture_cache::thrashed_set result;
{
std::lock_guard<shared_mutex> lock(m_secondary_cb_guard);
result = std::move(m_texture_cache.invalidate_address(address, is_writing, false, m_secondary_command_buffer, m_memory_type_mapping, m_swapchain->get_graphics_queue()));
result = std::move(m_texture_cache.invalidate_address(address, is_writing, false, m_secondary_command_buffer, m_swapchain->get_graphics_queue()));
}
if (!result.violation_handled)
@ -852,7 +849,7 @@ bool VKGSRender::on_access_violation(u32 address, bool is_writing)
m_flush_requests.producer_wait();
}
m_texture_cache.flush_all(result, m_secondary_command_buffer, m_memory_type_mapping, m_swapchain->get_graphics_queue());
m_texture_cache.flush_all(result, m_secondary_command_buffer, m_swapchain->get_graphics_queue());
if (has_queue_ref)
{
@ -868,7 +865,7 @@ void VKGSRender::on_notify_memory_unmapped(u32 address_base, u32 size)
{
std::lock_guard<shared_mutex> lock(m_secondary_cb_guard);
if (m_texture_cache.invalidate_range(address_base, size, true, true, false,
m_secondary_command_buffer, m_memory_type_mapping, m_swapchain->get_graphics_queue()).violation_handled)
m_secondary_command_buffer, m_swapchain->get_graphics_queue()).violation_handled)
{
m_texture_cache.purge_dirty();
{
@ -1835,7 +1832,7 @@ void VKGSRender::copy_render_targets_to_dma_location()
continue;
m_texture_cache.flush_memory_to_cache(m_surface_info[index].address, m_surface_info[index].pitch * m_surface_info[index].height, true,
*m_current_command_buffer, m_memory_type_mapping, m_swapchain->get_graphics_queue());
*m_current_command_buffer, m_swapchain->get_graphics_queue());
}
}
@ -1844,7 +1841,7 @@ void VKGSRender::copy_render_targets_to_dma_location()
if (m_depth_surface_info.pitch)
{
m_texture_cache.flush_memory_to_cache(m_depth_surface_info.address, m_depth_surface_info.pitch * m_depth_surface_info.height, true,
*m_current_command_buffer, m_memory_type_mapping, m_swapchain->get_graphics_queue());
*m_current_command_buffer, m_swapchain->get_graphics_queue());
}
}
@ -2705,7 +2702,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
clip_width, clip_height,
target,
surface_addresses, zeta_address,
(*m_device), &*m_current_command_buffer, m_optimal_tiling_supported_formats, m_memory_type_mapping);
(*m_device), &*m_current_command_buffer);
//Reset framebuffer information
VkFormat old_format = VK_FORMAT_UNDEFINED;
@ -2719,7 +2716,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
m_texture_cache.set_memory_read_flags(m_surface_info[i].address, m_surface_info[i].pitch * m_surface_info[i].height, rsx::memory_read_flags::flush_once);
m_texture_cache.flush_if_cache_miss_likely(old_format, m_surface_info[i].address, m_surface_info[i].pitch * m_surface_info[i].height,
*m_current_command_buffer, m_memory_type_mapping, m_swapchain->get_graphics_queue());
*m_current_command_buffer, m_swapchain->get_graphics_queue());
}
m_surface_info[i].address = m_surface_info[i].pitch = 0;
@ -2732,10 +2729,10 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
{
if (m_depth_surface_info.pitch && g_cfg.video.write_depth_buffer)
{
auto old_format = vk::get_compatible_depth_surface_format(m_optimal_tiling_supported_formats, m_depth_surface_info.depth_format);
auto old_format = vk::get_compatible_depth_surface_format(m_device->get_formats_support(), m_depth_surface_info.depth_format);
m_texture_cache.set_memory_read_flags(m_depth_surface_info.address, m_depth_surface_info.pitch * m_depth_surface_info.height, rsx::memory_read_flags::flush_once);
m_texture_cache.flush_if_cache_miss_likely(old_format, m_depth_surface_info.address, m_depth_surface_info.pitch * m_depth_surface_info.height,
*m_current_command_buffer, m_memory_type_mapping, m_swapchain->get_graphics_queue());
*m_current_command_buffer, m_swapchain->get_graphics_queue());
}
m_depth_surface_info.address = m_depth_surface_info.pitch = 0;
@ -2816,7 +2813,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context)
}
}
auto vk_depth_format = (zeta_address == 0) ? VK_FORMAT_UNDEFINED : vk::get_compatible_depth_surface_format(m_optimal_tiling_supported_formats, depth_fmt);
auto vk_depth_format = (zeta_address == 0) ? VK_FORMAT_UNDEFINED : vk::get_compatible_depth_surface_format(m_device->get_formats_support(), depth_fmt);
m_current_renderpass_id = vk::get_render_pass_location(vk::get_compatible_surface_format(color_fmt).first, vk_depth_format, m_draw_buffers_count);
//Search old framebuffers for this same configuration
@ -3198,7 +3195,7 @@ void VKGSRender::flip(int buffer)
if (m_custom_ui)
{
m_ui_renderer->run(*m_current_command_buffer, direct_fbo->width(), direct_fbo->height(), direct_fbo.get(), single_target_pass, m_memory_type_mapping, m_texture_upload_buffer_ring_info, *m_custom_ui);
m_ui_renderer->run(*m_current_command_buffer, direct_fbo->width(), direct_fbo->height(), direct_fbo.get(), single_target_pass, m_texture_upload_buffer_ring_info, *m_custom_ui);
}
if (g_cfg.video.overlay)
@ -3288,7 +3285,7 @@ bool VKGSRender::scaled_image_from_memory(rsx::blit_src_info& src, rsx::blit_dst
if (result.dst_image)
{
if (m_texture_cache.flush_if_cache_miss_likely(result.dst_image->info.format, result.real_dst_address, result.real_dst_size,
*m_current_command_buffer, m_memory_type_mapping, m_swapchain->get_graphics_queue()))
*m_current_command_buffer, m_swapchain->get_graphics_queue()))
require_flush = true;
}

View File

@ -254,9 +254,6 @@ private:
vk::texture_cache m_texture_cache;
rsx::vk_render_targets m_rtts;
vk::gpu_formats_support m_optimal_tiling_supported_formats;
vk::memory_type_mapping m_memory_type_mapping;
std::unique_ptr<vk::buffer> null_buffer;
std::unique_ptr<vk::buffer_view> null_buffer_view;

View File

@ -135,7 +135,14 @@ namespace vk
uint32_t device_local;
};
struct gpu_formats_support
{
bool d24_unorm_s8;
bool d32_sfloat_s8;
};
memory_type_mapping get_memory_mapping(const physical_device& dev);
gpu_formats_support get_optimal_tiling_supported_formats(const physical_device& dev);
class physical_device
{
@ -202,6 +209,7 @@ namespace vk
{
physical_device *pgpu = nullptr;
memory_type_mapping memory_map{};
gpu_formats_support m_formats_support{};
VkDevice dev = VK_NULL_HANDLE;
public:
@ -253,7 +261,9 @@ namespace vk
device.pEnabledFeatures = &available_features;
CHECK_RESULT(vkCreateDevice(*pgpu, &device, nullptr, &dev));
memory_map = vk::get_memory_mapping(pdev);
m_formats_support = vk::get_optimal_tiling_supported_formats(pdev);
}
~render_device()
@ -300,6 +310,11 @@ namespace vk
return memory_map;
}
const gpu_formats_support& get_formats_support() const
{
return m_formats_support;
}
operator VkDevice&()
{
return dev;

View File

@ -490,7 +490,7 @@ namespace vk
m_fragment_shader.id = 100005;
}
vk::image_view* upload_simple_texture(vk::render_device &dev, vk::command_buffer &cmd, vk::memory_type_mapping &memory_types,
vk::image_view* upload_simple_texture(vk::render_device &dev, vk::command_buffer &cmd,
vk::vk_data_heap& upload_heap, u64 key, int w, int h, bool font, bool temp, void *pixel_src)
{
const VkFormat format = (font) ? VK_FORMAT_R8_UNORM : VK_FORMAT_B8G8R8A8_UNORM;
@ -505,7 +505,7 @@ namespace vk
const VkImageSubresourceRange range = { VK_IMAGE_ASPECT_COLOR_BIT, 0, 1, 0, 1 };
auto tex = std::make_unique<vk::image>(dev, memory_types.device_local, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
auto tex = std::make_unique<vk::image>(dev, dev.get_memory_mapping().device_local, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
VK_IMAGE_TYPE_2D, format, std::max(w, 1), std::max(h, 1), 1, 1, 1, VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_LAYOUT_UNDEFINED,
VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_SAMPLED_BIT,
0);
@ -548,7 +548,7 @@ namespace vk
return result;
}
void create(vk::command_buffer &cmd, vk::memory_type_mapping &memory_types, vk::vk_data_heap &upload_heap)
void create(vk::command_buffer &cmd, vk::vk_data_heap &upload_heap)
{
auto& dev = cmd.get_command_pool().get_owner();
overlay_pass::create(dev);
@ -559,7 +559,7 @@ namespace vk
u64 storage_key = 1;
for (const auto &res : configuration.texture_raw_data)
{
upload_simple_texture(dev, cmd, memory_types, upload_heap, storage_key++, res->w, res->h, false, false, res->data);
upload_simple_texture(dev, cmd, upload_heap, storage_key++, res->w, res->h, false, false, res->data);
}
configuration.free_resources();
@ -583,7 +583,7 @@ namespace vk
temp_view_cache.clear();
}
vk::image_view* find_font(rsx::overlays::font *font, vk::command_buffer &cmd, vk::memory_type_mapping &memory_types, vk::vk_data_heap &upload_heap)
vk::image_view* find_font(rsx::overlays::font *font, vk::command_buffer &cmd, vk::vk_data_heap &upload_heap)
{
u64 key = (u64)font;
auto found = view_cache.find(key);
@ -591,17 +591,17 @@ namespace vk
return found->second.get();
//Create font file
return upload_simple_texture(cmd.get_command_pool().get_owner(), cmd, memory_types, upload_heap, key, font->width, font->height, true, false, font->glyph_data.data());
return upload_simple_texture(cmd.get_command_pool().get_owner(), cmd, upload_heap, key, font->width, font->height, true, false, font->glyph_data.data());
}
vk::image_view* find_temp_image(rsx::overlays::image_info *desc, vk::command_buffer &cmd, vk::memory_type_mapping &memory_types, vk::vk_data_heap &upload_heap)
vk::image_view* find_temp_image(rsx::overlays::image_info *desc, vk::command_buffer &cmd, vk::vk_data_heap &upload_heap)
{
u64 key = (u64)desc;
auto found = temp_view_cache.find(key);
if (found != temp_view_cache.end())
return found->second.get();
return upload_simple_texture(cmd.get_command_pool().get_owner(), cmd, memory_types, upload_heap, key, desc->w, desc->h, false, true, desc->data);
return upload_simple_texture(cmd.get_command_pool().get_owner(), cmd, upload_heap, key, desc->w, desc->h, false, true, desc->data);
}
void update_uniforms(vk::glsl::program* /*program*/) override
@ -639,7 +639,7 @@ namespace vk
}
}
void run(vk::command_buffer &cmd, u16 w, u16 h, vk::framebuffer* target, VkRenderPass render_pass, vk::memory_type_mapping &memory_types,
void run(vk::command_buffer &cmd, u16 w, u16 h, vk::framebuffer* target, VkRenderPass render_pass,
vk::vk_data_heap &upload_heap, rsx::overlays::user_interface &ui)
{
m_scale_offset = color4f((f32)ui.virtual_width, (f32)ui.virtual_height, 1.f, 1.f);
@ -671,10 +671,10 @@ namespace vk
m_skip_texture_read = true;
break;
case rsx::overlays::image_resource_id::font_file:
src = find_font(command.first.font_ref, cmd, memory_types, upload_heap)->value;
src = find_font(command.first.font_ref, cmd, upload_heap)->value;
break;
case rsx::overlays::image_resource_id::raw_image:
src = find_temp_image((rsx::overlays::image_info*)command.first.external_data_ref, cmd, memory_types, upload_heap)->value;
src = find_temp_image((rsx::overlays::image_info*)command.first.external_data_ref, cmd, upload_heap)->value;
break;
default:
src = view_cache[command.first.texture_ref]->value;

View File

@ -122,13 +122,13 @@ namespace rsx
surface_color_format format,
size_t width, size_t height,
vk::render_target* old_surface,
vk::render_device &device, vk::command_buffer *cmd, const vk::gpu_formats_support &, const vk::memory_type_mapping &mem_mapping)
vk::render_device &device, vk::command_buffer *cmd)
{
auto fmt = vk::get_compatible_surface_format(format);
VkFormat requested_format = fmt.first;
std::unique_ptr<vk::render_target> rtt;
rtt.reset(new vk::render_target(device, mem_mapping.device_local,
rtt.reset(new vk::render_target(device, device.get_memory_mapping().device_local,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
VK_IMAGE_TYPE_2D,
requested_format,
@ -158,9 +158,9 @@ namespace rsx
surface_depth_format format,
size_t width, size_t height,
vk::render_target* old_surface,
vk::render_device &device, vk::command_buffer *cmd, const vk::gpu_formats_support &support, const vk::memory_type_mapping &mem_mapping)
vk::render_device &device, vk::command_buffer *cmd)
{
VkFormat requested_format = vk::get_compatible_depth_surface_format(support, format);
VkFormat requested_format = vk::get_compatible_depth_surface_format(device.get_formats_support(), format);
VkImageSubresourceRange range = vk::get_image_subresource_range(0, 0, 1, 1, VK_IMAGE_ASPECT_DEPTH_BIT);
if (requested_format != VK_FORMAT_D16_UNORM)
@ -169,7 +169,7 @@ namespace rsx
const auto scale = rsx::get_resolution_scale();
std::unique_ptr<vk::render_target> ds;
ds.reset(new vk::render_target(device, mem_mapping.device_local,
ds.reset(new vk::render_target(device, device.get_memory_mapping().device_local,
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
VK_IMAGE_TYPE_2D,
requested_format,

View File

@ -252,12 +252,12 @@ namespace vk
}
}
void init(vk::render_device &dev, vk::memory_type_mapping &memory_types, VkRenderPass &render_pass)
void init(vk::render_device &dev, VkRenderPass &render_pass)
{
//At worst case, 1 char = 16*16*8 bytes (average about 24*8), so ~256K for 128 chars. Allocating 512k for verts
//uniform params are 8k in size, allocating for 120 lines (max lines at 4k, one column per row. Can be expanded
m_vertex_buffer.reset( new vk::buffer(dev, 524288, memory_types.host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, 0));
m_uniforms_buffer.reset(new vk::buffer(dev, 983040, memory_types.host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 0));
m_vertex_buffer.reset( new vk::buffer(dev, 524288, dev.get_memory_mapping().host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, 0));
m_uniforms_buffer.reset(new vk::buffer(dev, 983040, dev.get_memory_mapping().host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT, 0));
m_render_pass = render_pass;
m_uniform_buffer_size = 983040;

View File

@ -141,7 +141,7 @@ namespace vk
return (protection == utils::protection::rw && uploaded_image_view.get() == nullptr && managed_texture.get() == nullptr);
}
void copy_texture(bool manage_cb_lifetime, vk::command_buffer& cmd, vk::memory_type_mapping& memory_types, VkQueue submit_queue)
void copy_texture(bool manage_cb_lifetime, vk::command_buffer& cmd, VkQueue submit_queue)
{
if (m_device == nullptr)
{
@ -157,7 +157,8 @@ namespace vk
if (dma_buffer.get() == nullptr)
{
dma_buffer.reset(new vk::buffer(*m_device, align(cpu_address_range, 256), memory_types.host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, VK_BUFFER_USAGE_TRANSFER_DST_BIT, 0));
auto memory_type = m_device->get_memory_mapping().host_visible_coherent;
dma_buffer.reset(new vk::buffer(*m_device, align(cpu_address_range, 256), memory_type, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT, VK_BUFFER_USAGE_TRANSFER_DST_BIT, 0));
}
if (manage_cb_lifetime)
@ -227,7 +228,7 @@ namespace vk
}
}
bool flush(vk::command_buffer& cmd, vk::memory_type_mapping& memory_types, VkQueue submit_queue)
bool flush(vk::command_buffer& cmd, VkQueue submit_queue)
{
if (flushed) return true;
@ -242,7 +243,7 @@ namespace vk
if (!synchronized)
{
LOG_WARNING(RSX, "Cache miss at address 0x%X. This is gonna hurt...", cpu_address_base);
copy_texture(true, cmd, memory_types, submit_queue);
copy_texture(true, cmd, submit_queue);
result = false;
}
@ -513,7 +514,7 @@ namespace vk
VkImageAspectFlags aspect;
VkImageCreateFlags image_flags;
VkFormat dst_format = vk::get_compatible_sampler_format(gcm_format);
VkFormat dst_format = vk::get_compatible_sampler_format(m_formats_support, gcm_format);
if (source)
{
@ -609,7 +610,7 @@ namespace vk
std::unique_ptr<vk::image> image;
std::unique_ptr<vk::image_view> view;
VkFormat dst_format = vk::get_compatible_sampler_format(gcm_format);
VkFormat dst_format = vk::get_compatible_sampler_format(m_formats_support, gcm_format);
VkImageAspectFlags dst_aspect = vk::get_aspect_flags(dst_format);
image.reset(new vk::image(*vk::get_current_renderer(), m_memory_types.device_local, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
@ -672,7 +673,7 @@ namespace vk
std::unique_ptr<vk::image> image;
std::unique_ptr<vk::image_view> view;
VkFormat dst_format = vk::get_compatible_sampler_format(gcm_format);
VkFormat dst_format = vk::get_compatible_sampler_format(m_formats_support, gcm_format);
VkImageAspectFlags dst_aspect = vk::get_aspect_flags(dst_format);
image.reset(new vk::image(*vk::get_current_renderer(), m_memory_types.device_local, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
@ -845,7 +846,7 @@ namespace vk
break;
default:
aspect_flags = VK_IMAGE_ASPECT_COLOR_BIT;
vk_format = get_compatible_sampler_format(gcm_format);
vk_format = get_compatible_sampler_format(m_formats_support, gcm_format);
if (colorspace != rsx::texture_colorspace::rgb_linear)
vk_format = get_compatible_srgb_format(vk_format);
@ -1034,12 +1035,11 @@ namespace vk
public:
void initialize(vk::render_device& device, vk::memory_type_mapping& memory_types, vk::gpu_formats_support& formats_support,
VkQueue submit_queue, vk::vk_data_heap& upload_heap)
void initialize(vk::render_device& device, VkQueue submit_queue, vk::vk_data_heap& upload_heap)
{
m_memory_types = memory_types;
m_formats_support = formats_support;
m_device = &device;
m_memory_types = device.get_memory_mapping();
m_formats_support = device.get_formats_support();
m_submit_queue = submit_queue;
m_texture_upload_heap = &upload_heap;
}
@ -1112,7 +1112,7 @@ namespace vk
template<typename RsxTextureType>
sampled_image_descriptor _upload_texture(vk::command_buffer& cmd, RsxTextureType& tex, rsx::vk_render_targets& m_rtts)
{
return upload_texture(cmd, tex, m_rtts, cmd, m_memory_types, const_cast<const VkQueue>(m_submit_queue));
return upload_texture(cmd, tex, m_rtts, cmd, const_cast<const VkQueue>(m_submit_queue));
}
vk::image *upload_image_simple(vk::command_buffer& /*cmd*/, u32 address, u32 width, u32 height)
@ -1225,7 +1225,7 @@ namespace vk
}
helper(&cmd);
auto reply = upload_scaled_image(src, dst, interpolate, cmd, m_rtts, helper, cmd, m_memory_types, const_cast<const VkQueue>(m_submit_queue));
auto reply = upload_scaled_image(src, dst, interpolate, cmd, m_rtts, helper, cmd, const_cast<const VkQueue>(m_submit_queue));
vk_blit_op_result result = reply.succeeded;
result.real_dst_address = reply.real_dst_address;