|
From: quzar <qu...@us...> - 2024-08-24 19:58:05
|
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "A pseudo Operating System for the Dreamcast.".
The branch, master has been updated
via d2ace52770a1f001847db31f829c3a572c9b8730 (commit)
from 6e3584b4874fef191384ec50ff1ffae25e0e1882 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit d2ace52770a1f001847db31f829c3a572c9b8730
Author: Falco Girgis <gyr...@gm...>
Date: Sat Aug 24 14:57:30 2024 -0500
Fixed Overflow with Writing PVR BG Plane (#694)
* Fixed overflow with writing pvr bg plane.
- skmp (correctly) reported that our little loop to copy the internally
populated pvr_bkg_poly_t polygon (which gets color info from
pvr_set_bg_color()) was looping too far.
* structure is only 60 bytes, we looped for 64 and then wrote
another word even beyond that.
- swapped implementation to use memcpy() based on sizeof(pvr_bkg_poly_t)
which is safer, and is smart enough to do per-word operations when
they are valid (not here, lolz).
- removed final vrl[0x11] = 0 assignment, as it clearly wasn't
necessary and doesn't appear to even be doing anything useful at-all.
The BG polygon types are special and don't need end-of-list flags, and
interpolate the 4th vertex, more like PVR sprites.
* Fixed PVR BG clear color code
- VRAM writes need to be word-sized, and while mempcy() was doing the
right thing internally, that's sketchy... explicitly using mempcy4()
now.
* Adjusted PVR BG plane size based on FB resolution.
- Also cleaned up the code a bit.
- Changed Z coord to FLT_EPSILON instead of 0.2f.
-----------------------------------------------------------------------
Summary of changes:
kernel/arch/dreamcast/hardware/pvr/pvr_misc.c | 43 +++++++++++++--------------
1 file changed, 21 insertions(+), 22 deletions(-)
diff --git a/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c b/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c
index 061b9c33..b484dc99 100644
--- a/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c
+++ b/kernel/arch/dreamcast/hardware/pvr/pvr_misc.c
@@ -8,9 +8,13 @@
#include <assert.h>
#include <string.h>
+#include <float.h>
+
#include <arch/timer.h>
#include <dc/pvr.h>
#include <dc/video.h>
+#include <kos/string.h>
+
#include "pvr_internal.h"
/*
@@ -174,9 +178,8 @@ void pvr_begin_queued_render(void) {
volatile pvr_ta_buffers_t * tbuf;
volatile pvr_frame_buffers_t * rbuf;
pvr_bkg_poly_t bkg;
- uint32 *vrl, *bkgdata;
+ uint32_t *vrl;
uint32 vert_end;
- int i;
int bufn = pvr_state.view_target;
union {
float f;
@@ -197,26 +200,22 @@ void pvr_begin_queued_render(void) {
/* Throw the background data on the end of the TA's list */
bkg.flags1 = 0x90800000; /* These are from libdream.. ought to figure out */
bkg.flags2 = 0x20800440; /* what they mean for sure... heh =) */
- bkg.dummy = 0;
- bkg.x1 = 0.0f;
- bkg.y1 = 480.0f;
- bkg.z1 = 0.2f;
- bkg.argb1 = pvr_state.bg_color;
- bkg.x2 = 0.0f;
- bkg.y2 = 0.0f;
- bkg.z2 = 0.2f;
- bkg.argb2 = pvr_state.bg_color;
- bkg.x3 = 640.0f;
- bkg.y3 = 480.0f;
- bkg.z3 = 0.2f;
- bkg.argb3 = pvr_state.bg_color;
- bkgdata = (uint32 *)&bkg;
- vrl = (uint32*)(PVR_RAM_BASE | PVR_GET(PVR_TA_VERTBUF_POS));
-
- for(i = 0; i < 0x10; i++)
- vrl[i] = bkgdata[i];
-
- vrl[0x11] = 0;
+ bkg.dummy = 0;
+ bkg.x1 = 0.0f;
+ bkg.y1 = pvr_state.h;
+ bkg.z1 = FLT_EPSILON;
+ bkg.argb1 = pvr_state.bg_color;
+ bkg.x2 = 0.0f;
+ bkg.y2 = 0.0f;
+ bkg.z2 = FLT_EPSILON;
+ bkg.argb2 = pvr_state.bg_color;
+ bkg.x3 = pvr_state.w;
+ bkg.y3 = pvr_state.h;
+ bkg.z3 = FLT_EPSILON;
+ bkg.argb3 = pvr_state.bg_color;
+ vrl = (uint32_t *)(PVR_RAM_BASE | PVR_GET(PVR_TA_VERTBUF_POS));
+
+ memcpy4(vrl, &bkg, sizeof(bkg));
/* Reset the ISP/TSP, just in case */
//PVR_SET(PVR_RESET, PVR_RESET_ISPTSP);
hooks/post-receive
--
A pseudo Operating System for the Dreamcast.
|