Skip to content

Commit

Permalink
added lines and texture-overflow tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JaCzekanski committed Sep 30, 2019
1 parent da6b472 commit b0a94a8
Show file tree
Hide file tree
Showing 12 changed files with 5,659 additions and 10 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ IMAGES = gpu/bandwidth \
gpu/benchmark \
gpu/quad \
gpu/transparency \
gpu/lines \
gpu/texture-overflow \
gte-fuzz \
spu/test \
spu/stereo \
Expand Down
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,18 @@

## Tests

Name | Description
----------------|------------
gpu/bandwidth | Measure GPU/VRAM bandwidth
gpu/benchmark | Simple GPU test to benchmark rasteriser
gpu/quad | Semi-transparent polygon commands - for testing fill rules and transparency handling
gpu/transparency| Draws rectangles with 4 semi-transparent blending modes
gte-fuzz | Executes GTE opcodes with random parameters, can be used to verify agains real console
spu/test | Check SPU behaviour (data is lost randomly on 32bit access, ok on 16bit)
spu/stereo | Play samples on first two voices
timers | Run Timer0,1,2 using various clock sources and sync modes and time them using busy loops and vblank interrupt
Name | Description
---------------------|------------
gpu/bandwidth | Measure GPU/VRAM bandwidth
gpu/benchmark | Simple GPU test to benchmark rasteriser
gpu/quad | Semi-transparent polygon commands - for testing fill rules and transparency handling
gpu/transparency | Draws rectangles with 4 semi-transparent blending modes
gpu/lines | Draws hexagon using opaque lines - for line rendering comparison
gpu/texture-overflow | Draws textured rectangle with UV overflowing VRAM width
gte-fuzz | Executes GTE opcodes with random parameters, can be used to verify agains real console
spu/test | Check SPU behaviour (data is lost randomly on 32bit access, ok on 16bit)
spu/stereo | Play samples on first two voices
timers | Run Timer0,1,2 using various clock sources and sync modes and time them using busy loops and vblank interrupt

Note: Make sure your PS-EXE loaded does set default value for Stack Pointer - these .exes has SP set to 0.

Expand Down
4 changes: 4 additions & 0 deletions gpu/lines/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include $(PSN00BSDK)/sdk-common.mk

TARGET = lines.elf
LIBS += -lpsxgte -lpsxapi
77 changes: 77 additions & 0 deletions gpu/lines/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include <stdio.h>
#include <stdlib.h>
#include <psxgpu.h>
#include <psxgte.h>
#include <psxetc.h>

DISPENV disp;
DRAWENV draw;

#define SCR_W 320
#define SCR_H 240

void setResolution(int w, int h) {
SetDefDispEnv(&disp, 0, 0, w, h);
SetDefDrawEnv(&draw, 0, 0, w, h);

PutDispEnv(&disp);
PutDrawEnv(&draw);
}

void initVideo()
{
ResetGraph(0);
setResolution(SCR_W, SCR_H);
SetDispMask(1);
}

void fillRect(int x, int y, int w, int h, int r, int g, int b) {
FILL f;
setFill(&f);
setRGB0(&f, r, g, b);
setXY0(&f, x, y);
setWH(&f, w, h);

DrawPrim(&f);
}

void clearScreen() {
fillRect(0, 0, 512, 256, 0xff, 0xff, 0xff);
fillRect(512, 0, 512, 256, 0xff, 0xff, 0xff);
fillRect(0, 256, 512, 256, 0xff, 0xff, 0xff);
fillRect(512, 256, 0x3f1, 256, 0xff, 0xff, 0xff);
}

int main() {
initVideo();
InitGeom();
printf("\ngpu/lines\n");

for (;;) {
const int PI = 4096/2;
const int CX = SCR_W/2;
const int CY = SCR_H/2;
const int SEGS = 6;
const int ANGLE = 2 * PI / SEGS;
const int H_ANGLE = ANGLE / 2;
const int SCALE = 48;

clearScreen();

for (int s = 0; s < SEGS; s++) {
LINE_F2 l;

setLineF2(&l);
setRGB0(&l, 0, 0, 0);
l.x0 = CX + icos(ANGLE * s - H_ANGLE) / SCALE;
l.y0 = CY + isin(ANGLE * s - H_ANGLE) / SCALE;
l.x1 = CX + icos(ANGLE * s + H_ANGLE) / SCALE;
l.y1 = CY + isin(ANGLE * s + H_ANGLE) / SCALE;

DrawPrim(&l);
}

VSync(0);
}
return 0;
}
Binary file added gpu/lines/vram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions gpu/texture-overflow/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include $(PSN00BSDK)/sdk-common.mk

TARGET = texture-overflow.elf
LIBS += -lpsxapi
2,736 changes: 2,736 additions & 0 deletions gpu/texture-overflow/cube.h

Large diffs are not rendered by default.

Binary file added gpu/texture-overflow/cube.tim
Binary file not shown.
2,736 changes: 2,736 additions & 0 deletions gpu/texture-overflow/lena.h

Large diffs are not rendered by default.

Binary file added gpu/texture-overflow/lena.tim
Binary file not shown.
88 changes: 88 additions & 0 deletions gpu/texture-overflow/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#include <stdio.h>
#include <stdlib.h>
#include <psxgpu.h>
#include <psxetc.h>
#include "lena.h"
#include "cube.h"

DISPENV disp;
DRAWENV draw;

#define SCR_W 320
#define SCR_H 240

void setResolution(int w, int h) {
SetDefDispEnv(&disp, 0, 0, w, h);
SetDefDrawEnv(&draw, 0, 0, w, h);

PutDispEnv(&disp);
PutDrawEnv(&draw);
}

void initVideo()
{
ResetGraph(0);
setResolution(SCR_W, SCR_H);
SetDispMask(1);
}

void fillRect(int x, int y, int w, int h, int r, int g, int b) {
FILL f;
setFill(&f);
setRGB0(&f, r, g, b);
setXY0(&f, x, y);
setWH(&f, w, h);

DrawPrim(&f);
}

void clearVram() {
fillRect(0, 0, 512, 256, 0xff, 0x00, 0x00);
fillRect(512, 0, 512, 256, 0xff, 0x00, 0x00);
fillRect(0, 256, 512, 256, 0xff, 0x00, 0x00);
fillRect(512, 256, 0x3f1, 256, 0xff, 0x00, 0x00);
}

void setTexPage(int x, int y) {
DR_TPAGE e;
unsigned short texpage = getTPage(/* 15bit */ 2, /* semi-transparency mode */ 0, /*x*/x, /*y*/y);
setDrawTPage(&e, /* Drawing to display area */ 1, /* dithering */ 0, texpage);
DrawPrim(&e);
}


int main() {
initVideo();
printf("\ngpu/texture-overflow\n");

clearVram();

TIM_IMAGE tim;
GetTimInfo((unsigned int*)lena_tim, &tim);
LoadImage(tim.prect, tim.paddr);

GetTimInfo((unsigned int*)cube_tim, &tim);
LoadImage(tim.prect, tim.paddr);

for (;;) {
fillRect(0, 0, SCR_W, SCR_H, 0xff, 0xff, 0xff);

setTexPage(896, 256);

SPRT s;
setSprt(&s);
setSemiTrans(&s, 0);
setRGB0(&s, 128, 128, 128 );
s.x0 = 16;
s.y0 = 16;
s.w = 256;
s.h = 128;
s.u0 = 0;
s.v0 = 0;

DrawPrim(&s);

VSync(0);
}
return 0;
}
Binary file added gpu/texture-overflow/vram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b0a94a8

Please sign in to comment.