summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965/brw_exec.h
blob: 2fa111dc8b38d4b06b2931d300c23f06048a6ebb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/**************************************************************************

Copyright 2002 Tungsten Graphics Inc., Cedar Park, Texas.

All Rights Reserved.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
on the rights to use, copy, modify, merge, publish, distribute, sub
license, and/or sell copies of the Software, and to permit persons to whom
the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice (including the next
paragraph) shall be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
TUNGSTEN GRAPHICS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.

**************************************************************************/

/*
 * Authors:
 *   Keith Whitwell <keith@tungstengraphics.com>
 *
 */

#ifndef __BRW_EXEC_H__
#define __BRW_EXEC_H__

#include "mtypes.h"
#include "brw_attrib.h"
#include "brw_draw.h"


#define BRW_MAX_PRIM 64

/* Wierd implementation stuff:
 */
#define BRW_VERT_BUFFER_SIZE (1024*16)	/* dwords == 64k */
#define BRW_MAX_ATTR_CODEGEN 16 
#define ERROR_ATTRIB 16




struct brw_exec_eval1_map {
   struct gl_1d_map *map;
   GLuint sz;
};

struct brw_exec_eval2_map {
   struct gl_2d_map *map;
   GLuint sz;
};



struct brw_exec_copied_vtx {
   GLfloat buffer[BRW_ATTRIB_MAX * 4 * BRW_MAX_COPIED_VERTS];
   GLuint nr;
};


typedef void (*brw_attrfv_func)( const GLfloat * );


struct brw_exec_context
{
   GLcontext *ctx;   
   GLvertexformat vtxfmt;

   struct {
      struct gl_buffer_object *bufferobj;
      GLubyte *buffer_map;

      GLuint vertex_size;

      struct brw_draw_prim prim[BRW_MAX_PRIM];
      GLuint prim_count;

      GLfloat *vbptr;		     /* cursor, points into buffer */
      GLfloat vertex[BRW_ATTRIB_MAX*4]; /* current vertex */

      GLfloat *current[BRW_ATTRIB_MAX]; /* points into ctx->Current, ctx->Light.Material */
      GLfloat CurrentFloatEdgeFlag;

      GLuint vert_count;
      GLuint max_vert;
      struct brw_exec_copied_vtx copied;

      brw_attrfv_func tabfv[BRW_MAX_ATTR_CODEGEN+1][4]; /* plus 1 for ERROR_ATTRIB */

      GLubyte attrsz[BRW_ATTRIB_MAX];
      GLfloat *attrptr[BRW_ATTRIB_MAX]; 
      struct gl_client_array arrays[BRW_ATTRIB_MAX];
      const struct gl_client_array *inputs[BRW_ATTRIB_MAX];
   } vtx;

   
   struct {
      GLboolean recalculate_maps;
      struct brw_exec_eval1_map map1[BRW_ATTRIB_MAX];
      struct brw_exec_eval2_map map2[BRW_ATTRIB_MAX];
   } eval;

   struct {
      GLboolean recalculate_inputs;
      const struct gl_client_array *inputs[BRW_ATTRIB_MAX];
      const struct gl_client_array *attrib_arrays[BRW_ATTRIB_MAX];
      const struct gl_client_array *legacy_arrays[BRW_ATTRIB_MAX];

      struct gl_buffer_object *index_obj;
   } array;
};



/* External API:
 */
void brw_exec_init( GLcontext *ctx );
void brw_exec_destroy( GLcontext *ctx );
void brw_exec_invalidate_state( GLcontext *ctx, GLuint new_state );
void brw_exec_FlushVertices( GLcontext *ctx, GLuint flags );
void brw_exec_wakeup( GLcontext *ctx );


/* Internal functions:
 */
void brw_exec_array_init( struct brw_exec_context *exec );
void brw_exec_array_destroy( struct brw_exec_context *exec );


void brw_exec_vtx_init( struct brw_exec_context *exec );
void brw_exec_vtx_destroy( struct brw_exec_context *exec );
void brw_exec_vtx_flush( struct brw_exec_context *exec );
void brw_exec_vtx_wrap( struct brw_exec_context *exec );

void brw_exec_eval_update( struct brw_exec_context *exec );

void brw_exec_do_EvalCoord2f( struct brw_exec_context *exec, 
				     GLfloat u, GLfloat v );

void brw_exec_do_EvalCoord1f( struct brw_exec_context *exec,
				     GLfloat u);



void brw_exec_vtx_generic_init( struct brw_exec_context *exec );

void brw_exec_generic_attr_table_init( brw_attrfv_func (*tab)[4] );


#endif