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