Created
February 26, 2018 02:19
-
-
Save snickerbockers/a77ae138e30216827f5df27290c25157 to your computer and use it in GitHub Desktop.
Patch to make WashingtonDC *not* copy framebuffers upside-down. It actually slows things down because it causes more cache misses.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/gfx/opengl/opengl_output.c b/src/gfx/opengl/opengl_output.c | |
index e00a4df..172596f 100644 | |
--- a/src/gfx/opengl/opengl_output.c | |
+++ b/src/gfx/opengl/opengl_output.c | |
@@ -56,17 +56,11 @@ static struct shader fb_shader; | |
#define FB_VERT_LEN 5 | |
#define FB_VERT_COUNT 4 | |
static GLfloat fb_quad_verts[FB_VERT_LEN * FB_VERT_COUNT] = { | |
- /* | |
- * it is not a mistake that the texture-coordinates are upside-down | |
- * this is because dreamcast puts the origin at upper-left corner, | |
- * but opengl textures put the origin at the lower-left corner | |
- */ | |
- | |
// position // texture coordinates | |
- -1.0f, -1.0f, 0.0f, 0.0f, 1.0f, | |
- -1.0f, 1.0f, 0.0f, 0.0f, 0.0f, | |
- 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, | |
- 1.0f, -1.0f, 0.0f, 1.0f, 1.0f | |
+ -1.0f, 1.0f, 0.0f, 0.0f, 1.0f, | |
+ -1.0f, -1.0f, 0.0f, 0.0f, 0.0f, | |
+ 1.0f, -1.0f, 0.0f, 1.0f, 0.0f, | |
+ 1.0f, 1.0f, 0.0f, 1.0f, 1.0f | |
}; | |
#define FB_QUAD_IDX_COUNT 4 | |
diff --git a/src/hw/pvr2/framebuffer.c b/src/hw/pvr2/framebuffer.c | |
index 427a6a1..758b2d0 100644 | |
--- a/src/hw/pvr2/framebuffer.c | |
+++ b/src/hw/pvr2/framebuffer.c | |
@@ -184,7 +184,7 @@ void read_framebuffer_rgb565_prog(uint32_t *pixels_out, addr32_t start_addr, | |
unsigned row; | |
for (row = 0; row < height; row++) { | |
uint16_t const *in_col_start = pixels_in + stride * row; | |
- uint32_t *out_col_start = pixels_out + row * width; | |
+ uint32_t *out_col_start = pixels_out + (height - row - 1) * width; | |
conv_rgb565_to_rgba8888(out_col_start, in_col_start, width, concat); | |
} | |
@@ -246,17 +246,16 @@ void read_framebuffer_rgb565_intl(uint32_t *pixels_out, | |
unsigned row; | |
for (row = 0; row < fb_height; row++) { | |
uint16_t const *ptr_row1 = | |
- (uint16_t const*)(pvr2_tex32_mem + row_start_field1); | |
+ (uint16_t const*)(pvr2_tex32_mem + row_start_field1 + field_adv * row); | |
uint16_t const *ptr_row2 = | |
- (uint16_t const*)(pvr2_tex32_mem + row_start_field2); | |
- | |
- conv_rgb565_to_rgba8888(pixels_out + (row << 1) * fb_width, | |
- ptr_row1, fb_width, concat); | |
- conv_rgb565_to_rgba8888(pixels_out + ((row << 1) + 1) * fb_width, | |
- ptr_row2, fb_width, concat); | |
- | |
- row_start_field1 += field_adv; | |
- row_start_field2 += field_adv; | |
+ (uint16_t const*)(pvr2_tex32_mem + row_start_field2 + field_adv * row); | |
+ | |
+ conv_rgb565_to_rgba8888( | |
+ pixels_out + (((fb_height - row - 1) << 1) + 1) * fb_width, | |
+ ptr_row1, fb_width, concat); | |
+ conv_rgb565_to_rgba8888( | |
+ pixels_out + ((fb_height - row - 1) << 1) * fb_width, | |
+ ptr_row2, fb_width, concat); | |
} | |
} | |
@@ -287,7 +286,7 @@ void read_framebuffer_rgb0888_prog(uint32_t *pixels_out, addr32_t start_addr, | |
unsigned row; | |
for (row = 0; row < height; row++) { | |
uint32_t const *in_col_start = pixels_in + width * row; | |
- uint32_t *out_col_start = pixels_out + row * width; | |
+ uint32_t *out_col_start = pixels_out + (height - row - 1) * width; | |
conv_rgb0888_to_rgba8888(out_col_start, in_col_start, width); | |
} | |
@@ -338,17 +337,14 @@ void read_framebuffer_rgb0888_intl(uint32_t *pixels_out, | |
unsigned row; | |
for (row = 0; row < fb_height; row++) { | |
uint32_t const *ptr_row1 = | |
- (uint32_t const*)(pvr2_tex32_mem + row_start_field1); | |
+ (uint32_t const*)(pvr2_tex32_mem + row_start_field1 + field_adv * row); | |
uint32_t const *ptr_row2 = | |
- (uint32_t const*)(pvr2_tex32_mem + row_start_field2); | |
+ (uint32_t const*)(pvr2_tex32_mem + row_start_field2 + field_adv * row); | |
- conv_rgb0888_to_rgba8888(pixels_out + (row << 1) * fb_width, | |
+ conv_rgb0888_to_rgba8888(pixels_out + (((fb_height - row - 1) << 1) + 1) * fb_width, | |
ptr_row1, fb_width); | |
- conv_rgb0888_to_rgba8888(pixels_out + ((row << 1) + 1) * fb_width, | |
+ conv_rgb0888_to_rgba8888(pixels_out + ((fb_height - row - 1) << 1) * fb_width, | |
ptr_row2, fb_width); | |
- | |
- row_start_field1 += field_adv; | |
- row_start_field2 += field_adv; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment