|
Nugget
Bare-metal libraries and examples for the original PlayStation
|
#include "common/hardware/dma.h"#include "common/hardware/gpu.h"#include "common/hardware/hwregs.h"#include "common/hardware/irq.h"#include "common/syscalls/syscalls.h"#include "exotic/cester.h"#include "raster-helpers.h"
Macros | |
| #define | CESTER_NO_SIGNAL |
| #define | CESTER_NO_TIME |
| #define | EXIT_SUCCESS 0 |
| #define | EXIT_FAILURE 1 |
| #define | STRESS_X 256 |
| #define | STRESS_Y 256 |
| #define | STRESS_CELLS 16 |
Functions | |
| CESTER_BODY (static int s_interruptsWereEnabled;static uint32_t s_seed;static uint32_t stressRand(void) { s_seed=s_seed *1103515245u+12345u;return s_seed > > 8;} #define STRESS_X #define STRESS_Y #define STRESS_CELLS static uint16_t s_model;static void modelFill(int cx, int cy, int cw, int ch, uint16_t value) { for(int y=cy;y< cy+ch;y++) { for(int x=cx;x< cx+cw;x++) s_model[y *STRESS_CELLS+x]=value;} } static void stressReset(void) { rasterReset();rasterFillRect(STRESS_X, STRESS_Y, STRESS_CELLS *8, STRESS_CELLS *8, 0);modelFill(0, 0, STRESS_CELLS, STRESS_CELLS, 0);} static uint16_t stressColor(uint32_t *cmd) { uint8_t r=stressRand() &0x1f, g=stressRand() &0x1f, b=stressRand() &0x1f;*cmd=rasterCmdColor(r, g, b);return rasterVram555(r, g, b);} static void vramCopy(int16_t sx, int16_t sy, int16_t dx, int16_t dy, int16_t w, int16_t h) { waitGPU();GPU_DATA=0x80000000u;GPU_DATA=((uint32_t)(uint16_t) sy<< 16)|(uint32_t)(uint16_t) sx;GPU_DATA=((uint32_t)(uint16_t) dy<< 16)|(uint32_t)(uint16_t) dx;GPU_DATA=((uint32_t)(uint16_t) h<< 16)|(uint32_t)(uint16_t) w;} static int stressCheck(void) { int bad=0;for(int cy=0;cy< STRESS_CELLS;cy++) { uint16_t row[STRESS_CELLS *8];rasterReadStrip(STRESS_X, STRESS_Y+cy *8+3, STRESS_CELLS *8, row);for(int cx=0;cx< STRESS_CELLS;cx++) { uint16_t expect=s_model[cy *STRESS_CELLS+cx];uint16_t got=row[cx *8+5];if(got !=expect) { if(bad< 8) ramsyscall_printf("cell %d,%d: got 0x%04x expect 0x%04x\n", cx, cy, got, expect);bad++;} } } return bad;}[STRESS_CELLS *STRESS_CELLS]) | |
| cester_assert_int_eq (0, bad) | |
| CESTER_TEST (long_queue_of_rects, gpu_async_stress, stressReset();s_seed=2;for(int i=0;i< 4000;i++) { uint32_t cmd;uint16_t color=stressColor(&cmd);int cx=stressRand() % STRESS_CELLS, cy=stressRand() % STRESS_CELLS;int cw=1+stressRand() %(STRESS_CELLS - cx), ch=1+stressRand() %(STRESS_CELLS - cy);rasterFlatRect(cmd, STRESS_X+cx *8, STRESS_Y+cy *8, cw *8, ch *8);modelFill(cx, cy, cw, ch, color);} cester_assert_int_eq(0, stressCheck());) CESTER_TEST(mixed_draw_upload_copy | |
| stressReset () | |
| for (int i=0;i< 1500;i++) | |
| cester_assert_int_eq (0, stressCheck()) | |
Variables | |
| gpu_async_stress | |
| s_seed = 3 | |
| #define CESTER_NO_SIGNAL |
| #define CESTER_NO_TIME |
| #define EXIT_FAILURE 1 |
| #define EXIT_SUCCESS 0 |
| #define STRESS_CELLS 16 |
| #define STRESS_X 256 |
| #define STRESS_Y 256 |
| cester_assert_int_eq | ( | 0 | , |
| bad | |||
| ) |
| cester_assert_int_eq | ( | 0 | , |
| stressCheck() | |||
| ) |
| CESTER_BODY | ( | static int s_interruptsWereEnabled;static uint32_t s_seed;static uint32_t stressRand(void) { s_seed=s_seed *1103515245u+12345u;return s_seed > > 8;} #define STRESS_X #define STRESS_Y #define STRESS_CELLS static uint16_t s_model;static void modelFill(int cx, int cy, int cw, int ch, uint16_t value) { for(int y=cy;y< cy+ch;y++) { for(int x=cx;x< cx+cw;x++) s_model[y *STRESS_CELLS+x]=value;} } static void stressReset(void) { rasterReset();rasterFillRect(STRESS_X, STRESS_Y, STRESS_CELLS *8, STRESS_CELLS *8, 0);modelFill(0, 0, STRESS_CELLS, STRESS_CELLS, 0);} static uint16_t stressColor(uint32_t *cmd) { uint8_t r=stressRand() &0x1f, g=stressRand() &0x1f, b=stressRand() &0x1f; *cmd=rasterCmdColor(r, g, b);return rasterVram555(r, g, b);} static void vramCopy(int16_t sx, int16_t sy, int16_t dx, int16_t dy, int16_t w, int16_t h) { waitGPU();GPU_DATA=0x80000000u;GPU_DATA=((uint32_t)(uint16_t) sy<< 16)|(uint32_t)(uint16_t) sx;GPU_DATA=((uint32_t)(uint16_t) dy<< 16)|(uint32_t)(uint16_t) dx;GPU_DATA=((uint32_t)(uint16_t) h<< 16)|(uint32_t)(uint16_t) w;} static int stressCheck(void) { int bad=0;for(int cy=0;cy< STRESS_CELLS;cy++) { uint16_t row[STRESS_CELLS *8];rasterReadStrip(STRESS_X, STRESS_Y+cy *8+3, STRESS_CELLS *8, row);for(int cx=0;cx< STRESS_CELLS;cx++) { uint16_t expect=s_model[cy *STRESS_CELLS+cx];uint16_t got=row[cx *8+5];if(got !=expect) { if(bad< 8) ramsyscall_printf("cell %d,%d: got 0x%04x expect 0x%04x\n", cx, cy, got, expect);bad++;} } } return bad;} | [STRESS_CELLS *STRESS_CELLS] | ) |
| CESTER_TEST | ( | long_queue_of_rects | , |
| gpu_async_stress | , | ||
| stressReset(); | s_seed = 2; for (int i = 0; i < 4000; i++) { uint32_t cmd; uint16_t color = stressColor(&cmd); int cx = stressRand() % STRESS_CELLS, cy = stressRand() % STRESS_CELLS; int cw = 1 + stressRand() % (STRESS_CELLS - cx), ch = 1 + stressRand() % (STRESS_CELLS - cy); rasterFlatRect(cmd, STRESS_X + cx * 8, STRESS_Y + cy * 8, cw * 8, ch * 8); modelFill(cx, cy, cw, ch, color); } cester_assert_int_eq(0, stressCheck()); |
||
| ) |
| for | ( | ) |
| stressReset | ( | ) |
| gpu_async_stress |
| s_seed = 3 |