43 lines1.5 KBC
1/*
2gpu.h: what a platform does to draw the UI on its graphics chip (the PS3's
3RSX). gfx.c turns the drawing calls into a list of quads; the platform
4draws the list. The simulator draws it in software, the same way, so the
5list can be checked against the CPU renderer pixel by pixel.
6
7Every quad is a rectangle on the canvas (1280x720 units) with a colour per
8corner and two textures: colour = tex0 * colour, its alpha times tex1.alpha, blended over
9what's there (src alpha, 1 - src alpha). Textures are A8R8G8B8, linear,
10sampled with bilinear filtering and clamped at the edges.
11*/
12#ifndef GPU_H
13#define GPU_H
14
15#include <stdint.h>
16
17typedef 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
24typedef 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
31typedef 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
38int gpu_tex_alloc(gtex_t *t, int w, int h); // 0 if there's no memory
39void gpu_tex_free(gtex_t *t);
40void gpu_frame_begin(void); // the previous frame is finished with every texture
41void gpu_frame_submit(const gquad_t *q, int nq, const gbatch_t *b, int nb);
42
43#endif