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