4 * PVR2 scene description structure (pvr2-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_scene_H
20 #define lxdream_scene_H 1
26 /************************* Intermediate vertex buffer ************************/
30 SORT_TILEFLAG = 1, /* In this mode, sorting is controlled by the per-segment flag */
34 typedef enum { SHADOW_NONE=0, SHADOW_CHEAP=1, SHADOW_FULL=2 } shadow_mode_t;
37 struct vertex_struct {
44 struct polygon_struct {
46 uint32_t vertex_count; // number of vertexes in polygon
48 int32_t vertex_index; // index of first vertex in vertex buffer
50 int32_t mod_vertex_index; // index of first modified vertex in vertex buffer
51 struct polygon_struct *next; // chain for tri/quad arrays
54 void pvr2_scene_init(void);
55 void pvr2_scene_read(void);
56 void pvr2_scene_shutdown();
58 uint32_t pvr2_scene_buffer_width();
59 uint32_t pvr2_scene_buffer_height();
61 extern unsigned char *video_base;
64 * Maximum possible size of the vertex buffer. This is figured as follows:
65 * PVR2 polygon buffer is limited to 4MB. The tightest polygon format
66 * is 3 vertexes in 48 bytes = 16 bytes/vertex, (shadow triangle)
67 * (the next tightest is 8 vertex in 140 bytes (6-strip colour-only)).
68 * giving a theoretical maximum of 262144 vertexes.
69 * The expanded structure is 44 bytes/vertex, giving
72 #define MAX_VERTEXES 262144
73 #define MAX_VERTEX_BUFFER_SIZE (MAX_VERTEXES*sizeof(struct vertex_struct))
76 * Maximum polygons - smallest is 1 polygon in 48 bytes, giving
77 * 87381, plus 1 for the background
80 #define MAX_POLYGONS 87382
81 #define MAX_POLY_BUFFER_SIZE (MAX_POLYGONS*sizeof(struct polygon_struct))
82 #define BUF_POLY_MAP_SIZE (4 MB)
84 /*************************************************************************/
86 /* Scene data - this structure holds all the intermediate data used during
87 * the rendering process.
89 * Special note: if vbo_supported == FALSE, then vertex_array points to a
90 * malloced chunk of system RAM. Otherwise, vertex_array will be either NULL
91 * (if the VBO is unmapped), or a pointer into a chunk of GL managed RAM
92 * (possibly direct-mapped VRAM).
94 struct pvr2_scene_struct {
95 /** GL ID of the VBO used by the scene (or 0 if VBOs are not in use). */
97 /** Pointer to the vertex array data, or NULL for unmapped VBOs */
98 struct vertex_struct *vertex_array;
99 /** Current allocated size (in bytes) of the vertex array */
100 uint32_t vertex_array_size;
101 /** Total number of vertexes in the scene (note modified vertexes
102 * count for 2 vertexes */
103 uint32_t vertex_count;
105 /** Pointer to the polygon data for the scene (main ram).
106 * This will always have room for at least MAX_POLYGONS */
107 struct polygon_struct *poly_array;
108 /** Pointer to the background polygon. This is always a quad, and
109 * normally the last member of poly_array */
110 struct polygon_struct *bkgnd_poly;
111 /** Total number of polygons in the scene */
114 /** Image bounds in 3D - x1,x2,y1,y2,z1,z2
115 * x and y values are determined by the clip planes, while z values are
116 * determined from the vertex data itself.
120 /* Total size of the image buffer, determined by the tile map used to
121 * render the scene */
122 uint32_t buffer_width, buffer_height;
124 /** Specifies the translucency auto-sort mode for the scene */
125 tile_sort_mode_t sort_mode;
127 shadow_mode_t shadow_mode;
129 float fog_lut_colour[4];
130 float fog_vert_colour[4];
132 /** Pointer to the start of the tile segment list in PVR2 VRAM (32-bit) */
133 struct tile_segment *segment_list;
134 /** Map from PVR2 polygon address to an element of poly_array. */
135 struct polygon_struct **buf_to_poly_map;
136 /** Pointer to the start of the raw polygon buffer in PVR2 VRAM (32-bit).
137 * Also only used during parsing */
139 /** Current vertex index during parsing */
140 uint32_t vertex_index;
144 * Current scene structure. Note this should only be written to by vertex bufer
147 extern struct pvr2_scene_struct pvr2_scene;
153 #endif /* !lxdream_scene_H */
.