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