Search
lxdream.org :: lxdream/src/pvr2/scene.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/scene.h
changeset 653:3202ff01d48e
next669:ab344e42bca9
author nkeynes
date Fri Mar 28 12:32:25 2008 +0000 (13 years ago)
permissions -rw-r--r--
last change Merge lxdream-render branch (643:670) to trunk
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/pvr2/scene.h Fri Mar 28 12:32:25 2008 +0000
1.3 @@ -0,0 +1,138 @@
1.4 +/**
1.5 + * $Id$
1.6 + *
1.7 + * PVR2 rendering functions (private)
1.8 + *
1.9 + * Copyright (c) 2005 Nathan Keynes.
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.20 + */
1.21 +
1.22 +#ifndef lxdream_render_H
1.23 +#define lxdream_render_H 1
1.24 +
1.25 +/************************* Intermediate vertex buffer ************************/
1.26 +
1.27 +typedef enum {
1.28 + SORT_NEVER = 0,
1.29 + SORT_TILEFLAG = 1, /* In this mode, sorting is controlled by the per-segment flag */
1.30 + SORT_ALWAYS = 2
1.31 +} tile_sort_mode_t;
1.32 +
1.33 +struct vertex_struct {
1.34 + float u,v;
1.35 + uint32_t rgba;
1.36 + float x,y,z;
1.37 + uint32_t offset_rgba;
1.38 +};
1.39 +
1.40 +struct polygon_struct {
1.41 + uint32_t *context;
1.42 + int cull; // culling mode
1.43 + uint32_t vertex_count; // number of vertexes in polygon
1.44 + uint32_t tex_id;
1.45 + int32_t vertex_index; // index of first vertex in vertex buffer
1.46 + uint32_t mod_tex_id;
1.47 + int32_t mod_vertex_index; // index of first modified vertex in vertex buffer
1.48 + float center_z;
1.49 + struct polygon_struct *next; // chain for tri/quad arrays
1.50 +};
1.51 +
1.52 +void pvr2_scene_init(void);
1.53 +void pvr2_scene_read(void);
1.54 +void pvr2_scene_shutdown();
1.55 +
1.56 +extern char *video_base;
1.57 +
1.58 +/**
1.59 + * Maximum possible size of the vertex buffer. This is figured as follows:
1.60 + * PVR2 polygon buffer is limited to 4MB. The tightest polygon format
1.61 + * is 3 vertexes in 48 bytes = 16 bytes/vertex, (shadow triangle)
1.62 + * (the next tightest is 8 vertex in 140 bytes (6-strip colour-only)).
1.63 + * giving a theoretical maximum of 262144 vertexes.
1.64 + * The expanded structure is 44 bytes/vertex, giving
1.65 + * 11534336 bytes...
1.66 + */
1.67 +#define MAX_VERTEXES 262144
1.68 +#define MAX_VERTEX_BUFFER_SIZE (MAX_VERTEXES*sizeof(struct vertex_struct))
1.69 +
1.70 +/**
1.71 + * Maximum polygons - smallest is 1 polygon in 48 bytes, giving
1.72 + * 87381
1.73 + *
1.74 + */
1.75 +#define MAX_POLYGONS 87382
1.76 +#define MAX_POLY_BUFFER_SIZE (MAX_POLYGONS*sizeof(struct polygon_struct))
1.77 +#define BUF_POLY_MAP_SIZE (4 MB)
1.78 +
1.79 +/*************************************************************************/
1.80 +
1.81 +/* Scene data - this structure holds all the intermediate data used during
1.82 + * the rendering process.
1.83 + *
1.84 + * Special note: if vbo_supported == FALSE, then vertex_array points to a
1.85 + * malloced chunk of system RAM. Otherwise, vertex_array will be either NULL
1.86 + * (if the VBO is unmapped), or a pointer into a chunk of GL managed RAM
1.87 + * (possibly direct-mapped VRAM).
1.88 + */
1.89 +struct pvr2_scene_struct {
1.90 + /** GL ID of the VBO used by the scene (or 0 if VBOs are not in use). */
1.91 + GLuint vbo_id;
1.92 + /** Pointer to the vertex array data, or NULL for unmapped VBOs */
1.93 + struct vertex_struct *vertex_array;
1.94 + /** Current allocated size (in bytes) of the vertex array */
1.95 + uint32_t vertex_array_size;
1.96 + /** Total number of vertexes in the scene (note modified vertexes
1.97 + * count for 2 vertexes */
1.98 + uint32_t vertex_count;
1.99 +
1.100 + /** Pointer to the polygon data for the scene (main ram).
1.101 + * This will always have room for at least MAX_POLYGONS */
1.102 + struct polygon_struct *poly_array;
1.103 + /** Total number of polygons in the scene */
1.104 + uint32_t poly_count;
1.105 +
1.106 + /** Image bounds in 3D - x1,x2,y1,y2,z1,z2
1.107 + * x and y values are determined by the clip planes, while z values are
1.108 + * determined from the vertex data itself.
1.109 + */
1.110 + float bounds[6];
1.111 +
1.112 + /* Total size of the image buffer, determined by the tile map used to
1.113 + * render the scene */
1.114 + uint32_t buffer_width, buffer_height;
1.115 +
1.116 + /** True if modifier volumes use the two-parameter form, False if they
1.117 + * use the cheap-shadow option.
1.118 + */
1.119 + gboolean full_shadow;
1.120 + /** Specifies the translucency auto-sort mode for the scene */
1.121 + tile_sort_mode_t sort_mode;
1.122 +
1.123 + /** Pointer to the start of the tile segment list in PVR2 VRAM (32-bit) */
1.124 + struct tile_segment *segment_list;
1.125 + /** Map from PVR2 polygon address to an element of poly_array. */
1.126 + struct polygon_struct **buf_to_poly_map;
1.127 + /** Pointer to the start of the raw polygon buffer in PVR2 VRAM (32-bit).
1.128 + * Also only used during parsing */
1.129 + uint32_t *pvr2_pbuf;
1.130 + /** Current vertex index during parsing */
1.131 + uint32_t vertex_index;
1.132 +};
1.133 +
1.134 +/**
1.135 + * Current scene structure. Note this should only be written to by vertex bufer
1.136 + * functions
1.137 + */
1.138 +extern struct pvr2_scene_struct pvr2_scene;
1.139 +
1.140 +
1.141 +#endif /* !lxdream_render_H */
.