| 1 | /* |
| 2 | gpu.h: what a platform does to draw the UI on its graphics chip (the PS3's |
| 3 | RSX). gfx.c turns the drawing calls into a list of quads; the platform |
| 4 | draws the list. The simulator draws it in software, the same way, so the |
| 5 | list can be checked against the CPU renderer pixel by pixel. |
| 6 |
|
| 7 | Every quad is a rectangle on the canvas (1280x720 units) with a colour per |
| 8 | corner and two textures: colour = tex0 * colour, its alpha times tex1.alpha, blended over |
| 9 | what's there (src alpha, 1 - src alpha). Textures are A8R8G8B8, linear, |
| 10 | sampled with bilinear filtering and clamped at the edges. |
| 11 | */ |
| 12 | #ifndef GPU_H |
| 13 | #define GPU_H |
| 14 |
|
| 15 | #include <stdint.h> |
| 16 |
|
| 17 | typedef struct { |
| 18 | void *px; // where the CPU writes the pixels (in RSX memory on a PS3) |
| 19 | uint32_t off; // what the GPU calls it (an RSX offset) |
| 20 | int w, h; |
| 21 | int pitch; // bytes from one row to the next (the RSX wants them 64-byte aligned) |
| 22 | } gtex_t; |
| 23 |
|
| 24 | typedef struct { |
| 25 | float x0, y0, x1, y1; // canvas units |
| 26 | float u0, v0, u1, v1; // tex0, 0..1 |
| 27 | float s0, t0, s1, t1; // tex1, 0..1 |
| 28 | uint32_t c[4]; // ARGB: top left, top right, bottom left, bottom right |
| 29 | } gquad_t; |
| 30 |
|
| 31 | typedef struct { |
| 32 | int first, count; // quads |
| 33 | const gtex_t *tex0, *tex1; |
| 34 | int sx, sy, sw, sh; // scissor, canvas units |
| 35 | } gbatch_t; |
| 36 |
|
| 37 | // the platform's side |
| 38 | int gpu_tex_alloc(gtex_t *t, int w, int h); // 0 if there's no memory |
| 39 | void gpu_tex_free(gtex_t *t); |
| 40 | void gpu_frame_begin(void); // the previous frame is finished with every texture |
| 41 | void gpu_frame_submit(const gquad_t *q, int nq, const gbatch_t *b, int nb); |
| 42 |
|
| 43 | #endif |