filename | src/pvr2/scene.h |
changeset | 669:ab344e42bca9 |
prev | 653:3202ff01d48e |
next | 687:6bdc2b7032ea |
author | nkeynes |
date | Mon May 12 10:00:13 2008 +0000 (14 years ago) |
permissions | -rw-r--r-- |
last change | Cleanup most of the -Wall warnings (getting a bit sloppy...) Convert FP code to use fixed banks rather than indirect pointer (3-4% faster this way now) |
view | annotate | diff | log | raw |
1 /**
2 * $Id$
3 *
4 * PVR2 rendering functions (private)
5 *
6 * Copyright (c) 2005 Nathan Keynes.
7 *
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.
12 *
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.
17 */
19 #ifndef lxdream_render_H
20 #define lxdream_render_H 1
22 /************************* Intermediate vertex buffer ************************/
24 typedef enum {
25 SORT_NEVER = 0,
26 SORT_TILEFLAG = 1, /* In this mode, sorting is controlled by the per-segment flag */
27 SORT_ALWAYS = 2
28 } tile_sort_mode_t;
30 struct vertex_struct {
31 float u,v;
32 uint32_t rgba;
33 float x,y,z;
34 uint32_t offset_rgba;
35 };
37 struct polygon_struct {
38 uint32_t *context;
39 int cull; // culling mode
40 uint32_t vertex_count; // number of vertexes in polygon
41 uint32_t tex_id;
42 int32_t vertex_index; // index of first vertex in vertex buffer
43 uint32_t mod_tex_id;
44 int32_t mod_vertex_index; // index of first modified vertex in vertex buffer
45 float center_z;
46 struct polygon_struct *next; // chain for tri/quad arrays
47 };
49 void pvr2_scene_init(void);
50 void pvr2_scene_read(void);
51 void pvr2_scene_shutdown();
53 uint32_t pvr2_scene_buffer_width();
54 uint32_t pvr2_scene_buffer_height();
56 extern unsigned char *video_base;
58 /**
59 * Maximum possible size of the vertex buffer. This is figured as follows:
60 * PVR2 polygon buffer is limited to 4MB. The tightest polygon format
61 * is 3 vertexes in 48 bytes = 16 bytes/vertex, (shadow triangle)
62 * (the next tightest is 8 vertex in 140 bytes (6-strip colour-only)).
63 * giving a theoretical maximum of 262144 vertexes.
64 * The expanded structure is 44 bytes/vertex, giving
65 * 11534336 bytes...
66 */
67 #define MAX_VERTEXES 262144
68 #define MAX_VERTEX_BUFFER_SIZE (MAX_VERTEXES*sizeof(struct vertex_struct))
70 /**
71 * Maximum polygons - smallest is 1 polygon in 48 bytes, giving
72 * 87381
73 *
74 */
75 #define MAX_POLYGONS 87382
76 #define MAX_POLY_BUFFER_SIZE (MAX_POLYGONS*sizeof(struct polygon_struct))
77 #define BUF_POLY_MAP_SIZE (4 MB)
79 /*************************************************************************/
81 /* Scene data - this structure holds all the intermediate data used during
82 * the rendering process.
83 *
84 * Special note: if vbo_supported == FALSE, then vertex_array points to a
85 * malloced chunk of system RAM. Otherwise, vertex_array will be either NULL
86 * (if the VBO is unmapped), or a pointer into a chunk of GL managed RAM
87 * (possibly direct-mapped VRAM).
88 */
89 struct pvr2_scene_struct {
90 /** GL ID of the VBO used by the scene (or 0 if VBOs are not in use). */
91 GLuint vbo_id;
92 /** Pointer to the vertex array data, or NULL for unmapped VBOs */
93 struct vertex_struct *vertex_array;
94 /** Current allocated size (in bytes) of the vertex array */
95 uint32_t vertex_array_size;
96 /** Total number of vertexes in the scene (note modified vertexes
97 * count for 2 vertexes */
98 uint32_t vertex_count;
100 /** Pointer to the polygon data for the scene (main ram).
101 * This will always have room for at least MAX_POLYGONS */
102 struct polygon_struct *poly_array;
103 /** Total number of polygons in the scene */
104 uint32_t poly_count;
106 /** Image bounds in 3D - x1,x2,y1,y2,z1,z2
107 * x and y values are determined by the clip planes, while z values are
108 * determined from the vertex data itself.
109 */
110 float bounds[6];
112 /* Total size of the image buffer, determined by the tile map used to
113 * render the scene */
114 uint32_t buffer_width, buffer_height;
116 /** True if modifier volumes use the two-parameter form, False if they
117 * use the cheap-shadow option.
118 */
119 gboolean full_shadow;
120 /** Specifies the translucency auto-sort mode for the scene */
121 tile_sort_mode_t sort_mode;
123 /** Pointer to the start of the tile segment list in PVR2 VRAM (32-bit) */
124 struct tile_segment *segment_list;
125 /** Map from PVR2 polygon address to an element of poly_array. */
126 struct polygon_struct **buf_to_poly_map;
127 /** Pointer to the start of the raw polygon buffer in PVR2 VRAM (32-bit).
128 * Also only used during parsing */
129 uint32_t *pvr2_pbuf;
130 /** Current vertex index during parsing */
131 uint32_t vertex_index;
132 };
134 /**
135 * Current scene structure. Note this should only be written to by vertex bufer
136 * functions
137 */
138 extern struct pvr2_scene_struct pvr2_scene;
141 #endif /* !lxdream_render_H */
.