Search
lxdream.org :: lxdream/src/pvr2/scene.h :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/pvr2/scene.h
changeset 635:76c63aac3590
next636:2ccf94f966fc
author nkeynes
date Thu Feb 14 13:54:11 2008 +0000 (14 years ago)
branchlxdream-render
permissions -rw-r--r--
last change Commit render work in progress. Main changes:
* Preliminary OSMesa support
* Move the generic gl code out to pvr2/
* Implement scene data structure + reader
* Remove the 1/z adjustments
file annotate diff log raw
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/pvr2/scene.h Thu Feb 14 13:54:11 2008 +0000
1.3 @@ -0,0 +1,137 @@
1.4 +/**
1.5 + * $Id: pvr2.h 602 2008-01-15 20:50:23Z nkeynes $
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_BYFLAG = 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 x,y,z;
1.35 + float u,v;
1.36 + uint32_t rgba;
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 + int32_t vertex_index; // index of first vertex in vertex buffer
1.45 + int32_t mod_vertex_index; // index of first modified vertex in vertex buffer
1.46 + float center_z;
1.47 + struct polygon_struct *next; // chain for tri/quad arrays
1.48 +};
1.49 +
1.50 +void pvr2_scene_init(void);
1.51 +void pvr2_scene_read(void);
1.52 +void pvr2_scene_shutdown();
1.53 +
1.54 +extern char *video_base;
1.55 +
1.56 +/**
1.57 + * Maximum possible size of the vertex buffer. This is figured as follows:
1.58 + * PVR2 polygon buffer is limited to 4MB. The tightest polygon format
1.59 + * is 3 vertexes in 48 bytes = 16 bytes/vertex, (shadow triangle)
1.60 + * (the next tightest is 8 vertex in 140 bytes (6-strip colour-only)).
1.61 + * giving a theoretical maximum of 262144 vertexes.
1.62 + * The expanded structure is 44 bytes/vertex, giving
1.63 + * 11534336 bytes...
1.64 + */
1.65 +#define MAX_VERTEXES 262144
1.66 +#define MAX_VERTEX_BUFFER_SIZE (MAX_VERTEXES*sizeof(struct vertex_struct))
1.67 +
1.68 +/**
1.69 + * Maximum polygons - smallest is 1 polygon in 48 bytes, giving
1.70 + * 87381
1.71 + *
1.72 + */
1.73 +#define MAX_POLYGONS 87382
1.74 +#define MAX_POLY_BUFFER_SIZE (MAX_POLYGONS*sizeof(struct polygon_struct))
1.75 +#define BUF_POLY_MAP_SIZE (4 MB)
1.76 +
1.77 +/*************************************************************************/
1.78 +
1.79 +/* Scene data - this structure holds all the intermediate data used during
1.80 + * the rendering process.
1.81 + *
1.82 + * Special note: if vbo_supported == FALSE, then vertex_array points to a
1.83 + * malloced chunk of system RAM. Otherwise, vertex_array will be either NULL
1.84 + * (if the VBO is unmapped), or a pointer into a chunk of GL managed RAM
1.85 + * (possibly direct-mapped VRAM).
1.86 + */
1.87 +struct pvr2_scene_struct {
1.88 + /** GL ID of the VBO used by the scene (or 0 if VBOs are not in use). */
1.89 + GLuint vbo_id;
1.90 + /** Pointer to the vertex array data, or NULL for unmapped VBOs */
1.91 + struct vertex_struct *vertex_array;
1.92 + /** Current allocated size (in bytes) of the vertex array */
1.93 + uint32_t vertex_array_size;
1.94 + /** Total number of vertexes in the scene (note modified vertexes
1.95 + * count for 2 vertexes */
1.96 + uint32_t vertex_count;
1.97 +
1.98 + /** Pointer to the polygon data for the scene (main ram).
1.99 + * This will always have room for at least MAX_POLYGONS */
1.100 + struct polygon_struct *poly_array;
1.101 + /** Total number of polygons in the scene */
1.102 + uint32_t poly_count;
1.103 +
1.104 + /** Image bounds in 3D - x1,x2,y1,y2,z1,z2
1.105 + * x and y values are determined by the clip planes, while z values are
1.106 + * determined from the vertex data itself.
1.107 + */
1.108 + float bounds[6];
1.109 +
1.110 + /* Total size of the image buffer, determined by the tile map used to
1.111 + * render the scene */
1.112 + uint32_t buffer_width, buffer_height;
1.113 +
1.114 + /** True if modifier volumes use the two-parameter form, False if they
1.115 + * use the cheap-shadow option.
1.116 + */
1.117 + gboolean full_shadow;
1.118 + /** Specifies the translucency auto-sort mode for the scene */
1.119 + tile_sort_mode_t sort_mode;
1.120 +
1.121 + /** Pointer to the start of the tile segment list in PVR2 VRAM (32-bit) */
1.122 + struct tile_segment *segment_list;
1.123 + /** Map from PVR2 polygon address to an element of poly_array. Temporary,
1.124 + * used only during poly buffer parsing */
1.125 + struct polygon_struct **buf_to_poly_map;
1.126 + /** Pointer to the start of the raw polygon buffer in PVR2 VRAM (32-bit).
1.127 + * Also only used during parsing */
1.128 + uint32_t *pvr2_pbuf;
1.129 + /** Current vertex index during parsing */
1.130 + uint32_t vertex_index;
1.131 +};
1.132 +
1.133 +/**
1.134 + * Current scene structure. Note this should only be written to by vertex bufer
1.135 + * functions
1.136 + */
1.137 +extern struct pvr2_scene_struct pvr2_scene;
1.138 +
1.139 +
1.140 +#endif /* !lxdream_render_H */
.