2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2004 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.
46 #include "nvfragparse.h"
47 #include "nvfragprog.h"
48 #include "nvvertexec.h"
49 #include "nvvertparse.h"
50 #include "nvvertprog.h"
51 #include "nvprogram.h"
57 * Execute a vertex state program.
58 * \note Called from the GL API dispatcher.
61 _mesa_ExecuteProgramNV(GLenum target
, GLuint id
, const GLfloat
*params
)
63 struct vertex_program
*vprog
;
64 GET_CURRENT_CONTEXT(ctx
);
65 ASSERT_OUTSIDE_BEGIN_END(ctx
);
67 if (target
!= GL_VERTEX_STATE_PROGRAM_NV
) {
68 _mesa_error(ctx
, GL_INVALID_ENUM
, "glExecuteProgramNV");
72 vprog
= (struct vertex_program
*)
73 _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
75 if (!vprog
|| vprog
->Base
.Target
!= GL_VERTEX_STATE_PROGRAM_NV
) {
76 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glExecuteProgramNV");
80 _mesa_init_vp_registers(ctx
);
81 _mesa_init_tracked_matrices(ctx
);
82 COPY_4V(ctx
->VertexProgram
.Inputs
[VERT_ATTRIB_POS
], params
);
83 _mesa_exec_vertex_program(ctx
, vprog
);
88 * Determine if a set of programs is resident in hardware.
89 * \note Not compiled into display lists.
90 * \note Called from the GL API dispatcher.
92 GLboolean GLAPIENTRY
_mesa_AreProgramsResidentNV(GLsizei n
, const GLuint
*ids
,
93 GLboolean
*residences
)
96 GLboolean allResident
= GL_TRUE
;
97 GET_CURRENT_CONTEXT(ctx
);
98 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
101 _mesa_error(ctx
, GL_INVALID_VALUE
, "glAreProgramsResidentNV(n)");
105 for (i
= 0; i
< n
; i
++) {
106 const struct program
*prog
;
108 _mesa_error(ctx
, GL_INVALID_VALUE
, "glAreProgramsResidentNV");
111 prog
= (const struct program
*)
112 _mesa_HashLookup(ctx
->Shared
->Programs
, ids
[i
]);
114 _mesa_error(ctx
, GL_INVALID_VALUE
, "glAreProgramsResidentNV");
117 if (prog
->Resident
) {
119 residences
[i
] = GL_TRUE
;
123 allResident
= GL_FALSE
;
124 for (j
= 0; j
< i
; j
++)
125 residences
[j
] = GL_TRUE
;
127 residences
[i
] = GL_FALSE
;
136 * Request that a set of programs be resident in hardware.
137 * \note Called from the GL API dispatcher.
140 _mesa_RequestResidentProgramsNV(GLsizei n
, const GLuint
*ids
)
143 GET_CURRENT_CONTEXT(ctx
);
144 ASSERT_OUTSIDE_BEGIN_END(ctx
);
147 _mesa_error(ctx
, GL_INVALID_VALUE
, "glRequestResidentProgramsNV(n)");
151 /* just error checking for now */
152 for (i
= 0; i
< n
; i
++) {
153 struct program
*prog
;
156 _mesa_error(ctx
, GL_INVALID_VALUE
, "glRequestResidentProgramsNV(id)");
160 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, ids
[i
]);
163 _mesa_error(ctx
, GL_INVALID_VALUE
, "glRequestResidentProgramsNV(id)");
167 prog
->Resident
= GL_TRUE
;
173 * Get a program parameter register.
174 * \note Not compiled into display lists.
175 * \note Called from the GL API dispatcher.
178 _mesa_GetProgramParameterfvNV(GLenum target
, GLuint index
,
179 GLenum pname
, GLfloat
*params
)
181 GET_CURRENT_CONTEXT(ctx
);
182 ASSERT_OUTSIDE_BEGIN_END(ctx
);
184 if (target
== GL_VERTEX_PROGRAM_NV
) {
185 if (pname
== GL_PROGRAM_PARAMETER_NV
) {
186 if (index
< MAX_NV_VERTEX_PROGRAM_PARAMS
) {
187 COPY_4V(params
, ctx
->VertexProgram
.Parameters
[index
]);
190 _mesa_error(ctx
, GL_INVALID_VALUE
,
191 "glGetProgramParameterfvNV(index)");
196 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramParameterfvNV(pname)");
201 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramParameterfvNV(target)");
208 * Get a program parameter register.
209 * \note Not compiled into display lists.
210 * \note Called from the GL API dispatcher.
213 _mesa_GetProgramParameterdvNV(GLenum target
, GLuint index
,
214 GLenum pname
, GLdouble
*params
)
216 GET_CURRENT_CONTEXT(ctx
);
217 ASSERT_OUTSIDE_BEGIN_END(ctx
);
219 if (target
== GL_VERTEX_PROGRAM_NV
) {
220 if (pname
== GL_PROGRAM_PARAMETER_NV
) {
221 if (index
< MAX_NV_VERTEX_PROGRAM_PARAMS
) {
222 COPY_4V(params
, ctx
->VertexProgram
.Parameters
[index
]);
225 _mesa_error(ctx
, GL_INVALID_VALUE
,
226 "glGetProgramParameterdvNV(index)");
231 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramParameterdvNV(pname)");
236 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramParameterdvNV(target)");
243 * Get a program attribute.
244 * \note Not compiled into display lists.
245 * \note Called from the GL API dispatcher.
248 _mesa_GetProgramivNV(GLuint id
, GLenum pname
, GLint
*params
)
250 struct program
*prog
;
251 GET_CURRENT_CONTEXT(ctx
);
253 if (!ctx
->_CurrentProgram
)
254 ASSERT_OUTSIDE_BEGIN_END(ctx
);
256 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
258 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetProgramivNV");
263 case GL_PROGRAM_TARGET_NV
:
264 *params
= prog
->Target
;
266 case GL_PROGRAM_LENGTH_NV
:
267 *params
= prog
->String
? _mesa_strlen((char *) prog
->String
) : 0;
269 case GL_PROGRAM_RESIDENT_NV
:
270 *params
= prog
->Resident
;
273 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramivNV(pname)");
280 * Get the program source code.
281 * \note Not compiled into display lists.
282 * \note Called from the GL API dispatcher.
285 _mesa_GetProgramStringNV(GLuint id
, GLenum pname
, GLubyte
*program
)
287 struct program
*prog
;
288 GET_CURRENT_CONTEXT(ctx
);
290 if (!ctx
->_CurrentProgram
)
291 ASSERT_OUTSIDE_BEGIN_END(ctx
);
293 if (pname
!= GL_PROGRAM_STRING_NV
) {
294 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramStringNV(pname)");
298 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
300 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetProgramStringNV");
305 MEMCPY(program
, prog
->String
, _mesa_strlen((char *) prog
->String
));
314 * Get matrix tracking information.
315 * \note Not compiled into display lists.
316 * \note Called from the GL API dispatcher.
319 _mesa_GetTrackMatrixivNV(GLenum target
, GLuint address
,
320 GLenum pname
, GLint
*params
)
322 GET_CURRENT_CONTEXT(ctx
);
323 ASSERT_OUTSIDE_BEGIN_END(ctx
);
325 if (target
== GL_VERTEX_PROGRAM_NV
326 && ctx
->Extensions
.NV_vertex_program
) {
329 if ((address
& 0x3) || address
>= MAX_NV_VERTEX_PROGRAM_PARAMS
) {
330 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetTrackMatrixivNV(address)");
337 case GL_TRACK_MATRIX_NV
:
338 params
[0] = (GLint
) ctx
->VertexProgram
.TrackMatrix
[i
];
340 case GL_TRACK_MATRIX_TRANSFORM_NV
:
341 params
[0] = (GLint
) ctx
->VertexProgram
.TrackMatrixTransform
[i
];
344 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTrackMatrixivNV");
349 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTrackMatrixivNV");
356 * Get a vertex (or vertex array) attribute.
357 * \note Not compiled into display lists.
358 * \note Called from the GL API dispatcher.
361 _mesa_GetVertexAttribdvNV(GLuint index
, GLenum pname
, GLdouble
*params
)
363 GET_CURRENT_CONTEXT(ctx
);
364 ASSERT_OUTSIDE_BEGIN_END(ctx
);
366 if (index
== 0 || index
>= MAX_NV_VERTEX_PROGRAM_INPUTS
) {
367 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribdvNV(index)");
372 case GL_ATTRIB_ARRAY_SIZE_NV
:
373 params
[0] = ctx
->Array
.VertexAttrib
[index
].Size
;
375 case GL_ATTRIB_ARRAY_STRIDE_NV
:
376 params
[0] = ctx
->Array
.VertexAttrib
[index
].Stride
;
378 case GL_ATTRIB_ARRAY_TYPE_NV
:
379 params
[0] = ctx
->Array
.VertexAttrib
[index
].Type
;
381 case GL_CURRENT_ATTRIB_NV
:
382 FLUSH_CURRENT(ctx
, 0);
383 COPY_4V(params
, ctx
->Current
.Attrib
[index
]);
386 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribdvNV");
392 * Get a vertex (or vertex array) attribute.
393 * \note Not compiled into display lists.
394 * \note Called from the GL API dispatcher.
397 _mesa_GetVertexAttribfvNV(GLuint index
, GLenum pname
, GLfloat
*params
)
399 GET_CURRENT_CONTEXT(ctx
);
400 ASSERT_OUTSIDE_BEGIN_END(ctx
);
402 if (index
== 0 || index
>= MAX_NV_VERTEX_PROGRAM_INPUTS
) {
403 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribdvNV(index)");
408 case GL_ATTRIB_ARRAY_SIZE_NV
:
409 params
[0] = (GLfloat
) ctx
->Array
.VertexAttrib
[index
].Size
;
411 case GL_ATTRIB_ARRAY_STRIDE_NV
:
412 params
[0] = (GLfloat
) ctx
->Array
.VertexAttrib
[index
].Stride
;
414 case GL_ATTRIB_ARRAY_TYPE_NV
:
415 params
[0] = (GLfloat
) ctx
->Array
.VertexAttrib
[index
].Type
;
417 case GL_CURRENT_ATTRIB_NV
:
418 FLUSH_CURRENT(ctx
, 0);
419 COPY_4V(params
, ctx
->Current
.Attrib
[index
]);
422 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribdvNV");
428 * Get a vertex (or vertex array) attribute.
429 * \note Not compiled into display lists.
430 * \note Called from the GL API dispatcher.
433 _mesa_GetVertexAttribivNV(GLuint index
, GLenum pname
, GLint
*params
)
435 GET_CURRENT_CONTEXT(ctx
);
436 ASSERT_OUTSIDE_BEGIN_END(ctx
);
438 if (index
== 0 || index
>= MAX_NV_VERTEX_PROGRAM_INPUTS
) {
439 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribdvNV(index)");
444 case GL_ATTRIB_ARRAY_SIZE_NV
:
445 params
[0] = ctx
->Array
.VertexAttrib
[index
].Size
;
447 case GL_ATTRIB_ARRAY_STRIDE_NV
:
448 params
[0] = ctx
->Array
.VertexAttrib
[index
].Stride
;
450 case GL_ATTRIB_ARRAY_TYPE_NV
:
451 params
[0] = ctx
->Array
.VertexAttrib
[index
].Type
;
453 case GL_CURRENT_ATTRIB_NV
:
454 FLUSH_CURRENT(ctx
, 0);
455 params
[0] = (GLint
) ctx
->Current
.Attrib
[index
][0];
456 params
[1] = (GLint
) ctx
->Current
.Attrib
[index
][1];
457 params
[2] = (GLint
) ctx
->Current
.Attrib
[index
][2];
458 params
[3] = (GLint
) ctx
->Current
.Attrib
[index
][3];
460 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB
:
461 if (!ctx
->Extensions
.ARB_vertex_buffer_object
) {
462 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribdvNV");
465 params
[0] = ctx
->Array
.VertexAttrib
[index
].BufferObj
->Name
;
468 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribdvNV");
475 * Get a vertex array attribute pointer.
476 * \note Not compiled into display lists.
477 * \note Called from the GL API dispatcher.
480 _mesa_GetVertexAttribPointervNV(GLuint index
, GLenum pname
, GLvoid
**pointer
)
482 GET_CURRENT_CONTEXT(ctx
);
483 ASSERT_OUTSIDE_BEGIN_END(ctx
);
485 if (index
>= MAX_NV_VERTEX_PROGRAM_INPUTS
) {
486 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribPointerNV(index)");
490 if (pname
!= GL_ATTRIB_ARRAY_POINTER_NV
) {
491 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribPointerNV(pname)");
495 *pointer
= (GLvoid
*) ctx
->Array
.VertexAttrib
[index
].Ptr
;;
501 * Load/parse/compile a program.
502 * \note Called from the GL API dispatcher.
505 _mesa_LoadProgramNV(GLenum target
, GLuint id
, GLsizei len
,
506 const GLubyte
*program
)
508 struct program
*prog
;
509 GET_CURRENT_CONTEXT(ctx
);
510 ASSERT_OUTSIDE_BEGIN_END(ctx
);
513 _mesa_error(ctx
, GL_INVALID_VALUE
, "glLoadProgramNV(id)");
517 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
519 if (prog
&& prog
->Target
!= 0 && prog
->Target
!= target
) {
520 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glLoadProgramNV(target)");
524 if ((target
== GL_VERTEX_PROGRAM_NV
||
525 target
== GL_VERTEX_STATE_PROGRAM_NV
)
526 && ctx
->Extensions
.NV_vertex_program
) {
527 struct vertex_program
*vprog
= (struct vertex_program
*) prog
;
529 vprog
= CALLOC_STRUCT(vertex_program
);
531 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glLoadProgramNV");
534 vprog
->Base
.RefCount
= 1;
535 vprog
->Base
.Resident
= GL_TRUE
;
536 _mesa_HashInsert(ctx
->Shared
->Programs
, id
, vprog
);
538 _mesa_parse_nv_vertex_program(ctx
, target
, program
, len
, vprog
);
540 else if (target
== GL_FRAGMENT_PROGRAM_NV
541 && ctx
->Extensions
.NV_fragment_program
) {
542 struct fragment_program
*fprog
= (struct fragment_program
*) prog
;
544 fprog
= CALLOC_STRUCT(fragment_program
);
546 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glLoadProgramNV");
549 fprog
->Base
.RefCount
= 1;
550 fprog
->Base
.Resident
= GL_TRUE
;
551 _mesa_HashInsert(ctx
->Shared
->Programs
, id
, fprog
);
553 _mesa_parse_nv_fragment_program(ctx
, target
, program
, len
, fprog
);
556 _mesa_error(ctx
, GL_INVALID_ENUM
, "glLoadProgramNV(target)");
563 * Set a program parameter register.
564 * \note Called from the GL API dispatcher.
567 _mesa_ProgramParameter4dNV(GLenum target
, GLuint index
,
568 GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
570 _mesa_ProgramParameter4fNV(target
, index
,
571 (GLfloat
)x
, (GLfloat
)y
, (GLfloat
)z
, (GLfloat
)w
);
576 * Set a program parameter register.
577 * \note Called from the GL API dispatcher.
580 _mesa_ProgramParameter4dvNV(GLenum target
, GLuint index
,
581 const GLdouble
*params
)
583 _mesa_ProgramParameter4fNV(target
, index
,
584 (GLfloat
)params
[0], (GLfloat
)params
[1],
585 (GLfloat
)params
[2], (GLfloat
)params
[3]);
590 * Set a program parameter register.
591 * \note Called from the GL API dispatcher.
594 _mesa_ProgramParameter4fNV(GLenum target
, GLuint index
,
595 GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
597 GET_CURRENT_CONTEXT(ctx
);
598 ASSERT_OUTSIDE_BEGIN_END(ctx
);
600 if (target
== GL_VERTEX_PROGRAM_NV
&& ctx
->Extensions
.NV_vertex_program
) {
601 if (index
< MAX_NV_VERTEX_PROGRAM_PARAMS
) {
602 ASSIGN_4V(ctx
->VertexProgram
.Parameters
[index
], x
, y
, z
, w
);
605 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramParameterNV(index)");
610 _mesa_error(ctx
, GL_INVALID_ENUM
, "glProgramParameterNV");
617 * Set a program parameter register.
618 * \note Called from the GL API dispatcher.
621 _mesa_ProgramParameter4fvNV(GLenum target
, GLuint index
,
622 const GLfloat
*params
)
624 _mesa_ProgramParameter4fNV(target
, index
,
625 params
[0], params
[1], params
[2], params
[3]);
631 * Set a sequence of program parameter registers.
632 * \note Called from the GL API dispatcher.
635 _mesa_ProgramParameters4dvNV(GLenum target
, GLuint index
,
636 GLuint num
, const GLdouble
*params
)
638 GET_CURRENT_CONTEXT(ctx
);
639 ASSERT_OUTSIDE_BEGIN_END(ctx
);
641 if (target
== GL_VERTEX_PROGRAM_NV
&& ctx
->Extensions
.NV_vertex_program
) {
643 if (index
+ num
> MAX_NV_VERTEX_PROGRAM_PARAMS
) {
644 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramParameters4dvNV");
647 for (i
= 0; i
< num
; i
++) {
648 ctx
->VertexProgram
.Parameters
[index
+ i
][0] = (GLfloat
) params
[0];
649 ctx
->VertexProgram
.Parameters
[index
+ i
][1] = (GLfloat
) params
[1];
650 ctx
->VertexProgram
.Parameters
[index
+ i
][2] = (GLfloat
) params
[2];
651 ctx
->VertexProgram
.Parameters
[index
+ i
][3] = (GLfloat
) params
[3];
656 _mesa_error(ctx
, GL_INVALID_ENUM
, "glProgramParameters4dvNV");
663 * Set a sequence of program parameter registers.
664 * \note Called from the GL API dispatcher.
667 _mesa_ProgramParameters4fvNV(GLenum target
, GLuint index
,
668 GLuint num
, const GLfloat
*params
)
670 GET_CURRENT_CONTEXT(ctx
);
671 ASSERT_OUTSIDE_BEGIN_END(ctx
);
673 if (target
== GL_VERTEX_PROGRAM_NV
&& ctx
->Extensions
.NV_vertex_program
) {
675 if (index
+ num
> MAX_NV_VERTEX_PROGRAM_PARAMS
) {
676 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramParameters4fvNV");
679 for (i
= 0; i
< num
; i
++) {
680 COPY_4V(ctx
->VertexProgram
.Parameters
[index
+ i
], params
);
685 _mesa_error(ctx
, GL_INVALID_ENUM
, "glProgramParameters4fvNV");
693 * Setup tracking of matrices into program parameter registers.
694 * \note Called from the GL API dispatcher.
697 _mesa_TrackMatrixNV(GLenum target
, GLuint address
,
698 GLenum matrix
, GLenum transform
)
700 GET_CURRENT_CONTEXT(ctx
);
701 ASSERT_OUTSIDE_BEGIN_END(ctx
);
703 if (target
== GL_VERTEX_PROGRAM_NV
&& ctx
->Extensions
.NV_vertex_program
) {
705 /* addr must be multiple of four */
706 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTrackMatrixNV(address)");
716 case GL_MODELVIEW_PROJECTION_NV
:
725 /* OK, fallthrough */
728 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTrackMatrixNV(matrix)");
735 case GL_TRANSPOSE_NV
:
736 case GL_INVERSE_TRANSPOSE_NV
:
737 /* OK, fallthrough */
740 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTrackMatrixNV(transform)");
744 ctx
->VertexProgram
.TrackMatrix
[address
/ 4] = matrix
;
745 ctx
->VertexProgram
.TrackMatrixTransform
[address
/ 4] = transform
;
748 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTrackMatrixNV(target)");
755 _mesa_ProgramNamedParameter4fNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
756 GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
758 struct program
*prog
;
759 struct fragment_program
*fragProg
;
762 GET_CURRENT_CONTEXT(ctx
);
763 ASSERT_OUTSIDE_BEGIN_END(ctx
);
765 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
766 if (!prog
|| prog
->Target
!= GL_FRAGMENT_PROGRAM_NV
) {
767 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glProgramNamedParameterNV");
772 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramNamedParameterNV");
776 fragProg
= (struct fragment_program
*) prog
;
777 v
= _mesa_lookup_parameter_value(fragProg
->Parameters
, len
, (char *) name
);
786 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramNamedParameterNV");
791 _mesa_ProgramNamedParameter4fvNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
794 _mesa_ProgramNamedParameter4fNV(id
, len
, name
, v
[0], v
[1], v
[2], v
[3]);
799 _mesa_ProgramNamedParameter4dNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
800 GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
802 _mesa_ProgramNamedParameter4fNV(id
, len
, name
, (GLfloat
)x
, (GLfloat
)y
,
803 (GLfloat
)z
, (GLfloat
)w
);
808 _mesa_ProgramNamedParameter4dvNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
811 _mesa_ProgramNamedParameter4fNV(id
, len
, name
,
812 (GLfloat
)v
[0], (GLfloat
)v
[1],
813 (GLfloat
)v
[2], (GLfloat
)v
[3]);
818 _mesa_GetProgramNamedParameterfvNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
821 struct program
*prog
;
822 struct fragment_program
*fragProg
;
825 GET_CURRENT_CONTEXT(ctx
);
827 if (!ctx
->_CurrentProgram
)
828 ASSERT_OUTSIDE_BEGIN_END(ctx
);
830 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
831 if (!prog
|| prog
->Target
!= GL_FRAGMENT_PROGRAM_NV
) {
832 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetProgramNamedParameterNV");
837 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetProgramNamedParameterNV");
841 fragProg
= (struct fragment_program
*) prog
;
842 v
= _mesa_lookup_parameter_value(fragProg
->Parameters
, len
, (char *) name
);
851 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetProgramNamedParameterNV");
856 _mesa_GetProgramNamedParameterdvNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
859 GLfloat floatParams
[4];
860 _mesa_GetProgramNamedParameterfvNV(id
, len
, name
, floatParams
);
861 COPY_4V(params
, floatParams
);