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