VirtualBox

source: vbox/trunk/src/VBox/HostServices/SharedOpenGL/unpacker/unpack_shaders.c@ 23495

Last change on this file since 23495 was 23399, checked in by vboxsync, 15 years ago

crOpenGL: cache uniforms info

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 8.1 KB
Line 
1/* $Id: unpack_shaders.c 23399 2009-09-29 05:04:38Z vboxsync $ */
2
3/** @file
4 * VBox OpenGL DRI driver functions
5 */
6
7/*
8 * Copyright (C) 2009 Sun Microsystems, Inc.
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 *
18 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
19 * Clara, CA 95054 USA or visit http://www.sun.com if you need
20 * additional information or have any questions.
21 */
22
23#include "unpacker.h"
24#include "cr_error.h"
25#include "cr_protocol.h"
26#include "cr_mem.h"
27#include "cr_string.h"
28#include "cr_version.h"
29
30void crUnpackExtendBindAttribLocation(void)
31{
32 GLuint program = READ_DATA(8, GLuint);
33 GLuint index = READ_DATA(12, GLuint);
34 const char *name = DATA_POINTER(16, const char);
35
36 cr_unpackDispatch.BindAttribLocation(program, index, name);
37}
38
39void crUnpackExtendShaderSource(void)
40{
41 GLint *length = NULL;
42 GLuint shader = READ_DATA(8, GLuint);
43 GLsizei count = READ_DATA(12, GLsizei);
44 GLint hasNonLocalLen = READ_DATA(16, GLsizei);
45 GLint *pLocalLength = DATA_POINTER(20, GLint);
46 const char **ppStrings = NULL;
47 GLsizei i;
48 int pos=20+count*sizeof(*pLocalLength);
49
50 if (hasNonLocalLen>0)
51 {
52 length = DATA_POINTER(pos, GLint);
53 pos += count*sizeof(*length);
54 }
55
56 ppStrings = crAlloc(count*sizeof(char*));
57 if (!ppStrings) return;
58
59 for (i=0; i<count; ++i)
60 {
61 ppStrings[i] = DATA_POINTER(pos, char);
62 pos += pLocalLength[i];
63 if (!length)
64 {
65 pLocalLength[i] -= 1;
66 }
67 }
68
69 cr_unpackDispatch.ShaderSource(shader, count, ppStrings, length ? length : pLocalLength);
70 crFree(ppStrings);
71}
72
73void crUnpackExtendUniform1fv(void)
74{
75 GLint location = READ_DATA(8, GLint);
76 GLsizei count = READ_DATA(12, GLsizei);
77 const GLfloat *value = DATA_POINTER(16, const GLfloat);
78 cr_unpackDispatch.Uniform1fv(location, count, value);
79}
80
81void crUnpackExtendUniform1iv(void)
82{
83 GLint location = READ_DATA(8, GLint);
84 GLsizei count = READ_DATA(12, GLsizei);
85 const GLint *value = DATA_POINTER(16, const GLint);
86 cr_unpackDispatch.Uniform1iv(location, count, value);
87}
88
89void crUnpackExtendUniform2fv(void)
90{
91 GLint location = READ_DATA(8, GLint);
92 GLsizei count = READ_DATA(12, GLsizei);
93 const GLfloat *value = DATA_POINTER(16, const GLfloat);
94 cr_unpackDispatch.Uniform2fv(location, count, value);
95}
96
97void crUnpackExtendUniform2iv(void)
98{
99 GLint location = READ_DATA(8, GLint);
100 GLsizei count = READ_DATA(12, GLsizei);
101 const GLint *value = DATA_POINTER(16, const GLint);
102 cr_unpackDispatch.Uniform2iv(location, count, value);
103}
104
105void crUnpackExtendUniform3fv(void)
106{
107 GLint location = READ_DATA(8, GLint);
108 GLsizei count = READ_DATA(12, GLsizei);
109 const GLfloat *value = DATA_POINTER(16, const GLfloat);
110 cr_unpackDispatch.Uniform3fv(location, count, value);
111}
112
113void crUnpackExtendUniform3iv(void)
114{
115 GLint location = READ_DATA(8, GLint);
116 GLsizei count = READ_DATA(12, GLsizei);
117 const GLint *value = DATA_POINTER(16, const GLint);
118 cr_unpackDispatch.Uniform3iv(location, count, value);
119}
120
121void crUnpackExtendUniform4fv(void)
122{
123 GLint location = READ_DATA(8, GLint);
124 GLsizei count = READ_DATA(12, GLsizei);
125 const GLfloat *value = DATA_POINTER(16, const GLfloat);
126 cr_unpackDispatch.Uniform4fv(location, count, value);
127}
128
129void crUnpackExtendUniform4iv(void)
130{
131 GLint location = READ_DATA(8, GLint);
132 GLsizei count = READ_DATA(12, GLsizei);
133 const GLint *value = DATA_POINTER(16, const GLint);
134 cr_unpackDispatch.Uniform4iv(location, count, value);
135}
136
137void crUnpackExtendUniformMatrix2fv(void)
138{
139 GLint location = READ_DATA(8, GLint);
140 GLsizei count = READ_DATA(12, GLsizei);
141 GLboolean transpose = READ_DATA(16, GLboolean);
142 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
143 cr_unpackDispatch.UniformMatrix2fv(location, count, transpose, value);
144}
145
146void crUnpackExtendUniformMatrix3fv(void)
147{
148 GLint location = READ_DATA(8, GLint);
149 GLsizei count = READ_DATA(12, GLsizei);
150 GLboolean transpose = READ_DATA(16, GLboolean);
151 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
152 cr_unpackDispatch.UniformMatrix3fv(location, count, transpose, value);
153}
154
155void crUnpackExtendUniformMatrix4fv(void)
156{
157 GLint location = READ_DATA(8, GLint);
158 GLsizei count = READ_DATA(12, GLsizei);
159 GLboolean transpose = READ_DATA(16, GLboolean);
160 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
161 cr_unpackDispatch.UniformMatrix4fv(location, count, transpose, value);
162}
163
164void crUnpackExtendDrawBuffers(void)
165{
166 GLsizei n = READ_DATA(8, GLsizei);
167 const GLenum *bufs = DATA_POINTER(8+sizeof(GLsizei), const GLenum);
168 cr_unpackDispatch.DrawBuffers(n, bufs);
169}
170
171void crUnpackExtendGetActiveAttrib(void)
172{
173 GLuint program = READ_DATA(8, GLuint);
174 GLuint index = READ_DATA(12, GLuint);
175 GLsizei bufSize = READ_DATA(16, GLsizei);
176 SET_RETURN_PTR(20);
177 SET_WRITEBACK_PTR(28);
178 cr_unpackDispatch.GetActiveAttrib(program, index, bufSize, NULL, NULL, NULL, NULL);
179}
180
181void crUnpackExtendGetActiveUniform(void)
182{
183 GLuint program = READ_DATA(8, GLuint);
184 GLuint index = READ_DATA(12, GLuint);
185 GLsizei bufSize = READ_DATA(16, GLsizei);
186 SET_RETURN_PTR(20);
187 SET_WRITEBACK_PTR(28);
188 cr_unpackDispatch.GetActiveUniform(program, index, bufSize, NULL, NULL, NULL, NULL);
189}
190
191void crUnpackExtendGetAttachedShaders(void)
192{
193 GLuint program = READ_DATA(8, GLuint);
194 GLsizei maxCount = READ_DATA(12, GLsizei);
195 SET_RETURN_PTR(16);
196 SET_WRITEBACK_PTR(24);
197 cr_unpackDispatch.GetAttachedShaders(program, maxCount, NULL, NULL);
198}
199
200void crUnpackExtendGetAttachedObjectsARB(void)
201{
202 GLhandleARB containerObj = READ_DATA(8, GLhandleARB);
203 GLsizei maxCount = READ_DATA(12, GLsizei);
204 SET_RETURN_PTR(16);
205 SET_WRITEBACK_PTR(24);
206 cr_unpackDispatch.GetAttachedObjectsARB(containerObj, maxCount, NULL, NULL);
207}
208
209void crUnpackExtendGetInfoLogARB(void)
210{
211 GLhandleARB obj = READ_DATA(8, GLhandleARB);
212 GLsizei maxLength = READ_DATA(12, GLsizei);
213 SET_RETURN_PTR(16);
214 SET_WRITEBACK_PTR(24);
215 cr_unpackDispatch.GetInfoLogARB(obj, maxLength, NULL, NULL);
216}
217
218void crUnpackExtendGetProgramInfoLog(void)
219{
220 GLuint program = READ_DATA(8, GLuint);
221 GLsizei bufSize = READ_DATA(12, GLsizei);
222 SET_RETURN_PTR(16);
223 SET_WRITEBACK_PTR(24);
224 cr_unpackDispatch.GetProgramInfoLog(program, bufSize, NULL, NULL);
225}
226
227void crUnpackExtendGetShaderInfoLog(void)
228{
229 GLuint shader = READ_DATA(8, GLuint);
230 GLsizei bufSize = READ_DATA(12, GLsizei);
231 SET_RETURN_PTR(16);
232 SET_WRITEBACK_PTR(24);
233 cr_unpackDispatch.GetShaderInfoLog(shader, bufSize, NULL, NULL);
234}
235
236void crUnpackExtendGetShaderSource(void)
237{
238 GLuint shader = READ_DATA(8, GLuint);
239 GLsizei bufSize = READ_DATA(12, GLsizei);
240 SET_RETURN_PTR(16);
241 SET_WRITEBACK_PTR(24);
242 cr_unpackDispatch.GetShaderSource(shader, bufSize, NULL, NULL);
243}
244
245void crUnpackExtendGetAttribLocation(void)
246{
247 int packet_length = READ_DATA(0, int);
248 GLuint program = READ_DATA(8, GLuint);
249 const char *name = DATA_POINTER(12, const char);
250 SET_RETURN_PTR(packet_length-16);
251 SET_WRITEBACK_PTR(packet_length-8);
252 cr_unpackDispatch.GetAttribLocation(program, name);
253}
254
255void crUnpackExtendGetUniformLocation(void)
256{
257 int packet_length = READ_DATA(0, int);
258 GLuint program = READ_DATA(8, GLuint);
259 const char *name = DATA_POINTER(12, const char);
260 SET_RETURN_PTR(packet_length-16);
261 SET_WRITEBACK_PTR(packet_length-8);
262 cr_unpackDispatch.GetUniformLocation(program, name);
263}
264
265void crUnpackExtendGetUniformsLocations(void)
266{
267 GLuint program = READ_DATA(8, GLuint);
268 GLsizei maxcbData = READ_DATA(12, GLsizei);
269 SET_RETURN_PTR(16);
270 SET_WRITEBACK_PTR(24);
271 cr_unpackDispatch.GetUniformsLocations(program, maxcbData, NULL, NULL);
272}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette