summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2024-02-01 17:34:06 +0100
committerGitHub <noreply@github.com>2024-02-01 17:34:06 +0100
commitd49275f0e7b681c952b95dc941fecdd6138d8a06 (patch)
treed4728072509e44abec5cbe73be2f11b483570127
parentMerge pull request #12848 from german77/caps-interface (diff)
parentSwBlitter: Fix Pitch linear reading/writting (diff)
downloadyuzu-d49275f0e7b681c952b95dc941fecdd6138d8a06.tar
yuzu-d49275f0e7b681c952b95dc941fecdd6138d8a06.tar.gz
yuzu-d49275f0e7b681c952b95dc941fecdd6138d8a06.tar.bz2
yuzu-d49275f0e7b681c952b95dc941fecdd6138d8a06.tar.lz
yuzu-d49275f0e7b681c952b95dc941fecdd6138d8a06.tar.xz
yuzu-d49275f0e7b681c952b95dc941fecdd6138d8a06.tar.zst
yuzu-d49275f0e7b681c952b95dc941fecdd6138d8a06.zip
-rw-r--r--src/video_core/engines/sw_blitter/blitter.cpp37
1 files changed, 19 insertions, 18 deletions
diff --git a/src/video_core/engines/sw_blitter/blitter.cpp b/src/video_core/engines/sw_blitter/blitter.cpp
index 4bc079024..8bcc2f7a7 100644
--- a/src/video_core/engines/sw_blitter/blitter.cpp
+++ b/src/video_core/engines/sw_blitter/blitter.cpp
@@ -111,6 +111,20 @@ void Bilinear(std::span<const f32> input, std::span<f32> output, size_t src_widt
}
}
+template <bool unpack>
+void ProcessPitchLinear(std::span<const u8> input, std::span<u8> output, size_t extent_x,
+ size_t extent_y, u32 pitch, u32 x0, u32 y0, size_t bpp) {
+ const size_t base_offset = x0 * bpp;
+ const size_t copy_size = extent_x * bpp;
+ for (size_t y = 0; y < extent_y; y++) {
+ const size_t first_offset = (y + y0) * pitch + base_offset;
+ const size_t second_offset = y * extent_x * bpp;
+ u8* write_to = unpack ? &output[first_offset] : &output[second_offset];
+ const u8* read_from = unpack ? &input[second_offset] : &input[first_offset];
+ std::memcpy(write_to, read_from, copy_size);
+ }
+}
+
} // namespace
struct SoftwareBlitEngine::BlitEngineImpl {
@@ -138,19 +152,6 @@ bool SoftwareBlitEngine::Blit(Fermi2D::Surface& src, Fermi2D::Surface& dst,
}
return static_cast<size_t>(surface.pitch * surface.height);
};
- const auto process_pitch_linear = [](bool unpack, std::span<const u8> input,
- std::span<u8> output, u32 extent_x, u32 extent_y,
- u32 pitch, u32 x0, u32 y0, size_t bpp) {
- const size_t base_offset = x0 * bpp;
- const size_t copy_size = extent_x * bpp;
- for (u32 y = y0; y < extent_y; y++) {
- const size_t first_offset = y * pitch + base_offset;
- const size_t second_offset = y * extent_x * bpp;
- u8* write_to = unpack ? &output[first_offset] : &output[second_offset];
- const u8* read_from = unpack ? &input[second_offset] : &input[first_offset];
- std::memcpy(write_to, read_from, copy_size);
- }
- };
const u32 src_extent_x = config.src_x1 - config.src_x0;
const u32 src_extent_y = config.src_y1 - config.src_y0;
@@ -205,8 +206,8 @@ bool SoftwareBlitEngine::Blit(Fermi2D::Surface& src, Fermi2D::Surface& dst,
src.depth, config.src_x0, config.src_y0, src_extent_x, src_extent_y,
src.block_height, src.block_depth, src_extent_x * src_bytes_per_pixel);
} else {
- process_pitch_linear(false, tmp_buffer, impl->src_buffer, src_extent_x, src_extent_y,
- src.pitch, config.src_x0, config.src_y0, src_bytes_per_pixel);
+ ProcessPitchLinear<false>(tmp_buffer, impl->src_buffer, src_extent_x, src_extent_y,
+ src.pitch, config.src_x0, config.src_y0, src_bytes_per_pixel);
}
// Conversion Phase
@@ -229,9 +230,9 @@ bool SoftwareBlitEngine::Blit(Fermi2D::Surface& src, Fermi2D::Surface& dst,
dst.depth, config.dst_x0, config.dst_y0, dst_extent_x, dst_extent_y,
dst.block_height, dst.block_depth, dst_extent_x * dst_bytes_per_pixel);
} else {
- process_pitch_linear(true, impl->dst_buffer, tmp_buffer2, dst_extent_x, dst_extent_y,
- dst.pitch, config.dst_x0, config.dst_y0,
- static_cast<size_t>(dst_bytes_per_pixel));
+ ProcessPitchLinear<true>(impl->dst_buffer, tmp_buffer2, dst_extent_x, dst_extent_y,
+ dst.pitch, config.dst_x0, config.dst_y0,
+ static_cast<size_t>(dst_bytes_per_pixel));
}
return true;
}