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 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
74 vprog
= (struct vertex_program
*)
75 _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
77 if (!vprog
|| vprog
->Base
.Target
!= GL_VERTEX_STATE_PROGRAM_NV
) {
78 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glExecuteProgramNV");
82 _mesa_init_vp_per_vertex_registers(ctx
);
83 _mesa_init_vp_per_primitive_registers(ctx
);
84 COPY_4V(ctx
->VertexProgram
.Inputs
[VERT_ATTRIB_POS
], params
);
85 _mesa_exec_vertex_program(ctx
, vprog
);
90 * Determine if a set of programs is resident in hardware.
91 * \note Not compiled into display lists.
92 * \note Called from the GL API dispatcher.
94 GLboolean GLAPIENTRY
_mesa_AreProgramsResidentNV(GLsizei n
, const GLuint
*ids
,
95 GLboolean
*residences
)
98 GLboolean allResident
= GL_TRUE
;
99 GET_CURRENT_CONTEXT(ctx
);
100 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
103 _mesa_error(ctx
, GL_INVALID_VALUE
, "glAreProgramsResidentNV(n)");
107 for (i
= 0; i
< n
; i
++) {
108 const struct program
*prog
;
110 _mesa_error(ctx
, GL_INVALID_VALUE
, "glAreProgramsResidentNV");
113 prog
= (const struct program
*)
114 _mesa_HashLookup(ctx
->Shared
->Programs
, ids
[i
]);
116 _mesa_error(ctx
, GL_INVALID_VALUE
, "glAreProgramsResidentNV");
119 if (prog
->Resident
) {
121 residences
[i
] = GL_TRUE
;
125 allResident
= GL_FALSE
;
126 for (j
= 0; j
< i
; j
++)
127 residences
[j
] = GL_TRUE
;
129 residences
[i
] = GL_FALSE
;
138 * Request that a set of programs be resident in hardware.
139 * \note Called from the GL API dispatcher.
142 _mesa_RequestResidentProgramsNV(GLsizei n
, const GLuint
*ids
)
145 GET_CURRENT_CONTEXT(ctx
);
146 ASSERT_OUTSIDE_BEGIN_END(ctx
);
149 _mesa_error(ctx
, GL_INVALID_VALUE
, "glRequestResidentProgramsNV(n)");
153 /* just error checking for now */
154 for (i
= 0; i
< n
; i
++) {
155 struct program
*prog
;
158 _mesa_error(ctx
, GL_INVALID_VALUE
, "glRequestResidentProgramsNV(id)");
162 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, ids
[i
]);
165 _mesa_error(ctx
, GL_INVALID_VALUE
, "glRequestResidentProgramsNV(id)");
169 prog
->Resident
= GL_TRUE
;
175 * Get a program parameter register.
176 * \note Not compiled into display lists.
177 * \note Called from the GL API dispatcher.
180 _mesa_GetProgramParameterfvNV(GLenum target
, GLuint index
,
181 GLenum pname
, GLfloat
*params
)
183 GET_CURRENT_CONTEXT(ctx
);
184 ASSERT_OUTSIDE_BEGIN_END(ctx
);
186 if (target
== GL_VERTEX_PROGRAM_NV
) {
187 if (pname
== GL_PROGRAM_PARAMETER_NV
) {
188 if (index
< MAX_NV_VERTEX_PROGRAM_PARAMS
) {
189 COPY_4V(params
, ctx
->VertexProgram
.Parameters
[index
]);
192 _mesa_error(ctx
, GL_INVALID_VALUE
,
193 "glGetProgramParameterfvNV(index)");
198 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramParameterfvNV(pname)");
203 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramParameterfvNV(target)");
210 * Get a program parameter register.
211 * \note Not compiled into display lists.
212 * \note Called from the GL API dispatcher.
215 _mesa_GetProgramParameterdvNV(GLenum target
, GLuint index
,
216 GLenum pname
, GLdouble
*params
)
218 GET_CURRENT_CONTEXT(ctx
);
219 ASSERT_OUTSIDE_BEGIN_END(ctx
);
221 if (target
== GL_VERTEX_PROGRAM_NV
) {
222 if (pname
== GL_PROGRAM_PARAMETER_NV
) {
223 if (index
< MAX_NV_VERTEX_PROGRAM_PARAMS
) {
224 COPY_4V(params
, ctx
->VertexProgram
.Parameters
[index
]);
227 _mesa_error(ctx
, GL_INVALID_VALUE
,
228 "glGetProgramParameterdvNV(index)");
233 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramParameterdvNV(pname)");
238 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramParameterdvNV(target)");
245 * Get a program attribute.
246 * \note Not compiled into display lists.
247 * \note Called from the GL API dispatcher.
250 _mesa_GetProgramivNV(GLuint id
, GLenum pname
, GLint
*params
)
252 struct program
*prog
;
253 GET_CURRENT_CONTEXT(ctx
);
255 if (!ctx
->_CurrentProgram
)
256 ASSERT_OUTSIDE_BEGIN_END(ctx
);
258 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
260 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetProgramivNV");
265 case GL_PROGRAM_TARGET_NV
:
266 *params
= prog
->Target
;
268 case GL_PROGRAM_LENGTH_NV
:
269 *params
= prog
->String
? _mesa_strlen((char *) prog
->String
) : 0;
271 case GL_PROGRAM_RESIDENT_NV
:
272 *params
= prog
->Resident
;
275 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramivNV(pname)");
282 * Get the program source code.
283 * \note Not compiled into display lists.
284 * \note Called from the GL API dispatcher.
287 _mesa_GetProgramStringNV(GLuint id
, GLenum pname
, GLubyte
*program
)
289 struct program
*prog
;
290 GET_CURRENT_CONTEXT(ctx
);
292 if (!ctx
->_CurrentProgram
)
293 ASSERT_OUTSIDE_BEGIN_END(ctx
);
295 if (pname
!= GL_PROGRAM_STRING_NV
) {
296 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramStringNV(pname)");
300 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
302 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetProgramStringNV");
307 MEMCPY(program
, prog
->String
, _mesa_strlen((char *) prog
->String
));
316 * Get matrix tracking information.
317 * \note Not compiled into display lists.
318 * \note Called from the GL API dispatcher.
321 _mesa_GetTrackMatrixivNV(GLenum target
, GLuint address
,
322 GLenum pname
, GLint
*params
)
324 GET_CURRENT_CONTEXT(ctx
);
325 ASSERT_OUTSIDE_BEGIN_END(ctx
);
327 if (target
== GL_VERTEX_PROGRAM_NV
328 && ctx
->Extensions
.NV_vertex_program
) {
331 if ((address
& 0x3) || address
>= MAX_NV_VERTEX_PROGRAM_PARAMS
) {
332 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetTrackMatrixivNV(address)");
339 case GL_TRACK_MATRIX_NV
:
340 params
[0] = (GLint
) ctx
->VertexProgram
.TrackMatrix
[i
];
342 case GL_TRACK_MATRIX_TRANSFORM_NV
:
343 params
[0] = (GLint
) ctx
->VertexProgram
.TrackMatrixTransform
[i
];
346 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTrackMatrixivNV");
351 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTrackMatrixivNV");
358 * Get a vertex (or vertex array) attribute.
359 * \note Not compiled into display lists.
360 * \note Called from the GL API dispatcher.
363 _mesa_GetVertexAttribdvNV(GLuint index
, GLenum pname
, GLdouble
*params
)
365 GET_CURRENT_CONTEXT(ctx
);
366 ASSERT_OUTSIDE_BEGIN_END(ctx
);
368 if (index
== 0 || index
>= MAX_NV_VERTEX_PROGRAM_INPUTS
) {
369 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribdvNV(index)");
374 case GL_ATTRIB_ARRAY_SIZE_NV
:
375 params
[0] = ctx
->Array
.VertexAttrib
[index
].Size
;
377 case GL_ATTRIB_ARRAY_STRIDE_NV
:
378 params
[0] = ctx
->Array
.VertexAttrib
[index
].Stride
;
380 case GL_ATTRIB_ARRAY_TYPE_NV
:
381 params
[0] = ctx
->Array
.VertexAttrib
[index
].Type
;
383 case GL_CURRENT_ATTRIB_NV
:
384 FLUSH_CURRENT(ctx
, 0);
385 COPY_4V(params
, ctx
->Current
.Attrib
[index
]);
388 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribdvNV");
394 * Get a vertex (or vertex array) attribute.
395 * \note Not compiled into display lists.
396 * \note Called from the GL API dispatcher.
399 _mesa_GetVertexAttribfvNV(GLuint index
, GLenum pname
, GLfloat
*params
)
401 GET_CURRENT_CONTEXT(ctx
);
402 ASSERT_OUTSIDE_BEGIN_END(ctx
);
404 if (index
== 0 || index
>= MAX_NV_VERTEX_PROGRAM_INPUTS
) {
405 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribdvNV(index)");
410 case GL_ATTRIB_ARRAY_SIZE_NV
:
411 params
[0] = (GLfloat
) ctx
->Array
.VertexAttrib
[index
].Size
;
413 case GL_ATTRIB_ARRAY_STRIDE_NV
:
414 params
[0] = (GLfloat
) ctx
->Array
.VertexAttrib
[index
].Stride
;
416 case GL_ATTRIB_ARRAY_TYPE_NV
:
417 params
[0] = (GLfloat
) ctx
->Array
.VertexAttrib
[index
].Type
;
419 case GL_CURRENT_ATTRIB_NV
:
420 FLUSH_CURRENT(ctx
, 0);
421 COPY_4V(params
, ctx
->Current
.Attrib
[index
]);
424 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribdvNV");
430 * Get a vertex (or vertex array) attribute.
431 * \note Not compiled into display lists.
432 * \note Called from the GL API dispatcher.
435 _mesa_GetVertexAttribivNV(GLuint index
, GLenum pname
, GLint
*params
)
437 GET_CURRENT_CONTEXT(ctx
);
438 ASSERT_OUTSIDE_BEGIN_END(ctx
);
440 if (index
== 0 || index
>= MAX_NV_VERTEX_PROGRAM_INPUTS
) {
441 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribdvNV(index)");
446 case GL_ATTRIB_ARRAY_SIZE_NV
:
447 params
[0] = ctx
->Array
.VertexAttrib
[index
].Size
;
449 case GL_ATTRIB_ARRAY_STRIDE_NV
:
450 params
[0] = ctx
->Array
.VertexAttrib
[index
].Stride
;
452 case GL_ATTRIB_ARRAY_TYPE_NV
:
453 params
[0] = ctx
->Array
.VertexAttrib
[index
].Type
;
455 case GL_CURRENT_ATTRIB_NV
:
456 FLUSH_CURRENT(ctx
, 0);
457 params
[0] = (GLint
) ctx
->Current
.Attrib
[index
][0];
458 params
[1] = (GLint
) ctx
->Current
.Attrib
[index
][1];
459 params
[2] = (GLint
) ctx
->Current
.Attrib
[index
][2];
460 params
[3] = (GLint
) ctx
->Current
.Attrib
[index
][3];
462 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB
:
463 if (!ctx
->Extensions
.ARB_vertex_buffer_object
) {
464 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribdvNV");
467 params
[0] = ctx
->Array
.VertexAttrib
[index
].BufferObj
->Name
;
470 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribdvNV");
477 * Get a vertex array attribute pointer.
478 * \note Not compiled into display lists.
479 * \note Called from the GL API dispatcher.
482 _mesa_GetVertexAttribPointervNV(GLuint index
, GLenum pname
, GLvoid
**pointer
)
484 GET_CURRENT_CONTEXT(ctx
);
485 ASSERT_OUTSIDE_BEGIN_END(ctx
);
487 if (index
>= MAX_NV_VERTEX_PROGRAM_INPUTS
) {
488 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribPointerNV(index)");
492 if (pname
!= GL_ATTRIB_ARRAY_POINTER_NV
) {
493 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribPointerNV(pname)");
497 *pointer
= (GLvoid
*) ctx
->Array
.VertexAttrib
[index
].Ptr
;;
503 * Load/parse/compile a program.
504 * \note Called from the GL API dispatcher.
507 _mesa_LoadProgramNV(GLenum target
, GLuint id
, GLsizei len
,
508 const GLubyte
*program
)
510 struct program
*prog
;
511 GET_CURRENT_CONTEXT(ctx
);
512 ASSERT_OUTSIDE_BEGIN_END(ctx
);
515 _mesa_error(ctx
, GL_INVALID_VALUE
, "glLoadProgramNV(id)");
519 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
521 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
523 if (prog
&& prog
->Target
!= 0 && prog
->Target
!= target
) {
524 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glLoadProgramNV(target)");
528 if ((target
== GL_VERTEX_PROGRAM_NV
||
529 target
== GL_VERTEX_STATE_PROGRAM_NV
)
530 && ctx
->Extensions
.NV_vertex_program
) {
531 struct vertex_program
*vprog
= (struct vertex_program
*) prog
;
533 vprog
= CALLOC_STRUCT(vertex_program
);
535 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glLoadProgramNV");
538 vprog
->Base
.RefCount
= 1;
539 vprog
->Base
.Resident
= GL_TRUE
;
540 _mesa_HashInsert(ctx
->Shared
->Programs
, id
, vprog
);
542 _mesa_parse_nv_vertex_program(ctx
, target
, program
, len
, vprog
);
544 else if (target
== GL_FRAGMENT_PROGRAM_NV
545 && ctx
->Extensions
.NV_fragment_program
) {
546 struct fragment_program
*fprog
= (struct fragment_program
*) prog
;
548 fprog
= CALLOC_STRUCT(fragment_program
);
550 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glLoadProgramNV");
553 fprog
->Base
.RefCount
= 1;
554 fprog
->Base
.Resident
= GL_TRUE
;
555 _mesa_HashInsert(ctx
->Shared
->Programs
, id
, fprog
);
557 _mesa_parse_nv_fragment_program(ctx
, target
, program
, len
, fprog
);
560 _mesa_error(ctx
, GL_INVALID_ENUM
, "glLoadProgramNV(target)");
567 * Set a program parameter register.
568 * \note Called from the GL API dispatcher.
571 _mesa_ProgramParameter4dNV(GLenum target
, GLuint index
,
572 GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
574 _mesa_ProgramParameter4fNV(target
, index
,
575 (GLfloat
)x
, (GLfloat
)y
, (GLfloat
)z
, (GLfloat
)w
);
580 * Set a program parameter register.
581 * \note Called from the GL API dispatcher.
584 _mesa_ProgramParameter4dvNV(GLenum target
, GLuint index
,
585 const GLdouble
*params
)
587 _mesa_ProgramParameter4fNV(target
, index
,
588 (GLfloat
)params
[0], (GLfloat
)params
[1],
589 (GLfloat
)params
[2], (GLfloat
)params
[3]);
594 * Set a program parameter register.
595 * \note Called from the GL API dispatcher.
598 _mesa_ProgramParameter4fNV(GLenum target
, GLuint index
,
599 GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
601 GET_CURRENT_CONTEXT(ctx
);
602 ASSERT_OUTSIDE_BEGIN_END(ctx
);
604 if (target
== GL_VERTEX_PROGRAM_NV
&& ctx
->Extensions
.NV_vertex_program
) {
605 if (index
< MAX_NV_VERTEX_PROGRAM_PARAMS
) {
606 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
607 ASSIGN_4V(ctx
->VertexProgram
.Parameters
[index
], x
, y
, z
, w
);
610 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramParameterNV(index)");
615 _mesa_error(ctx
, GL_INVALID_ENUM
, "glProgramParameterNV");
622 * Set a program parameter register.
623 * \note Called from the GL API dispatcher.
626 _mesa_ProgramParameter4fvNV(GLenum target
, GLuint index
,
627 const GLfloat
*params
)
629 _mesa_ProgramParameter4fNV(target
, index
,
630 params
[0], params
[1], params
[2], params
[3]);
636 * Set a sequence of program parameter registers.
637 * \note Called from the GL API dispatcher.
640 _mesa_ProgramParameters4dvNV(GLenum target
, GLuint index
,
641 GLuint num
, const GLdouble
*params
)
643 GET_CURRENT_CONTEXT(ctx
);
644 ASSERT_OUTSIDE_BEGIN_END(ctx
);
646 if (target
== GL_VERTEX_PROGRAM_NV
&& ctx
->Extensions
.NV_vertex_program
) {
648 if (index
+ num
> MAX_NV_VERTEX_PROGRAM_PARAMS
) {
649 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramParameters4dvNV");
652 for (i
= 0; i
< num
; i
++) {
653 ctx
->VertexProgram
.Parameters
[index
+ i
][0] = (GLfloat
) params
[0];
654 ctx
->VertexProgram
.Parameters
[index
+ i
][1] = (GLfloat
) params
[1];
655 ctx
->VertexProgram
.Parameters
[index
+ i
][2] = (GLfloat
) params
[2];
656 ctx
->VertexProgram
.Parameters
[index
+ i
][3] = (GLfloat
) params
[3];
661 _mesa_error(ctx
, GL_INVALID_ENUM
, "glProgramParameters4dvNV");
668 * Set a sequence of program parameter registers.
669 * \note Called from the GL API dispatcher.
672 _mesa_ProgramParameters4fvNV(GLenum target
, GLuint index
,
673 GLuint num
, const GLfloat
*params
)
675 GET_CURRENT_CONTEXT(ctx
);
676 ASSERT_OUTSIDE_BEGIN_END(ctx
);
678 if (target
== GL_VERTEX_PROGRAM_NV
&& ctx
->Extensions
.NV_vertex_program
) {
680 if (index
+ num
> MAX_NV_VERTEX_PROGRAM_PARAMS
) {
681 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramParameters4fvNV");
684 for (i
= 0; i
< num
; i
++) {
685 COPY_4V(ctx
->VertexProgram
.Parameters
[index
+ i
], params
);
690 _mesa_error(ctx
, GL_INVALID_ENUM
, "glProgramParameters4fvNV");
698 * Setup tracking of matrices into program parameter registers.
699 * \note Called from the GL API dispatcher.
702 _mesa_TrackMatrixNV(GLenum target
, GLuint address
,
703 GLenum matrix
, GLenum transform
)
705 GET_CURRENT_CONTEXT(ctx
);
706 ASSERT_OUTSIDE_BEGIN_END(ctx
);
708 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
710 if (target
== GL_VERTEX_PROGRAM_NV
&& ctx
->Extensions
.NV_vertex_program
) {
712 /* addr must be multiple of four */
713 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTrackMatrixNV(address)");
723 case GL_MODELVIEW_PROJECTION_NV
:
732 /* OK, fallthrough */
735 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTrackMatrixNV(matrix)");
742 case GL_TRANSPOSE_NV
:
743 case GL_INVERSE_TRANSPOSE_NV
:
744 /* OK, fallthrough */
747 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTrackMatrixNV(transform)");
751 ctx
->VertexProgram
.TrackMatrix
[address
/ 4] = matrix
;
752 ctx
->VertexProgram
.TrackMatrixTransform
[address
/ 4] = transform
;
755 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTrackMatrixNV(target)");
762 _mesa_ProgramNamedParameter4fNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
763 GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
765 struct program
*prog
;
766 struct fragment_program
*fragProg
;
769 GET_CURRENT_CONTEXT(ctx
);
770 ASSERT_OUTSIDE_BEGIN_END(ctx
);
772 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
774 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
775 if (!prog
|| prog
->Target
!= GL_FRAGMENT_PROGRAM_NV
) {
776 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glProgramNamedParameterNV");
781 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramNamedParameterNV");
785 fragProg
= (struct fragment_program
*) prog
;
786 v
= _mesa_lookup_parameter_value(fragProg
->Parameters
, len
, (char *) name
);
795 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramNamedParameterNV");
800 _mesa_ProgramNamedParameter4fvNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
803 _mesa_ProgramNamedParameter4fNV(id
, len
, name
, v
[0], v
[1], v
[2], v
[3]);
808 _mesa_ProgramNamedParameter4dNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
809 GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
811 _mesa_ProgramNamedParameter4fNV(id
, len
, name
, (GLfloat
)x
, (GLfloat
)y
,
812 (GLfloat
)z
, (GLfloat
)w
);
817 _mesa_ProgramNamedParameter4dvNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
820 _mesa_ProgramNamedParameter4fNV(id
, len
, name
,
821 (GLfloat
)v
[0], (GLfloat
)v
[1],
822 (GLfloat
)v
[2], (GLfloat
)v
[3]);
827 _mesa_GetProgramNamedParameterfvNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
830 struct program
*prog
;
831 struct fragment_program
*fragProg
;
834 GET_CURRENT_CONTEXT(ctx
);
836 if (!ctx
->_CurrentProgram
)
837 ASSERT_OUTSIDE_BEGIN_END(ctx
);
839 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
840 if (!prog
|| prog
->Target
!= GL_FRAGMENT_PROGRAM_NV
) {
841 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetProgramNamedParameterNV");
846 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetProgramNamedParameterNV");
850 fragProg
= (struct fragment_program
*) prog
;
851 v
= _mesa_lookup_parameter_value(fragProg
->Parameters
, len
, (char *) name
);
860 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetProgramNamedParameterNV");
865 _mesa_GetProgramNamedParameterdvNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
868 GLfloat floatParams
[4];
869 _mesa_GetProgramNamedParameterfvNV(id
, len
, name
, floatParams
);
870 COPY_4V(params
, floatParams
);