formatting: Unify indentation type in the newly added files to tabs

This commit is contained in:
kd-11 2020-01-17 23:17:14 +03:00 committed by kd-11
parent bad4d1ff05
commit 48407752a6
2 changed files with 185 additions and 185 deletions

View File

@ -3,67 +3,67 @@
GLuint GLGSRender::get_present_source(gl::present_surface_info* info, const rsx::avconf* avconfig) GLuint GLGSRender::get_present_source(gl::present_surface_info* info, const rsx::avconf* avconfig)
{ {
GLuint image = GL_NONE; GLuint image = GL_NONE;
// Check the surface store first // Check the surface store first
gl::command_context cmd = { gl_state }; gl::command_context cmd = { gl_state };
const auto format_bpp = get_format_block_size_in_bytes(info->format); const auto format_bpp = get_format_block_size_in_bytes(info->format);
const auto overlap_info = m_rtts.get_merged_texture_memory_region(cmd, const auto overlap_info = m_rtts.get_merged_texture_memory_region(cmd,
info->address, info->width, info->height, info->pitch, format_bpp, rsx::surface_access::read); info->address, info->width, info->height, info->pitch, format_bpp, rsx::surface_access::read);
if (!overlap_info.empty()) if (!overlap_info.empty())
{ {
const auto& section = overlap_info.back(); const auto& section = overlap_info.back();
auto surface = gl::as_rtt(section.surface); auto surface = gl::as_rtt(section.surface);
if (section.base_address >= info->address) if (section.base_address >= info->address)
{ {
// Check for intentional 'borders' // Check for intentional 'borders'
const u32 inset_offset = section.base_address - info->address; const u32 inset_offset = section.base_address - info->address;
const u32 inset_y = inset_offset / info->pitch; const u32 inset_y = inset_offset / info->pitch;
const u32 inset_x = (inset_offset % info->pitch) / format_bpp; const u32 inset_x = (inset_offset % info->pitch) / format_bpp;
const u32 full_width = surface->get_surface_width(rsx::surface_metrics::samples) + inset_x + inset_x; const u32 full_width = surface->get_surface_width(rsx::surface_metrics::samples) + inset_x + inset_x;
const u32 full_height = surface->get_surface_height(rsx::surface_metrics::samples) + inset_y + inset_y; const u32 full_height = surface->get_surface_height(rsx::surface_metrics::samples) + inset_y + inset_y;
if (full_width == info->width && full_height == info->height) if (full_width == info->width && full_height == info->height)
{ {
surface->read_barrier(cmd); surface->read_barrier(cmd);
image = section.surface->get_surface(rsx::surface_access::read)->id(); image = section.surface->get_surface(rsx::surface_access::read)->id();
info->width = rsx::apply_resolution_scale(full_width - (inset_x + inset_x), true); info->width = rsx::apply_resolution_scale(full_width - (inset_x + inset_x), true);
info->height = rsx::apply_resolution_scale(full_height - (inset_y + inset_y), true); info->height = rsx::apply_resolution_scale(full_height - (inset_y + inset_y), true);
} }
} }
} }
else if (auto surface = m_gl_texture_cache.find_texture_from_dimensions<true>(info->address, info->format, info->width, info->height)) else if (auto surface = m_gl_texture_cache.find_texture_from_dimensions<true>(info->address, info->format, info->width, info->height))
{ {
//Hack - this should be the first location to check for output // Hack - this should be the first location to check for output
//The render might have been done offscreen or in software and a blit used to display // The render might have been done offscreen or in software and a blit used to display
if (const auto tex = surface->get_raw_texture(); tex) image = tex->id(); if (const auto tex = surface->get_raw_texture(); tex) image = tex->id();
} }
if (!image) if (!image)
{ {
LOG_WARNING(RSX, "Flip texture was not found in cache. Uploading surface from CPU"); LOG_WARNING(RSX, "Flip texture was not found in cache. Uploading surface from CPU");
gl::pixel_unpack_settings unpack_settings; gl::pixel_unpack_settings unpack_settings;
unpack_settings.alignment(1).row_length(info->pitch / 4); unpack_settings.alignment(1).row_length(info->pitch / 4);
if (!m_flip_tex_color || m_flip_tex_color->size2D() != sizei{ static_cast<int>(info->width), static_cast<int>(info->height) }) if (!m_flip_tex_color || m_flip_tex_color->size2D() != sizei{ static_cast<int>(info->width), static_cast<int>(info->height) })
{ {
m_flip_tex_color = std::make_unique<gl::texture>(GL_TEXTURE_2D, info->width, info->height, 1, 1, GL_RGBA8); m_flip_tex_color = std::make_unique<gl::texture>(GL_TEXTURE_2D, info->width, info->height, 1, 1, GL_RGBA8);
} }
gl::command_context cmd{ gl_state }; gl::command_context cmd{ gl_state };
const auto range = utils::address_range::start_length(info->address, info->pitch * info->height); const auto range = utils::address_range::start_length(info->address, info->pitch * info->height);
m_gl_texture_cache.invalidate_range(cmd, range, rsx::invalidation_cause::read); m_gl_texture_cache.invalidate_range(cmd, range, rsx::invalidation_cause::read);
m_flip_tex_color->copy_from(vm::base(info->address), gl::texture::format::bgra, gl::texture::type::uint_8_8_8_8, unpack_settings); m_flip_tex_color->copy_from(vm::base(info->address), gl::texture::format::bgra, gl::texture::type::uint_8_8_8_8, unpack_settings);
image = m_flip_tex_color->id(); image = m_flip_tex_color->id();
} }
return image; return image;
} }
void GLGSRender::flip(const rsx::display_flip_info_t& info) void GLGSRender::flip(const rsx::display_flip_info_t& info)
@ -106,24 +106,24 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info)
gl::screen.bind(); gl::screen.bind();
gl::screen.clear(gl::buffers::color); gl::screen.clear(gl::buffers::color);
GLuint image_to_flip = GL_NONE; GLuint image_to_flip = GL_NONE;
if (info.buffer < display_buffers_count && buffer_width && buffer_height) if (info.buffer < display_buffers_count && buffer_width && buffer_height)
{ {
// Find the source image // Find the source image
gl::present_surface_info present_info; gl::present_surface_info present_info;
present_info.width = buffer_width; present_info.width = buffer_width;
present_info.height = buffer_height; present_info.height = buffer_height;
present_info.pitch = buffer_pitch; present_info.pitch = buffer_pitch;
present_info.format = av_format; present_info.format = av_format;
present_info.address = rsx::get_address(display_buffers[info.buffer].offset, CELL_GCM_LOCATION_LOCAL); present_info.address = rsx::get_address(display_buffers[info.buffer].offset, CELL_GCM_LOCATION_LOCAL);
image_to_flip = get_present_source(&present_info, avconfig); image_to_flip = get_present_source(&present_info, avconfig);
buffer_width = present_info.width; buffer_width = present_info.width;
buffer_height = present_info.height; buffer_height = present_info.height;
} }
// Calculate blit coordinates // Calculate blit coordinates
coordi aspect_ratio; coordi aspect_ratio;
sizei csize(m_frame->client_width(), m_frame->client_height()); sizei csize(m_frame->client_width(), m_frame->client_height());
sizei new_size = csize; sizei new_size = csize;
@ -148,8 +148,8 @@ void GLGSRender::flip(const rsx::display_flip_info_t& info)
aspect_ratio.size = new_size; aspect_ratio.size = new_size;
if (image_to_flip) if (image_to_flip)
{ {
if (m_frame->screenshot_toggle == true) if (m_frame->screenshot_toggle == true)
{ {
m_frame->screenshot_toggle = false; m_frame->screenshot_toggle = false;

View File

@ -57,10 +57,10 @@ void VKGSRender::reinitialize_swapchain()
vk::change_image_layout(*m_current_command_buffer, target_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, target_layout, range); vk::change_image_layout(*m_current_command_buffer, target_image, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, target_layout, range);
} }
//Will have to block until rendering is completed // Will have to block until rendering is completed
vk::fence resize_fence(*m_device); vk::fence resize_fence(*m_device);
//Flush the command buffer // Flush the command buffer
close_and_submit_command_buffer(&resize_fence); close_and_submit_command_buffer(&resize_fence);
vk::wait_for_fence(&resize_fence); vk::wait_for_fence(&resize_fence);
@ -104,10 +104,10 @@ void VKGSRender::advance_queued_frames()
// Check all other frames for completion and clear resources // Check all other frames for completion and clear resources
check_present_status(); check_present_status();
//m_rtts storage is double buffered and should be safe to tag on frame boundary // m_rtts storage is double buffered and should be safe to tag on frame boundary
m_rtts.free_invalidated(); m_rtts.free_invalidated();
//texture cache is also double buffered to prevent use-after-free // Texture cache is also double buffered to prevent use-after-free
m_texture_cache.on_frame_end(); m_texture_cache.on_frame_end();
m_samplers_dirty.store(true); m_samplers_dirty.store(true);
@ -221,7 +221,7 @@ void VKGSRender::frame_context_cleanup(vk::frame_context_t *ctx, bool free_resou
{ {
m_last_heap_sync_time = ctx->last_frame_sync_time; m_last_heap_sync_time = ctx->last_frame_sync_time;
//Heap cleanup; deallocates memory consumed by the frame if it is still held // Heap cleanup; deallocates memory consumed by the frame if it is still held
m_attrib_ring_info.m_get_pos = ctx->attrib_heap_ptr; m_attrib_ring_info.m_get_pos = ctx->attrib_heap_ptr;
m_vertex_env_ring_info.m_get_pos = ctx->vtx_env_heap_ptr; m_vertex_env_ring_info.m_get_pos = ctx->vtx_env_heap_ptr;
m_fragment_env_ring_info.m_get_pos = ctx->frag_env_heap_ptr; m_fragment_env_ring_info.m_get_pos = ctx->frag_env_heap_ptr;
@ -263,71 +263,71 @@ void VKGSRender::frame_context_cleanup(vk::frame_context_t *ctx, bool free_resou
vk::image* VKGSRender::get_present_source(vk::present_surface_info* info, const rsx::avconf* avconfig) vk::image* VKGSRender::get_present_source(vk::present_surface_info* info, const rsx::avconf* avconfig)
{ {
vk::image* image_to_flip = nullptr; vk::image* image_to_flip = nullptr;
// Check the surface store first // Check the surface store first
const auto format_bpp = get_format_block_size_in_bytes(info->format); const auto format_bpp = get_format_block_size_in_bytes(info->format);
const auto overlap_info = m_rtts.get_merged_texture_memory_region(*m_current_command_buffer, const auto overlap_info = m_rtts.get_merged_texture_memory_region(*m_current_command_buffer,
info->address, info->width, info->height, info->pitch, format_bpp, rsx::surface_access::read); info->address, info->width, info->height, info->pitch, format_bpp, rsx::surface_access::read);
if (!overlap_info.empty()) if (!overlap_info.empty())
{ {
const auto& section = overlap_info.back(); const auto& section = overlap_info.back();
auto surface = vk::as_rtt(section.surface); auto surface = vk::as_rtt(section.surface);
if (section.base_address >= info->address) if (section.base_address >= info->address)
{ {
// Check for intentional 'borders' // Check for intentional 'borders'
const u32 inset_offset = section.base_address - info->address; const u32 inset_offset = section.base_address - info->address;
const u32 inset_y = inset_offset / info->pitch; const u32 inset_y = inset_offset / info->pitch;
const u32 inset_x = (inset_offset % info->pitch) / format_bpp; const u32 inset_x = (inset_offset % info->pitch) / format_bpp;
const u32 full_width = surface->get_surface_width(rsx::surface_metrics::samples) + inset_x + inset_x; const u32 full_width = surface->get_surface_width(rsx::surface_metrics::samples) + inset_x + inset_x;
const u32 full_height = surface->get_surface_height(rsx::surface_metrics::samples) + inset_y + inset_y; const u32 full_height = surface->get_surface_height(rsx::surface_metrics::samples) + inset_y + inset_y;
if (full_width == info->width && full_height == info->height) if (full_width == info->width && full_height == info->height)
{ {
surface->read_barrier(*m_current_command_buffer); surface->read_barrier(*m_current_command_buffer);
image_to_flip = section.surface->get_surface(rsx::surface_access::read); image_to_flip = section.surface->get_surface(rsx::surface_access::read);
info->width = rsx::apply_resolution_scale(full_width - (inset_x + inset_x), true); info->width = rsx::apply_resolution_scale(full_width - (inset_x + inset_x), true);
info->height = rsx::apply_resolution_scale(full_height - (inset_y + inset_y), true); info->height = rsx::apply_resolution_scale(full_height - (inset_y + inset_y), true);
} }
} }
} }
else if (auto surface = m_texture_cache.find_texture_from_dimensions<true>(info->address, info->format, info->width, info->height)) else if (auto surface = m_texture_cache.find_texture_from_dimensions<true>(info->address, info->format, info->width, info->height))
{ {
// Hack - this should be the first location to check for output // Hack - this should be the first location to check for output
// The render might have been done offscreen or in software and a blit used to display // The render might have been done offscreen or in software and a blit used to display
image_to_flip = surface->get_raw_texture(); image_to_flip = surface->get_raw_texture();
} }
if (!image_to_flip) if (!image_to_flip)
{ {
// Read from cell // Read from cell
const auto range = utils::address_range::start_length(info->address, info->pitch * info->height); const auto range = utils::address_range::start_length(info->address, info->pitch * info->height);
const u32 lookup_mask = rsx::texture_upload_context::blit_engine_dst | rsx::texture_upload_context::framebuffer_storage; const u32 lookup_mask = rsx::texture_upload_context::blit_engine_dst | rsx::texture_upload_context::framebuffer_storage;
const auto overlap = m_texture_cache.find_texture_from_range<true>(range, 0, lookup_mask); const auto overlap = m_texture_cache.find_texture_from_range<true>(range, 0, lookup_mask);
for (const auto & section : overlap) for (const auto & section : overlap)
{ {
if (!section->is_synchronized()) if (!section->is_synchronized())
{ {
section->copy_texture(*m_current_command_buffer, true); section->copy_texture(*m_current_command_buffer, true);
} }
} }
if (m_current_command_buffer->flags & vk::command_buffer::cb_has_dma_transfer) if (m_current_command_buffer->flags & vk::command_buffer::cb_has_dma_transfer)
{ {
// Submit for processing to lower hard fault penalty // Submit for processing to lower hard fault penalty
flush_command_queue(); flush_command_queue();
} }
m_texture_cache.invalidate_range(*m_current_command_buffer, range, rsx::invalidation_cause::read); m_texture_cache.invalidate_range(*m_current_command_buffer, range, rsx::invalidation_cause::read);
image_to_flip = m_texture_cache.upload_image_simple(*m_current_command_buffer, info->address, info->width, info->height); image_to_flip = m_texture_cache.upload_image_simple(*m_current_command_buffer, info->address, info->width, info->height);
} }
return image_to_flip; return image_to_flip;
} }
void VKGSRender::flip(const rsx::display_flip_info_t& info) void VKGSRender::flip(const rsx::display_flip_info_t& info)
@ -415,20 +415,20 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info)
buffer_pitch = buffer_width * 4; buffer_pitch = buffer_width * 4;
} }
// Scan memory for required data. This is done early to optimize waiting for the driver image acquire below. // Scan memory for required data. This is done early to optimize waiting for the driver image acquire below.
vk::image* image_to_flip = nullptr; vk::image* image_to_flip = nullptr;
if (info.buffer < display_buffers_count && buffer_width && buffer_height) if (info.buffer < display_buffers_count && buffer_width && buffer_height)
{ {
vk::present_surface_info present_info; vk::present_surface_info present_info;
present_info.width = buffer_width; present_info.width = buffer_width;
present_info.height = buffer_height; present_info.height = buffer_height;
present_info.pitch = buffer_pitch; present_info.pitch = buffer_pitch;
present_info.format = av_format; present_info.format = av_format;
present_info.address = rsx::get_address(display_buffers[info.buffer].offset, CELL_GCM_LOCATION_LOCAL); present_info.address = rsx::get_address(display_buffers[info.buffer].offset, CELL_GCM_LOCATION_LOCAL);
image_to_flip = get_present_source(&present_info, avconfig); image_to_flip = get_present_source(&present_info, avconfig);
buffer_width = present_info.width; buffer_width = present_info.width;
buffer_height = present_info.height; buffer_height = present_info.height;
} }
// Prepare surface for new frame. Set no timeout here so that we wait for the next image if need be // Prepare surface for new frame. Set no timeout here so that we wait for the next image if need be
@ -471,30 +471,30 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info)
// Confirm that the driver did not silently fail // Confirm that the driver did not silently fail
verify(HERE), m_current_frame->present_image != UINT32_MAX; verify(HERE), m_current_frame->present_image != UINT32_MAX;
// Calculate output dimensions. Done after swapchain acquisition in case it was recreated. // Calculate output dimensions. Done after swapchain acquisition in case it was recreated.
coordi aspect_ratio; coordi aspect_ratio;
sizei csize = m_swapchain_dims; sizei csize = m_swapchain_dims;
sizei new_size = csize; sizei new_size = csize;
if (!g_cfg.video.stretch_to_display_area) if (!g_cfg.video.stretch_to_display_area)
{ {
const double aq = 1. * buffer_width / buffer_height; const double aq = 1. * buffer_width / buffer_height;
const double rq = 1. * new_size.width / new_size.height; const double rq = 1. * new_size.width / new_size.height;
const double q = aq / rq; const double q = aq / rq;
if (q > 1.0) if (q > 1.0)
{ {
new_size.height = static_cast<int>(new_size.height / q); new_size.height = static_cast<int>(new_size.height / q);
aspect_ratio.y = (csize.height - new_size.height) / 2; aspect_ratio.y = (csize.height - new_size.height) / 2;
} }
else if (q < 1.0) else if (q < 1.0)
{ {
new_size.width = static_cast<int>(new_size.width * q); new_size.width = static_cast<int>(new_size.width * q);
aspect_ratio.x = (csize.width - new_size.width) / 2; aspect_ratio.x = (csize.width - new_size.width) / 2;
} }
} }
aspect_ratio.size = new_size; aspect_ratio.size = new_size;
// Blit contents to screen.. // Blit contents to screen..
VkImage target_image = m_swapchain->get_image(m_current_frame->present_image); VkImage target_image = m_swapchain->get_image(m_current_frame->present_image);
@ -548,42 +548,42 @@ void VKGSRender::flip(const rsx::display_flip_info_t& info)
direct_fbo->release(); direct_fbo->release();
} }
if (m_frame->screenshot_toggle == true) if (m_frame->screenshot_toggle == true)
{ {
m_frame->screenshot_toggle = false; m_frame->screenshot_toggle = false;
const size_t sshot_size = buffer_height * buffer_width * 4; const size_t sshot_size = buffer_height * buffer_width * 4;
vk::buffer sshot_vkbuf(*m_device, align(sshot_size, 0x100000), m_device->get_memory_mapping().host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, vk::buffer sshot_vkbuf(*m_device, align(sshot_size, 0x100000), m_device->get_memory_mapping().host_visible_coherent, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT,
VK_BUFFER_USAGE_TRANSFER_DST_BIT, 0); VK_BUFFER_USAGE_TRANSFER_DST_BIT, 0);
VkBufferImageCopy copy_info; VkBufferImageCopy copy_info;
copy_info.bufferOffset = 0; copy_info.bufferOffset = 0;
copy_info.bufferRowLength = 0; copy_info.bufferRowLength = 0;
copy_info.bufferImageHeight = 0; copy_info.bufferImageHeight = 0;
copy_info.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; copy_info.imageSubresource.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT;
copy_info.imageSubresource.baseArrayLayer = 0; copy_info.imageSubresource.baseArrayLayer = 0;
copy_info.imageSubresource.layerCount = 1; copy_info.imageSubresource.layerCount = 1;
copy_info.imageSubresource.mipLevel = 0; copy_info.imageSubresource.mipLevel = 0;
copy_info.imageOffset.x = 0; copy_info.imageOffset.x = 0;
copy_info.imageOffset.y = 0; copy_info.imageOffset.y = 0;
copy_info.imageOffset.z = 0; copy_info.imageOffset.z = 0;
copy_info.imageExtent.width = buffer_width; copy_info.imageExtent.width = buffer_width;
copy_info.imageExtent.height = buffer_height; copy_info.imageExtent.height = buffer_height;
copy_info.imageExtent.depth = 1; copy_info.imageExtent.depth = 1;
image_to_flip->push_layout(*m_current_command_buffer, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL); image_to_flip->push_layout(*m_current_command_buffer, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL);
vk::copy_image_to_buffer(*m_current_command_buffer, image_to_flip, &sshot_vkbuf, copy_info); vk::copy_image_to_buffer(*m_current_command_buffer, image_to_flip, &sshot_vkbuf, copy_info);
image_to_flip->pop_layout(*m_current_command_buffer); image_to_flip->pop_layout(*m_current_command_buffer);
flush_command_queue(true); flush_command_queue(true);
auto src = sshot_vkbuf.map(0, sshot_size); auto src = sshot_vkbuf.map(0, sshot_size);
std::vector<u8> sshot_frame(sshot_size); std::vector<u8> sshot_frame(sshot_size);
memcpy(sshot_frame.data(), src, sshot_size); memcpy(sshot_frame.data(), src, sshot_size);
sshot_vkbuf.unmap(); sshot_vkbuf.unmap();
m_frame->take_screenshot(std::move(sshot_frame), buffer_width, buffer_height); m_frame->take_screenshot(std::move(sshot_frame), buffer_width, buffer_height);
} }
} }
else else
{ {