diff options
author | wwylele <wwylele@gmail.com> | 2016-09-27 21:48:03 +0800 |
---|---|---|
committer | wwylele <wwylele@gmail.com> | 2016-09-29 10:01:34 +0800 |
commit | 58ae94af4c5c7777cab40ebb4f2bc517dd0f9f2c (patch) | |
tree | 1345ff8aceb7a1f2672320685411f7b5cb1d9ddd /src | |
parent | 30ab0fa45dc3b12821e8cf629158f78814774f7c (diff) |
gpu: DisplayTransfer: a less amazing algorithm for flip
the old implementation modifies the loop variable in the loop. Though it actually works, it is really confusing. Makes it morereadable now.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/hw/gpu.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/core/hw/gpu.cpp b/src/core/hw/gpu.cpp index 8a46d71a5..28cb97d8e 100644 --- a/src/core/hw/gpu.cpp +++ b/src/core/hw/gpu.cpp @@ -217,11 +217,14 @@ static void DisplayTransfer(const Regs::DisplayTransferConfig& config) { u32 input_x = x << horizontal_scale; u32 input_y = y << vertical_scale; + u32 output_y; if (config.flip_vertically) { // Flip the y value of the output data, // we do this after calculating the [x,y] position of the input image // to account for the scaling options. - y = output_height - y - 1; + output_y = output_height - y - 1; + } else { + output_y = y; } u32 dst_bytes_per_pixel = GPU::Regs::BytesPerPixel(config.output_format); @@ -232,16 +235,16 @@ static void DisplayTransfer(const Regs::DisplayTransferConfig& config) { if (config.input_linear) { if (!config.dont_swizzle) { // Interpret the input as linear and the output as tiled - u32 coarse_y = y & ~7; + u32 coarse_y = output_y & ~7; u32 stride = output_width * dst_bytes_per_pixel; src_offset = (input_x + input_y * config.input_width) * src_bytes_per_pixel; - dst_offset = - VideoCore::GetMortonOffset(x, y, dst_bytes_per_pixel) + coarse_y * stride; + dst_offset = VideoCore::GetMortonOffset(x, output_y, dst_bytes_per_pixel) + + coarse_y * stride; } else { // Both input and output are linear src_offset = (input_x + input_y * config.input_width) * src_bytes_per_pixel; - dst_offset = (x + y * output_width) * dst_bytes_per_pixel; + dst_offset = (x + output_y * output_width) * dst_bytes_per_pixel; } } else { if (!config.dont_swizzle) { @@ -251,10 +254,10 @@ static void DisplayTransfer(const Regs::DisplayTransferConfig& config) { src_offset = VideoCore::GetMortonOffset(input_x, input_y, src_bytes_per_pixel) + coarse_y * stride; - dst_offset = (x + y * output_width) * dst_bytes_per_pixel; + dst_offset = (x + output_y * output_width) * dst_bytes_per_pixel; } else { // Both input and output are tiled - u32 out_coarse_y = y & ~7; + u32 out_coarse_y = output_y & ~7; u32 out_stride = output_width * dst_bytes_per_pixel; u32 in_coarse_y = input_y & ~7; @@ -262,7 +265,7 @@ static void DisplayTransfer(const Regs::DisplayTransferConfig& config) { src_offset = VideoCore::GetMortonOffset(input_x, input_y, src_bytes_per_pixel) + in_coarse_y * in_stride; - dst_offset = VideoCore::GetMortonOffset(x, y, dst_bytes_per_pixel) + + dst_offset = VideoCore::GetMortonOffset(x, output_y, dst_bytes_per_pixel) + out_coarse_y * out_stride; } } |