2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * NVIDIA vertex/fragment program state management functions.
32 * Regarding GL_NV_fragment/vertex_program, GL_NV_vertex_program1_1, etc:
34 * Portions of this software may use or implement intellectual
35 * property owned and licensed by NVIDIA Corporation. NVIDIA disclaims
36 * any and all warranties with respect to such intellectual property,
37 * including any use thereof or modifications thereto.
40 #include "main/glheader.h"
41 #include "main/context.h"
42 #include "main/hash.h"
43 #include "main/imports.h"
44 #include "main/macros.h"
46 #include "prog_parameter.h"
47 #include "prog_instruction.h"
48 #include "nvfragparse.h"
49 #include "nvvertparse.h"
50 #include "arbprogparse.h"
51 #include "nvprogram.h"
56 * Execute a vertex state program.
57 * \note Called from the GL API dispatcher.
60 _mesa_ExecuteProgramNV(GLenum target
, GLuint id
, const GLfloat
*params
)
62 struct gl_vertex_program
*vprog
;
63 GET_CURRENT_CONTEXT(ctx
);
64 ASSERT_OUTSIDE_BEGIN_END(ctx
);
66 if (target
!= GL_VERTEX_STATE_PROGRAM_NV
) {
67 _mesa_error(ctx
, GL_INVALID_ENUM
, "glExecuteProgramNV");
71 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
73 vprog
= (struct gl_vertex_program
*) _mesa_lookup_program(ctx
, id
);
75 if (!vprog
|| vprog
->Base
.Target
!= GL_VERTEX_STATE_PROGRAM_NV
) {
76 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glExecuteProgramNV");
80 _mesa_problem(ctx
, "glExecuteProgramNV() not supported");
85 * Determine if a set of programs is resident in hardware.
86 * \note Not compiled into display lists.
87 * \note Called from the GL API dispatcher.
90 _mesa_AreProgramsResidentNV(GLsizei n
, const GLuint
*ids
,
91 GLboolean
*residences
)
94 GLboolean allResident
= GL_TRUE
;
95 GET_CURRENT_CONTEXT(ctx
);
96 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
99 _mesa_error(ctx
, GL_INVALID_VALUE
, "glAreProgramsResidentNV(n)");
103 for (i
= 0; i
< n
; i
++) {
104 const struct gl_program
*prog
;
106 _mesa_error(ctx
, GL_INVALID_VALUE
, "glAreProgramsResidentNV");
109 prog
= _mesa_lookup_program(ctx
, ids
[i
]);
111 _mesa_error(ctx
, GL_INVALID_VALUE
, "glAreProgramsResidentNV");
114 if (prog
->Resident
) {
116 residences
[i
] = GL_TRUE
;
120 allResident
= GL_FALSE
;
121 for (j
= 0; j
< i
; j
++)
122 residences
[j
] = GL_TRUE
;
124 residences
[i
] = GL_FALSE
;
133 * Request that a set of programs be resident in hardware.
134 * \note Called from the GL API dispatcher.
137 _mesa_RequestResidentProgramsNV(GLsizei n
, const GLuint
*ids
)
140 GET_CURRENT_CONTEXT(ctx
);
141 ASSERT_OUTSIDE_BEGIN_END(ctx
);
144 _mesa_error(ctx
, GL_INVALID_VALUE
, "glRequestResidentProgramsNV(n)");
148 /* just error checking for now */
149 for (i
= 0; i
< n
; i
++) {
150 struct gl_program
*prog
;
153 _mesa_error(ctx
, GL_INVALID_VALUE
, "glRequestResidentProgramsNV(id)");
157 prog
= _mesa_lookup_program(ctx
, ids
[i
]);
159 _mesa_error(ctx
, GL_INVALID_VALUE
, "glRequestResidentProgramsNV(id)");
163 /* XXX this is really a hardware thing we should hook out */
164 prog
->Resident
= GL_TRUE
;
170 * Get a program parameter register.
171 * \note Not compiled into display lists.
172 * \note Called from the GL API dispatcher.
175 _mesa_GetProgramParameterfvNV(GLenum target
, GLuint index
,
176 GLenum pname
, GLfloat
*params
)
178 GET_CURRENT_CONTEXT(ctx
);
179 ASSERT_OUTSIDE_BEGIN_END(ctx
);
181 if (target
== GL_VERTEX_PROGRAM_NV
) {
182 if (pname
== GL_PROGRAM_PARAMETER_NV
) {
183 if (index
< MAX_NV_VERTEX_PROGRAM_PARAMS
) {
184 COPY_4V(params
, ctx
->VertexProgram
.Parameters
[index
]);
187 _mesa_error(ctx
, GL_INVALID_VALUE
,
188 "glGetProgramParameterfvNV(index)");
193 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramParameterfvNV(pname)");
198 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramParameterfvNV(target)");
205 * Get a program parameter register.
206 * \note Not compiled into display lists.
207 * \note Called from the GL API dispatcher.
210 _mesa_GetProgramParameterdvNV(GLenum target
, GLuint index
,
211 GLenum pname
, GLdouble
*params
)
213 GET_CURRENT_CONTEXT(ctx
);
214 ASSERT_OUTSIDE_BEGIN_END(ctx
);
216 if (target
== GL_VERTEX_PROGRAM_NV
) {
217 if (pname
== GL_PROGRAM_PARAMETER_NV
) {
218 if (index
< MAX_NV_VERTEX_PROGRAM_PARAMS
) {
219 COPY_4V(params
, ctx
->VertexProgram
.Parameters
[index
]);
222 _mesa_error(ctx
, GL_INVALID_VALUE
,
223 "glGetProgramParameterdvNV(index)");
228 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramParameterdvNV(pname)");
233 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramParameterdvNV(target)");
240 * Get a program attribute.
241 * \note Not compiled into display lists.
242 * \note Called from the GL API dispatcher.
245 _mesa_GetProgramivNV(GLuint id
, GLenum pname
, GLint
*params
)
247 struct gl_program
*prog
;
248 GET_CURRENT_CONTEXT(ctx
);
250 ASSERT_OUTSIDE_BEGIN_END(ctx
);
252 prog
= _mesa_lookup_program(ctx
, id
);
254 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetProgramivNV");
259 case GL_PROGRAM_TARGET_NV
:
260 *params
= prog
->Target
;
262 case GL_PROGRAM_LENGTH_NV
:
263 *params
= prog
->String
?(GLint
)_mesa_strlen((char *) prog
->String
) : 0;
265 case GL_PROGRAM_RESIDENT_NV
:
266 *params
= prog
->Resident
;
269 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramivNV(pname)");
276 * Get the program source code.
277 * \note Not compiled into display lists.
278 * \note Called from the GL API dispatcher.
281 _mesa_GetProgramStringNV(GLuint id
, GLenum pname
, GLubyte
*program
)
283 struct gl_program
*prog
;
284 GET_CURRENT_CONTEXT(ctx
);
286 ASSERT_OUTSIDE_BEGIN_END(ctx
);
288 if (pname
!= GL_PROGRAM_STRING_NV
) {
289 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramStringNV(pname)");
293 prog
= _mesa_lookup_program(ctx
, id
);
295 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetProgramStringNV");
300 MEMCPY(program
, prog
->String
, _mesa_strlen((char *) prog
->String
));
309 * Get matrix tracking information.
310 * \note Not compiled into display lists.
311 * \note Called from the GL API dispatcher.
314 _mesa_GetTrackMatrixivNV(GLenum target
, GLuint address
,
315 GLenum pname
, GLint
*params
)
317 GET_CURRENT_CONTEXT(ctx
);
318 ASSERT_OUTSIDE_BEGIN_END(ctx
);
320 if (target
== GL_VERTEX_PROGRAM_NV
321 && ctx
->Extensions
.NV_vertex_program
) {
324 if ((address
& 0x3) || address
>= MAX_NV_VERTEX_PROGRAM_PARAMS
) {
325 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetTrackMatrixivNV(address)");
332 case GL_TRACK_MATRIX_NV
:
333 params
[0] = (GLint
) ctx
->VertexProgram
.TrackMatrix
[i
];
335 case GL_TRACK_MATRIX_TRANSFORM_NV
:
336 params
[0] = (GLint
) ctx
->VertexProgram
.TrackMatrixTransform
[i
];
339 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTrackMatrixivNV");
344 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTrackMatrixivNV");
351 * Get a vertex (or vertex array) attribute.
352 * \note Not compiled into display lists.
353 * \note Called from the GL API dispatcher.
356 _mesa_GetVertexAttribdvNV(GLuint index
, GLenum pname
, GLdouble
*params
)
358 const struct gl_client_array
*array
;
359 GET_CURRENT_CONTEXT(ctx
);
360 ASSERT_OUTSIDE_BEGIN_END(ctx
);
362 if (index
>= MAX_NV_VERTEX_PROGRAM_INPUTS
) {
363 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribdvNV(index)");
367 array
= &ctx
->Array
.ArrayObj
->VertexAttrib
[index
];
370 case GL_ATTRIB_ARRAY_SIZE_NV
:
371 params
[0] = array
->Size
;
373 case GL_ATTRIB_ARRAY_STRIDE_NV
:
374 params
[0] = array
->Stride
;
376 case GL_ATTRIB_ARRAY_TYPE_NV
:
377 params
[0] = array
->Type
;
379 case GL_CURRENT_ATTRIB_NV
:
381 _mesa_error(ctx
, GL_INVALID_OPERATION
,
382 "glGetVertexAttribdvNV(index == 0)");
385 FLUSH_CURRENT(ctx
, 0);
386 COPY_4V(params
, ctx
->Current
.Attrib
[index
]);
389 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribdvNV");
395 * Get a vertex (or vertex array) attribute.
396 * \note Not compiled into display lists.
397 * \note Called from the GL API dispatcher.
400 _mesa_GetVertexAttribfvNV(GLuint index
, GLenum pname
, GLfloat
*params
)
402 const struct gl_client_array
*array
;
403 GET_CURRENT_CONTEXT(ctx
);
404 ASSERT_OUTSIDE_BEGIN_END(ctx
);
406 if (index
>= MAX_NV_VERTEX_PROGRAM_INPUTS
) {
407 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribdvNV(index)");
411 array
= &ctx
->Array
.ArrayObj
->VertexAttrib
[index
];
414 case GL_ATTRIB_ARRAY_SIZE_NV
:
415 params
[0] = (GLfloat
) array
->Size
;
417 case GL_ATTRIB_ARRAY_STRIDE_NV
:
418 params
[0] = (GLfloat
) array
->Stride
;
420 case GL_ATTRIB_ARRAY_TYPE_NV
:
421 params
[0] = (GLfloat
) array
->Type
;
423 case GL_CURRENT_ATTRIB_NV
:
425 _mesa_error(ctx
, GL_INVALID_OPERATION
,
426 "glGetVertexAttribfvNV(index == 0)");
429 FLUSH_CURRENT(ctx
, 0);
430 COPY_4V(params
, ctx
->Current
.Attrib
[index
]);
433 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribdvNV");
439 * Get a vertex (or vertex array) attribute.
440 * \note Not compiled into display lists.
441 * \note Called from the GL API dispatcher.
444 _mesa_GetVertexAttribivNV(GLuint index
, GLenum pname
, GLint
*params
)
446 const struct gl_client_array
*array
;
447 GET_CURRENT_CONTEXT(ctx
);
448 ASSERT_OUTSIDE_BEGIN_END(ctx
);
450 if (index
>= MAX_NV_VERTEX_PROGRAM_INPUTS
) {
451 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribdvNV(index)");
455 array
= &ctx
->Array
.ArrayObj
->VertexAttrib
[index
];
458 case GL_ATTRIB_ARRAY_SIZE_NV
:
459 params
[0] = array
->Size
;
461 case GL_ATTRIB_ARRAY_STRIDE_NV
:
462 params
[0] = array
->Stride
;
464 case GL_ATTRIB_ARRAY_TYPE_NV
:
465 params
[0] = array
->Type
;
467 case GL_CURRENT_ATTRIB_NV
:
469 _mesa_error(ctx
, GL_INVALID_OPERATION
,
470 "glGetVertexAttribivNV(index == 0)");
473 FLUSH_CURRENT(ctx
, 0);
474 params
[0] = (GLint
) ctx
->Current
.Attrib
[index
][0];
475 params
[1] = (GLint
) ctx
->Current
.Attrib
[index
][1];
476 params
[2] = (GLint
) ctx
->Current
.Attrib
[index
][2];
477 params
[3] = (GLint
) ctx
->Current
.Attrib
[index
][3];
479 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB
:
480 params
[0] = array
->BufferObj
->Name
;
483 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribdvNV");
490 * Get a vertex array attribute pointer.
491 * \note Not compiled into display lists.
492 * \note Called from the GL API dispatcher.
495 _mesa_GetVertexAttribPointervNV(GLuint index
, GLenum pname
, GLvoid
**pointer
)
497 GET_CURRENT_CONTEXT(ctx
);
498 ASSERT_OUTSIDE_BEGIN_END(ctx
);
500 if (index
>= MAX_NV_VERTEX_PROGRAM_INPUTS
) {
501 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribPointerNV(index)");
505 if (pname
!= GL_ATTRIB_ARRAY_POINTER_NV
) {
506 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribPointerNV(pname)");
510 *pointer
= (GLvoid
*) ctx
->Array
.ArrayObj
->VertexAttrib
[index
].Ptr
;
514 _mesa_emit_nv_temp_initialization(GLcontext
*ctx
,
515 struct gl_program
*program
)
517 struct prog_instruction
*inst
;
520 if (!ctx
->Shader
.EmitNVTempInitialization
)
523 /* We'll swizzle up a zero temporary so we can use it for the
526 if (program
->NumTemporaries
== 0)
527 program
->NumTemporaries
= 1;
529 _mesa_insert_instructions(program
, 0, program
->NumTemporaries
+ 1);
531 for (i
= 0; i
< program
->NumTemporaries
; i
++) {
532 struct prog_instruction
*inst
= &program
->Instructions
[i
];
534 inst
->Opcode
= OPCODE_SWZ
;
535 inst
->DstReg
.File
= PROGRAM_TEMPORARY
;
536 inst
->DstReg
.Index
= i
;
537 inst
->DstReg
.WriteMask
= WRITEMASK_XYZW
;
538 inst
->SrcReg
[0].File
= PROGRAM_TEMPORARY
;
539 inst
->SrcReg
[0].Index
= 0;
540 inst
->SrcReg
[0].Swizzle
= MAKE_SWIZZLE4(SWIZZLE_ZERO
,
546 inst
= &program
->Instructions
[i
];
547 inst
->Opcode
= OPCODE_ARL
;
548 inst
->DstReg
.File
= PROGRAM_ADDRESS
;
549 inst
->DstReg
.Index
= 0;
550 inst
->DstReg
.WriteMask
= WRITEMASK_XYZW
;
551 inst
->SrcReg
[0].File
= PROGRAM_TEMPORARY
;
552 inst
->SrcReg
[0].Index
= 0;
553 inst
->SrcReg
[0].Swizzle
= SWIZZLE_XXXX
;
555 if (program
->NumAddressRegs
== 0)
556 program
->NumAddressRegs
= 1;
560 _mesa_setup_nv_temporary_count(GLcontext
*ctx
, struct gl_program
*program
)
564 program
->NumTemporaries
= 0;
565 for (i
= 0; i
< program
->NumInstructions
; i
++) {
566 struct prog_instruction
*inst
= &program
->Instructions
[i
];
568 if (inst
->DstReg
.File
== PROGRAM_TEMPORARY
) {
569 program
->NumTemporaries
= MAX2(program
->NumTemporaries
,
570 inst
->DstReg
.Index
+ 1);
572 if (inst
->SrcReg
[0].File
== PROGRAM_TEMPORARY
) {
573 program
->NumTemporaries
= MAX2(program
->NumTemporaries
,
574 inst
->SrcReg
[0].Index
+ 1);
576 if (inst
->SrcReg
[1].File
== PROGRAM_TEMPORARY
) {
577 program
->NumTemporaries
= MAX2(program
->NumTemporaries
,
578 inst
->SrcReg
[1].Index
+ 1);
580 if (inst
->SrcReg
[2].File
== PROGRAM_TEMPORARY
) {
581 program
->NumTemporaries
= MAX2(program
->NumTemporaries
,
582 inst
->SrcReg
[2].Index
+ 1);
588 * Load/parse/compile a program.
589 * \note Called from the GL API dispatcher.
592 _mesa_LoadProgramNV(GLenum target
, GLuint id
, GLsizei len
,
593 const GLubyte
*program
)
595 struct gl_program
*prog
;
596 GET_CURRENT_CONTEXT(ctx
);
597 ASSERT_OUTSIDE_BEGIN_END(ctx
);
599 if (!ctx
->Extensions
.NV_vertex_program
600 && !ctx
->Extensions
.NV_fragment_program
) {
601 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glLoadProgramNV()");
606 _mesa_error(ctx
, GL_INVALID_VALUE
, "glLoadProgramNV(id)");
611 _mesa_error(ctx
, GL_INVALID_VALUE
, "glLoadProgramNV(len)");
615 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
617 prog
= _mesa_lookup_program(ctx
, id
);
619 if (prog
&& prog
->Target
!= 0 && prog
->Target
!= target
) {
620 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glLoadProgramNV(target)");
624 if ((target
== GL_VERTEX_PROGRAM_NV
||
625 target
== GL_VERTEX_STATE_PROGRAM_NV
)
626 && ctx
->Extensions
.NV_vertex_program
) {
627 struct gl_vertex_program
*vprog
= (struct gl_vertex_program
*) prog
;
628 if (!vprog
|| prog
== &_mesa_DummyProgram
) {
629 vprog
= (struct gl_vertex_program
*)
630 ctx
->Driver
.NewProgram(ctx
, target
, id
);
632 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glLoadProgramNV");
635 _mesa_HashInsert(ctx
->Shared
->Programs
, id
, vprog
);
638 if (ctx
->Extensions
.ARB_vertex_program
639 && (strncmp((char *) program
, "!!ARB", 5) == 0)) {
640 _mesa_parse_arb_vertex_program(ctx
, target
, program
, len
, vprog
);
642 _mesa_parse_nv_vertex_program(ctx
, target
, program
, len
, vprog
);
645 else if (target
== GL_FRAGMENT_PROGRAM_NV
646 && ctx
->Extensions
.NV_fragment_program
) {
647 struct gl_fragment_program
*fprog
= (struct gl_fragment_program
*) prog
;
648 if (!fprog
|| prog
== &_mesa_DummyProgram
) {
649 fprog
= (struct gl_fragment_program
*)
650 ctx
->Driver
.NewProgram(ctx
, target
, id
);
652 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glLoadProgramNV");
655 _mesa_HashInsert(ctx
->Shared
->Programs
, id
, fprog
);
657 _mesa_parse_nv_fragment_program(ctx
, target
, program
, len
, fprog
);
659 else if (target
== GL_FRAGMENT_PROGRAM_ARB
660 && ctx
->Extensions
.ARB_fragment_program
) {
661 struct gl_fragment_program
*fprog
= (struct gl_fragment_program
*) prog
;
662 if (!fprog
|| prog
== &_mesa_DummyProgram
) {
663 fprog
= (struct gl_fragment_program
*)
664 ctx
->Driver
.NewProgram(ctx
, target
, id
);
666 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glLoadProgramNV");
669 _mesa_HashInsert(ctx
->Shared
->Programs
, id
, fprog
);
671 _mesa_parse_arb_fragment_program(ctx
, target
, program
, len
, fprog
);
674 _mesa_error(ctx
, GL_INVALID_ENUM
, "glLoadProgramNV(target)");
681 * Set a sequence of program parameter registers.
682 * \note Called from the GL API dispatcher.
685 _mesa_ProgramParameters4dvNV(GLenum target
, GLuint index
,
686 GLuint num
, const GLdouble
*params
)
688 GET_CURRENT_CONTEXT(ctx
);
689 ASSERT_OUTSIDE_BEGIN_END(ctx
);
691 if (target
== GL_VERTEX_PROGRAM_NV
&& ctx
->Extensions
.NV_vertex_program
) {
693 if (index
+ num
> MAX_NV_VERTEX_PROGRAM_PARAMS
) {
694 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramParameters4dvNV");
697 for (i
= 0; i
< num
; i
++) {
698 ctx
->VertexProgram
.Parameters
[index
+ i
][0] = (GLfloat
) params
[0];
699 ctx
->VertexProgram
.Parameters
[index
+ i
][1] = (GLfloat
) params
[1];
700 ctx
->VertexProgram
.Parameters
[index
+ i
][2] = (GLfloat
) params
[2];
701 ctx
->VertexProgram
.Parameters
[index
+ i
][3] = (GLfloat
) params
[3];
706 _mesa_error(ctx
, GL_INVALID_ENUM
, "glProgramParameters4dvNV");
713 * Set a sequence of program parameter registers.
714 * \note Called from the GL API dispatcher.
717 _mesa_ProgramParameters4fvNV(GLenum target
, GLuint index
,
718 GLuint num
, const GLfloat
*params
)
720 GET_CURRENT_CONTEXT(ctx
);
721 ASSERT_OUTSIDE_BEGIN_END(ctx
);
723 if (target
== GL_VERTEX_PROGRAM_NV
&& ctx
->Extensions
.NV_vertex_program
) {
725 if (index
+ num
> MAX_NV_VERTEX_PROGRAM_PARAMS
) {
726 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramParameters4fvNV");
729 for (i
= 0; i
< num
; i
++) {
730 COPY_4V(ctx
->VertexProgram
.Parameters
[index
+ i
], params
);
735 _mesa_error(ctx
, GL_INVALID_ENUM
, "glProgramParameters4fvNV");
743 * Setup tracking of matrices into program parameter registers.
744 * \note Called from the GL API dispatcher.
747 _mesa_TrackMatrixNV(GLenum target
, GLuint address
,
748 GLenum matrix
, GLenum transform
)
750 GET_CURRENT_CONTEXT(ctx
);
751 ASSERT_OUTSIDE_BEGIN_END(ctx
);
753 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
755 if (target
== GL_VERTEX_PROGRAM_NV
&& ctx
->Extensions
.NV_vertex_program
) {
757 /* addr must be multiple of four */
758 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTrackMatrixNV(address)");
768 case GL_MODELVIEW_PROJECTION_NV
:
777 /* OK, fallthrough */
780 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTrackMatrixNV(matrix)");
787 case GL_TRANSPOSE_NV
:
788 case GL_INVERSE_TRANSPOSE_NV
:
789 /* OK, fallthrough */
792 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTrackMatrixNV(transform)");
796 ctx
->VertexProgram
.TrackMatrix
[address
/ 4] = matrix
;
797 ctx
->VertexProgram
.TrackMatrixTransform
[address
/ 4] = transform
;
800 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTrackMatrixNV(target)");
807 _mesa_ProgramNamedParameter4fNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
808 GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
810 struct gl_program
*prog
;
811 struct gl_fragment_program
*fragProg
;
814 GET_CURRENT_CONTEXT(ctx
);
815 ASSERT_OUTSIDE_BEGIN_END(ctx
);
817 FLUSH_VERTICES(ctx
, _NEW_PROGRAM_CONSTANTS
);
819 prog
= _mesa_lookup_program(ctx
, id
);
820 if (!prog
|| prog
->Target
!= GL_FRAGMENT_PROGRAM_NV
) {
821 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glProgramNamedParameterNV");
826 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramNamedParameterNV(len)");
830 fragProg
= (struct gl_fragment_program
*) prog
;
831 v
= _mesa_lookup_parameter_value(fragProg
->Base
.Parameters
, len
,
841 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramNamedParameterNV(name)");
846 _mesa_ProgramNamedParameter4fvNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
849 _mesa_ProgramNamedParameter4fNV(id
, len
, name
, v
[0], v
[1], v
[2], v
[3]);
854 _mesa_ProgramNamedParameter4dNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
855 GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
857 _mesa_ProgramNamedParameter4fNV(id
, len
, name
, (GLfloat
)x
, (GLfloat
)y
,
858 (GLfloat
)z
, (GLfloat
)w
);
863 _mesa_ProgramNamedParameter4dvNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
866 _mesa_ProgramNamedParameter4fNV(id
, len
, name
,
867 (GLfloat
)v
[0], (GLfloat
)v
[1],
868 (GLfloat
)v
[2], (GLfloat
)v
[3]);
873 _mesa_GetProgramNamedParameterfvNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
876 struct gl_program
*prog
;
877 struct gl_fragment_program
*fragProg
;
880 GET_CURRENT_CONTEXT(ctx
);
882 ASSERT_OUTSIDE_BEGIN_END(ctx
);
884 prog
= _mesa_lookup_program(ctx
, id
);
885 if (!prog
|| prog
->Target
!= GL_FRAGMENT_PROGRAM_NV
) {
886 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetProgramNamedParameterNV");
891 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetProgramNamedParameterNV");
895 fragProg
= (struct gl_fragment_program
*) prog
;
896 v
= _mesa_lookup_parameter_value(fragProg
->Base
.Parameters
,
906 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetProgramNamedParameterNV");
911 _mesa_GetProgramNamedParameterdvNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
914 GLfloat floatParams
[4];
915 _mesa_GetProgramNamedParameterfvNV(id
, len
, name
, floatParams
);
916 COPY_4V(params
, floatParams
);