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