VirtualBox

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

Last change on this file since 78105 was 78105, checked in by vboxsync, 6 years ago

GuestHost/OpenGL,HostServices/SharedOpenGL: Updates bugref:9407

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 12.0 KB
Line 
1/* $Id: unpack_shaders.c 78105 2019-04-10 20:01:12Z vboxsync $ */
2/** @file
3 * VBox OpenGL DRI driver functions
4 */
5
6/*
7 * Copyright (C) 2009-2019 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, pos_check;
44
45 if (count <= 0 || count >= INT32_MAX / sizeof(GLint) / 8)
46 {
47 crError("crUnpackExtendShaderSource: count %u is out of range", count);
48 return;
49 }
50
51 pos = 20 + count * sizeof(*pLocalLength);
52
53 if (!DATA_POINTER_CHECK(pos))
54 {
55 crError("crUnpackExtendShaderSource: pos %d is out of range", pos);
56 return;
57 }
58
59 if (hasNonLocalLen > 0)
60 {
61 length = DATA_POINTER(pos, GLint);
62 pos += count * sizeof(*length);
63 }
64
65 if (!DATA_POINTER_CHECK(pos))
66 {
67 crError("crUnpackExtendShaderSource: pos %d is out of range", pos);
68 return;
69 }
70
71 pos_check = pos;
72
73 for (i = 0; i < count; ++i)
74 {
75 if (pLocalLength[i] <= 0 || pos_check >= INT32_MAX - pLocalLength[i])
76 {
77 crError("crUnpackExtendShaderSource: pos %d is out of range", pos_check);
78 return;
79 }
80
81 pos_check += pLocalLength[i];
82
83 if (!DATA_POINTER_CHECK(pos_check))
84 {
85 crError("crUnpackExtendShaderSource: pos %d is out of range", pos_check);
86 return;
87 }
88 }
89
90 ppStrings = crAlloc(count * sizeof(char*));
91 if (!ppStrings) return;
92
93 for (i = 0; i < count; ++i)
94 {
95 ppStrings[i] = DATA_POINTER(pos, char);
96 pos += pLocalLength[i];
97 if (!length)
98 {
99 pLocalLength[i] -= 1;
100 }
101
102 Assert(pLocalLength[i] > 0);
103 jUpTo = i == count -1 ? pLocalLength[i] - 1 : pLocalLength[i];
104 for (j = 0; j < jUpTo; ++j)
105 {
106 char *pString = ppStrings[i];
107
108 if (pString[j] == '\0')
109 {
110 Assert(j == jUpTo - 1);
111 pString[j] = '\n';
112 }
113 }
114 }
115
116// cr_unpackDispatch.ShaderSource(shader, count, ppStrings, length ? length : pLocalLength);
117 cr_unpackDispatch.ShaderSource(shader, 1, (const char**)ppStrings, 0);
118
119 crFree(ppStrings);
120}
121
122void crUnpackExtendUniform1fv(void)
123{
124 GLint location = READ_DATA(8, GLint);
125 GLsizei count = READ_DATA(12, GLsizei);
126 const GLfloat *value = DATA_POINTER(16, const GLfloat);
127 cr_unpackDispatch.Uniform1fv(location, count, value);
128}
129
130void crUnpackExtendUniform1iv(void)
131{
132 GLint location = READ_DATA(8, GLint);
133 GLsizei count = READ_DATA(12, GLsizei);
134 const GLint *value = DATA_POINTER(16, const GLint);
135 cr_unpackDispatch.Uniform1iv(location, count, value);
136}
137
138void crUnpackExtendUniform2fv(void)
139{
140 GLint location = READ_DATA(8, GLint);
141 GLsizei count = READ_DATA(12, GLsizei);
142 const GLfloat *value = DATA_POINTER(16, const GLfloat);
143 cr_unpackDispatch.Uniform2fv(location, count, value);
144}
145
146void crUnpackExtendUniform2iv(void)
147{
148 GLint location = READ_DATA(8, GLint);
149 GLsizei count = READ_DATA(12, GLsizei);
150 const GLint *value = DATA_POINTER(16, const GLint);
151 cr_unpackDispatch.Uniform2iv(location, count, value);
152}
153
154void crUnpackExtendUniform3fv(void)
155{
156 GLint location = READ_DATA(8, GLint);
157 GLsizei count = READ_DATA(12, GLsizei);
158 const GLfloat *value = DATA_POINTER(16, const GLfloat);
159 cr_unpackDispatch.Uniform3fv(location, count, value);
160}
161
162void crUnpackExtendUniform3iv(void)
163{
164 GLint location = READ_DATA(8, GLint);
165 GLsizei count = READ_DATA(12, GLsizei);
166 const GLint *value = DATA_POINTER(16, const GLint);
167 cr_unpackDispatch.Uniform3iv(location, count, value);
168}
169
170void crUnpackExtendUniform4fv(void)
171{
172 GLint location = READ_DATA(8, GLint);
173 GLsizei count = READ_DATA(12, GLsizei);
174 const GLfloat *value = DATA_POINTER(16, const GLfloat);
175 cr_unpackDispatch.Uniform4fv(location, count, value);
176}
177
178void crUnpackExtendUniform4iv(void)
179{
180 GLint location = READ_DATA(8, GLint);
181 GLsizei count = READ_DATA(12, GLsizei);
182 const GLint *value = DATA_POINTER(16, const GLint);
183 cr_unpackDispatch.Uniform4iv(location, count, value);
184}
185
186void crUnpackExtendUniformMatrix2fv(void)
187{
188 GLint location = READ_DATA(8, GLint);
189 GLsizei count = READ_DATA(12, GLsizei);
190 GLboolean transpose = READ_DATA(16, GLboolean);
191 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
192 cr_unpackDispatch.UniformMatrix2fv(location, count, transpose, value);
193}
194
195void crUnpackExtendUniformMatrix3fv(void)
196{
197 GLint location = READ_DATA(8, GLint);
198 GLsizei count = READ_DATA(12, GLsizei);
199 GLboolean transpose = READ_DATA(16, GLboolean);
200 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
201 cr_unpackDispatch.UniformMatrix3fv(location, count, transpose, value);
202}
203
204void crUnpackExtendUniformMatrix4fv(void)
205{
206 GLint location = READ_DATA(8, GLint);
207 GLsizei count = READ_DATA(12, GLsizei);
208 GLboolean transpose = READ_DATA(16, GLboolean);
209 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
210 cr_unpackDispatch.UniformMatrix4fv(location, count, transpose, value);
211}
212
213void crUnpackExtendUniformMatrix2x3fv(void)
214{
215 GLint location = READ_DATA(8, GLint);
216 GLsizei count = READ_DATA(12, GLsizei);
217 GLboolean transpose = READ_DATA(16, GLboolean);
218 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
219 cr_unpackDispatch.UniformMatrix2x3fv(location, count, transpose, value);
220}
221
222void crUnpackExtendUniformMatrix3x2fv(void)
223{
224 GLint location = READ_DATA(8, GLint);
225 GLsizei count = READ_DATA(12, GLsizei);
226 GLboolean transpose = READ_DATA(16, GLboolean);
227 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
228 cr_unpackDispatch.UniformMatrix3x2fv(location, count, transpose, value);
229}
230
231void crUnpackExtendUniformMatrix2x4fv(void)
232{
233 GLint location = READ_DATA(8, GLint);
234 GLsizei count = READ_DATA(12, GLsizei);
235 GLboolean transpose = READ_DATA(16, GLboolean);
236 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
237 cr_unpackDispatch.UniformMatrix2x4fv(location, count, transpose, value);
238}
239
240void crUnpackExtendUniformMatrix4x2fv(void)
241{
242 GLint location = READ_DATA(8, GLint);
243 GLsizei count = READ_DATA(12, GLsizei);
244 GLboolean transpose = READ_DATA(16, GLboolean);
245 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
246 cr_unpackDispatch.UniformMatrix4x2fv(location, count, transpose, value);
247}
248
249void crUnpackExtendUniformMatrix3x4fv(void)
250{
251 GLint location = READ_DATA(8, GLint);
252 GLsizei count = READ_DATA(12, GLsizei);
253 GLboolean transpose = READ_DATA(16, GLboolean);
254 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
255 cr_unpackDispatch.UniformMatrix3x4fv(location, count, transpose, value);
256}
257
258void crUnpackExtendUniformMatrix4x3fv(void)
259{
260 GLint location = READ_DATA(8, GLint);
261 GLsizei count = READ_DATA(12, GLsizei);
262 GLboolean transpose = READ_DATA(16, GLboolean);
263 const GLfloat *value = DATA_POINTER(16+sizeof(GLboolean), const GLfloat);
264 cr_unpackDispatch.UniformMatrix4x3fv(location, count, transpose, value);
265}
266
267void crUnpackExtendDrawBuffers(void)
268{
269 GLsizei n = READ_DATA(8, GLsizei);
270 const GLenum *bufs = DATA_POINTER(8+sizeof(GLsizei), const GLenum);
271 cr_unpackDispatch.DrawBuffers(n, bufs);
272}
273
274void crUnpackExtendGetActiveAttrib(void)
275{
276 GLuint program = READ_DATA(8, GLuint);
277 GLuint index = READ_DATA(12, GLuint);
278 GLsizei bufSize = READ_DATA(16, GLsizei);
279 SET_RETURN_PTR(20);
280 SET_WRITEBACK_PTR(28);
281 cr_unpackDispatch.GetActiveAttrib(program, index, bufSize, NULL, NULL, NULL, NULL);
282}
283
284void crUnpackExtendGetActiveUniform(void)
285{
286 GLuint program = READ_DATA(8, GLuint);
287 GLuint index = READ_DATA(12, GLuint);
288 GLsizei bufSize = READ_DATA(16, GLsizei);
289 SET_RETURN_PTR(20);
290 SET_WRITEBACK_PTR(28);
291 cr_unpackDispatch.GetActiveUniform(program, index, bufSize, NULL, NULL, NULL, NULL);
292}
293
294void crUnpackExtendGetAttachedShaders(void)
295{
296 GLuint program = READ_DATA(8, GLuint);
297 GLsizei maxCount = READ_DATA(12, GLsizei);
298 SET_RETURN_PTR(16);
299 SET_WRITEBACK_PTR(24);
300 cr_unpackDispatch.GetAttachedShaders(program, maxCount, NULL, NULL);
301}
302
303void crUnpackExtendGetAttachedObjectsARB(void)
304{
305 VBoxGLhandleARB containerObj = READ_DATA(8, VBoxGLhandleARB);
306 GLsizei maxCount = READ_DATA(12, GLsizei);
307 SET_RETURN_PTR(16);
308 SET_WRITEBACK_PTR(24);
309 cr_unpackDispatch.GetAttachedObjectsARB(containerObj, maxCount, NULL, NULL);
310}
311
312void crUnpackExtendGetInfoLogARB(void)
313{
314 VBoxGLhandleARB obj = READ_DATA(8, VBoxGLhandleARB);
315 GLsizei maxLength = READ_DATA(12, GLsizei);
316 SET_RETURN_PTR(16);
317 SET_WRITEBACK_PTR(24);
318 cr_unpackDispatch.GetInfoLogARB(obj, maxLength, NULL, NULL);
319}
320
321void crUnpackExtendGetProgramInfoLog(void)
322{
323 GLuint program = READ_DATA(8, GLuint);
324 GLsizei bufSize = READ_DATA(12, GLsizei);
325 SET_RETURN_PTR(16);
326 SET_WRITEBACK_PTR(24);
327 cr_unpackDispatch.GetProgramInfoLog(program, bufSize, NULL, NULL);
328}
329
330void crUnpackExtendGetShaderInfoLog(void)
331{
332 GLuint shader = READ_DATA(8, GLuint);
333 GLsizei bufSize = READ_DATA(12, GLsizei);
334 SET_RETURN_PTR(16);
335 SET_WRITEBACK_PTR(24);
336 cr_unpackDispatch.GetShaderInfoLog(shader, bufSize, NULL, NULL);
337}
338
339void crUnpackExtendGetShaderSource(void)
340{
341 GLuint shader = READ_DATA(8, GLuint);
342 GLsizei bufSize = READ_DATA(12, GLsizei);
343 SET_RETURN_PTR(16);
344 SET_WRITEBACK_PTR(24);
345 cr_unpackDispatch.GetShaderSource(shader, bufSize, NULL, NULL);
346}
347
348void crUnpackExtendGetAttribLocation(void)
349{
350 int packet_length = READ_DATA(0, int);
351 GLuint program = READ_DATA(8, GLuint);
352 const char *name = DATA_POINTER(12, const char);
353
354 if (!DATA_POINTER_CHECK(packet_length))
355 {
356 crError("crUnpackExtendGetAttribLocation: packet_length is out of range");
357 return;
358 }
359
360 SET_RETURN_PTR(packet_length-16);
361 SET_WRITEBACK_PTR(packet_length-8);
362 cr_unpackDispatch.GetAttribLocation(program, name);
363}
364
365void crUnpackExtendGetUniformLocation(void)
366{
367 int packet_length = READ_DATA(0, int);
368 GLuint program = READ_DATA(8, GLuint);
369 const char *name = DATA_POINTER(12, const char);
370
371 if (!DATA_POINTER_CHECK(packet_length))
372 {
373 crError("crUnpackExtendGetUniformLocation: packet_length is out of range");
374 return;
375 }
376
377 SET_RETURN_PTR(packet_length-16);
378 SET_WRITEBACK_PTR(packet_length-8);
379 cr_unpackDispatch.GetUniformLocation(program, name);
380}
381
382void crUnpackExtendGetUniformsLocations(void)
383{
384 GLuint program = READ_DATA(8, GLuint);
385 GLsizei maxcbData = READ_DATA(12, GLsizei);
386 SET_RETURN_PTR(16);
387 SET_WRITEBACK_PTR(24);
388 cr_unpackDispatch.GetUniformsLocations(program, maxcbData, NULL, NULL);
389}
390
391void crUnpackExtendGetAttribsLocations(void)
392{
393 GLuint program = READ_DATA(8, GLuint);
394 GLsizei maxcbData = READ_DATA(12, GLsizei);
395 SET_RETURN_PTR(16);
396 SET_WRITEBACK_PTR(24);
397 cr_unpackDispatch.GetAttribsLocations(program, maxcbData, NULL, NULL);
398}
Note: See TracBrowser for help on using the repository browser.

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