mesa/version: only enable GL4.1 with correct limits.
[mesa.git] / src / mesa / main / uniforms.c
1 /*
2 * Mesa 3-D graphics library
3 *
4 * Copyright (C) 2004-2008 Brian Paul All Rights Reserved.
5 * Copyright (C) 2009-2010 VMware, Inc. All Rights Reserved.
6 * Copyright © 2010 Intel Corporation
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27 /**
28 * \file uniforms.c
29 * Functions related to GLSL uniform variables.
30 * \author Brian Paul
31 */
32
33 /**
34 * XXX things to do:
35 * 1. Check that the right error code is generated for all _mesa_error() calls.
36 * 2. Insert FLUSH_VERTICES calls in various places
37 */
38
39 #include "main/glheader.h"
40 #include "main/context.h"
41 #include "main/shaderapi.h"
42 #include "main/shaderobj.h"
43 #include "main/uniforms.h"
44 #include "main/enums.h"
45 #include "compiler/glsl/ir_uniform.h"
46 #include "compiler/glsl_types.h"
47 #include "program/program.h"
48 #include "util/bitscan.h"
49
50 /**
51 * Update the vertex/fragment program's TexturesUsed array.
52 *
53 * This needs to be called after glUniform(set sampler var) is called.
54 * A call to glUniform(samplerVar, value) causes a sampler to point to a
55 * particular texture unit. We know the sampler's texture target
56 * (1D/2D/3D/etc) from compile time but the sampler's texture unit is
57 * set by glUniform() calls.
58 *
59 * So, scan the program->SamplerUnits[] and program->SamplerTargets[]
60 * information to update the prog->TexturesUsed[] values.
61 * Each value of TexturesUsed[unit] is one of zero, TEXTURE_1D_INDEX,
62 * TEXTURE_2D_INDEX, TEXTURE_3D_INDEX, etc.
63 * We'll use that info for state validation before rendering.
64 */
65 static inline void
66 update_single_shader_texture_used(struct gl_shader_program *shProg,
67 struct gl_program *prog,
68 GLuint unit, GLuint target)
69 {
70 gl_shader_stage prog_stage =
71 _mesa_program_enum_to_shader_stage(prog->Target);
72
73 assert(unit < ARRAY_SIZE(prog->TexturesUsed));
74 assert(target < NUM_TEXTURE_TARGETS);
75
76 /* From section 7.10 (Samplers) of the OpenGL 4.5 spec:
77 *
78 * "It is not allowed to have variables of different sampler types pointing
79 * to the same texture image unit within a program object."
80 */
81 unsigned stages_mask = shProg->data->linked_stages;
82 while (stages_mask) {
83 const int stage = u_bit_scan(&stages_mask);
84
85 /* Skip validation if we are yet to update textures used in this
86 * stage.
87 */
88 if (prog_stage < stage)
89 break;
90
91 struct gl_program *glprog = shProg->_LinkedShaders[stage]->Program;
92 if (glprog->TexturesUsed[unit] & ~(1 << target))
93 shProg->SamplersValidated = GL_FALSE;
94 }
95
96 prog->TexturesUsed[unit] |= (1 << target);
97 }
98
99 void
100 _mesa_update_shader_textures_used(struct gl_shader_program *shProg,
101 struct gl_program *prog)
102 {
103 GLbitfield mask = prog->SamplersUsed;
104 ASSERTED gl_shader_stage prog_stage =
105 _mesa_program_enum_to_shader_stage(prog->Target);
106 GLuint s;
107
108 assert(shProg->_LinkedShaders[prog_stage]);
109
110 memset(prog->TexturesUsed, 0, sizeof(prog->TexturesUsed));
111
112 while (mask) {
113 s = u_bit_scan(&mask);
114
115 update_single_shader_texture_used(shProg, prog,
116 prog->SamplerUnits[s],
117 prog->sh.SamplerTargets[s]);
118 }
119
120 if (unlikely(prog->sh.HasBoundBindlessSampler)) {
121 /* Loop over bindless samplers bound to texture units.
122 */
123 for (s = 0; s < prog->sh.NumBindlessSamplers; s++) {
124 struct gl_bindless_sampler *sampler = &prog->sh.BindlessSamplers[s];
125
126 if (!sampler->bound)
127 continue;
128
129 update_single_shader_texture_used(shProg, prog, sampler->unit,
130 sampler->target);
131 }
132 }
133 }
134
135 /**
136 * Connect a piece of driver storage with a part of a uniform
137 *
138 * \param uni The uniform with which the storage will be associated
139 * \param element_stride Byte-stride between array elements.
140 * \sa gl_uniform_driver_storage::element_stride.
141 * \param vector_stride Byte-stride between vectors (in a matrix).
142 * \sa gl_uniform_driver_storage::vector_stride.
143 * \param format Conversion from native format to driver format
144 * required by the driver.
145 * \param data Location to dump the data.
146 */
147 void
148 _mesa_uniform_attach_driver_storage(struct gl_uniform_storage *uni,
149 unsigned element_stride,
150 unsigned vector_stride,
151 enum gl_uniform_driver_format format,
152 void *data)
153 {
154 uni->driver_storage =
155 realloc(uni->driver_storage,
156 sizeof(struct gl_uniform_driver_storage)
157 * (uni->num_driver_storage + 1));
158
159 uni->driver_storage[uni->num_driver_storage].element_stride = element_stride;
160 uni->driver_storage[uni->num_driver_storage].vector_stride = vector_stride;
161 uni->driver_storage[uni->num_driver_storage].format = format;
162 uni->driver_storage[uni->num_driver_storage].data = data;
163
164 uni->num_driver_storage++;
165 }
166
167 /**
168 * Sever all connections with all pieces of driver storage for all uniforms
169 *
170 * \warning
171 * This function does \b not release any of the \c data pointers
172 * previously passed in to \c _mesa_uniform_attach_driver_stoarge.
173 */
174 void
175 _mesa_uniform_detach_all_driver_storage(struct gl_uniform_storage *uni)
176 {
177 free(uni->driver_storage);
178 uni->driver_storage = NULL;
179 uni->num_driver_storage = 0;
180 }
181
182 void GLAPIENTRY
183 _mesa_Uniform1f(GLint location, GLfloat v0)
184 {
185 GET_CURRENT_CONTEXT(ctx);
186 _mesa_uniform(location, 1, &v0, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_FLOAT, 1);
187 }
188
189 void GLAPIENTRY
190 _mesa_Uniform2f(GLint location, GLfloat v0, GLfloat v1)
191 {
192 GET_CURRENT_CONTEXT(ctx);
193 GLfloat v[2];
194 v[0] = v0;
195 v[1] = v1;
196 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_FLOAT, 2);
197 }
198
199 void GLAPIENTRY
200 _mesa_Uniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2)
201 {
202 GET_CURRENT_CONTEXT(ctx);
203 GLfloat v[3];
204 v[0] = v0;
205 v[1] = v1;
206 v[2] = v2;
207 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_FLOAT, 3);
208 }
209
210 void GLAPIENTRY
211 _mesa_Uniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2,
212 GLfloat v3)
213 {
214 GET_CURRENT_CONTEXT(ctx);
215 GLfloat v[4];
216 v[0] = v0;
217 v[1] = v1;
218 v[2] = v2;
219 v[3] = v3;
220 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_FLOAT, 4);
221 }
222
223 void GLAPIENTRY
224 _mesa_Uniform1i(GLint location, GLint v0)
225 {
226 GET_CURRENT_CONTEXT(ctx);
227 _mesa_uniform(location, 1, &v0, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_INT, 1);
228 }
229
230 void GLAPIENTRY
231 _mesa_Uniform2i(GLint location, GLint v0, GLint v1)
232 {
233 GET_CURRENT_CONTEXT(ctx);
234 GLint v[2];
235 v[0] = v0;
236 v[1] = v1;
237 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_INT, 2);
238 }
239
240 void GLAPIENTRY
241 _mesa_Uniform3i(GLint location, GLint v0, GLint v1, GLint v2)
242 {
243 GET_CURRENT_CONTEXT(ctx);
244 GLint v[3];
245 v[0] = v0;
246 v[1] = v1;
247 v[2] = v2;
248 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_INT, 3);
249 }
250
251 void GLAPIENTRY
252 _mesa_Uniform4i(GLint location, GLint v0, GLint v1, GLint v2, GLint v3)
253 {
254 GET_CURRENT_CONTEXT(ctx);
255 GLint v[4];
256 v[0] = v0;
257 v[1] = v1;
258 v[2] = v2;
259 v[3] = v3;
260 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_INT, 4);
261 }
262
263 void GLAPIENTRY
264 _mesa_Uniform1fv(GLint location, GLsizei count, const GLfloat * value)
265 {
266 GET_CURRENT_CONTEXT(ctx);
267 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_FLOAT, 1);
268 }
269
270 void GLAPIENTRY
271 _mesa_Uniform2fv(GLint location, GLsizei count, const GLfloat * value)
272 {
273 GET_CURRENT_CONTEXT(ctx);
274 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_FLOAT, 2);
275 }
276
277 void GLAPIENTRY
278 _mesa_Uniform3fv(GLint location, GLsizei count, const GLfloat * value)
279 {
280 GET_CURRENT_CONTEXT(ctx);
281 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_FLOAT, 3);
282 }
283
284 void GLAPIENTRY
285 _mesa_Uniform4fv(GLint location, GLsizei count, const GLfloat * value)
286 {
287 GET_CURRENT_CONTEXT(ctx);
288 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_FLOAT, 4);
289 }
290
291 void GLAPIENTRY
292 _mesa_Uniform1iv(GLint location, GLsizei count, const GLint * value)
293 {
294 GET_CURRENT_CONTEXT(ctx);
295 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_INT, 1);
296 }
297
298 void GLAPIENTRY
299 _mesa_Uniform2iv(GLint location, GLsizei count, const GLint * value)
300 {
301 GET_CURRENT_CONTEXT(ctx);
302 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_INT, 2);
303 }
304
305 void GLAPIENTRY
306 _mesa_Uniform3iv(GLint location, GLsizei count, const GLint * value)
307 {
308 GET_CURRENT_CONTEXT(ctx);
309 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_INT, 3);
310 }
311
312 void GLAPIENTRY
313 _mesa_Uniform4iv(GLint location, GLsizei count, const GLint * value)
314 {
315 GET_CURRENT_CONTEXT(ctx);
316 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_INT, 4);
317 }
318
319 void GLAPIENTRY
320 _mesa_UniformHandleui64ARB(GLint location, GLuint64 value)
321 {
322 GET_CURRENT_CONTEXT(ctx);
323 _mesa_uniform_handle(location, 1, &value, ctx, ctx->_Shader->ActiveProgram);
324 }
325
326 void GLAPIENTRY
327 _mesa_UniformHandleui64vARB(GLint location, GLsizei count,
328 const GLuint64 *value)
329 {
330 GET_CURRENT_CONTEXT(ctx);
331 _mesa_uniform_handle(location, count, value, ctx,
332 ctx->_Shader->ActiveProgram);
333 }
334
335
336 /** Same as above with direct state access **/
337 void GLAPIENTRY
338 _mesa_ProgramUniform1f(GLuint program, GLint location, GLfloat v0)
339 {
340 GET_CURRENT_CONTEXT(ctx);
341 struct gl_shader_program *shProg =
342 _mesa_lookup_shader_program_err(ctx, program,
343 "glProgramUniform1f");
344 _mesa_uniform(location, 1, &v0, ctx, shProg, GLSL_TYPE_FLOAT, 1);
345 }
346
347 void GLAPIENTRY
348 _mesa_ProgramUniform2f(GLuint program, GLint location, GLfloat v0, GLfloat v1)
349 {
350 GET_CURRENT_CONTEXT(ctx);
351 GLfloat v[2];
352 struct gl_shader_program *shProg;
353 v[0] = v0;
354 v[1] = v1;
355 shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform2f");
356 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_FLOAT, 2);
357 }
358
359 void GLAPIENTRY
360 _mesa_ProgramUniform3f(GLuint program, GLint location, GLfloat v0, GLfloat v1,
361 GLfloat v2)
362 {
363 GET_CURRENT_CONTEXT(ctx);
364 GLfloat v[3];
365 struct gl_shader_program *shProg;
366 v[0] = v0;
367 v[1] = v1;
368 v[2] = v2;
369 shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform3f");
370 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_FLOAT, 3);
371 }
372
373 void GLAPIENTRY
374 _mesa_ProgramUniform4f(GLuint program, GLint location, GLfloat v0, GLfloat v1,
375 GLfloat v2, GLfloat v3)
376 {
377 GET_CURRENT_CONTEXT(ctx);
378 GLfloat v[4];
379 struct gl_shader_program *shProg;
380 v[0] = v0;
381 v[1] = v1;
382 v[2] = v2;
383 v[3] = v3;
384 shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform4f");
385 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_FLOAT, 4);
386 }
387
388 void GLAPIENTRY
389 _mesa_ProgramUniform1i(GLuint program, GLint location, GLint v0)
390 {
391 GET_CURRENT_CONTEXT(ctx);
392 struct gl_shader_program *shProg =
393 _mesa_lookup_shader_program_err(ctx, program,
394 "glProgramUniform1i");
395 _mesa_uniform(location, 1, &v0, ctx, shProg, GLSL_TYPE_INT, 1);
396 }
397
398 void GLAPIENTRY
399 _mesa_ProgramUniform2i(GLuint program, GLint location, GLint v0, GLint v1)
400 {
401 GET_CURRENT_CONTEXT(ctx);
402 GLint v[2];
403 struct gl_shader_program *shProg;
404 v[0] = v0;
405 v[1] = v1;
406 shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform2i");
407 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_INT, 2);
408 }
409
410 void GLAPIENTRY
411 _mesa_ProgramUniform3i(GLuint program, GLint location, GLint v0, GLint v1,
412 GLint v2)
413 {
414 GET_CURRENT_CONTEXT(ctx);
415 GLint v[3];
416 struct gl_shader_program *shProg;
417 v[0] = v0;
418 v[1] = v1;
419 v[2] = v2;
420 shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform3i");
421 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_INT, 3);
422 }
423
424 void GLAPIENTRY
425 _mesa_ProgramUniform4i(GLuint program, GLint location, GLint v0, GLint v1,
426 GLint v2, GLint v3)
427 {
428 GET_CURRENT_CONTEXT(ctx);
429 GLint v[4];
430 struct gl_shader_program *shProg;
431 v[0] = v0;
432 v[1] = v1;
433 v[2] = v2;
434 v[3] = v3;
435 shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform4i");
436 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_INT, 4);
437 }
438
439 void GLAPIENTRY
440 _mesa_ProgramUniform1fv(GLuint program, GLint location, GLsizei count,
441 const GLfloat * value)
442 {
443 GET_CURRENT_CONTEXT(ctx);
444 struct gl_shader_program *shProg =
445 _mesa_lookup_shader_program_err(ctx, program,
446 "glProgramUniform1fv");
447 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_FLOAT, 1);
448 }
449
450 void GLAPIENTRY
451 _mesa_ProgramUniform2fv(GLuint program, GLint location, GLsizei count,
452 const GLfloat * value)
453 {
454 GET_CURRENT_CONTEXT(ctx);
455 struct gl_shader_program *shProg =
456 _mesa_lookup_shader_program_err(ctx, program,
457 "glProgramUniform2fv");
458 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_FLOAT, 2);
459 }
460
461 void GLAPIENTRY
462 _mesa_ProgramUniform3fv(GLuint program, GLint location, GLsizei count,
463 const GLfloat * value)
464 {
465 GET_CURRENT_CONTEXT(ctx);
466 struct gl_shader_program *shProg =
467 _mesa_lookup_shader_program_err(ctx, program,
468 "glProgramUniform3fv");
469 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_FLOAT, 3);
470 }
471
472 void GLAPIENTRY
473 _mesa_ProgramUniform4fv(GLuint program, GLint location, GLsizei count,
474 const GLfloat * value)
475 {
476 GET_CURRENT_CONTEXT(ctx);
477 struct gl_shader_program *shProg =
478 _mesa_lookup_shader_program_err(ctx, program,
479 "glProgramUniform4fv");
480 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_FLOAT, 4);
481 }
482
483 void GLAPIENTRY
484 _mesa_ProgramUniform1iv(GLuint program, GLint location, GLsizei count,
485 const GLint * value)
486 {
487 GET_CURRENT_CONTEXT(ctx);
488 struct gl_shader_program *shProg =
489 _mesa_lookup_shader_program_err(ctx, program,
490 "glProgramUniform1iv");
491 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_INT, 1);
492 }
493
494 void GLAPIENTRY
495 _mesa_ProgramUniform2iv(GLuint program, GLint location, GLsizei count,
496 const GLint * value)
497 {
498 GET_CURRENT_CONTEXT(ctx);
499 struct gl_shader_program *shProg =
500 _mesa_lookup_shader_program_err(ctx, program,
501 "glProgramUniform2iv");
502 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_INT, 2);
503 }
504
505 void GLAPIENTRY
506 _mesa_ProgramUniform3iv(GLuint program, GLint location, GLsizei count,
507 const GLint * value)
508 {
509 GET_CURRENT_CONTEXT(ctx);
510 struct gl_shader_program *shProg =
511 _mesa_lookup_shader_program_err(ctx, program,
512 "glProgramUniform3iv");
513 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_INT, 3);
514 }
515
516 void GLAPIENTRY
517 _mesa_ProgramUniform4iv(GLuint program, GLint location, GLsizei count,
518 const GLint * value)
519 {
520 GET_CURRENT_CONTEXT(ctx);
521 struct gl_shader_program *shProg =
522 _mesa_lookup_shader_program_err(ctx, program,
523 "glProgramUniform4iv");
524 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_INT, 4);
525 }
526
527 void GLAPIENTRY
528 _mesa_ProgramUniformHandleui64ARB(GLuint program, GLint location,
529 GLuint64 value)
530 {
531 GET_CURRENT_CONTEXT(ctx);
532 struct gl_shader_program *shProg =
533 _mesa_lookup_shader_program_err(ctx, program,
534 "glProgramUniformHandleui64ARB");
535 _mesa_uniform_handle(location, 1, &value, ctx, shProg);
536 }
537
538 void GLAPIENTRY
539 _mesa_ProgramUniformHandleui64vARB(GLuint program, GLint location,
540 GLsizei count, const GLuint64 *values)
541 {
542 GET_CURRENT_CONTEXT(ctx);
543 struct gl_shader_program *shProg =
544 _mesa_lookup_shader_program_err(ctx, program,
545 "glProgramUniformHandleui64vARB");
546 _mesa_uniform_handle(location, count, values, ctx, shProg);
547 }
548
549
550 /** OpenGL 3.0 GLuint-valued functions **/
551 void GLAPIENTRY
552 _mesa_Uniform1ui(GLint location, GLuint v0)
553 {
554 GET_CURRENT_CONTEXT(ctx);
555 _mesa_uniform(location, 1, &v0, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_UINT, 1);
556 }
557
558 void GLAPIENTRY
559 _mesa_Uniform2ui(GLint location, GLuint v0, GLuint v1)
560 {
561 GET_CURRENT_CONTEXT(ctx);
562 GLuint v[2];
563 v[0] = v0;
564 v[1] = v1;
565 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_UINT, 2);
566 }
567
568 void GLAPIENTRY
569 _mesa_Uniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2)
570 {
571 GET_CURRENT_CONTEXT(ctx);
572 GLuint v[3];
573 v[0] = v0;
574 v[1] = v1;
575 v[2] = v2;
576 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_UINT, 3);
577 }
578
579 void GLAPIENTRY
580 _mesa_Uniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3)
581 {
582 GET_CURRENT_CONTEXT(ctx);
583 GLuint v[4];
584 v[0] = v0;
585 v[1] = v1;
586 v[2] = v2;
587 v[3] = v3;
588 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_UINT, 4);
589 }
590
591 void GLAPIENTRY
592 _mesa_Uniform1uiv(GLint location, GLsizei count, const GLuint *value)
593 {
594 GET_CURRENT_CONTEXT(ctx);
595 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_UINT, 1);
596 }
597
598 void GLAPIENTRY
599 _mesa_Uniform2uiv(GLint location, GLsizei count, const GLuint *value)
600 {
601 GET_CURRENT_CONTEXT(ctx);
602 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_UINT, 2);
603 }
604
605 void GLAPIENTRY
606 _mesa_Uniform3uiv(GLint location, GLsizei count, const GLuint *value)
607 {
608 GET_CURRENT_CONTEXT(ctx);
609 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_UINT, 3);
610 }
611
612 void GLAPIENTRY
613 _mesa_Uniform4uiv(GLint location, GLsizei count, const GLuint *value)
614 {
615 GET_CURRENT_CONTEXT(ctx);
616 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_UINT, 4);
617 }
618
619
620
621 void GLAPIENTRY
622 _mesa_UniformMatrix2fv(GLint location, GLsizei count, GLboolean transpose,
623 const GLfloat * value)
624 {
625 GET_CURRENT_CONTEXT(ctx);
626 _mesa_uniform_matrix(location, count, transpose, value,
627 ctx, ctx->_Shader->ActiveProgram, 2, 2, GLSL_TYPE_FLOAT);
628 }
629
630 void GLAPIENTRY
631 _mesa_UniformMatrix3fv(GLint location, GLsizei count, GLboolean transpose,
632 const GLfloat * value)
633 {
634 GET_CURRENT_CONTEXT(ctx);
635 _mesa_uniform_matrix(location, count, transpose, value,
636 ctx, ctx->_Shader->ActiveProgram, 3, 3, GLSL_TYPE_FLOAT);
637 }
638
639 void GLAPIENTRY
640 _mesa_UniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose,
641 const GLfloat * value)
642 {
643 GET_CURRENT_CONTEXT(ctx);
644 _mesa_uniform_matrix(location, count, transpose, value,
645 ctx, ctx->_Shader->ActiveProgram, 4, 4, GLSL_TYPE_FLOAT);
646 }
647
648 /** Same as above with direct state access **/
649
650 void GLAPIENTRY
651 _mesa_ProgramUniform1ui(GLuint program, GLint location, GLuint v0)
652 {
653 GET_CURRENT_CONTEXT(ctx);
654 struct gl_shader_program *shProg =
655 _mesa_lookup_shader_program_err(ctx, program,
656 "glProgramUniform1ui");
657 _mesa_uniform(location, 1, &v0, ctx, shProg, GLSL_TYPE_UINT, 1);
658 }
659
660 void GLAPIENTRY
661 _mesa_ProgramUniform2ui(GLuint program, GLint location, GLuint v0, GLuint v1)
662 {
663 GET_CURRENT_CONTEXT(ctx);
664 GLuint v[2];
665 struct gl_shader_program *shProg;
666 v[0] = v0;
667 v[1] = v1;
668 shProg = _mesa_lookup_shader_program_err(ctx, program,
669 "glProgramUniform2ui");
670 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_UINT, 2);
671 }
672
673 void GLAPIENTRY
674 _mesa_ProgramUniform3ui(GLuint program, GLint location, GLuint v0, GLuint v1,
675 GLuint v2)
676 {
677 GET_CURRENT_CONTEXT(ctx);
678 GLuint v[3];
679 struct gl_shader_program *shProg;
680 v[0] = v0;
681 v[1] = v1;
682 v[2] = v2;
683 shProg = _mesa_lookup_shader_program_err(ctx, program,
684 "glProgramUniform3ui");
685 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_UINT, 3);
686 }
687
688 void GLAPIENTRY
689 _mesa_ProgramUniform4ui(GLuint program, GLint location, GLuint v0, GLuint v1,
690 GLuint v2, GLuint v3)
691 {
692 GET_CURRENT_CONTEXT(ctx);
693 GLuint v[4];
694 struct gl_shader_program *shProg;
695 v[0] = v0;
696 v[1] = v1;
697 v[2] = v2;
698 v[3] = v3;
699 shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform4ui");
700 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_UINT, 4);
701 }
702
703 void GLAPIENTRY
704 _mesa_ProgramUniform1uiv(GLuint program, GLint location, GLsizei count,
705 const GLuint *value)
706 {
707 GET_CURRENT_CONTEXT(ctx);
708 struct gl_shader_program *shProg =
709 _mesa_lookup_shader_program_err(ctx, program,
710 "glProgramUniform1uiv");
711 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_UINT, 1);
712 }
713
714 void GLAPIENTRY
715 _mesa_ProgramUniform2uiv(GLuint program, GLint location, GLsizei count,
716 const GLuint *value)
717 {
718 GET_CURRENT_CONTEXT(ctx);
719 struct gl_shader_program *shProg =
720 _mesa_lookup_shader_program_err(ctx, program,
721 "glProgramUniform2uiv");
722 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_UINT, 2);
723 }
724
725 void GLAPIENTRY
726 _mesa_ProgramUniform3uiv(GLuint program, GLint location, GLsizei count,
727 const GLuint *value)
728 {
729 GET_CURRENT_CONTEXT(ctx);
730 struct gl_shader_program *shProg =
731 _mesa_lookup_shader_program_err(ctx, program,
732 "glProgramUniform3uiv");
733 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_UINT, 3);
734 }
735
736 void GLAPIENTRY
737 _mesa_ProgramUniform4uiv(GLuint program, GLint location, GLsizei count,
738 const GLuint *value)
739 {
740 GET_CURRENT_CONTEXT(ctx);
741 struct gl_shader_program *shProg =
742 _mesa_lookup_shader_program_err(ctx, program,
743 "glProgramUniform4uiv");
744 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_UINT, 4);
745 }
746
747
748
749 void GLAPIENTRY
750 _mesa_ProgramUniformMatrix2fv(GLuint program, GLint location, GLsizei count,
751 GLboolean transpose, const GLfloat * value)
752 {
753 GET_CURRENT_CONTEXT(ctx);
754 struct gl_shader_program *shProg =
755 _mesa_lookup_shader_program_err(ctx, program,
756 "glProgramUniformMatrix2fv");
757 _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 2, 2, GLSL_TYPE_FLOAT);
758 }
759
760 void GLAPIENTRY
761 _mesa_ProgramUniformMatrix3fv(GLuint program, GLint location, GLsizei count,
762 GLboolean transpose, const GLfloat * value)
763 {
764 GET_CURRENT_CONTEXT(ctx);
765 struct gl_shader_program *shProg =
766 _mesa_lookup_shader_program_err(ctx, program,
767 "glProgramUniformMatrix3fv");
768 _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 3, 3, GLSL_TYPE_FLOAT);
769 }
770
771 void GLAPIENTRY
772 _mesa_ProgramUniformMatrix4fv(GLuint program, GLint location, GLsizei count,
773 GLboolean transpose, const GLfloat * value)
774 {
775 GET_CURRENT_CONTEXT(ctx);
776 struct gl_shader_program *shProg =
777 _mesa_lookup_shader_program_err(ctx, program,
778 "glProgramUniformMatrix4fv");
779 _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 4, 4, GLSL_TYPE_FLOAT);
780 }
781
782
783 /**
784 * Non-square UniformMatrix are OpenGL 2.1
785 */
786 void GLAPIENTRY
787 _mesa_UniformMatrix2x3fv(GLint location, GLsizei count, GLboolean transpose,
788 const GLfloat *value)
789 {
790 GET_CURRENT_CONTEXT(ctx);
791 _mesa_uniform_matrix(location, count, transpose, value,
792 ctx, ctx->_Shader->ActiveProgram, 2, 3, GLSL_TYPE_FLOAT);
793 }
794
795 void GLAPIENTRY
796 _mesa_UniformMatrix3x2fv(GLint location, GLsizei count, GLboolean transpose,
797 const GLfloat *value)
798 {
799 GET_CURRENT_CONTEXT(ctx);
800 _mesa_uniform_matrix(location, count, transpose, value,
801 ctx, ctx->_Shader->ActiveProgram, 3, 2, GLSL_TYPE_FLOAT);
802 }
803
804 void GLAPIENTRY
805 _mesa_UniformMatrix2x4fv(GLint location, GLsizei count, GLboolean transpose,
806 const GLfloat *value)
807 {
808 GET_CURRENT_CONTEXT(ctx);
809 _mesa_uniform_matrix(location, count, transpose, value,
810 ctx, ctx->_Shader->ActiveProgram, 2, 4, GLSL_TYPE_FLOAT);
811 }
812
813 void GLAPIENTRY
814 _mesa_UniformMatrix4x2fv(GLint location, GLsizei count, GLboolean transpose,
815 const GLfloat *value)
816 {
817 GET_CURRENT_CONTEXT(ctx);
818 _mesa_uniform_matrix(location, count, transpose, value,
819 ctx, ctx->_Shader->ActiveProgram, 4, 2, GLSL_TYPE_FLOAT);
820 }
821
822 void GLAPIENTRY
823 _mesa_UniformMatrix3x4fv(GLint location, GLsizei count, GLboolean transpose,
824 const GLfloat *value)
825 {
826 GET_CURRENT_CONTEXT(ctx);
827 _mesa_uniform_matrix(location, count, transpose, value,
828 ctx, ctx->_Shader->ActiveProgram, 3, 4, GLSL_TYPE_FLOAT);
829 }
830
831 void GLAPIENTRY
832 _mesa_UniformMatrix4x3fv(GLint location, GLsizei count, GLboolean transpose,
833 const GLfloat *value)
834 {
835 GET_CURRENT_CONTEXT(ctx);
836 _mesa_uniform_matrix(location, count, transpose, value,
837 ctx, ctx->_Shader->ActiveProgram, 4, 3, GLSL_TYPE_FLOAT);
838 }
839
840 /** Same as above with direct state access **/
841
842 void GLAPIENTRY
843 _mesa_ProgramUniformMatrix2x3fv(GLuint program, GLint location, GLsizei count,
844 GLboolean transpose, const GLfloat * value)
845 {
846 GET_CURRENT_CONTEXT(ctx);
847 struct gl_shader_program *shProg =
848 _mesa_lookup_shader_program_err(ctx, program,
849 "glProgramUniformMatrix2x3fv");
850 _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 2, 3, GLSL_TYPE_FLOAT);
851 }
852
853 void GLAPIENTRY
854 _mesa_ProgramUniformMatrix3x2fv(GLuint program, GLint location, GLsizei count,
855 GLboolean transpose, const GLfloat * value)
856 {
857 GET_CURRENT_CONTEXT(ctx);
858 struct gl_shader_program *shProg =
859 _mesa_lookup_shader_program_err(ctx, program,
860 "glProgramUniformMatrix3x2fv");
861 _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 3, 2, GLSL_TYPE_FLOAT);
862 }
863
864 void GLAPIENTRY
865 _mesa_ProgramUniformMatrix2x4fv(GLuint program, GLint location, GLsizei count,
866 GLboolean transpose, const GLfloat * value)
867 {
868 GET_CURRENT_CONTEXT(ctx);
869 struct gl_shader_program *shProg =
870 _mesa_lookup_shader_program_err(ctx, program,
871 "glProgramUniformMatrix2x4fv");
872 _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 2, 4, GLSL_TYPE_FLOAT);
873 }
874
875 void GLAPIENTRY
876 _mesa_ProgramUniformMatrix4x2fv(GLuint program, GLint location, GLsizei count,
877 GLboolean transpose, const GLfloat * value)
878 {
879 GET_CURRENT_CONTEXT(ctx);
880 struct gl_shader_program *shProg =
881 _mesa_lookup_shader_program_err(ctx, program,
882 "glProgramUniformMatrix4x2fv");
883 _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 4, 2, GLSL_TYPE_FLOAT);
884 }
885
886 void GLAPIENTRY
887 _mesa_ProgramUniformMatrix3x4fv(GLuint program, GLint location, GLsizei count,
888 GLboolean transpose, const GLfloat * value)
889 {
890 GET_CURRENT_CONTEXT(ctx);
891 struct gl_shader_program *shProg =
892 _mesa_lookup_shader_program_err(ctx, program,
893 "glProgramUniformMatrix3x4fv");
894 _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 3, 4, GLSL_TYPE_FLOAT);
895 }
896
897 void GLAPIENTRY
898 _mesa_ProgramUniformMatrix4x3fv(GLuint program, GLint location, GLsizei count,
899 GLboolean transpose, const GLfloat * value)
900 {
901 GET_CURRENT_CONTEXT(ctx);
902 struct gl_shader_program *shProg =
903 _mesa_lookup_shader_program_err(ctx, program,
904 "glProgramUniformMatrix4x3fv");
905 _mesa_uniform_matrix(location, count, transpose, value, ctx, shProg, 4, 3, GLSL_TYPE_FLOAT);
906 }
907
908
909 void GLAPIENTRY
910 _mesa_GetnUniformfvARB(GLuint program, GLint location,
911 GLsizei bufSize, GLfloat *params)
912 {
913 GET_CURRENT_CONTEXT(ctx);
914 _mesa_get_uniform(ctx, program, location, bufSize, GLSL_TYPE_FLOAT, params);
915 }
916
917 void GLAPIENTRY
918 _mesa_GetUniformfv(GLuint program, GLint location, GLfloat *params)
919 {
920 _mesa_GetnUniformfvARB(program, location, INT_MAX, params);
921 }
922
923
924 void GLAPIENTRY
925 _mesa_GetnUniformivARB(GLuint program, GLint location,
926 GLsizei bufSize, GLint *params)
927 {
928 GET_CURRENT_CONTEXT(ctx);
929 _mesa_get_uniform(ctx, program, location, bufSize, GLSL_TYPE_INT, params);
930 }
931
932 void GLAPIENTRY
933 _mesa_GetUniformiv(GLuint program, GLint location, GLint *params)
934 {
935 _mesa_GetnUniformivARB(program, location, INT_MAX, params);
936 }
937
938
939 /* GL3 */
940 void GLAPIENTRY
941 _mesa_GetnUniformuivARB(GLuint program, GLint location,
942 GLsizei bufSize, GLuint *params)
943 {
944 GET_CURRENT_CONTEXT(ctx);
945 _mesa_get_uniform(ctx, program, location, bufSize, GLSL_TYPE_UINT, params);
946 }
947
948 void GLAPIENTRY
949 _mesa_GetUniformuiv(GLuint program, GLint location, GLuint *params)
950 {
951 _mesa_GetnUniformuivARB(program, location, INT_MAX, params);
952 }
953
954
955 /* GL4 */
956 void GLAPIENTRY
957 _mesa_GetnUniformdvARB(GLuint program, GLint location,
958 GLsizei bufSize, GLdouble *params)
959 {
960 GET_CURRENT_CONTEXT(ctx);
961
962 _mesa_get_uniform(ctx, program, location, bufSize, GLSL_TYPE_DOUBLE, params);
963 }
964
965 void GLAPIENTRY
966 _mesa_GetUniformdv(GLuint program, GLint location, GLdouble *params)
967 {
968 _mesa_GetnUniformdvARB(program, location, INT_MAX, params);
969 }
970
971 void GLAPIENTRY
972 _mesa_GetnUniformi64vARB(GLuint program, GLint location,
973 GLsizei bufSize, GLint64 *params)
974 {
975 GET_CURRENT_CONTEXT(ctx);
976 _mesa_get_uniform(ctx, program, location, bufSize, GLSL_TYPE_INT64, params);
977 }
978 void GLAPIENTRY
979 _mesa_GetUniformi64vARB(GLuint program, GLint location, GLint64 *params)
980 {
981 _mesa_GetnUniformi64vARB(program, location, INT_MAX, params);
982 }
983
984 void GLAPIENTRY
985 _mesa_GetnUniformui64vARB(GLuint program, GLint location,
986 GLsizei bufSize, GLuint64 *params)
987 {
988 GET_CURRENT_CONTEXT(ctx);
989 _mesa_get_uniform(ctx, program, location, bufSize, GLSL_TYPE_UINT64, params);
990 }
991
992 void GLAPIENTRY
993 _mesa_GetUniformui64vARB(GLuint program, GLint location, GLuint64 *params)
994 {
995 _mesa_GetnUniformui64vARB(program, location, INT_MAX, params);
996 }
997
998
999 GLint GLAPIENTRY
1000 _mesa_GetUniformLocation(GLuint programObj, const GLcharARB *name)
1001 {
1002 struct gl_shader_program *shProg;
1003
1004 GET_CURRENT_CONTEXT(ctx);
1005
1006 shProg = _mesa_lookup_shader_program_err(ctx, programObj,
1007 "glGetUniformLocation");
1008 if (!shProg || !name)
1009 return -1;
1010
1011 /* Page 80 (page 94 of the PDF) of the OpenGL 2.1 spec says:
1012 *
1013 * "If program has not been successfully linked, the error
1014 * INVALID_OPERATION is generated."
1015 */
1016 if (shProg->data->LinkStatus == LINKING_FAILURE) {
1017 _mesa_error(ctx, GL_INVALID_OPERATION,
1018 "glGetUniformLocation(program not linked)");
1019 return -1;
1020 }
1021
1022 return _mesa_program_resource_location(shProg, GL_UNIFORM, name);
1023 }
1024
1025 GLint GLAPIENTRY
1026 _mesa_GetUniformLocation_no_error(GLuint programObj, const GLcharARB *name)
1027 {
1028 GET_CURRENT_CONTEXT(ctx);
1029
1030 struct gl_shader_program *shProg =
1031 _mesa_lookup_shader_program(ctx, programObj);
1032
1033 return _mesa_program_resource_location(shProg, GL_UNIFORM, name);
1034 }
1035
1036 GLuint GLAPIENTRY
1037 _mesa_GetUniformBlockIndex(GLuint program,
1038 const GLchar *uniformBlockName)
1039 {
1040 GET_CURRENT_CONTEXT(ctx);
1041 struct gl_shader_program *shProg;
1042
1043 if (!ctx->Extensions.ARB_uniform_buffer_object) {
1044 _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformBlockIndex");
1045 return GL_INVALID_INDEX;
1046 }
1047
1048 shProg = _mesa_lookup_shader_program_err(ctx, program,
1049 "glGetUniformBlockIndex");
1050 if (!shProg)
1051 return GL_INVALID_INDEX;
1052
1053 struct gl_program_resource *res =
1054 _mesa_program_resource_find_name(shProg, GL_UNIFORM_BLOCK,
1055 uniformBlockName, NULL);
1056 if (!res)
1057 return GL_INVALID_INDEX;
1058
1059 return _mesa_program_resource_index(shProg, res);
1060 }
1061
1062 void GLAPIENTRY
1063 _mesa_GetUniformIndices(GLuint program,
1064 GLsizei uniformCount,
1065 const GLchar * const *uniformNames,
1066 GLuint *uniformIndices)
1067 {
1068 GET_CURRENT_CONTEXT(ctx);
1069 GLsizei i;
1070 struct gl_shader_program *shProg;
1071
1072 if (!ctx->Extensions.ARB_uniform_buffer_object) {
1073 _mesa_error(ctx, GL_INVALID_OPERATION, "glGetUniformIndices");
1074 return;
1075 }
1076
1077 shProg = _mesa_lookup_shader_program_err(ctx, program,
1078 "glGetUniformIndices");
1079 if (!shProg)
1080 return;
1081
1082 if (uniformCount < 0) {
1083 _mesa_error(ctx, GL_INVALID_VALUE,
1084 "glGetUniformIndices(uniformCount < 0)");
1085 return;
1086 }
1087
1088 for (i = 0; i < uniformCount; i++) {
1089 struct gl_program_resource *res =
1090 _mesa_program_resource_find_name(shProg, GL_UNIFORM, uniformNames[i],
1091 NULL);
1092 uniformIndices[i] = _mesa_program_resource_index(shProg, res);
1093 }
1094 }
1095
1096 static void
1097 uniform_block_binding(struct gl_context *ctx, struct gl_shader_program *shProg,
1098 GLuint uniformBlockIndex, GLuint uniformBlockBinding)
1099 {
1100 if (shProg->data->UniformBlocks[uniformBlockIndex].Binding !=
1101 uniformBlockBinding) {
1102
1103 FLUSH_VERTICES(ctx, 0);
1104 ctx->NewDriverState |= ctx->DriverFlags.NewUniformBuffer;
1105
1106 shProg->data->UniformBlocks[uniformBlockIndex].Binding =
1107 uniformBlockBinding;
1108 }
1109 }
1110
1111 void GLAPIENTRY
1112 _mesa_UniformBlockBinding_no_error(GLuint program, GLuint uniformBlockIndex,
1113 GLuint uniformBlockBinding)
1114 {
1115 GET_CURRENT_CONTEXT(ctx);
1116
1117 struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, program);
1118 uniform_block_binding(ctx, shProg, uniformBlockIndex, uniformBlockBinding);
1119 }
1120
1121 void GLAPIENTRY
1122 _mesa_UniformBlockBinding(GLuint program,
1123 GLuint uniformBlockIndex,
1124 GLuint uniformBlockBinding)
1125 {
1126 GET_CURRENT_CONTEXT(ctx);
1127 struct gl_shader_program *shProg;
1128
1129 if (!ctx->Extensions.ARB_uniform_buffer_object) {
1130 _mesa_error(ctx, GL_INVALID_OPERATION, "glUniformBlockBinding");
1131 return;
1132 }
1133
1134 shProg = _mesa_lookup_shader_program_err(ctx, program,
1135 "glUniformBlockBinding");
1136 if (!shProg)
1137 return;
1138
1139 if (uniformBlockIndex >= shProg->data->NumUniformBlocks) {
1140 _mesa_error(ctx, GL_INVALID_VALUE,
1141 "glUniformBlockBinding(block index %u >= %u)",
1142 uniformBlockIndex, shProg->data->NumUniformBlocks);
1143 return;
1144 }
1145
1146 if (uniformBlockBinding >= ctx->Const.MaxUniformBufferBindings) {
1147 _mesa_error(ctx, GL_INVALID_VALUE,
1148 "glUniformBlockBinding(block binding %u >= %u)",
1149 uniformBlockBinding, ctx->Const.MaxUniformBufferBindings);
1150 return;
1151 }
1152
1153 uniform_block_binding(ctx, shProg, uniformBlockIndex, uniformBlockBinding);
1154 }
1155
1156 static void
1157 shader_storage_block_binding(struct gl_context *ctx,
1158 struct gl_shader_program *shProg,
1159 GLuint shaderStorageBlockIndex,
1160 GLuint shaderStorageBlockBinding)
1161 {
1162 if (shProg->data->ShaderStorageBlocks[shaderStorageBlockIndex].Binding !=
1163 shaderStorageBlockBinding) {
1164
1165 FLUSH_VERTICES(ctx, 0);
1166 ctx->NewDriverState |= ctx->DriverFlags.NewShaderStorageBuffer;
1167
1168 shProg->data->ShaderStorageBlocks[shaderStorageBlockIndex].Binding =
1169 shaderStorageBlockBinding;
1170 }
1171 }
1172
1173 void GLAPIENTRY
1174 _mesa_ShaderStorageBlockBinding_no_error(GLuint program,
1175 GLuint shaderStorageBlockIndex,
1176 GLuint shaderStorageBlockBinding)
1177 {
1178 GET_CURRENT_CONTEXT(ctx);
1179
1180 struct gl_shader_program *shProg = _mesa_lookup_shader_program(ctx, program);
1181 shader_storage_block_binding(ctx, shProg, shaderStorageBlockIndex,
1182 shaderStorageBlockBinding);
1183 }
1184
1185 void GLAPIENTRY
1186 _mesa_ShaderStorageBlockBinding(GLuint program,
1187 GLuint shaderStorageBlockIndex,
1188 GLuint shaderStorageBlockBinding)
1189 {
1190 GET_CURRENT_CONTEXT(ctx);
1191 struct gl_shader_program *shProg;
1192
1193 if (!ctx->Extensions.ARB_shader_storage_buffer_object) {
1194 _mesa_error(ctx, GL_INVALID_OPERATION, "glShaderStorageBlockBinding");
1195 return;
1196 }
1197
1198 shProg = _mesa_lookup_shader_program_err(ctx, program,
1199 "glShaderStorageBlockBinding");
1200 if (!shProg)
1201 return;
1202
1203 if (shaderStorageBlockIndex >= shProg->data->NumShaderStorageBlocks) {
1204 _mesa_error(ctx, GL_INVALID_VALUE,
1205 "glShaderStorageBlockBinding(block index %u >= %u)",
1206 shaderStorageBlockIndex,
1207 shProg->data->NumShaderStorageBlocks);
1208 return;
1209 }
1210
1211 if (shaderStorageBlockBinding >= ctx->Const.MaxShaderStorageBufferBindings) {
1212 _mesa_error(ctx, GL_INVALID_VALUE,
1213 "glShaderStorageBlockBinding(block binding %u >= %u)",
1214 shaderStorageBlockBinding,
1215 ctx->Const.MaxShaderStorageBufferBindings);
1216 return;
1217 }
1218
1219 shader_storage_block_binding(ctx, shProg, shaderStorageBlockIndex,
1220 shaderStorageBlockBinding);
1221 }
1222
1223 /**
1224 * Generic program resource property query.
1225 */
1226 static void
1227 mesa_bufferiv(struct gl_shader_program *shProg, GLenum type,
1228 GLuint index, GLenum pname, GLint *params, const char *caller)
1229 {
1230 GET_CURRENT_CONTEXT(ctx);
1231 struct gl_program_resource *res =
1232 _mesa_program_resource_find_index(shProg, type, index);
1233
1234 if (!res) {
1235 _mesa_error(ctx, GL_INVALID_VALUE, "%s(bufferindex %d)", caller, index);
1236 return;
1237 }
1238
1239 switch (pname) {
1240 case GL_UNIFORM_BLOCK_BINDING:
1241 case GL_ATOMIC_COUNTER_BUFFER_BINDING:
1242 _mesa_program_resource_prop(shProg, res, index, GL_BUFFER_BINDING,
1243 params, caller);
1244 return;
1245 case GL_UNIFORM_BLOCK_DATA_SIZE:
1246 case GL_ATOMIC_COUNTER_BUFFER_DATA_SIZE:
1247 _mesa_program_resource_prop(shProg, res, index, GL_BUFFER_DATA_SIZE,
1248 params, caller);
1249 return;
1250 case GL_UNIFORM_BLOCK_NAME_LENGTH:
1251 _mesa_program_resource_prop(shProg, res, index, GL_NAME_LENGTH,
1252 params, caller);
1253 return;
1254 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS:
1255 case GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTERS:
1256 _mesa_program_resource_prop(shProg, res, index, GL_NUM_ACTIVE_VARIABLES,
1257 params, caller);
1258 return;
1259 case GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES:
1260 case GL_ATOMIC_COUNTER_BUFFER_ACTIVE_ATOMIC_COUNTER_INDICES:
1261 _mesa_program_resource_prop(shProg, res, index, GL_ACTIVE_VARIABLES,
1262 params, caller);
1263 return;
1264 case GL_UNIFORM_BLOCK_REFERENCED_BY_VERTEX_SHADER:
1265 case GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_VERTEX_SHADER:
1266 _mesa_program_resource_prop(shProg, res, index,
1267 GL_REFERENCED_BY_VERTEX_SHADER, params,
1268 caller);
1269 return;
1270
1271 case GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_CONTROL_SHADER:
1272 case GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_CONTROL_SHADER:
1273 _mesa_program_resource_prop(shProg, res, index,
1274 GL_REFERENCED_BY_TESS_CONTROL_SHADER, params,
1275 caller);
1276 return;
1277
1278 case GL_UNIFORM_BLOCK_REFERENCED_BY_TESS_EVALUATION_SHADER:
1279 case GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_TESS_EVALUATION_SHADER:
1280 _mesa_program_resource_prop(shProg, res, index,
1281 GL_REFERENCED_BY_TESS_EVALUATION_SHADER, params,
1282 caller);
1283 return;
1284
1285 case GL_UNIFORM_BLOCK_REFERENCED_BY_GEOMETRY_SHADER:
1286 case GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_GEOMETRY_SHADER:
1287 _mesa_program_resource_prop(shProg, res, index,
1288 GL_REFERENCED_BY_GEOMETRY_SHADER, params,
1289 caller);
1290 return;
1291 case GL_UNIFORM_BLOCK_REFERENCED_BY_FRAGMENT_SHADER:
1292 case GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_FRAGMENT_SHADER:
1293 _mesa_program_resource_prop(shProg, res, index,
1294 GL_REFERENCED_BY_FRAGMENT_SHADER, params,
1295 caller);
1296 return;
1297 case GL_UNIFORM_BLOCK_REFERENCED_BY_COMPUTE_SHADER:
1298 case GL_ATOMIC_COUNTER_BUFFER_REFERENCED_BY_COMPUTE_SHADER:
1299 _mesa_program_resource_prop(shProg, res, index,
1300 GL_REFERENCED_BY_COMPUTE_SHADER, params,
1301 caller);
1302 return;
1303 default:
1304 _mesa_error(ctx, GL_INVALID_ENUM,
1305 "%s(pname 0x%x (%s))", caller, pname,
1306 _mesa_enum_to_string(pname));
1307 return;
1308 }
1309 }
1310
1311
1312 void GLAPIENTRY
1313 _mesa_GetActiveUniformBlockiv(GLuint program,
1314 GLuint uniformBlockIndex,
1315 GLenum pname,
1316 GLint *params)
1317 {
1318 GET_CURRENT_CONTEXT(ctx);
1319 struct gl_shader_program *shProg;
1320
1321 if (!ctx->Extensions.ARB_uniform_buffer_object) {
1322 _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformBlockiv");
1323 return;
1324 }
1325
1326 shProg = _mesa_lookup_shader_program_err(ctx, program,
1327 "glGetActiveUniformBlockiv");
1328 if (!shProg)
1329 return;
1330
1331 mesa_bufferiv(shProg, GL_UNIFORM_BLOCK, uniformBlockIndex, pname, params,
1332 "glGetActiveUniformBlockiv");
1333 }
1334
1335 void GLAPIENTRY
1336 _mesa_GetActiveUniformBlockName(GLuint program,
1337 GLuint uniformBlockIndex,
1338 GLsizei bufSize,
1339 GLsizei *length,
1340 GLchar *uniformBlockName)
1341 {
1342 GET_CURRENT_CONTEXT(ctx);
1343 struct gl_shader_program *shProg;
1344
1345 if (!ctx->Extensions.ARB_uniform_buffer_object) {
1346 _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformBlockiv");
1347 return;
1348 }
1349
1350 if (bufSize < 0) {
1351 _mesa_error(ctx, GL_INVALID_VALUE,
1352 "glGetActiveUniformBlockName(bufSize %d < 0)",
1353 bufSize);
1354 return;
1355 }
1356
1357 shProg = _mesa_lookup_shader_program_err(ctx, program,
1358 "glGetActiveUniformBlockiv");
1359 if (!shProg)
1360 return;
1361
1362 if (uniformBlockName)
1363 _mesa_get_program_resource_name(shProg, GL_UNIFORM_BLOCK,
1364 uniformBlockIndex, bufSize, length,
1365 uniformBlockName,
1366 "glGetActiveUniformBlockName");
1367 }
1368
1369 void GLAPIENTRY
1370 _mesa_GetActiveUniformName(GLuint program, GLuint uniformIndex,
1371 GLsizei bufSize, GLsizei *length,
1372 GLchar *uniformName)
1373 {
1374 GET_CURRENT_CONTEXT(ctx);
1375 struct gl_shader_program *shProg;
1376
1377 if (!ctx->Extensions.ARB_uniform_buffer_object) {
1378 _mesa_error(ctx, GL_INVALID_OPERATION, "glGetActiveUniformName");
1379 return;
1380 }
1381
1382 if (bufSize < 0) {
1383 _mesa_error(ctx, GL_INVALID_VALUE,
1384 "glGetActiveUniformName(bufSize %d < 0)",
1385 bufSize);
1386 return;
1387 }
1388
1389 shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetActiveUniformName");
1390
1391 if (!shProg)
1392 return;
1393
1394 _mesa_get_program_resource_name(shProg, GL_UNIFORM, uniformIndex, bufSize,
1395 length, uniformName, "glGetActiveUniformName");
1396 }
1397
1398 void GLAPIENTRY
1399 _mesa_GetActiveAtomicCounterBufferiv(GLuint program, GLuint bufferIndex,
1400 GLenum pname, GLint *params)
1401 {
1402 GET_CURRENT_CONTEXT(ctx);
1403 struct gl_shader_program *shProg;
1404
1405 if (!ctx->Extensions.ARB_shader_atomic_counters) {
1406 _mesa_error(ctx, GL_INVALID_OPERATION,
1407 "glGetActiveAtomicCounterBufferiv");
1408 return;
1409 }
1410
1411 shProg = _mesa_lookup_shader_program_err(ctx, program,
1412 "glGetActiveAtomicCounterBufferiv");
1413 if (!shProg)
1414 return;
1415
1416 mesa_bufferiv(shProg, GL_ATOMIC_COUNTER_BUFFER, bufferIndex, pname, params,
1417 "glGetActiveAtomicCounterBufferiv");
1418 }
1419
1420 void GLAPIENTRY
1421 _mesa_Uniform1d(GLint location, GLdouble v0)
1422 {
1423 GET_CURRENT_CONTEXT(ctx);
1424 _mesa_uniform(location, 1, &v0, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_DOUBLE, 1);
1425 }
1426
1427 void GLAPIENTRY
1428 _mesa_Uniform2d(GLint location, GLdouble v0, GLdouble v1)
1429 {
1430 GET_CURRENT_CONTEXT(ctx);
1431 GLdouble v[2];
1432 v[0] = v0;
1433 v[1] = v1;
1434 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_DOUBLE, 2);
1435 }
1436
1437 void GLAPIENTRY
1438 _mesa_Uniform3d(GLint location, GLdouble v0, GLdouble v1, GLdouble v2)
1439 {
1440 GET_CURRENT_CONTEXT(ctx);
1441 GLdouble v[3];
1442 v[0] = v0;
1443 v[1] = v1;
1444 v[2] = v2;
1445 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_DOUBLE, 3);
1446 }
1447
1448 void GLAPIENTRY
1449 _mesa_Uniform4d(GLint location, GLdouble v0, GLdouble v1, GLdouble v2,
1450 GLdouble v3)
1451 {
1452 GET_CURRENT_CONTEXT(ctx);
1453 GLdouble v[4];
1454 v[0] = v0;
1455 v[1] = v1;
1456 v[2] = v2;
1457 v[3] = v3;
1458 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_DOUBLE, 4);
1459 }
1460
1461 void GLAPIENTRY
1462 _mesa_Uniform1dv(GLint location, GLsizei count, const GLdouble * value)
1463 {
1464 GET_CURRENT_CONTEXT(ctx);
1465 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_DOUBLE, 1);
1466 }
1467
1468 void GLAPIENTRY
1469 _mesa_Uniform2dv(GLint location, GLsizei count, const GLdouble * value)
1470 {
1471 GET_CURRENT_CONTEXT(ctx);
1472 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_DOUBLE, 2);
1473 }
1474
1475 void GLAPIENTRY
1476 _mesa_Uniform3dv(GLint location, GLsizei count, const GLdouble * value)
1477 {
1478 GET_CURRENT_CONTEXT(ctx);
1479 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_DOUBLE, 3);
1480 }
1481
1482 void GLAPIENTRY
1483 _mesa_Uniform4dv(GLint location, GLsizei count, const GLdouble * value)
1484 {
1485 GET_CURRENT_CONTEXT(ctx);
1486 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_DOUBLE, 4);
1487 }
1488
1489 void GLAPIENTRY
1490 _mesa_UniformMatrix2dv(GLint location, GLsizei count, GLboolean transpose,
1491 const GLdouble * value)
1492 {
1493 GET_CURRENT_CONTEXT(ctx);
1494 _mesa_uniform_matrix(location, count, transpose, value,
1495 ctx, ctx->_Shader->ActiveProgram, 2, 2, GLSL_TYPE_DOUBLE);
1496 }
1497
1498 void GLAPIENTRY
1499 _mesa_UniformMatrix3dv(GLint location, GLsizei count, GLboolean transpose,
1500 const GLdouble * value)
1501 {
1502 GET_CURRENT_CONTEXT(ctx);
1503 _mesa_uniform_matrix(location, count, transpose, value,
1504 ctx, ctx->_Shader->ActiveProgram, 3, 3, GLSL_TYPE_DOUBLE);
1505 }
1506
1507 void GLAPIENTRY
1508 _mesa_UniformMatrix4dv(GLint location, GLsizei count, GLboolean transpose,
1509 const GLdouble * value)
1510 {
1511 GET_CURRENT_CONTEXT(ctx);
1512 _mesa_uniform_matrix(location, count, transpose, value,
1513 ctx, ctx->_Shader->ActiveProgram, 4, 4, GLSL_TYPE_DOUBLE);
1514 }
1515
1516 void GLAPIENTRY
1517 _mesa_UniformMatrix2x3dv(GLint location, GLsizei count, GLboolean transpose,
1518 const GLdouble *value)
1519 {
1520 GET_CURRENT_CONTEXT(ctx);
1521 _mesa_uniform_matrix(location, count, transpose, value,
1522 ctx, ctx->_Shader->ActiveProgram, 2, 3, GLSL_TYPE_DOUBLE);
1523 }
1524
1525 void GLAPIENTRY
1526 _mesa_UniformMatrix3x2dv(GLint location, GLsizei count, GLboolean transpose,
1527 const GLdouble *value)
1528 {
1529 GET_CURRENT_CONTEXT(ctx);
1530 _mesa_uniform_matrix(location, count, transpose, value,
1531 ctx, ctx->_Shader->ActiveProgram, 3, 2, GLSL_TYPE_DOUBLE);
1532 }
1533
1534 void GLAPIENTRY
1535 _mesa_UniformMatrix2x4dv(GLint location, GLsizei count, GLboolean transpose,
1536 const GLdouble *value)
1537 {
1538 GET_CURRENT_CONTEXT(ctx);
1539 _mesa_uniform_matrix(location, count, transpose, value,
1540 ctx, ctx->_Shader->ActiveProgram, 2, 4, GLSL_TYPE_DOUBLE);
1541 }
1542
1543 void GLAPIENTRY
1544 _mesa_UniformMatrix4x2dv(GLint location, GLsizei count, GLboolean transpose,
1545 const GLdouble *value)
1546 {
1547 GET_CURRENT_CONTEXT(ctx);
1548 _mesa_uniform_matrix(location, count, transpose, value,
1549 ctx, ctx->_Shader->ActiveProgram, 4, 2, GLSL_TYPE_DOUBLE);
1550 }
1551
1552 void GLAPIENTRY
1553 _mesa_UniformMatrix3x4dv(GLint location, GLsizei count, GLboolean transpose,
1554 const GLdouble *value)
1555 {
1556 GET_CURRENT_CONTEXT(ctx);
1557 _mesa_uniform_matrix(location, count, transpose, value,
1558 ctx, ctx->_Shader->ActiveProgram, 3, 4, GLSL_TYPE_DOUBLE);
1559 }
1560
1561 void GLAPIENTRY
1562 _mesa_UniformMatrix4x3dv(GLint location, GLsizei count, GLboolean transpose,
1563 const GLdouble *value)
1564 {
1565 GET_CURRENT_CONTEXT(ctx);
1566 _mesa_uniform_matrix(location, count, transpose, value,
1567 ctx, ctx->_Shader->ActiveProgram, 4, 3, GLSL_TYPE_DOUBLE);
1568 }
1569
1570 void GLAPIENTRY
1571 _mesa_ProgramUniform1d(GLuint program, GLint location, GLdouble v0)
1572 {
1573 GET_CURRENT_CONTEXT(ctx);
1574 struct gl_shader_program *shProg =
1575 _mesa_lookup_shader_program_err(ctx, program,
1576 "glProgramUniform1d");
1577 _mesa_uniform(location, 1, &v0, ctx, shProg, GLSL_TYPE_DOUBLE, 1);
1578 }
1579
1580 void GLAPIENTRY
1581 _mesa_ProgramUniform2d(GLuint program, GLint location, GLdouble v0, GLdouble v1)
1582 {
1583 GET_CURRENT_CONTEXT(ctx);
1584 GLdouble v[2];
1585 struct gl_shader_program *shProg;
1586 v[0] = v0;
1587 v[1] = v1;
1588 shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform2d");
1589 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_DOUBLE, 2);
1590 }
1591
1592 void GLAPIENTRY
1593 _mesa_ProgramUniform3d(GLuint program, GLint location, GLdouble v0, GLdouble v1,
1594 GLdouble v2)
1595 {
1596 GET_CURRENT_CONTEXT(ctx);
1597 GLdouble v[3];
1598 struct gl_shader_program *shProg;
1599 v[0] = v0;
1600 v[1] = v1;
1601 v[2] = v2;
1602 shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform3d");
1603 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_DOUBLE, 3);
1604 }
1605
1606 void GLAPIENTRY
1607 _mesa_ProgramUniform4d(GLuint program, GLint location, GLdouble v0, GLdouble v1,
1608 GLdouble v2, GLdouble v3)
1609 {
1610 GET_CURRENT_CONTEXT(ctx);
1611 GLdouble v[4];
1612 struct gl_shader_program *shProg;
1613 v[0] = v0;
1614 v[1] = v1;
1615 v[2] = v2;
1616 v[3] = v3;
1617 shProg = _mesa_lookup_shader_program_err(ctx, program, "glProgramUniform4d");
1618 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_DOUBLE, 4);
1619 }
1620
1621 void GLAPIENTRY
1622 _mesa_ProgramUniform1dv(GLuint program, GLint location, GLsizei count,
1623 const GLdouble * value)
1624 {
1625 GET_CURRENT_CONTEXT(ctx);
1626 struct gl_shader_program *shProg =
1627 _mesa_lookup_shader_program_err(ctx, program,
1628 "glProgramUniform1dv");
1629 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_DOUBLE, 1);
1630 }
1631
1632 void GLAPIENTRY
1633 _mesa_ProgramUniform2dv(GLuint program, GLint location, GLsizei count,
1634 const GLdouble * value)
1635 {
1636 GET_CURRENT_CONTEXT(ctx);
1637 struct gl_shader_program *shProg =
1638 _mesa_lookup_shader_program_err(ctx, program,
1639 "glProgramUniform2dv");
1640 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_DOUBLE, 2);
1641 }
1642
1643 void GLAPIENTRY
1644 _mesa_ProgramUniform3dv(GLuint program, GLint location, GLsizei count,
1645 const GLdouble * value)
1646 {
1647 GET_CURRENT_CONTEXT(ctx);
1648 struct gl_shader_program *shProg =
1649 _mesa_lookup_shader_program_err(ctx, program,
1650 "glProgramUniform3dv");
1651 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_DOUBLE, 3);
1652 }
1653
1654 void GLAPIENTRY
1655 _mesa_ProgramUniform4dv(GLuint program, GLint location, GLsizei count,
1656 const GLdouble * value)
1657 {
1658 GET_CURRENT_CONTEXT(ctx);
1659 struct gl_shader_program *shProg =
1660 _mesa_lookup_shader_program_err(ctx, program,
1661 "glProgramUniform4dv");
1662 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_DOUBLE, 4);
1663 }
1664
1665 void GLAPIENTRY
1666 _mesa_ProgramUniformMatrix2dv(GLuint program, GLint location, GLsizei count,
1667 GLboolean transpose, const GLdouble * value)
1668 {
1669 GET_CURRENT_CONTEXT(ctx);
1670 struct gl_shader_program *shProg =
1671 _mesa_lookup_shader_program_err(ctx, program,
1672 "glProgramUniformMatrix2dv");
1673 _mesa_uniform_matrix(location, count, transpose, value,
1674 ctx, shProg, 2, 2, GLSL_TYPE_DOUBLE);
1675 }
1676
1677 void GLAPIENTRY
1678 _mesa_ProgramUniformMatrix3dv(GLuint program, GLint location, GLsizei count,
1679 GLboolean transpose, const GLdouble * value)
1680 {
1681 GET_CURRENT_CONTEXT(ctx);
1682 struct gl_shader_program *shProg =
1683 _mesa_lookup_shader_program_err(ctx, program,
1684 "glProgramUniformMatrix3dv");
1685 _mesa_uniform_matrix(location, count, transpose, value,
1686 ctx, shProg, 3, 3, GLSL_TYPE_DOUBLE);
1687 }
1688
1689 void GLAPIENTRY
1690 _mesa_ProgramUniformMatrix4dv(GLuint program, GLint location, GLsizei count,
1691 GLboolean transpose, const GLdouble * value)
1692 {
1693 GET_CURRENT_CONTEXT(ctx);
1694 struct gl_shader_program *shProg =
1695 _mesa_lookup_shader_program_err(ctx, program,
1696 "glProgramUniformMatrix4dv");
1697 _mesa_uniform_matrix(location, count, transpose, value,
1698 ctx, shProg, 4, 4, GLSL_TYPE_DOUBLE);
1699 }
1700
1701 void GLAPIENTRY
1702 _mesa_ProgramUniformMatrix2x3dv(GLuint program, GLint location, GLsizei count,
1703 GLboolean transpose, const GLdouble * value)
1704 {
1705 GET_CURRENT_CONTEXT(ctx);
1706 struct gl_shader_program *shProg =
1707 _mesa_lookup_shader_program_err(ctx, program,
1708 "glProgramUniformMatrix2x3dv");
1709 _mesa_uniform_matrix(location, count, transpose, value,
1710 ctx, shProg, 2, 3, GLSL_TYPE_DOUBLE);
1711 }
1712
1713 void GLAPIENTRY
1714 _mesa_ProgramUniformMatrix3x2dv(GLuint program, GLint location, GLsizei count,
1715 GLboolean transpose, const GLdouble * value)
1716 {
1717 GET_CURRENT_CONTEXT(ctx);
1718 struct gl_shader_program *shProg =
1719 _mesa_lookup_shader_program_err(ctx, program,
1720 "glProgramUniformMatrix3x2dv");
1721 _mesa_uniform_matrix(location, count, transpose, value,
1722 ctx, shProg, 3, 2, GLSL_TYPE_DOUBLE);
1723 }
1724
1725 void GLAPIENTRY
1726 _mesa_ProgramUniformMatrix2x4dv(GLuint program, GLint location, GLsizei count,
1727 GLboolean transpose, const GLdouble * value)
1728 {
1729 GET_CURRENT_CONTEXT(ctx);
1730 struct gl_shader_program *shProg =
1731 _mesa_lookup_shader_program_err(ctx, program,
1732 "glProgramUniformMatrix2x4dv");
1733 _mesa_uniform_matrix(location, count, transpose, value,
1734 ctx, shProg, 2, 4, GLSL_TYPE_DOUBLE);
1735 }
1736
1737 void GLAPIENTRY
1738 _mesa_ProgramUniformMatrix4x2dv(GLuint program, GLint location, GLsizei count,
1739 GLboolean transpose, const GLdouble * value)
1740 {
1741 GET_CURRENT_CONTEXT(ctx);
1742 struct gl_shader_program *shProg =
1743 _mesa_lookup_shader_program_err(ctx, program,
1744 "glProgramUniformMatrix4x2dv");
1745 _mesa_uniform_matrix(location, count, transpose, value,
1746 ctx, shProg, 4, 2, GLSL_TYPE_DOUBLE);
1747 }
1748
1749 void GLAPIENTRY
1750 _mesa_ProgramUniformMatrix3x4dv(GLuint program, GLint location, GLsizei count,
1751 GLboolean transpose, const GLdouble * value)
1752 {
1753 GET_CURRENT_CONTEXT(ctx);
1754 struct gl_shader_program *shProg =
1755 _mesa_lookup_shader_program_err(ctx, program,
1756 "glProgramUniformMatrix3x4dv");
1757 _mesa_uniform_matrix(location, count, transpose, value,
1758 ctx, shProg, 3, 4, GLSL_TYPE_DOUBLE);
1759 }
1760
1761 void GLAPIENTRY
1762 _mesa_ProgramUniformMatrix4x3dv(GLuint program, GLint location, GLsizei count,
1763 GLboolean transpose, const GLdouble * value)
1764 {
1765 GET_CURRENT_CONTEXT(ctx);
1766 struct gl_shader_program *shProg =
1767 _mesa_lookup_shader_program_err(ctx, program,
1768 "glProgramUniformMatrix4x3dv");
1769 _mesa_uniform_matrix(location, count, transpose, value,
1770 ctx, shProg, 4, 3, GLSL_TYPE_DOUBLE);
1771 }
1772
1773 void GLAPIENTRY
1774 _mesa_Uniform1i64ARB(GLint location, GLint64 v0)
1775 {
1776 GET_CURRENT_CONTEXT(ctx);
1777 _mesa_uniform(location, 1, &v0, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_INT64, 1);
1778 }
1779
1780 void GLAPIENTRY
1781 _mesa_Uniform2i64ARB(GLint location, GLint64 v0, GLint64 v1)
1782 {
1783 GET_CURRENT_CONTEXT(ctx);
1784 int64_t v[2];
1785 v[0] = v0;
1786 v[1] = v1;
1787 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_INT64, 2);
1788 }
1789
1790 void GLAPIENTRY
1791 _mesa_Uniform3i64ARB(GLint location, GLint64 v0, GLint64 v1, GLint64 v2)
1792 {
1793 GET_CURRENT_CONTEXT(ctx);
1794 int64_t v[3];
1795 v[0] = v0;
1796 v[1] = v1;
1797 v[2] = v2;
1798 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_INT64, 3);
1799 }
1800
1801 void GLAPIENTRY
1802 _mesa_Uniform4i64ARB(GLint location, GLint64 v0, GLint64 v1, GLint64 v2, GLint64 v3)
1803 {
1804 GET_CURRENT_CONTEXT(ctx);
1805 int64_t v[4];
1806 v[0] = v0;
1807 v[1] = v1;
1808 v[2] = v2;
1809 v[3] = v3;
1810 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_INT64, 4);
1811 }
1812
1813 void GLAPIENTRY
1814 _mesa_Uniform1i64vARB(GLint location, GLsizei count, const GLint64 *value)
1815 {
1816 GET_CURRENT_CONTEXT(ctx);
1817 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_INT64, 1);
1818 }
1819
1820 void GLAPIENTRY
1821 _mesa_Uniform2i64vARB(GLint location, GLsizei count, const GLint64 *value)
1822 {
1823 GET_CURRENT_CONTEXT(ctx);
1824 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_INT64, 2);
1825 }
1826
1827 void GLAPIENTRY
1828 _mesa_Uniform3i64vARB(GLint location, GLsizei count, const GLint64 *value)
1829 {
1830 GET_CURRENT_CONTEXT(ctx);
1831 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_INT64, 3);
1832 }
1833
1834 void GLAPIENTRY
1835 _mesa_Uniform4i64vARB(GLint location, GLsizei count, const GLint64 *value)
1836 {
1837 GET_CURRENT_CONTEXT(ctx);
1838 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_INT64, 4);
1839 }
1840
1841 void GLAPIENTRY
1842 _mesa_Uniform1ui64ARB(GLint location, GLuint64 v0)
1843 {
1844 GET_CURRENT_CONTEXT(ctx);
1845 _mesa_uniform(location, 1, &v0, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_UINT64, 1);
1846 }
1847
1848 void GLAPIENTRY
1849 _mesa_Uniform2ui64ARB(GLint location, GLuint64 v0, GLuint64 v1)
1850 {
1851 GET_CURRENT_CONTEXT(ctx);
1852 uint64_t v[2];
1853 v[0] = v0;
1854 v[1] = v1;
1855 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_UINT64, 2);
1856 }
1857
1858 void GLAPIENTRY
1859 _mesa_Uniform3ui64ARB(GLint location, GLuint64 v0, GLuint64 v1, GLuint64 v2)
1860 {
1861 GET_CURRENT_CONTEXT(ctx);
1862 uint64_t v[3];
1863 v[0] = v0;
1864 v[1] = v1;
1865 v[2] = v2;
1866 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_UINT64, 3);
1867 }
1868
1869 void GLAPIENTRY
1870 _mesa_Uniform4ui64ARB(GLint location, GLuint64 v0, GLuint64 v1, GLuint64 v2, GLuint64 v3)
1871 {
1872 GET_CURRENT_CONTEXT(ctx);
1873 uint64_t v[4];
1874 v[0] = v0;
1875 v[1] = v1;
1876 v[2] = v2;
1877 v[3] = v3;
1878 _mesa_uniform(location, 1, v, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_UINT64, 4);
1879 }
1880
1881 void GLAPIENTRY
1882 _mesa_Uniform1ui64vARB(GLint location, GLsizei count, const GLuint64 *value)
1883 {
1884 GET_CURRENT_CONTEXT(ctx);
1885 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_UINT64, 1);
1886 }
1887
1888 void GLAPIENTRY
1889 _mesa_Uniform2ui64vARB(GLint location, GLsizei count, const GLuint64 *value)
1890 {
1891 GET_CURRENT_CONTEXT(ctx);
1892 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_UINT64, 2);
1893 }
1894
1895 void GLAPIENTRY
1896 _mesa_Uniform3ui64vARB(GLint location, GLsizei count, const GLuint64 *value)
1897 {
1898 GET_CURRENT_CONTEXT(ctx);
1899 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_UINT64, 3);
1900 }
1901
1902 void GLAPIENTRY
1903 _mesa_Uniform4ui64vARB(GLint location, GLsizei count, const GLuint64 *value)
1904 {
1905 GET_CURRENT_CONTEXT(ctx);
1906 _mesa_uniform(location, count, value, ctx, ctx->_Shader->ActiveProgram, GLSL_TYPE_UINT64, 4);
1907 }
1908
1909 /* DSA entrypoints */
1910 void GLAPIENTRY
1911 _mesa_ProgramUniform1i64ARB(GLuint program, GLint location, GLint64 v0)
1912 {
1913 GET_CURRENT_CONTEXT(ctx);
1914 struct gl_shader_program *shProg =
1915 _mesa_lookup_shader_program_err(ctx, program,
1916 "glProgramUniform1i64ARB");
1917 _mesa_uniform(location, 1, &v0, ctx, shProg, GLSL_TYPE_INT64, 1);
1918 }
1919
1920 void GLAPIENTRY
1921 _mesa_ProgramUniform2i64ARB(GLuint program, GLint location, GLint64 v0, GLint64 v1)
1922 {
1923 GET_CURRENT_CONTEXT(ctx);
1924 struct gl_shader_program *shProg =
1925 _mesa_lookup_shader_program_err(ctx, program,
1926 "glProgramUniform2i64ARB");
1927 int64_t v[2];
1928 v[0] = v0;
1929 v[1] = v1;
1930 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_INT64, 2);
1931 }
1932
1933 void GLAPIENTRY
1934 _mesa_ProgramUniform3i64ARB(GLuint program, GLint location, GLint64 v0, GLint64 v1, GLint64 v2)
1935 {
1936 GET_CURRENT_CONTEXT(ctx);
1937 struct gl_shader_program *shProg =
1938 _mesa_lookup_shader_program_err(ctx, program,
1939 "glProgramUniform3i64ARB");
1940 int64_t v[3];
1941 v[0] = v0;
1942 v[1] = v1;
1943 v[2] = v2;
1944 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_INT64, 3);
1945 }
1946
1947 void GLAPIENTRY
1948 _mesa_ProgramUniform4i64ARB(GLuint program, GLint location, GLint64 v0, GLint64 v1, GLint64 v2, GLint64 v3)
1949 {
1950 GET_CURRENT_CONTEXT(ctx);
1951 struct gl_shader_program *shProg =
1952 _mesa_lookup_shader_program_err(ctx, program,
1953 "glProgramUniform4i64ARB");
1954 int64_t v[4];
1955 v[0] = v0;
1956 v[1] = v1;
1957 v[2] = v2;
1958 v[3] = v3;
1959 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_INT64, 4);
1960 }
1961
1962 void GLAPIENTRY
1963 _mesa_ProgramUniform1i64vARB(GLuint program, GLint location, GLsizei count, const GLint64 *value)
1964 {
1965 GET_CURRENT_CONTEXT(ctx);
1966 struct gl_shader_program *shProg =
1967 _mesa_lookup_shader_program_err(ctx, program,
1968 "glProgramUniform1i64vARB");
1969 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_INT64, 1);
1970 }
1971
1972 void GLAPIENTRY
1973 _mesa_ProgramUniform2i64vARB(GLuint program, GLint location, GLsizei count, const GLint64 *value)
1974 {
1975 GET_CURRENT_CONTEXT(ctx);
1976 struct gl_shader_program *shProg =
1977 _mesa_lookup_shader_program_err(ctx, program,
1978 "glProgramUniform2i64vARB");
1979 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_INT64, 2);
1980 }
1981
1982 void GLAPIENTRY
1983 _mesa_ProgramUniform3i64vARB(GLuint program, GLint location, GLsizei count, const GLint64 *value)
1984 {
1985 GET_CURRENT_CONTEXT(ctx);
1986 struct gl_shader_program *shProg =
1987 _mesa_lookup_shader_program_err(ctx, program,
1988 "glProgramUniform3i64vARB");
1989 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_INT64, 3);
1990 }
1991
1992 void GLAPIENTRY
1993 _mesa_ProgramUniform4i64vARB(GLuint program, GLint location, GLsizei count, const GLint64 *value)
1994 {
1995 GET_CURRENT_CONTEXT(ctx);
1996 struct gl_shader_program *shProg =
1997 _mesa_lookup_shader_program_err(ctx, program,
1998 "glProgramUniform4i64vARB");
1999 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_INT64, 4);
2000 }
2001
2002 void GLAPIENTRY
2003 _mesa_ProgramUniform1ui64ARB(GLuint program, GLint location, GLuint64 v0)
2004 {
2005 GET_CURRENT_CONTEXT(ctx);
2006 struct gl_shader_program *shProg =
2007 _mesa_lookup_shader_program_err(ctx, program,
2008 "glProgramUniform1ui64ARB");
2009 _mesa_uniform(location, 1, &v0, ctx, shProg, GLSL_TYPE_UINT64, 1);
2010 }
2011
2012 void GLAPIENTRY
2013 _mesa_ProgramUniform2ui64ARB(GLuint program, GLint location, GLuint64 v0, GLuint64 v1)
2014 {
2015 GET_CURRENT_CONTEXT(ctx);
2016 struct gl_shader_program *shProg =
2017 _mesa_lookup_shader_program_err(ctx, program,
2018 "glProgramUniform2ui64ARB");
2019 uint64_t v[2];
2020 v[0] = v0;
2021 v[1] = v1;
2022 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_UINT64, 2);
2023 }
2024
2025 void GLAPIENTRY
2026 _mesa_ProgramUniform3ui64ARB(GLuint program, GLint location, GLuint64 v0, GLuint64 v1, GLuint64 v2)
2027 {
2028 GET_CURRENT_CONTEXT(ctx);
2029 struct gl_shader_program *shProg =
2030 _mesa_lookup_shader_program_err(ctx, program,
2031 "glProgramUniform3ui64ARB");
2032 uint64_t v[3];
2033 v[0] = v0;
2034 v[1] = v1;
2035 v[2] = v2;
2036 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_UINT64, 3);
2037 }
2038
2039 void GLAPIENTRY
2040 _mesa_ProgramUniform4ui64ARB(GLuint program, GLint location, GLuint64 v0, GLuint64 v1, GLuint64 v2, GLuint64 v3)
2041 {
2042 GET_CURRENT_CONTEXT(ctx);
2043 struct gl_shader_program *shProg =
2044 _mesa_lookup_shader_program_err(ctx, program,
2045 "glProgramUniform4ui64ARB");
2046 uint64_t v[4];
2047 v[0] = v0;
2048 v[1] = v1;
2049 v[2] = v2;
2050 v[3] = v3;
2051 _mesa_uniform(location, 1, v, ctx, shProg, GLSL_TYPE_UINT64, 4);
2052 }
2053
2054 void GLAPIENTRY
2055 _mesa_ProgramUniform1ui64vARB(GLuint program, GLint location, GLsizei count, const GLuint64 *value)
2056 {
2057 GET_CURRENT_CONTEXT(ctx);
2058 struct gl_shader_program *shProg =
2059 _mesa_lookup_shader_program_err(ctx, program,
2060 "glProgramUniform1ui64vARB");
2061 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_UINT64, 1);
2062 }
2063
2064 void GLAPIENTRY
2065 _mesa_ProgramUniform2ui64vARB(GLuint program, GLint location, GLsizei count, const GLuint64 *value)
2066 {
2067 GET_CURRENT_CONTEXT(ctx);
2068 struct gl_shader_program *shProg =
2069 _mesa_lookup_shader_program_err(ctx, program,
2070 "glProgramUniform2ui64vARB");
2071 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_UINT64, 2);
2072 }
2073
2074 void GLAPIENTRY
2075 _mesa_ProgramUniform3ui64vARB(GLuint program, GLint location, GLsizei count, const GLuint64 *value)
2076 {
2077 GET_CURRENT_CONTEXT(ctx);
2078 struct gl_shader_program *shProg =
2079 _mesa_lookup_shader_program_err(ctx, program,
2080 "glProgramUniform3ui64vARB");
2081 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_UINT64, 3);
2082 }
2083
2084 void GLAPIENTRY
2085 _mesa_ProgramUniform4ui64vARB(GLuint program, GLint location, GLsizei count, const GLuint64 *value)
2086 {
2087 GET_CURRENT_CONTEXT(ctx);
2088 struct gl_shader_program *shProg =
2089 _mesa_lookup_shader_program_err(ctx, program,
2090 "glProgramUniform4ui64vARB");
2091 _mesa_uniform(location, count, value, ctx, shProg, GLSL_TYPE_UINT64, 4);
2092 }