4 * PVR2 rendering functions (private)
6 * Copyright (c) 2005 Nathan Keynes.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
19 #ifndef lxdream_render_H
20 #define lxdream_render_H 1
22 /************************* Intermediate vertex buffer ************************/
26 SORT_BYFLAG = 1, /* In this mode, sorting is controlled by the per-segment flag */
30 struct vertex_struct {
37 struct polygon_struct {
39 int cull; // culling mode
40 uint32_t vertex_count; // number of vertexes in polygon
41 int32_t vertex_index; // index of first vertex in vertex buffer
42 int32_t mod_vertex_index; // index of first modified vertex in vertex buffer
44 struct polygon_struct *next; // chain for tri/quad arrays
47 void pvr2_scene_init(void);
48 void pvr2_scene_read(void);
49 void pvr2_scene_shutdown();
51 extern char *video_base;
54 * Maximum possible size of the vertex buffer. This is figured as follows:
55 * PVR2 polygon buffer is limited to 4MB. The tightest polygon format
56 * is 3 vertexes in 48 bytes = 16 bytes/vertex, (shadow triangle)
57 * (the next tightest is 8 vertex in 140 bytes (6-strip colour-only)).
58 * giving a theoretical maximum of 262144 vertexes.
59 * The expanded structure is 44 bytes/vertex, giving
62 #define MAX_VERTEXES 262144
63 #define MAX_VERTEX_BUFFER_SIZE (MAX_VERTEXES*sizeof(struct vertex_struct))
66 * Maximum polygons - smallest is 1 polygon in 48 bytes, giving
70 #define MAX_POLYGONS 87382
71 #define MAX_POLY_BUFFER_SIZE (MAX_POLYGONS*sizeof(struct polygon_struct))
72 #define BUF_POLY_MAP_SIZE (4 MB)
74 /*************************************************************************/
76 /* Scene data - this structure holds all the intermediate data used during
77 * the rendering process.
79 * Special note: if vbo_supported == FALSE, then vertex_array points to a
80 * malloced chunk of system RAM. Otherwise, vertex_array will be either NULL
81 * (if the VBO is unmapped), or a pointer into a chunk of GL managed RAM
82 * (possibly direct-mapped VRAM).
84 struct pvr2_scene_struct {
85 /** GL ID of the VBO used by the scene (or 0 if VBOs are not in use). */
87 /** Pointer to the vertex array data, or NULL for unmapped VBOs */
88 struct vertex_struct *vertex_array;
89 /** Current allocated size (in bytes) of the vertex array */
90 uint32_t vertex_array_size;
91 /** Total number of vertexes in the scene (note modified vertexes
92 * count for 2 vertexes */
93 uint32_t vertex_count;
95 /** Pointer to the polygon data for the scene (main ram).
96 * This will always have room for at least MAX_POLYGONS */
97 struct polygon_struct *poly_array;
98 /** Total number of polygons in the scene */
101 /** Image bounds in 3D - x1,x2,y1,y2,z1,z2
102 * x and y values are determined by the clip planes, while z values are
103 * determined from the vertex data itself.
107 /* Total size of the image buffer, determined by the tile map used to
108 * render the scene */
109 uint32_t buffer_width, buffer_height;
111 /** True if modifier volumes use the two-parameter form, False if they
112 * use the cheap-shadow option.
114 gboolean full_shadow;
115 /** Specifies the translucency auto-sort mode for the scene */
116 tile_sort_mode_t sort_mode;
118 /** Pointer to the start of the tile segment list in PVR2 VRAM (32-bit) */
119 struct tile_segment *segment_list;
120 /** Map from PVR2 polygon address to an element of poly_array. Temporary,
121 * used only during poly buffer parsing */
122 struct polygon_struct **buf_to_poly_map;
123 /** Pointer to the start of the raw polygon buffer in PVR2 VRAM (32-bit).
124 * Also only used during parsing */
126 /** Current vertex index during parsing */
127 uint32_t vertex_index;
131 * Current scene structure. Note this should only be written to by vertex bufer
134 extern struct pvr2_scene_struct pvr2_scene;
137 #endif /* !lxdream_render_H */
.