1 | /* Copyright (c) 2001, Stanford University
|
---|
2 | * All rights reserved
|
---|
3 | *
|
---|
4 | * See the file LICENSE.txt for information on redistributing this software.
|
---|
5 | */
|
---|
6 |
|
---|
7 | #include "packer.h"
|
---|
8 | #include "cr_opcodes.h"
|
---|
9 | #include "cr_error.h"
|
---|
10 |
|
---|
11 | #define UNUSED(x) ((void)(x))
|
---|
12 | /**
|
---|
13 | * \mainpage Packer
|
---|
14 | *
|
---|
15 | * \section PackerIntroduction Introduction
|
---|
16 | *
|
---|
17 | * Chromium consists of all the top-level files in the cr
|
---|
18 | * directory. The packer module basically takes care of API dispatch,
|
---|
19 | * and OpenGL state management.
|
---|
20 | *
|
---|
21 | */
|
---|
22 |
|
---|
23 | void PACK_APIENTRY crPackVertexPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
|
---|
24 | {
|
---|
25 | /* Packing this command is only useful if we have server-side vertex
|
---|
26 | * arrays - GL_ARB_vertex_buffer_object. Note that pointer will really
|
---|
27 | * be an offset into a server-side buffer.
|
---|
28 | */
|
---|
29 | GET_PACKER_CONTEXT(pc);
|
---|
30 | unsigned char *data_ptr;
|
---|
31 | int packet_length = 20 + sizeof(GLintptrARB);
|
---|
32 | GET_BUFFERED_POINTER( pc, packet_length );
|
---|
33 | WRITE_DATA( 0, GLint, packet_length );
|
---|
34 | WRITE_DATA( 4, GLenum, CR_VERTEXPOINTER_EXTEND_OPCODE );
|
---|
35 | WRITE_DATA( 8, GLint, size );
|
---|
36 | WRITE_DATA( 12, GLenum, type );
|
---|
37 | WRITE_DATA( 16, GLsizei, stride );
|
---|
38 | WRITE_DATA( 20, GLintptrARB, (GLintptrARB) pointer );
|
---|
39 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
40 | }
|
---|
41 |
|
---|
42 | void PACK_APIENTRY crPackColorPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
|
---|
43 | {
|
---|
44 | GET_PACKER_CONTEXT(pc);
|
---|
45 | unsigned char *data_ptr;
|
---|
46 | int packet_length = 20 + sizeof(GLintptrARB);
|
---|
47 | GET_BUFFERED_POINTER( pc, packet_length );
|
---|
48 | WRITE_DATA( 0, GLint, packet_length );
|
---|
49 | WRITE_DATA( 4, GLenum, CR_COLORPOINTER_EXTEND_OPCODE );
|
---|
50 | WRITE_DATA( 8, GLint, size );
|
---|
51 | WRITE_DATA( 12, GLenum, type );
|
---|
52 | WRITE_DATA( 16, GLsizei, stride );
|
---|
53 | WRITE_DATA( 20, GLintptrARB, (GLintptrARB) pointer );
|
---|
54 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
55 | }
|
---|
56 |
|
---|
57 | void PACK_APIENTRY crPackNormalPointer( GLenum type, GLsizei stride, const GLvoid *pointer )
|
---|
58 | {
|
---|
59 | GET_PACKER_CONTEXT(pc);
|
---|
60 | unsigned char *data_ptr;
|
---|
61 | int packet_length = 16 + sizeof(GLintptrARB);
|
---|
62 | GET_BUFFERED_POINTER( pc, packet_length );
|
---|
63 | WRITE_DATA( 0, GLint, packet_length );
|
---|
64 | WRITE_DATA( 4, GLenum, CR_NORMALPOINTER_EXTEND_OPCODE );
|
---|
65 | WRITE_DATA( 8, GLenum, type );
|
---|
66 | WRITE_DATA( 12, GLsizei, stride );
|
---|
67 | WRITE_DATA( 16, GLintptrARB, (GLintptrARB) pointer );
|
---|
68 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
69 | }
|
---|
70 |
|
---|
71 | void PACK_APIENTRY crPackTexCoordPointer( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
|
---|
72 | {
|
---|
73 | GET_PACKER_CONTEXT(pc);
|
---|
74 | unsigned char *data_ptr;
|
---|
75 | int packet_length = 20 + sizeof(GLintptrARB);
|
---|
76 | GET_BUFFERED_POINTER( pc, packet_length );
|
---|
77 | WRITE_DATA( 0, GLint, packet_length );
|
---|
78 | WRITE_DATA( 4, GLenum, CR_TEXCOORDPOINTER_EXTEND_OPCODE );
|
---|
79 | WRITE_DATA( 8, GLint, size );
|
---|
80 | WRITE_DATA( 12, GLenum, type );
|
---|
81 | WRITE_DATA( 16, GLsizei, stride );
|
---|
82 | WRITE_DATA( 20, GLintptrARB, (GLintptrARB) pointer );
|
---|
83 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
84 | }
|
---|
85 |
|
---|
86 | void PACK_APIENTRY crPackEdgeFlagPointer( GLsizei stride, const GLvoid *pointer )
|
---|
87 | {
|
---|
88 | GET_PACKER_CONTEXT(pc);
|
---|
89 | unsigned char *data_ptr;
|
---|
90 | int packet_length = 12 + sizeof(GLintptrARB);
|
---|
91 | GET_BUFFERED_POINTER( pc, packet_length );
|
---|
92 | WRITE_DATA( 0, GLint, packet_length );
|
---|
93 | WRITE_DATA( 4, GLenum, CR_EDGEFLAGPOINTER_EXTEND_OPCODE );
|
---|
94 | WRITE_DATA( 8, GLsizei, stride );
|
---|
95 | WRITE_DATA( 12, GLintptrARB, (GLintptrARB) pointer );
|
---|
96 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
97 | }
|
---|
98 |
|
---|
99 | void PACK_APIENTRY crPackIndexPointer( GLenum type, GLsizei stride, const GLvoid *pointer )
|
---|
100 | {
|
---|
101 | GET_PACKER_CONTEXT(pc);
|
---|
102 | unsigned char *data_ptr;
|
---|
103 | int packet_length = 16 + sizeof(GLintptrARB);
|
---|
104 | GET_BUFFERED_POINTER( pc, packet_length );
|
---|
105 | WRITE_DATA( 0, GLint, packet_length );
|
---|
106 | WRITE_DATA( 4, GLenum, CR_INDEXPOINTER_EXTEND_OPCODE );
|
---|
107 | WRITE_DATA( 8, GLenum, type );
|
---|
108 | WRITE_DATA( 12, GLsizei, stride );
|
---|
109 | WRITE_DATA( 16, GLintptrARB, (GLintptrARB) pointer );
|
---|
110 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
111 | }
|
---|
112 |
|
---|
113 | void PACK_APIENTRY crPackSecondaryColorPointerEXT( GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
|
---|
114 | {
|
---|
115 | GET_PACKER_CONTEXT(pc);
|
---|
116 | unsigned char *data_ptr;
|
---|
117 | int packet_length = 20 + sizeof(GLintptrARB);
|
---|
118 | GET_BUFFERED_POINTER( pc, packet_length );
|
---|
119 | WRITE_DATA( 0, GLint, packet_length );
|
---|
120 | WRITE_DATA( 4, GLenum, CR_SECONDARYCOLORPOINTEREXT_EXTEND_OPCODE );
|
---|
121 | WRITE_DATA( 8, GLint, size );
|
---|
122 | WRITE_DATA( 12, GLenum, type );
|
---|
123 | WRITE_DATA( 16, GLsizei, stride );
|
---|
124 | WRITE_DATA( 20, GLintptrARB, (GLintptrARB) pointer );
|
---|
125 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
126 | }
|
---|
127 |
|
---|
128 | void PACK_APIENTRY crPackFogCoordPointerEXT( GLenum type, GLsizei stride, const GLvoid * pointer )
|
---|
129 | {
|
---|
130 | GET_PACKER_CONTEXT(pc);
|
---|
131 | unsigned char *data_ptr;
|
---|
132 | int packet_length = 16 + sizeof(GLintptrARB);
|
---|
133 | GET_BUFFERED_POINTER( pc, packet_length );
|
---|
134 | WRITE_DATA( 0, GLint, packet_length );
|
---|
135 | WRITE_DATA( 4, GLenum, CR_FOGCOORDPOINTEREXT_EXTEND_OPCODE );
|
---|
136 | WRITE_DATA( 8, GLenum, type );
|
---|
137 | WRITE_DATA( 12, GLsizei, stride );
|
---|
138 | WRITE_DATA( 16, GLintptrARB, (GLintptrARB) pointer );
|
---|
139 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
140 | }
|
---|
141 |
|
---|
142 | void PACK_APIENTRY crPackVertexAttribPointerARB( GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer )
|
---|
143 | {
|
---|
144 | GET_PACKER_CONTEXT(pc);
|
---|
145 | unsigned char *data_ptr;
|
---|
146 | int packet_length = 28 + sizeof(GLintptrARB);
|
---|
147 | GET_BUFFERED_POINTER( pc, packet_length );
|
---|
148 | WRITE_DATA( 0, GLint, packet_length );
|
---|
149 | WRITE_DATA( 4, GLenum, CR_VERTEXATTRIBPOINTERARB_EXTEND_OPCODE );
|
---|
150 | WRITE_DATA( 8, GLint, index );
|
---|
151 | WRITE_DATA( 12, GLint, size );
|
---|
152 | WRITE_DATA( 16, GLenum, type );
|
---|
153 | WRITE_DATA( 20, GLboolean, normalized );
|
---|
154 | WRITE_DATA( 24, GLsizei, stride );
|
---|
155 | WRITE_DATA( 28, GLintptrARB, (GLintptrARB) pointer );
|
---|
156 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
157 | }
|
---|
158 |
|
---|
159 | void PACK_APIENTRY crPackVertexAttribPointerNV( GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer )
|
---|
160 | {
|
---|
161 | GET_PACKER_CONTEXT(pc);
|
---|
162 | unsigned char *data_ptr;
|
---|
163 | int packet_length = 24 + sizeof(GLintptrARB);
|
---|
164 | GET_BUFFERED_POINTER( pc, packet_length );
|
---|
165 | WRITE_DATA( 0, GLint, packet_length );
|
---|
166 | WRITE_DATA( 4, GLenum, CR_VERTEXATTRIBPOINTERNV_EXTEND_OPCODE );
|
---|
167 | WRITE_DATA( 8, GLint, index );
|
---|
168 | WRITE_DATA( 12, GLint, size );
|
---|
169 | WRITE_DATA( 16, GLenum, type );
|
---|
170 | WRITE_DATA( 20, GLsizei, stride );
|
---|
171 | WRITE_DATA( 24, GLintptrARB, (GLintptrARB) pointer );
|
---|
172 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
173 | }
|
---|
174 |
|
---|
175 | void PACK_APIENTRY crPackInterleavedArrays( GLenum format, GLsizei stride, const GLvoid *pointer )
|
---|
176 | {
|
---|
177 | GET_PACKER_CONTEXT(pc);
|
---|
178 | unsigned char *data_ptr;
|
---|
179 | int packet_length = 16 + sizeof(GLintptrARB);
|
---|
180 | GET_BUFFERED_POINTER( pc, packet_length );
|
---|
181 | WRITE_DATA( 0, GLint, packet_length );
|
---|
182 | WRITE_DATA( 4, GLenum, CR_INTERLEAVEDARRAYS_EXTEND_OPCODE );
|
---|
183 | WRITE_DATA( 8, GLenum, format );
|
---|
184 | WRITE_DATA( 12, GLsizei, stride );
|
---|
185 | WRITE_DATA( 16, GLintptrARB, (GLintptrARB) pointer );
|
---|
186 | WRITE_OPCODE( pc, CR_EXTEND_OPCODE );
|
---|
187 | }
|
---|
188 |
|
---|
189 |
|
---|
190 | void PACK_APIENTRY crPackVertexArrayRangeNV( GLsizei length, const GLvoid *pointer )
|
---|
191 | {
|
---|
192 | UNUSED( length );
|
---|
193 | UNUSED( pointer );
|
---|
194 | crWarning( "Unimplemented crPackVertexArrayRangeNV" );
|
---|
195 | }
|
---|