Minor r200 vertex program cleanups. Remove disabled leftovers from r300 vertex progra...
[mesa.git] / src / mesa / drivers / dri / i965 / brw_save.h
1 /**************************************************************************
2
3 Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.
4
5 All Rights Reserved.
6
7 Permission is hereby granted, free of charge, to any person obtaining a
8 copy of this software and associated documentation files (the "Software"),
9 to deal in the Software without restriction, including without limitation
10 on the rights to use, copy, modify, merge, publish, distribute, sub
11 license, and/or sell copies of the Software, and to permit persons to whom
12 the Software is furnished to do so, subject to the following conditions:
13
14 The above copyright notice and this permission notice (including the next
15 paragraph) shall be included in all copies or substantial portions of the
16 Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 USE OR OTHER DEALINGS IN THE SOFTWARE.
25
26 **************************************************************************/
27
28 /*
29 * Authors:
30 * Keith Whitwell <keith@tungstengraphics.com>
31 *
32 */
33
34 #ifndef BRW_SAVE_H
35 #define BRW_SAVE_H
36
37 #include "mtypes.h"
38 #include "brw_attrib.h"
39 #include "brw_draw.h"
40
41
42 struct brw_save_copied_vtx {
43 GLfloat buffer[BRW_ATTRIB_MAX * 4 * BRW_MAX_COPIED_VERTS];
44 GLuint nr;
45 };
46
47
48 /* For display lists, this structure holds a run of vertices of the
49 * same format, and a strictly well-formed set of begin/end pairs,
50 * starting on the first vertex and ending at the last. Vertex
51 * copying on buffer breaks is precomputed according to these
52 * primitives, though there are situations where the copying will need
53 * correction at execute-time, perhaps by replaying the list as
54 * immediate mode commands.
55 *
56 * On executing this list, the 'current' values may be updated with
57 * the values of the final vertex, and often no fixup of the start of
58 * the vertex list is required.
59 *
60 * Eval and other commands that don't fit into these vertex lists are
61 * compiled using the fallback opcode mechanism provided by dlist.c.
62 */
63 struct brw_save_vertex_list {
64 GLubyte attrsz[BRW_ATTRIB_MAX];
65 GLuint vertex_size;
66
67 GLuint buffer_offset;
68 GLuint count;
69 GLuint wrap_count; /* number of copied vertices at start */
70 GLboolean dangling_attr_ref; /* current attr implicitly referenced
71 outside the list */
72
73 struct brw_draw_prim *prim;
74 GLuint prim_count;
75
76 struct brw_save_vertex_store *vertex_store;
77 struct brw_save_primitive_store *prim_store;
78 };
79
80 /* These buffers should be a reasonable size to support upload to
81 * hardware. Current brw implementation will re-upload on any
82 * changes, so don't make too big or apps which dynamically create
83 * dlists and use only a few times will suffer.
84 *
85 * Consider stategy of uploading regions from the VBO on demand in the
86 * case of dynamic vbos. Then make the dlist code signal that
87 * likelyhood as it occurs. No reason we couldn't change usage
88 * internally even though this probably isn't allowed for client VBOs?
89 */
90 #define BRW_SAVE_BUFFER_SIZE (8*1024) /* dwords */
91 #define BRW_SAVE_PRIM_SIZE 128
92 #define BRW_SAVE_PRIM_WEAK 0x40
93
94 #define BRW_SAVE_FALLBACK 0x10000000
95
96 /* Storage to be shared among several vertex_lists.
97 */
98 struct brw_save_vertex_store {
99 struct gl_buffer_object *bufferobj;
100 GLfloat *buffer;
101 GLuint used;
102 GLuint refcount;
103 };
104
105 struct brw_save_primitive_store {
106 struct brw_draw_prim buffer[BRW_SAVE_PRIM_SIZE];
107 GLuint used;
108 GLuint refcount;
109 };
110
111
112 struct brw_save_context {
113 GLcontext *ctx;
114 GLvertexformat vtxfmt;
115 struct gl_client_array arrays[BRW_ATTRIB_MAX];
116 const struct gl_client_array *inputs[BRW_ATTRIB_MAX];
117
118 GLubyte attrsz[BRW_ATTRIB_MAX];
119 GLuint vertex_size;
120
121 GLfloat *buffer;
122 GLuint count;
123 GLuint wrap_count;
124 GLuint replay_flags;
125
126 struct brw_draw_prim *prim;
127 GLuint prim_count, prim_max;
128
129 struct brw_save_vertex_store *vertex_store;
130 struct brw_save_primitive_store *prim_store;
131
132 GLfloat *vbptr; /* cursor, points into buffer */
133 GLfloat vertex[BRW_ATTRIB_MAX*4]; /* current values */
134 GLfloat *attrptr[BRW_ATTRIB_MAX];
135 GLuint vert_count;
136 GLuint max_vert;
137 GLboolean dangling_attr_ref;
138 GLboolean have_materials;
139
140 GLuint opcode_vertex_list;
141
142 struct brw_save_copied_vtx copied;
143
144 GLfloat CurrentFloatEdgeFlag;
145
146 GLfloat *current[BRW_ATTRIB_MAX]; /* points into ctx->ListState */
147 GLubyte *currentsz[BRW_ATTRIB_MAX];
148
149 void (*tabfv[BRW_ATTRIB_MAX][4])( const GLfloat * );
150 };
151
152
153 void brw_save_init( GLcontext *ctx );
154 void brw_save_destroy( GLcontext *ctx );
155 void brw_save_wakeup( GLcontext *ctx );
156 void brw_save_invalidate_state( GLcontext *ctx, GLuint new_state );
157 void brw_save_fallback( GLcontext *ctx, GLboolean fallback );
158
159 /* Callbacks:
160 */
161 void brw_save_EndList( GLcontext *ctx );
162 void brw_save_NewList( GLcontext *ctx, GLuint list, GLenum mode );
163 void brw_save_EndCallList( GLcontext *ctx );
164 void brw_save_BeginCallList( GLcontext *ctx, struct mesa_display_list *list );
165 void brw_save_SaveFlushVertices( GLcontext *ctx );
166 GLboolean brw_save_NotifyBegin( GLcontext *ctx, GLenum mode );
167
168 void brw_save_playback_vertex_list( GLcontext *ctx, void *data );
169
170 void brw_save_api_init( struct brw_save_context *save );
171
172 #endif