summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar wwylele2016-09-27 21:48:03 +0800
committerGravatar wwylele2016-09-29 10:01:34 +0800
commit58ae94af4c5c7777cab40ebb4f2bc517dd0f9f2c (patch)
tree1345ff8aceb7a1f2672320685411f7b5cb1d9ddd /src
parentgpu: keep the old signal strategy for null pointer (diff)
downloadyuzu-58ae94af4c5c7777cab40ebb4f2bc517dd0f9f2c.tar.gz
yuzu-58ae94af4c5c7777cab40ebb4f2bc517dd0f9f2c.tar.xz
yuzu-58ae94af4c5c7777cab40ebb4f2bc517dd0f9f2c.zip
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.cpp19
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) {
217 u32 input_x = x << horizontal_scale; 217 u32 input_x = x << horizontal_scale;
218 u32 input_y = y << vertical_scale; 218 u32 input_y = y << vertical_scale;
219 219
220 u32 output_y;
220 if (config.flip_vertically) { 221 if (config.flip_vertically) {
221 // Flip the y value of the output data, 222 // Flip the y value of the output data,
222 // we do this after calculating the [x,y] position of the input image 223 // we do this after calculating the [x,y] position of the input image
223 // to account for the scaling options. 224 // to account for the scaling options.
224 y = output_height - y - 1; 225 output_y = output_height - y - 1;
226 } else {
227 output_y = y;
225 } 228 }
226 229
227 u32 dst_bytes_per_pixel = GPU::Regs::BytesPerPixel(config.output_format); 230 u32 dst_bytes_per_pixel = GPU::Regs::BytesPerPixel(config.output_format);
@@ -232,16 +235,16 @@ static void DisplayTransfer(const Regs::DisplayTransferConfig& config) {
232 if (config.input_linear) { 235 if (config.input_linear) {
233 if (!config.dont_swizzle) { 236 if (!config.dont_swizzle) {
234 // Interpret the input as linear and the output as tiled 237 // Interpret the input as linear and the output as tiled
235 u32 coarse_y = y & ~7; 238 u32 coarse_y = output_y & ~7;
236 u32 stride = output_width * dst_bytes_per_pixel; 239 u32 stride = output_width * dst_bytes_per_pixel;
237 240
238 src_offset = (input_x + input_y * config.input_width) * src_bytes_per_pixel; 241 src_offset = (input_x + input_y * config.input_width) * src_bytes_per_pixel;
239 dst_offset = 242 dst_offset = VideoCore::GetMortonOffset(x, output_y, dst_bytes_per_pixel) +
240 VideoCore::GetMortonOffset(x, y, dst_bytes_per_pixel) + coarse_y * stride; 243 coarse_y * stride;
241 } else { 244 } else {
242 // Both input and output are linear 245 // Both input and output are linear
243 src_offset = (input_x + input_y * config.input_width) * src_bytes_per_pixel; 246 src_offset = (input_x + input_y * config.input_width) * src_bytes_per_pixel;
244 dst_offset = (x + y * output_width) * dst_bytes_per_pixel; 247 dst_offset = (x + output_y * output_width) * dst_bytes_per_pixel;
245 } 248 }
246 } else { 249 } else {
247 if (!config.dont_swizzle) { 250 if (!config.dont_swizzle) {
@@ -251,10 +254,10 @@ static void DisplayTransfer(const Regs::DisplayTransferConfig& config) {
251 254
252 src_offset = VideoCore::GetMortonOffset(input_x, input_y, src_bytes_per_pixel) + 255 src_offset = VideoCore::GetMortonOffset(input_x, input_y, src_bytes_per_pixel) +
253 coarse_y * stride; 256 coarse_y * stride;
254 dst_offset = (x + y * output_width) * dst_bytes_per_pixel; 257 dst_offset = (x + output_y * output_width) * dst_bytes_per_pixel;
255 } else { 258 } else {
256 // Both input and output are tiled 259 // Both input and output are tiled
257 u32 out_coarse_y = y & ~7; 260 u32 out_coarse_y = output_y & ~7;
258 u32 out_stride = output_width * dst_bytes_per_pixel; 261 u32 out_stride = output_width * dst_bytes_per_pixel;
259 262
260 u32 in_coarse_y = input_y & ~7; 263 u32 in_coarse_y = input_y & ~7;
@@ -262,7 +265,7 @@ static void DisplayTransfer(const Regs::DisplayTransferConfig& config) {
262 265
263 src_offset = VideoCore::GetMortonOffset(input_x, input_y, src_bytes_per_pixel) + 266 src_offset = VideoCore::GetMortonOffset(input_x, input_y, src_bytes_per_pixel) +
264 in_coarse_y * in_stride; 267 in_coarse_y * in_stride;
265 dst_offset = VideoCore::GetMortonOffset(x, y, dst_bytes_per_pixel) + 268 dst_offset = VideoCore::GetMortonOffset(x, output_y, dst_bytes_per_pixel) +
266 out_coarse_y * out_stride; 269 out_coarse_y * out_stride;
267 } 270 }
268 } 271 }