From 284d2c43f9e585f99f0638ed6dd423ae1ed5d772 Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Tue, 22 Mar 2016 18:56:18 +0100 Subject: [PATCH 1/2] rsx/common: Use protected instead of private for surface_store content. --- rpcs3/Emu/RSX/Common/surface_store.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/surface_store.h b/rpcs3/Emu/RSX/Common/surface_store.h index 29b399b674..7d5448099a 100644 --- a/rpcs3/Emu/RSX/Common/surface_store.h +++ b/rpcs3/Emu/RSX/Common/surface_store.h @@ -58,7 +58,7 @@ namespace rsx } } - private: + protected: using surface_storage_type = typename Traits::surface_storage_type; using surface_type = typename Traits::surface_type; using command_list_type = typename Traits::command_list_type; @@ -76,7 +76,7 @@ namespace rsx surface_store() = default; ~surface_store() = default; surface_store(const surface_store&) = delete; - private: + protected: /** * If render target already exists at address, issue state change operation on cmdList. * Otherwise create one with width, height, clearColor info. From b00acff9dda91b36d25a39c3ac5a113a8ed209df Mon Sep 17 00:00:00 2001 From: Vincent Lejeune Date: Tue, 22 Mar 2016 19:03:30 +0100 Subject: [PATCH 2/2] rsx/common: Turn alignment constraints in textureUtils to multiple_of constraints. --- rpcs3/Emu/RSX/Common/TextureUtils.cpp | 25 +++++++++++++------------ rpcs3/Emu/RSX/Common/TextureUtils.h | 2 +- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index afbf6e4eba..fdd138d694 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -111,9 +111,10 @@ namespace } template -u32 get_row_pitch_in_block(u16 width_in_block, size_t alignment_in_bytes) +u32 get_row_pitch_in_block(u16 width_in_block, size_t multiple_constraints_in_byte) { - return static_cast(align(width_in_block * sizeof(T), alignment_in_bytes) / sizeof(T)); + size_t divided = (width_in_block * sizeof(T) + multiple_constraints_in_byte - 1) / multiple_constraints_in_byte; + return static_cast(divided * multiple_constraints_in_byte / sizeof(T)); } } @@ -173,7 +174,7 @@ std::vector get_subresources_layout(const rsx::texture & throw EXCEPTION("Wrong format %d", format); } -void upload_texture_subresource(gsl::span dst_buffer, const rsx_subresource_layout &src_layout, int format, bool is_swizzled, size_t dst_row_alignment) +void upload_texture_subresource(gsl::span dst_buffer, const rsx_subresource_layout &src_layout, int format, bool is_swizzled, size_t dst_row_pitch_multiple_of) { u16 w = src_layout.width_in_block; u16 h = src_layout.height_in_block; @@ -183,9 +184,9 @@ void upload_texture_subresource(gsl::span dst_buffer, const rsx_subre case CELL_GCM_TEXTURE_A8R8G8B8: case CELL_GCM_TEXTURE_D8R8G8B8: if (is_swizzled) - copy_unmodified_block_swizzled::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_alignment)); + copy_unmodified_block_swizzled::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of)); else - copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_alignment), src_layout.pitch_in_bytes); + copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); break; case CELL_GCM_TEXTURE_DEPTH16: case CELL_GCM_TEXTURE_D1R5G5B5: @@ -195,25 +196,25 @@ void upload_texture_subresource(gsl::span dst_buffer, const rsx_subre case CELL_GCM_TEXTURE_R5G6B5: case CELL_GCM_TEXTURE_G8B8: if (is_swizzled) - copy_unmodified_block_swizzled::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span>(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_alignment)); + copy_unmodified_block_swizzled::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span>(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of)); else - copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span>(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_alignment), src_layout.pitch_in_bytes); + copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span>(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); break; case CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT: - copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span>(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_alignment), src_layout.pitch_in_bytes); + copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span>(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); break; case CELL_GCM_TEXTURE_COMPRESSED_DXT1: - copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_alignment), src_layout.pitch_in_bytes); + copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); break; case CELL_GCM_TEXTURE_COMPRESSED_DXT23: case CELL_GCM_TEXTURE_COMPRESSED_DXT45: - copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_alignment), src_layout.pitch_in_bytes); + copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); break; case CELL_GCM_TEXTURE_B8: if (is_swizzled) - copy_unmodified_block_swizzled::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_alignment)); + copy_unmodified_block_swizzled::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of)); else - copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_alignment), src_layout.pitch_in_bytes); + copy_unmodified_block::copy_mipmap_level(as_span_workaround(dst_buffer), gsl::as_span(src_layout.data), w, h, depth, get_row_pitch_in_block(w, dst_row_pitch_multiple_of), src_layout.pitch_in_bytes); break; default: throw EXCEPTION("Wrong format %d", format); diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.h b/rpcs3/Emu/RSX/Common/TextureUtils.h index 6cc8a410f4..a59cfb2523 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.h +++ b/rpcs3/Emu/RSX/Common/TextureUtils.h @@ -23,7 +23,7 @@ size_t get_placed_texture_storage_size(const rsx::texture &texture, size_t rowPi */ std::vector get_subresources_layout(const rsx::texture &texture); -void upload_texture_subresource(gsl::span dst_buffer, const rsx_subresource_layout &src_layout, int format, bool is_swizzled, size_t dst_row_alignment); +void upload_texture_subresource(gsl::span dst_buffer, const rsx_subresource_layout &src_layout, int format, bool is_swizzled, size_t dst_row_pitch_multiple_of); u8 get_format_block_size_in_bytes(int format); u8 get_format_block_size_in_texel(int format);