From 01d603f6f494b470fe4cd881c5b2cf6d28353ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Czekan=CC=81ski?= Date: Tue, 23 Mar 2021 01:09:05 +0100 Subject: [PATCH] gpu/bandwidth: check clipping bandwidth --- gpu/bandwidth/{main.c => main.cpp} | 126 +++++++++-------------------- gpu/bandwidth/psx.log | 26 +++--- 2 files changed, 54 insertions(+), 98 deletions(-) rename gpu/bandwidth/{main.c => main.cpp} (54%) diff --git a/gpu/bandwidth/main.c b/gpu/bandwidth/main.cpp similarity index 54% rename from gpu/bandwidth/main.c rename to gpu/bandwidth/main.cpp index 559a4b5..64fd970 100644 --- a/gpu/bandwidth/main.c +++ b/gpu/bandwidth/main.cpp @@ -1,16 +1,17 @@ #include #include +#include #include #include #include #include #include -typedef char bool; - #define SCR_W 320 #define SCR_H 240 +bool semitransparent = false; + uint32_t getTimer() { uint32_t value = readTimer(1); if (timerDidOverflow(1)) value += 0xffff; @@ -28,7 +29,7 @@ void fillScreen() { DrawPrim(&f); } -void rectScreen(bool semitransparent) { +void rectScreen() { TILE t; setTile(&t); setSemiTrans(&t, semitransparent); @@ -39,7 +40,7 @@ void rectScreen(bool semitransparent) { DrawPrim(&t); } -void rectTexturedScreen(bool semitransparent) { +void rectTexturedScreen() { SPRT s; setSprt(&s); setSemiTrans(&s, semitransparent); @@ -54,15 +55,17 @@ void rectTexturedScreen(bool semitransparent) { DrawPrim(&s); } -void quadScreen(bool semitransparent) { +int xOffset = 0; + +void quadScreen() { POLY_F4 p; setPolyF4(&p); setSemiTrans(&p, semitransparent); setXY4(&p, - 0, 0, - SCR_W, 0, - 0, SCR_H, - SCR_W, SCR_H + xOffset + 0, 0, + xOffset + SCR_W, 0, + xOffset + 0, SCR_H, + xOffset + SCR_W, SCR_H ); setRGB0(&p, rand()%255, rand()%255, rand()%255); @@ -75,7 +78,7 @@ void quadScreen(bool semitransparent) { (p)->u2 = _u0, (p)->v2 = _v0+(_h), \ (p)->u3 = _u0+(_w), (p)->v3 = _v0+(_h) -void quadTexturedScreen(bool semitransparent) { +void quadTexturedScreen() { POLY_FT4 p; setPolyFT4(&p); setSemiTrans(&p, semitransparent); @@ -97,7 +100,7 @@ void quadTexturedScreen(bool semitransparent) { DrawPrim(&p); } -const int callCount = 400; +constexpr int callCount = 400; void calculate(const char* test, uint16_t hblanks) { const int scanlinesPerFrame = 263; @@ -118,47 +121,8 @@ void calculate(const char* test, uint16_t hblanks) { printf("%-30s dT: %5d.%-5d ms (hblanks: %5d), speed: %d MB/s\n", test, dt_q, dt_r, diff, megaBytesPerSecond); } -const char* testCases[9] = { - "FillScreen GP0(2)", - "Rectangle", - "Rectangle (semitransparent)", - "Rectangle textured", - "Rectangle textured (semi)", - "Polygon quad", - "Polygon quad (semi)", - "Polygon quad textured", - "Polygon quad textured (semi)" -}; - uint16_t* buffer = (uint16_t*)0x801a0000; -void testVramToCpu() { - DrawSync(0); - resetTimer(1); - for (int i = 0; i < callCount; i++) { - vramReadDMA(0, 0, SCR_W, SCR_H, buffer); - } - calculate("vramToCpu", getTimer()); -} - -void testCpuToVram() { - DrawSync(0); - resetTimer(1); - for (int i = 0; i < callCount; i++) { - vramWriteDMA(0, 0, SCR_W, SCR_H, buffer); - } - calculate("cpuToVram", getTimer()); -} - -void testVramToVram() { - DrawSync(0); - resetTimer(1); - for (int i = 0; i < callCount; i++) { - vramToVramCopy(0, 0, 320, 0, SCR_W, SCR_H); - } - calculate("vramToVram", getTimer()); -} - int main() { initVideo(SCR_W, SCR_H); SetVideoMode(MODE_NTSC); @@ -166,48 +130,38 @@ int main() { uint16_t oldTimer1Mode = initTimer(1, 1); // Timer1, HBlank - testVramToCpu(); - testCpuToVram(); - testVramToVram(); - - for (int test = 0; test<9; test++) { + auto test = [](const char* name, void (*func)(), bool semi = false) { clearScreen(); DrawSync(0); resetTimer(1); + semitransparent = semi; for (int i = 0; i < callCount; i++) { - switch (test) { - case 0: - fillScreen(); - break; - case 1: - rectScreen(false); - break; - case 2: - rectScreen(true); - break; - case 3: - rectTexturedScreen(false); - break; - case 4: - rectTexturedScreen(true); - break; - case 5: - quadScreen(false); - break; - case 6: - quadScreen(true); - break; - case 7: - quadTexturedScreen(false); - break; - case 8: - quadTexturedScreen(true); - break; - } + func(); } - calculate(testCases[test], getTimer()); - } + calculate(name, getTimer()); + }; + + EnterCriticalSection(); + test("vramToCpu", []() { vramReadDMA(0, 0, SCR_W, SCR_H, buffer); }); + test("cpuToVram", []() { vramWriteDMA(0, 0, SCR_W, SCR_H, buffer); }); + test("vramToVram", []() { vramToVramCopy(0, 0, 320, 0, SCR_W, SCR_H); }); + test("FillScreen GP0(2)", fillScreen); + test("Rectangle", rectScreen, false); + test("Rectangle (semitransparent)", rectScreen, true); + test("Rectangle textured", rectTexturedScreen, false); + test("Rectangle textured (semi)", rectTexturedScreen, true); + test("Polygon quad", quadScreen, false); + test("Polygon quad (semi)", quadScreen, true); + test("Polygon quad textured", quadTexturedScreen, false); + test("Polygon quad textured (semi)", quadTexturedScreen, true); + + xOffset = -SCR_W/4; + test("Polygon quad (1/4 off screen)", quadScreen, false); + + xOffset = -SCR_W/2; + test("Polygon quad (1/2 off screen)", quadScreen, false); + ExitCriticalSection(); restoreTimer(1, oldTimer1Mode); diff --git a/gpu/bandwidth/psx.log b/gpu/bandwidth/psx.log index ed38e9f..f8a952d 100644 --- a/gpu/bandwidth/psx.log +++ b/gpu/bandwidth/psx.log @@ -1,14 +1,16 @@ gpu/bandwidth -vramToCpu dT: 987.8140 ms (hblanks: 15583), speed: 60 MB/s -cpuToVram dT: 766.4520 ms (hblanks: 12092), speed: 78 MB/s -vramToVram dT: 1211.420 ms (hblanks: 19110), speed: 49 MB/s -FillScreen GP0(2) dT: 76.4720 ms (hblanks: 1204), speed: 789 MB/s -Rectangle dT: 476.720 ms (hblanks: 7512), speed: 126 MB/s -Rectangle (semitransparent) dT: 717.3740 ms (hblanks: 11318), speed: 83 MB/s -Rectangle textured dT: 951.5220 ms (hblanks: 15012), speed: 63 MB/s -Rectangle textured (semi) dT: 951.5220 ms (hblanks: 15012), speed: 63 MB/s -Polygon quad dT: 483.15260 ms (hblanks: 7637), speed: 124 MB/s -Polygon quad (semi) dT: 729.4380 ms (hblanks: 11508), speed: 82 MB/s -Polygon quad textured dT: 2501.2220 ms (hblanks: 39468), speed: 23 MB/s -Polygon quad textured (semi) dT: 2501.3220 ms (hblanks: 39469), speed: 23 MB/s +vramToCpu dT: 999.5780 ms (hblanks: 15770), speed: 60 MB/s +cpuToVram dT: 772.12840 ms (hblanks: 12195), speed: 77 MB/s +vramToVram dT: 1212.6640 ms (hblanks: 19132), speed: 49 MB/s +FillScreen GP0(2) dT: 77.940 ms (hblanks: 1216), speed: 779 MB/s +Rectangle dT: 481.12820 ms (hblanks: 7603), speed: 124 MB/s +Rectangle (semitransparent) dT: 725.14500 ms (hblanks: 11455), speed: 82 MB/s +Rectangle textured dT: 959.4980 ms (hblanks: 15138), speed: 62 MB/s +Rectangle textured (semi) dT: 959.5980 ms (hblanks: 15139), speed: 62 MB/s +Polygon quad dT: 489.10580 ms (hblanks: 7727), speed: 122 MB/s +Polygon quad (semi) dT: 738.2360 ms (hblanks: 11648), speed: 81 MB/s +Polygon quad textured dT: 2530.14600 ms (hblanks: 39938), speed: 23 MB/s +Polygon quad textured (semi) dT: 2530.14600 ms (hblanks: 39938), speed: 23 MB/s +Polygon quad (1/4 off screen) dT: 370.6400 ms (hblanks: 5845), speed: 162 MB/s +Polygon quad (1/2 off screen) dT: 251.7220 ms (hblanks: 3968), speed: 239 MB/s Done \ No newline at end of file