VirtualBox

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

Last change on this file since 69498 was 69498, checked in by vboxsync, 7 years ago

backed out r118835 as it incorrectly updated the 'This file is based on' file headers.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 10.7 KB
Line 
1/* $Id: unpack_shaders.c 69498 2017-10-28 15:07:25Z vboxsync $ */
2/** @file
3 * VBox OpenGL DRI driver functions
4 */
5
6/*
7 * Copyright (C) 2009-2016 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#include "unpacker.h"
19#include "cr_error.h"
20#include "cr_protocol.h"
21#include "cr_mem.h"
22#include "cr_string.h"
23#include "cr_version.h"
24
25void crUnpackExtendBindAttribLocation(void)
26{
27 GLuint program = READ_DATA(8, GLuint);
28 GLuint index = READ_DATA(12, GLuint);
29 const char *name = DATA_POINTER(16, const char);
30
31 cr_unpackDispatch.BindAttribLocation(program, index, name);
32}
33
34void crUnpackExtendShaderSource(void)
35{
36 GLint *length = NULL;
37 GLuint shader = READ_DATA(8, GLuint);
38 GLsizei count = READ_DATA(12, GLsizei);
39 GLint hasNonLocalLen = READ_DATA(16, GLsizei);
40 GLint *pLocalLength = DATA_POINTER(20, GLint);
41 char **ppStrings = NULL;
42 GLsizei i, j, jUpTo;
43 int pos=20+count*sizeof(*pLocalLength);
44
45 if (hasNonLocalLen>0)
46 {
47 length = DATA_POINTER(pos, GLint);
48 pos += count*sizeof(*length);
49 }
50
51 ppStrings = crAlloc(count*sizeof(char*));
52 if (!ppStrings) return;
53
54 for (i=0; i<count; ++i)
55 {
56 ppStrings[i] = DATA_POINTER(pos, char);
57 pos += pLocalLength[i];
58 if (!length)
59 {
60 pLocalLength[i] -= 1;
61 }
62
63 Assert(pLocalLength[i] > 0);
64 jUpTo = i == count -1 ? pLocalLength[i] - 1 : pLocalLength[i];
65 for (j = 0; j < jUpTo; ++j)
66 {
67 char *pString = ppStrings[i];
68
69 if (pString[j] == '\0')
70 {
71 Assert(j == jUpTo - 1);
72 pString[j] = '\n';
73 }
74 }
75 }
76
77// cr_unpackDispatch.ShaderSource(shader, count, ppStrings, length ? length : pLocalLength);
78 cr_unpackDispatch.ShaderSource(shader, 1, (const char**)ppStrings, 0);
79
80 crFree(ppStrings);
81}
82
83void crUnpackExtendUniform1fv(void)
84{
85 GLint location = READ_DATA(8, GLint);
86 GLsizei count = READ_DATA(12, GLsizei);
87 const GLfloat *value = DATA_POINTER(16, const GLfloat);
88 cr_unpackDispatch.Uniform1fv(location, count, value);
89}
90
91void crUnpackExtendUniform1iv(void)
92{
93 GLint location = READ_DATA(8, GLint);
94 GLsizei count = READ_DATA(12, GLsizei);
95 const GLint *value = DATA_POINTER(16, const GLint);
96 cr_unpackDispatch.Uniform1iv(location, count, value);
97}
98
99void crUnpackExtendUniform2fv(void)
100{
101 GLint location = READ_DATA(8, GLint);
102 GLsizei count = READ_DATA(12, GLsizei);
103 const GLfloat *value = DATA_POINTER(16, const GLfloat);
104 cr_unpackDispatch.Uniform2fv(location, count, value);
105}
106
107void crUnpackExtendUniform2iv(void)
108{
109 GLint location = READ_DATA(8, GLint);
110 GLsizei count = READ_DATA(12, GLsizei);
111 const GLint *value = DATA_POINTER(16, const GLint);
112 cr_unpackDispatch.Uniform2iv(location, count, value);
113}
114
115void crUnpackExtendUniform3fv(void)
116{
117 GLint location = READ_DATA(8, GLint);
118 GLsizei count = READ_DATA(12, GLsizei);
119 const GLfloat *value = DATA_POINTER(16, const GLfloat);
120 cr_unpackDispatch.Uniform3fv(location, count, value);
121}
122
123void crUnpackExtendUniform3iv(void)
124{
125 GLint location = READ_DATA(8, GLint);
126 GLsizei count = READ_DATA(12, GLsizei);
127 const GLint *value = DATA_POINTER(16, const GLint);
128 cr_unpackDispatch.Uniform3iv(location, count, value);
129}
130
131void crUnpackExtendUniform4fv(void)
132{
133 GLint location = READ_DATA(8, GLint);
134 GLsizei count = READ_DATA(12, GLsizei);
135 const GLfloat *value = DATA_POINTER(16, const GLfloat);
136 cr_unpackDispatch.Uniform4fv(location, count, value);
137}
138
139void crUnpackExtendUniform4iv(void)
140{
141 GLint location = READ_DATA(8, GLint);
142 GLsizei count = READ_DATA(12, GLsizei);
143 const GLint *value = DATA_POINTER(16, const GLint);
144 cr_unpackDispatch.Uniform4iv(location, count, value);
145}
146
147void crUnpackExtendUniformMatrix2fv(void)
148{
149 GLint location = READ_DATA(8, GLint);
150 GLsizei count = READ_DATA(12, GLsizei);
151 GLboolean transpose = READ_DATA(16, GLboolean);
152 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
153 cr_unpackDispatch.UniformMatrix2fv(location, count, transpose, value);
154}
155
156void crUnpackExtendUniformMatrix3fv(void)
157{
158 GLint location = READ_DATA(8, GLint);
159 GLsizei count = READ_DATA(12, GLsizei);
160 GLboolean transpose = READ_DATA(16, GLboolean);
161 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
162 cr_unpackDispatch.UniformMatrix3fv(location, count, transpose, value);
163}
164
165void crUnpackExtendUniformMatrix4fv(void)
166{
167 GLint location = READ_DATA(8, GLint);
168 GLsizei count = READ_DATA(12, GLsizei);
169 GLboolean transpose = READ_DATA(16, GLboolean);
170 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
171 cr_unpackDispatch.UniformMatrix4fv(location, count, transpose, value);
172}
173
174void crUnpackExtendUniformMatrix2x3fv(void)
175{
176 GLint location = READ_DATA(8, GLint);
177 GLsizei count = READ_DATA(12, GLsizei);
178 GLboolean transpose = READ_DATA(16, GLboolean);
179 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
180 cr_unpackDispatch.UniformMatrix2x3fv(location, count, transpose, value);
181}
182
183void crUnpackExtendUniformMatrix3x2fv(void)
184{
185 GLint location = READ_DATA(8, GLint);
186 GLsizei count = READ_DATA(12, GLsizei);
187 GLboolean transpose = READ_DATA(16, GLboolean);
188 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
189 cr_unpackDispatch.UniformMatrix3x2fv(location, count, transpose, value);
190}
191
192void crUnpackExtendUniformMatrix2x4fv(void)
193{
194 GLint location = READ_DATA(8, GLint);
195 GLsizei count = READ_DATA(12, GLsizei);
196 GLboolean transpose = READ_DATA(16, GLboolean);
197 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
198 cr_unpackDispatch.UniformMatrix2x4fv(location, count, transpose, value);
199}
200
201void crUnpackExtendUniformMatrix4x2fv(void)
202{
203 GLint location = READ_DATA(8, GLint);
204 GLsizei count = READ_DATA(12, GLsizei);
205 GLboolean transpose = READ_DATA(16, GLboolean);
206 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
207 cr_unpackDispatch.UniformMatrix4x2fv(location, count, transpose, value);
208}
209
210void crUnpackExtendUniformMatrix3x4fv(void)
211{
212 GLint location = READ_DATA(8, GLint);
213 GLsizei count = READ_DATA(12, GLsizei);
214 GLboolean transpose = READ_DATA(16, GLboolean);
215 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
216 cr_unpackDispatch.UniformMatrix3x4fv(location, count, transpose, value);
217}
218
219void crUnpackExtendUniformMatrix4x3fv(void)
220{
221 GLint location = READ_DATA(8, GLint);
222 GLsizei count = READ_DATA(12, GLsizei);
223 GLboolean transpose = READ_DATA(16, GLboolean);
224 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
225 cr_unpackDispatch.UniformMatrix4x3fv(location, count, transpose, value);
226}
227
228void crUnpackExtendDrawBuffers(void)
229{
230 GLsizei n = READ_DATA(8, GLsizei);
231 const GLenum *bufs = DATA_POINTER(8+sizeof(GLsizei), const GLenum);
232 cr_unpackDispatch.DrawBuffers(n, bufs);
233}
234
235void crUnpackExtendGetActiveAttrib(void)
236{
237 GLuint program = READ_DATA(8, GLuint);
238 GLuint index = READ_DATA(12, GLuint);
239 GLsizei bufSize = READ_DATA(16, GLsizei);
240 SET_RETURN_PTR(20);
241 SET_WRITEBACK_PTR(28);
242 cr_unpackDispatch.GetActiveAttrib(program, index, bufSize, NULL, NULL, NULL, NULL);
243}
244
245void crUnpackExtendGetActiveUniform(void)
246{
247 GLuint program = READ_DATA(8, GLuint);
248 GLuint index = READ_DATA(12, GLuint);
249 GLsizei bufSize = READ_DATA(16, GLsizei);
250 SET_RETURN_PTR(20);
251 SET_WRITEBACK_PTR(28);
252 cr_unpackDispatch.GetActiveUniform(program, index, bufSize, NULL, NULL, NULL, NULL);
253}
254
255void crUnpackExtendGetAttachedShaders(void)
256{
257 GLuint program = READ_DATA(8, GLuint);
258 GLsizei maxCount = READ_DATA(12, GLsizei);
259 SET_RETURN_PTR(16);
260 SET_WRITEBACK_PTR(24);
261 cr_unpackDispatch.GetAttachedShaders(program, maxCount, NULL, NULL);
262}
263
264void crUnpackExtendGetAttachedObjectsARB(void)
265{
266 VBoxGLhandleARB containerObj = READ_DATA(8, VBoxGLhandleARB);
267 GLsizei maxCount = READ_DATA(12, GLsizei);
268 SET_RETURN_PTR(16);
269 SET_WRITEBACK_PTR(24);
270 cr_unpackDispatch.GetAttachedObjectsARB(containerObj, maxCount, NULL, NULL);
271}
272
273void crUnpackExtendGetInfoLogARB(void)
274{
275 VBoxGLhandleARB obj = READ_DATA(8, VBoxGLhandleARB);
276 GLsizei maxLength = READ_DATA(12, GLsizei);
277 SET_RETURN_PTR(16);
278 SET_WRITEBACK_PTR(24);
279 cr_unpackDispatch.GetInfoLogARB(obj, maxLength, NULL, NULL);
280}
281
282void crUnpackExtendGetProgramInfoLog(void)
283{
284 GLuint program = READ_DATA(8, GLuint);
285 GLsizei bufSize = READ_DATA(12, GLsizei);
286 SET_RETURN_PTR(16);
287 SET_WRITEBACK_PTR(24);
288 cr_unpackDispatch.GetProgramInfoLog(program, bufSize, NULL, NULL);
289}
290
291void crUnpackExtendGetShaderInfoLog(void)
292{
293 GLuint shader = READ_DATA(8, GLuint);
294 GLsizei bufSize = READ_DATA(12, GLsizei);
295 SET_RETURN_PTR(16);
296 SET_WRITEBACK_PTR(24);
297 cr_unpackDispatch.GetShaderInfoLog(shader, bufSize, NULL, NULL);
298}
299
300void crUnpackExtendGetShaderSource(void)
301{
302 GLuint shader = READ_DATA(8, GLuint);
303 GLsizei bufSize = READ_DATA(12, GLsizei);
304 SET_RETURN_PTR(16);
305 SET_WRITEBACK_PTR(24);
306 cr_unpackDispatch.GetShaderSource(shader, bufSize, NULL, NULL);
307}
308
309void crUnpackExtendGetAttribLocation(void)
310{
311 int packet_length = READ_DATA(0, int);
312 GLuint program = READ_DATA(8, GLuint);
313 const char *name = DATA_POINTER(12, const char);
314 SET_RETURN_PTR(packet_length-16);
315 SET_WRITEBACK_PTR(packet_length-8);
316 cr_unpackDispatch.GetAttribLocation(program, name);
317}
318
319void crUnpackExtendGetUniformLocation(void)
320{
321 int packet_length = READ_DATA(0, int);
322 GLuint program = READ_DATA(8, GLuint);
323 const char *name = DATA_POINTER(12, const char);
324 SET_RETURN_PTR(packet_length-16);
325 SET_WRITEBACK_PTR(packet_length-8);
326 cr_unpackDispatch.GetUniformLocation(program, name);
327}
328
329void crUnpackExtendGetUniformsLocations(void)
330{
331 GLuint program = READ_DATA(8, GLuint);
332 GLsizei maxcbData = READ_DATA(12, GLsizei);
333 SET_RETURN_PTR(16);
334 SET_WRITEBACK_PTR(24);
335 cr_unpackDispatch.GetUniformsLocations(program, maxcbData, NULL, NULL);
336}
337
338void crUnpackExtendGetAttribsLocations(void)
339{
340 GLuint program = READ_DATA(8, GLuint);
341 GLsizei maxcbData = READ_DATA(12, GLsizei);
342 SET_RETURN_PTR(16);
343 SET_WRITEBACK_PTR(24);
344 cr_unpackDispatch.GetAttribsLocations(program, maxcbData, NULL, NULL);
345}
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