diff options
author | notaz | 2010-12-11 19:50:25 +0200 |
---|---|---|
committer | notaz | 2010-12-14 15:25:05 +0200 |
commit | d352cde27e89b1be21bf8f88c3ca79e0eb497165 (patch) | |
tree | 4dd77756eceeabd0532bd43b0c98c8f90d3db46f | |
parent | 5bf843dc7ca2eb95430607b49c0dde6798950317 (diff) | |
download | pcsx_rearmed-d352cde27e89b1be21bf8f88c3ca79e0eb497165.tar.gz pcsx_rearmed-d352cde27e89b1be21bf8f88c3ca79e0eb497165.tar.bz2 pcsx_rearmed-d352cde27e89b1be21bf8f88c3ca79e0eb497165.zip |
fix bgr2rgb16 and reduce mode change glitching
-rw-r--r-- | frontend/arm_utils.s | 56 | ||||
-rw-r--r-- | frontend/linux/fbdev.c | 26 | ||||
-rw-r--r-- | frontend/linux/fbdev.h | 2 | ||||
-rw-r--r-- | frontend/plugin_lib.c | 12 | ||||
-rw-r--r-- | plugins/dfxvideo/draw_fb.c | 4 |
5 files changed, 62 insertions, 38 deletions
diff --git a/frontend/arm_utils.s b/frontend/arm_utils.s index b0585b7..4736380 100644 --- a/frontend/arm_utils.s +++ b/frontend/arm_utils.s @@ -13,38 +13,44 @@ .global bgr555_to_rgb565 bgr555_to_rgb565: - mov r3, #0x03e0 + mov r3, #0x07c0 vdup.16 q15, r3 - mov r2, r2, lsr #6 + sub r2, r2, #64 0: vldmia r1!, {q0-q3} - vshr.u16 q4, q0, #10 - vshr.u16 q5, q1, #10 - vshr.u16 q6, q2, #10 - vshr.u16 q7, q3, #10 - vshl.u16 q8, q0, #11 - vshl.u16 q9, q1, #11 - vshl.u16 q10, q2, #11 - vshl.u16 q11, q3, #11 - vand q0, q0, q15 - vand q1, q1, q15 - vand q2, q2, q15 - vand q3, q3, q15 + vshl.u16 q4, q0, #11 + vshl.u16 q5, q1, #11 + vshl.u16 q6, q2, #11 + vshl.u16 q7, q3, #11 + vsri.u16 q4, q0, #10 + vsri.u16 q5, q1, #10 + vsri.u16 q6, q2, #10 + vsri.u16 q7, q3, #10 vshl.u16 q0, q0, #1 vshl.u16 q1, q1, #1 vshl.u16 q2, q2, #1 vshl.u16 q3, q3, #1 - vorr q0, q0, q4 - vorr q1, q1, q5 - vorr q2, q2, q6 - vorr q3, q3, q7 - vorr q0, q0, q8 - vorr q1, q1, q9 - vorr q2, q2, q10 - vorr q3, q3, q11 - vstmia r0!, {q0-q3} - subs r2, r2, #1 - bne 0b + vbit q4, q0, q15 + vbit q5, q1, q15 + vbit q6, q2, q15 + vbit q7, q3, q15 + vstmia r0!, {q4-q7} + subs r2, r2, #64 + bge 0b + + adds r2, r2, #64 + bxeq lr + + @ handle the remainder +0: + vld1.16 {q0}, [r1, :64]! + vshl.u16 q1, q0, #11 + vshl.u16 q2, q0, #1 + vsri.u16 q1, q0, #10 + vbit q1, q2, q15 + subs r2, r2, #16 + vst1.16 {q1}, [r0, :64]! + bgt 0b bx lr diff --git a/frontend/linux/fbdev.c b/frontend/linux/fbdev.c index b4889ea..bcef0fc 100644 --- a/frontend/linux/fbdev.c +++ b/frontend/linux/fbdev.c @@ -61,7 +61,8 @@ void vout_fbdev_wait_vsync(struct vout_fbdev *fbdev) ioctl(fbdev->fd, FBIO_WAITFORVSYNC, &arg); } -int vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h, int bpp, +/* it is recommended to call vout_fbdev_clear() before this */ +void *vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h, int bpp, int left_border, int right_border, int top_border, int bottom_border, int buffer_cnt) { int w_total = left_border + w + right_border; @@ -83,13 +84,20 @@ int vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h, int bpp, fbdev->fbvar_new.xres_virtual = w_total; fbdev->fbvar_new.yres_virtual = h_total; fbdev->fbvar_new.xoffset = left_border; + fbdev->fbvar_new.yoffset = top_border; fbdev->fbvar_new.bits_per_pixel = bpp; printf(" switching to %dx%d@%d\n", w, h, bpp); + + // seems to help a bit to avoid glitches + vout_fbdev_wait_vsync(fbdev); + ret = ioctl(fbdev->fd, FBIOPUT_VSCREENINFO, &fbdev->fbvar_new); if (ret == -1) { perror("FBIOPUT_VSCREENINFO ioctl"); - return -1; + return NULL; } + + fbdev->buffer_write = 1; } fbdev->buffer_count = buffer_cnt; @@ -99,6 +107,7 @@ int vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h, int bpp, ret = ioctl(fbdev->fd, FBIOPUT_VSCREENINFO, &fbdev->fbvar_new); if (ret == -1) { fbdev->buffer_count = 1; + fbdev->buffer_write = 0; fprintf(stderr, "Warning: failed to increase virtual resolution, " "doublebuffering disabled\n"); } @@ -110,7 +119,7 @@ int vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h, int bpp, mem_size = fbdev->fb_size * fbdev->buffer_count; if (fbdev->mem_size >= mem_size) - return 0; + goto out; if (fbdev->mem != NULL) munmap(fbdev->mem, fbdev->mem_size); @@ -126,11 +135,13 @@ int vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h, int bpp, fbdev->mem = NULL; fbdev->mem_size = 0; perror("mmap framebuffer"); - return -1; + return NULL; } fbdev->mem_size = mem_size; - return 0; + +out: + return (char *)fbdev->mem + fbdev->fb_size * fbdev->buffer_write; } void vout_fbdev_clear(struct vout_fbdev *fbdev) @@ -160,6 +171,7 @@ struct vout_fbdev *vout_fbdev_init(const char *fbdev_name, int *w, int *h, int b { struct vout_fbdev *fbdev; int req_w, req_h; + void *pret; int ret; fbdev = calloc(1, sizeof(*fbdev)); @@ -188,8 +200,8 @@ struct vout_fbdev *vout_fbdev_init(const char *fbdev_name, int *w, int *h, int b if (*h != 0) req_h = *h; - ret = vout_fbdev_resize(fbdev, req_w, req_h, bpp, 0, 0, 0, 0, buffer_cnt); - if (ret != 0) + pret = vout_fbdev_resize(fbdev, req_w, req_h, bpp, 0, 0, 0, 0, buffer_cnt); + if (pret == NULL) goto fail; printf("%s: %ix%i@%d\n", fbdev_name, fbdev->fbvar_new.xres, fbdev->fbvar_new.yres, diff --git a/frontend/linux/fbdev.h b/frontend/linux/fbdev.h index ddbfdab..2db9163 100644 --- a/frontend/linux/fbdev.h +++ b/frontend/linux/fbdev.h @@ -3,7 +3,7 @@ struct vout_fbdev; struct vout_fbdev *vout_fbdev_init(const char *fbdev_name, int *w, int *h, int bpp, int buffer_count); void *vout_fbdev_flip(struct vout_fbdev *fbdev); void vout_fbdev_wait_vsync(struct vout_fbdev *fbdev); -int vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h, int bpp, +void *vout_fbdev_resize(struct vout_fbdev *fbdev, int w, int h, int bpp, int left_border, int right_border, int top_border, int bottom_border, int buffer_count); void vout_fbdev_clear(struct vout_fbdev *fbdev); diff --git a/frontend/plugin_lib.c b/frontend/plugin_lib.c index e2a0d58..35a23c1 100644 --- a/frontend/plugin_lib.c +++ b/frontend/plugin_lib.c @@ -28,14 +28,18 @@ int pl_fbdev_init(void) int pl_fbdev_set_mode(int w, int h, int bpp) { - int ret; + void *ret; pl_fbdev_w = w; - printf("set mode %dx%d@%d\n", w, h, bpp); + + vout_fbdev_clear(layer_fb); ret = vout_fbdev_resize(layer_fb, w, h, bpp, 0, 0, 0, 0, 3); - if (ret) + if (ret == NULL) fprintf(stderr, "failed to set mode\n"); - return ret; + else + pl_fbdev_buf = ret; + + return (ret != NULL) ? 0 : -1; } void *pl_fbdev_flip(void) diff --git a/plugins/dfxvideo/draw_fb.c b/plugins/dfxvideo/draw_fb.c index f3d0cf2..b39e2ee 100644 --- a/plugins/dfxvideo/draw_fb.c +++ b/plugins/dfxvideo/draw_fb.c @@ -48,7 +48,7 @@ static void blit(void) { extern void bgr555_to_rgb565(void *dst, void *src, int bytes); extern void bgr888_to_rgb888(void *dst, void *src, int bytes); - int x = PSXDisplay.DisplayPosition.x; + int x = PSXDisplay.DisplayPosition.x & ~3; // XXX: align needed by bgr*_to_... int y = PSXDisplay.DisplayPosition.y; int w = PreviousPSXDisplay.Range.x1; int h = PreviousPSXDisplay.DisplayMode.y; @@ -93,6 +93,8 @@ void DoBufferSwap(void) if (PSXDisplay.DisplayMode.x == 0 || PSXDisplay.DisplayMode.y == 0) return; + /* careful if rearranging this code, we try to set mode and flip + * to get the hardware apply both changes at the same time */ if (PSXDisplay.DisplayMode.x != fbw || PSXDisplay.DisplayMode.y != fbh || PSXDisplay.RGB24 != fb24bpp) { fbw = PSXDisplay.DisplayMode.x; |