diff --git a/rpcs3/Emu/RSX/Common/surface_store.h b/rpcs3/Emu/RSX/Common/surface_store.h index 340c7ec8ae..3197adb12e 100644 --- a/rpcs3/Emu/RSX/Common/surface_store.h +++ b/rpcs3/Emu/RSX/Common/surface_store.h @@ -721,9 +721,9 @@ namespace rsx auto this_range = it->surface->get_memory_range(); ensure(this_range.overlaps(range)); - const auto native_pitch = it->surface->get_surface_width(rsx::surface_metrics::bytes); + const auto native_pitch = it->surface->get_surface_width(); const auto rsx_pitch = it->surface->get_rsx_pitch(); - auto num_rows = it->surface->get_surface_height(rsx::surface_metrics::samples); + auto num_rows = it->surface->get_surface_height(); bool valid = false; if (this_range.start < range.start) @@ -1002,8 +1002,8 @@ namespace rsx info.base_address = range.start; info.is_depth = is_depth; - const u32 normalized_surface_width = surface->get_surface_width(rsx::surface_metrics::bytes) / required_bpp; - const u32 normalized_surface_height = surface->get_surface_height(rsx::surface_metrics::samples); + const u32 normalized_surface_width = surface->get_surface_width() / required_bpp; + const u32 normalized_surface_height = surface->get_surface_height(); if (range.start >= texaddr) [[likely]] { diff --git a/rpcs3/Emu/RSX/Common/surface_utils.h b/rpcs3/Emu/RSX/Common/surface_utils.h index d96456fc5f..864e0acaf8 100644 --- a/rpcs3/Emu/RSX/Common/surface_utils.h +++ b/rpcs3/Emu/RSX/Common/surface_utils.h @@ -94,12 +94,12 @@ namespace rsx auto src = static_cast(source); std::tie(src_w, src_h) = rsx::apply_resolution_scale(src_w, src_h, - src->get_surface_width(rsx::surface_metrics::pixels), - src->get_surface_height(rsx::surface_metrics::pixels)); + src->get_surface_width(), + src->get_surface_height()); std::tie(dst_w, dst_h) = rsx::apply_resolution_scale(dst_w, dst_h, - target_surface->get_surface_width(rsx::surface_metrics::pixels), - target_surface->get_surface_height(rsx::surface_metrics::pixels)); + target_surface->get_surface_width()), + target_surface->get_surface_height())); } width = src_w; @@ -178,9 +178,10 @@ namespace rsx virtual bool is_depth_surface() const = 0; virtual void release_ref(image_storage_type) const = 0; - inline u32 get_surface_width(rsx::surface_metrics metrics = rsx::surface_metrics::pixels) const + template + u32 get_surface_width() const { - switch (metrics) + switch constexpr (Metrics) { case rsx::surface_metrics::samples: return surface_width * samples_x; @@ -188,22 +189,19 @@ namespace rsx return surface_width; case rsx::surface_metrics::bytes: return native_pitch; - default: - fmt::throw_exception("Unknown surface metric %d", u32(metrics)); } } - inline u32 get_surface_height(rsx::surface_metrics metrics = rsx::surface_metrics::pixels) const + template + u32 get_surface_height() const { - switch (metrics) + switch constexpr (Metrics) { case rsx::surface_metrics::samples: case rsx::surface_metrics::bytes: return surface_height * samples_y; case rsx::surface_metrics::pixels: return surface_height; - default: - fmt::throw_exception("Unknown surface metric %d", u32(metrics)); } } @@ -219,7 +217,7 @@ namespace rsx inline u8 get_bpp() const { - return u8(get_native_pitch() / get_surface_width(rsx::surface_metrics::samples)); + return u8(get_native_pitch() / get_surface_width()); } inline u8 get_spp() const @@ -514,11 +512,11 @@ namespace rsx template surface_inheritance_result inherit_surface_contents(T* surface) { - const auto child_w = get_surface_width(rsx::surface_metrics::bytes); - const auto child_h = get_surface_height(rsx::surface_metrics::bytes); + const auto child_w = get_surface_width(); + const auto child_h = get_surface_height(); - const auto parent_w = surface->get_surface_width(rsx::surface_metrics::bytes); - const auto parent_h = surface->get_surface_height(rsx::surface_metrics::bytes); + const auto parent_w = surface->get_surface_width(); + const auto parent_h = surface->get_surface_height(); const auto rect = rsx::intersect_region(surface->base_addr, parent_w, parent_h, 1, base_addr, child_w, child_h, 1, get_rsx_pitch()); const auto src_offset = std::get<0>(rect); @@ -606,17 +604,17 @@ namespace rsx } // Returns the rect area occupied by this surface expressed as an 8bpp image with no AA - areau get_normalized_memory_area() const + inline areau get_normalized_memory_area() const { - const u16 internal_width = get_surface_width(rsx::surface_metrics::bytes); - const u16 internal_height = get_surface_height(rsx::surface_metrics::bytes); + const u16 internal_width = get_surface_width(); + const u16 internal_height = get_surface_height(); return { 0, 0, internal_width, internal_height }; } - rsx::address_range get_memory_range() const + inline rsx::address_range get_memory_range() const { - const u32 internal_height = get_surface_height(rsx::surface_metrics::samples); + const u32 internal_height = get_surface_height()); const u32 excess = (rsx_pitch - native_pitch); return rsx::address_range::start_length(base_addr, internal_height * rsx_pitch - excess); } diff --git a/rpcs3/Emu/RSX/Common/texture_cache.h b/rpcs3/Emu/RSX/Common/texture_cache.h index af4af2d23f..7957f6c7cd 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache.h +++ b/rpcs3/Emu/RSX/Common/texture_cache.h @@ -1952,7 +1952,7 @@ namespace rsx u32 coverage_size = 0; for (const auto& section : overlapping_fbos) { - const auto area = section.surface->get_native_pitch() * section.surface->get_surface_height(rsx::surface_metrics::bytes); + const auto area = section.surface->get_native_pitch() * section.surface->get_surface_height(); coverage_size += area; } @@ -2509,8 +2509,8 @@ namespace rsx typeless_info.src_gcm_format = helpers::get_sized_blit_format(src_is_argb8, false, is_format_convert); } - if (surf->get_surface_width(rsx::surface_metrics::pixels) != surf->width() || - surf->get_surface_height(rsx::surface_metrics::pixels) != surf->height()) + if (surf->get_surface_width() != surf->width() || + surf->get_surface_height() != surf->height()) { // Must go through a scaling operation due to resolution scaling being present ensure(g_cfg.video.resolution_scale_percent != 100); @@ -2606,8 +2606,8 @@ namespace rsx size2u src_dimensions = { 0, 0 }; if (src_is_render_target) { - src_dimensions.width = src_subres.surface->get_surface_width(rsx::surface_metrics::samples); - src_dimensions.height = src_subres.surface->get_surface_height(rsx::surface_metrics::samples); + src_dimensions.width = src_subres.surface->get_surface_width(); + src_dimensions.height = src_subres.surface->get_surface_height(); } const auto props = texture_cache_helpers::get_optimal_blit_target_properties( @@ -2761,8 +2761,8 @@ namespace rsx typeless_info.dst_context = texture_upload_context::framebuffer_storage; dst_is_depth_surface = typeless_info.dst_is_typeless ? false : dst_subres.is_depth; - max_dst_width = static_cast(dst_subres.surface->get_surface_width(rsx::surface_metrics::samples) * typeless_info.dst_scaling_hint); - max_dst_height = dst_subres.surface->get_surface_height(rsx::surface_metrics::samples); + max_dst_width = static_cast(dst_subres.surface->get_surface_width() * typeless_info.dst_scaling_hint); + max_dst_height = dst_subres.surface->get_surface_height(); } // Create source texture if does not exist @@ -3109,8 +3109,8 @@ namespace rsx if (src_is_render_target) { - const auto surface_width = src_subres.surface->get_surface_width(rsx::surface_metrics::pixels); - const auto surface_height = src_subres.surface->get_surface_height(rsx::surface_metrics::pixels); + const auto surface_width = src_subres.surface->get_surface_width(); + const auto surface_height = src_subres.surface->get_surface_height(); std::tie(src_area.x1, src_area.y1) = rsx::apply_resolution_scale(src_area.x1, src_area.y1, surface_width, surface_height); std::tie(src_area.x2, src_area.y2) = rsx::apply_resolution_scale(src_area.x2, src_area.y2, surface_width, surface_height); @@ -3120,8 +3120,8 @@ namespace rsx if (dst_is_render_target) { - const auto surface_width = dst_subres.surface->get_surface_width(rsx::surface_metrics::pixels); - const auto surface_height = dst_subres.surface->get_surface_height(rsx::surface_metrics::pixels); + const auto surface_width = dst_subres.surface->get_surface_width(); + const auto surface_height = dst_subres.surface->get_surface_height(); std::tie(dst_area.x1, dst_area.y1) = rsx::apply_resolution_scale(dst_area.x1, dst_area.y1, surface_width, surface_height); std::tie(dst_area.x2, dst_area.y2) = rsx::apply_resolution_scale(dst_area.x2, dst_area.y2, surface_width, surface_height); diff --git a/rpcs3/Emu/RSX/Common/texture_cache_helpers.h b/rpcs3/Emu/RSX/Common/texture_cache_helpers.h index 7e067c8a9f..57217c0e10 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache_helpers.h +++ b/rpcs3/Emu/RSX/Common/texture_cache_helpers.h @@ -303,8 +303,8 @@ namespace rsx const auto h = std::min(section_end, slice_end) - dst_y; dst_y = (dst_y - slice_begin); - const auto surface_width = section.surface->get_surface_width(rsx::surface_metrics::pixels); - const auto surface_height = section.surface->get_surface_height(rsx::surface_metrics::pixels); + const auto surface_width = section.surface->get_surface_width(); + const auto surface_height = section.surface->get_surface_height(); const auto [src_width, src_height] = rsx::apply_resolution_scale(section.src_area.width, h, surface_width, surface_height); const auto [dst_width, dst_height] = rsx::apply_resolution_scale(section.dst_area.width, h, attr.width, attr.height); @@ -477,8 +477,8 @@ namespace rsx return false; } - const auto surface_width = texptr->get_surface_width(rsx::surface_metrics::samples); - const auto surface_height = texptr->get_surface_height(rsx::surface_metrics::samples); + const auto surface_width = texptr->get_surface_width(); + const auto surface_height = texptr->get_surface_height(); switch (extended_dimension) { @@ -507,8 +507,8 @@ namespace rsx { texptr->read_barrier(cmd); - const auto surface_width = texptr->get_surface_width(rsx::surface_metrics::samples); - const auto surface_height = texptr->get_surface_height(rsx::surface_metrics::samples); + const auto surface_width = texptr->get_surface_width(); + const auto surface_height = texptr->get_surface_height(); bool is_depth = texptr->is_depth_surface(); auto attr2 = attr; diff --git a/rpcs3/Emu/RSX/GL/GLPresent.cpp b/rpcs3/Emu/RSX/GL/GLPresent.cpp index 73ca6d0af5..b7942ebba0 100644 --- a/rpcs3/Emu/RSX/GL/GLPresent.cpp +++ b/rpcs3/Emu/RSX/GL/GLPresent.cpp @@ -38,8 +38,8 @@ gl::texture* GLGSRender::get_present_source(gl::present_surface_info* info, cons if (section.base_address >= info->address) { - const auto surface_width = surface->get_surface_width(rsx::surface_metrics::samples); - const auto surface_height = surface->get_surface_height(rsx::surface_metrics::samples); + const auto surface_width = surface->get_surface_width(); + const auto surface_height = surface->get_surface_height(); if (section.base_address == info->address) { diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp index 303f546804..0dff091cd3 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.cpp @@ -382,7 +382,7 @@ void GLGSRender::init_buffers(rsx::framebuffer_creation_context context, bool /* m_gl_texture_cache.lock_memory_region( cmd, surface, surface->get_memory_range(), false, - surface->get_surface_width(rsx::surface_metrics::pixels), surface->get_surface_height(rsx::surface_metrics::pixels), surface->get_rsx_pitch(), + surface->get_surface_width(), surface->get_surface_height(), surface->get_rsx_pitch(), format, type, swap_bytes); } diff --git a/rpcs3/Emu/RSX/GL/GLRenderTargets.h b/rpcs3/Emu/RSX/GL/GLRenderTargets.h index d883157ad1..e664981101 100644 --- a/rpcs3/Emu/RSX/GL/GLRenderTargets.h +++ b/rpcs3/Emu/RSX/GL/GLRenderTargets.h @@ -194,7 +194,7 @@ struct gl_render_target_traits { auto internal_format = static_cast(ref->get_internal_format()); const auto [new_w, new_h] = rsx::apply_resolution_scale(prev.width, prev.height, - ref->get_surface_width(rsx::surface_metrics::pixels), ref->get_surface_height(rsx::surface_metrics::pixels)); + ref->get_surface_width(), ref->get_surface_height()); sink = std::make_unique(new_w, new_h, internal_format, ref->format_class()); sink->add_ref(); @@ -237,8 +237,8 @@ struct gl_render_target_traits { return (surface->get_internal_format() == ref->get_internal_format() && surface->get_spp() == sample_count && - surface->get_surface_width(rsx::surface_metrics::pixels) >= width && - surface->get_surface_height(rsx::surface_metrics::pixels) >= height); + surface->get_surface_width() >= width && + surface->get_surface_height() >= height); } static diff --git a/rpcs3/Emu/RSX/VK/VKGSRender.cpp b/rpcs3/Emu/RSX/VK/VKGSRender.cpp index d3357eb611..985ef0ee1c 100644 --- a/rpcs3/Emu/RSX/VK/VKGSRender.cpp +++ b/rpcs3/Emu/RSX/VK/VKGSRender.cpp @@ -2463,7 +2463,7 @@ void VKGSRender::prepare_rtts(rsx::framebuffer_creation_context context) m_texture_cache.lock_memory_region( *m_current_command_buffer, surface, surface->get_memory_range(), false, - surface->get_surface_width(rsx::surface_metrics::pixels), surface->get_surface_height(rsx::surface_metrics::pixels), surface->get_rsx_pitch(), + surface->get_surface_width(), surface->get_surface_height(), surface->get_rsx_pitch(), gcm_format, swap_bytes); } diff --git a/rpcs3/Emu/RSX/VK/VKPresent.cpp b/rpcs3/Emu/RSX/VK/VKPresent.cpp index 93f728a621..dc9797bcf9 100644 --- a/rpcs3/Emu/RSX/VK/VKPresent.cpp +++ b/rpcs3/Emu/RSX/VK/VKPresent.cpp @@ -288,8 +288,8 @@ vk::viewable_image* VKGSRender::get_present_source(vk::present_surface_info* inf if (section.base_address >= info->address) { - const auto surface_width = surface->get_surface_width(rsx::surface_metrics::samples); - const auto surface_height = surface->get_surface_height(rsx::surface_metrics::samples); + const auto surface_width = surface->get_surface_width(); + const auto surface_height = surface->get_surface_height(); if (section.base_address == info->address) { diff --git a/rpcs3/Emu/RSX/VK/VKRenderTargets.h b/rpcs3/Emu/RSX/VK/VKRenderTargets.h index d2d738e5e5..bd967bcd9b 100644 --- a/rpcs3/Emu/RSX/VK/VKRenderTargets.h +++ b/rpcs3/Emu/RSX/VK/VKRenderTargets.h @@ -271,7 +271,7 @@ namespace vk if (!sink) { const auto [new_w, new_h] = rsx::apply_resolution_scale(prev.width, prev.height, - ref->get_surface_width(rsx::surface_metrics::pixels), ref->get_surface_height(rsx::surface_metrics::pixels)); + ref->get_surface_width(), ref->get_surface_height()); auto& dev = cmd.get_command_pool().get_owner(); sink = std::make_unique(dev, dev.get_memory_mapping().device_local,