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 "program_instruction.h"
48 #include "nvvertexec.h"
49 #include "nvvertparse.h"
50 #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 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 vertex_program
*)
74 _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
76 if (!vprog
|| vprog
->Base
.Target
!= GL_VERTEX_STATE_PROGRAM_NV
) {
77 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glExecuteProgramNV");
81 _mesa_init_vp_per_vertex_registers(ctx
);
82 _mesa_init_vp_per_primitive_registers(ctx
);
83 COPY_4V(ctx
->VertexProgram
.Inputs
[VERT_ATTRIB_POS
], params
);
84 _mesa_exec_vertex_program(ctx
, vprog
);
89 * Determine if a set of programs is resident in hardware.
90 * \note Not compiled into display lists.
91 * \note Called from the GL API dispatcher.
93 GLboolean GLAPIENTRY
_mesa_AreProgramsResidentNV(GLsizei n
, const GLuint
*ids
,
94 GLboolean
*residences
)
97 GLboolean allResident
= GL_TRUE
;
98 GET_CURRENT_CONTEXT(ctx
);
99 ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx
, GL_FALSE
);
102 _mesa_error(ctx
, GL_INVALID_VALUE
, "glAreProgramsResidentNV(n)");
106 for (i
= 0; i
< n
; i
++) {
107 const struct program
*prog
;
109 _mesa_error(ctx
, GL_INVALID_VALUE
, "glAreProgramsResidentNV");
112 prog
= (const struct program
*)
113 _mesa_HashLookup(ctx
->Shared
->Programs
, ids
[i
]);
115 _mesa_error(ctx
, GL_INVALID_VALUE
, "glAreProgramsResidentNV");
118 if (prog
->Resident
) {
120 residences
[i
] = GL_TRUE
;
124 allResident
= GL_FALSE
;
125 for (j
= 0; j
< i
; j
++)
126 residences
[j
] = GL_TRUE
;
128 residences
[i
] = GL_FALSE
;
137 * Request that a set of programs be resident in hardware.
138 * \note Called from the GL API dispatcher.
141 _mesa_RequestResidentProgramsNV(GLsizei n
, const GLuint
*ids
)
144 GET_CURRENT_CONTEXT(ctx
);
145 ASSERT_OUTSIDE_BEGIN_END(ctx
);
148 _mesa_error(ctx
, GL_INVALID_VALUE
, "glRequestResidentProgramsNV(n)");
152 /* just error checking for now */
153 for (i
= 0; i
< n
; i
++) {
154 struct program
*prog
;
157 _mesa_error(ctx
, GL_INVALID_VALUE
, "glRequestResidentProgramsNV(id)");
161 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, ids
[i
]);
163 _mesa_error(ctx
, GL_INVALID_VALUE
, "glRequestResidentProgramsNV(id)");
167 /* XXX this is really a hardware thing we should hook out */
168 prog
->Resident
= GL_TRUE
;
174 * Get a program parameter register.
175 * \note Not compiled into display lists.
176 * \note Called from the GL API dispatcher.
179 _mesa_GetProgramParameterfvNV(GLenum target
, GLuint index
,
180 GLenum pname
, GLfloat
*params
)
182 GET_CURRENT_CONTEXT(ctx
);
183 ASSERT_OUTSIDE_BEGIN_END(ctx
);
185 if (target
== GL_VERTEX_PROGRAM_NV
) {
186 if (pname
== GL_PROGRAM_PARAMETER_NV
) {
187 if (index
< MAX_NV_VERTEX_PROGRAM_PARAMS
) {
188 COPY_4V(params
, ctx
->VertexProgram
.Parameters
[index
]);
191 _mesa_error(ctx
, GL_INVALID_VALUE
,
192 "glGetProgramParameterfvNV(index)");
197 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramParameterfvNV(pname)");
202 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramParameterfvNV(target)");
209 * Get a program parameter register.
210 * \note Not compiled into display lists.
211 * \note Called from the GL API dispatcher.
214 _mesa_GetProgramParameterdvNV(GLenum target
, GLuint index
,
215 GLenum pname
, GLdouble
*params
)
217 GET_CURRENT_CONTEXT(ctx
);
218 ASSERT_OUTSIDE_BEGIN_END(ctx
);
220 if (target
== GL_VERTEX_PROGRAM_NV
) {
221 if (pname
== GL_PROGRAM_PARAMETER_NV
) {
222 if (index
< MAX_NV_VERTEX_PROGRAM_PARAMS
) {
223 COPY_4V(params
, ctx
->VertexProgram
.Parameters
[index
]);
226 _mesa_error(ctx
, GL_INVALID_VALUE
,
227 "glGetProgramParameterdvNV(index)");
232 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramParameterdvNV(pname)");
237 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramParameterdvNV(target)");
244 * Get a program attribute.
245 * \note Not compiled into display lists.
246 * \note Called from the GL API dispatcher.
249 _mesa_GetProgramivNV(GLuint id
, GLenum pname
, GLint
*params
)
251 struct program
*prog
;
252 GET_CURRENT_CONTEXT(ctx
);
254 if (!ctx
->_CurrentProgram
)
255 ASSERT_OUTSIDE_BEGIN_END(ctx
);
257 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
259 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetProgramivNV");
264 case GL_PROGRAM_TARGET_NV
:
265 *params
= prog
->Target
;
267 case GL_PROGRAM_LENGTH_NV
:
268 *params
= prog
->String
?(GLint
)_mesa_strlen((char *) prog
->String
) : 0;
270 case GL_PROGRAM_RESIDENT_NV
:
271 *params
= prog
->Resident
;
274 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramivNV(pname)");
281 * Get the program source code.
282 * \note Not compiled into display lists.
283 * \note Called from the GL API dispatcher.
286 _mesa_GetProgramStringNV(GLuint id
, GLenum pname
, GLubyte
*program
)
288 struct program
*prog
;
289 GET_CURRENT_CONTEXT(ctx
);
291 if (!ctx
->_CurrentProgram
)
292 ASSERT_OUTSIDE_BEGIN_END(ctx
);
294 if (pname
!= GL_PROGRAM_STRING_NV
) {
295 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramStringNV(pname)");
299 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
301 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetProgramStringNV");
306 MEMCPY(program
, prog
->String
, _mesa_strlen((char *) prog
->String
));
315 * Get matrix tracking information.
316 * \note Not compiled into display lists.
317 * \note Called from the GL API dispatcher.
320 _mesa_GetTrackMatrixivNV(GLenum target
, GLuint address
,
321 GLenum pname
, GLint
*params
)
323 GET_CURRENT_CONTEXT(ctx
);
324 ASSERT_OUTSIDE_BEGIN_END(ctx
);
326 if (target
== GL_VERTEX_PROGRAM_NV
327 && ctx
->Extensions
.NV_vertex_program
) {
330 if ((address
& 0x3) || address
>= MAX_NV_VERTEX_PROGRAM_PARAMS
) {
331 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetTrackMatrixivNV(address)");
338 case GL_TRACK_MATRIX_NV
:
339 params
[0] = (GLint
) ctx
->VertexProgram
.TrackMatrix
[i
];
341 case GL_TRACK_MATRIX_TRANSFORM_NV
:
342 params
[0] = (GLint
) ctx
->VertexProgram
.TrackMatrixTransform
[i
];
345 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTrackMatrixivNV");
350 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetTrackMatrixivNV");
357 * Get a vertex (or vertex array) attribute.
358 * \note Not compiled into display lists.
359 * \note Called from the GL API dispatcher.
362 _mesa_GetVertexAttribdvNV(GLuint index
, GLenum pname
, GLdouble
*params
)
364 GET_CURRENT_CONTEXT(ctx
);
365 ASSERT_OUTSIDE_BEGIN_END(ctx
);
367 if (index
== 0 || index
>= MAX_NV_VERTEX_PROGRAM_INPUTS
) {
368 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribdvNV(index)");
373 case GL_ATTRIB_ARRAY_SIZE_NV
:
374 params
[0] = ctx
->Array
.VertexAttrib
[index
].Size
;
376 case GL_ATTRIB_ARRAY_STRIDE_NV
:
377 params
[0] = ctx
->Array
.VertexAttrib
[index
].Stride
;
379 case GL_ATTRIB_ARRAY_TYPE_NV
:
380 params
[0] = ctx
->Array
.VertexAttrib
[index
].Type
;
382 case GL_CURRENT_ATTRIB_NV
:
383 FLUSH_CURRENT(ctx
, 0);
384 COPY_4V(params
, ctx
->Current
.Attrib
[index
]);
387 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribdvNV");
393 * Get a vertex (or vertex array) attribute.
394 * \note Not compiled into display lists.
395 * \note Called from the GL API dispatcher.
398 _mesa_GetVertexAttribfvNV(GLuint index
, GLenum pname
, GLfloat
*params
)
400 GET_CURRENT_CONTEXT(ctx
);
401 ASSERT_OUTSIDE_BEGIN_END(ctx
);
403 if (index
== 0 || index
>= MAX_NV_VERTEX_PROGRAM_INPUTS
) {
404 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribdvNV(index)");
409 case GL_ATTRIB_ARRAY_SIZE_NV
:
410 params
[0] = (GLfloat
) ctx
->Array
.VertexAttrib
[index
].Size
;
412 case GL_ATTRIB_ARRAY_STRIDE_NV
:
413 params
[0] = (GLfloat
) ctx
->Array
.VertexAttrib
[index
].Stride
;
415 case GL_ATTRIB_ARRAY_TYPE_NV
:
416 params
[0] = (GLfloat
) ctx
->Array
.VertexAttrib
[index
].Type
;
418 case GL_CURRENT_ATTRIB_NV
:
419 FLUSH_CURRENT(ctx
, 0);
420 COPY_4V(params
, ctx
->Current
.Attrib
[index
]);
423 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribdvNV");
429 * Get a vertex (or vertex array) attribute.
430 * \note Not compiled into display lists.
431 * \note Called from the GL API dispatcher.
434 _mesa_GetVertexAttribivNV(GLuint index
, GLenum pname
, GLint
*params
)
436 GET_CURRENT_CONTEXT(ctx
);
437 ASSERT_OUTSIDE_BEGIN_END(ctx
);
439 if (index
== 0 || index
>= MAX_NV_VERTEX_PROGRAM_INPUTS
) {
440 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribdvNV(index)");
445 case GL_ATTRIB_ARRAY_SIZE_NV
:
446 params
[0] = ctx
->Array
.VertexAttrib
[index
].Size
;
448 case GL_ATTRIB_ARRAY_STRIDE_NV
:
449 params
[0] = ctx
->Array
.VertexAttrib
[index
].Stride
;
451 case GL_ATTRIB_ARRAY_TYPE_NV
:
452 params
[0] = ctx
->Array
.VertexAttrib
[index
].Type
;
454 case GL_CURRENT_ATTRIB_NV
:
455 FLUSH_CURRENT(ctx
, 0);
456 params
[0] = (GLint
) ctx
->Current
.Attrib
[index
][0];
457 params
[1] = (GLint
) ctx
->Current
.Attrib
[index
][1];
458 params
[2] = (GLint
) ctx
->Current
.Attrib
[index
][2];
459 params
[3] = (GLint
) ctx
->Current
.Attrib
[index
][3];
461 case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB
:
462 if (!ctx
->Extensions
.ARB_vertex_buffer_object
) {
463 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribdvNV");
466 params
[0] = ctx
->Array
.VertexAttrib
[index
].BufferObj
->Name
;
469 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribdvNV");
476 * Get a vertex array attribute pointer.
477 * \note Not compiled into display lists.
478 * \note Called from the GL API dispatcher.
481 _mesa_GetVertexAttribPointervNV(GLuint index
, GLenum pname
, GLvoid
**pointer
)
483 GET_CURRENT_CONTEXT(ctx
);
484 ASSERT_OUTSIDE_BEGIN_END(ctx
);
486 if (index
>= MAX_NV_VERTEX_PROGRAM_INPUTS
) {
487 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetVertexAttribPointerNV(index)");
491 if (pname
!= GL_ATTRIB_ARRAY_POINTER_NV
) {
492 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetVertexAttribPointerNV(pname)");
496 *pointer
= (GLvoid
*) ctx
->Array
.VertexAttrib
[index
].Ptr
;;
502 * Load/parse/compile a program.
503 * \note Called from the GL API dispatcher.
506 _mesa_LoadProgramNV(GLenum target
, GLuint id
, GLsizei len
,
507 const GLubyte
*program
)
509 struct program
*prog
;
510 GET_CURRENT_CONTEXT(ctx
);
511 ASSERT_OUTSIDE_BEGIN_END(ctx
);
514 _mesa_error(ctx
, GL_INVALID_VALUE
, "glLoadProgramNV(id)");
518 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
520 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
522 if (prog
&& prog
->Target
!= 0 && prog
->Target
!= target
) {
523 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glLoadProgramNV(target)");
527 if ((target
== GL_VERTEX_PROGRAM_NV
||
528 target
== GL_VERTEX_STATE_PROGRAM_NV
)
529 && ctx
->Extensions
.NV_vertex_program
) {
530 struct vertex_program
*vprog
= (struct vertex_program
*) prog
;
531 if (!vprog
|| prog
== &_mesa_DummyProgram
) {
532 vprog
= (struct vertex_program
*)
533 ctx
->Driver
.NewProgram(ctx
, target
, id
);
535 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glLoadProgramNV");
538 _mesa_HashInsert(ctx
->Shared
->Programs
, id
, vprog
);
540 _mesa_parse_nv_vertex_program(ctx
, target
, program
, len
, vprog
);
542 else if (target
== GL_FRAGMENT_PROGRAM_NV
543 && ctx
->Extensions
.NV_fragment_program
) {
544 struct fragment_program
*fprog
= (struct fragment_program
*) prog
;
545 if (!fprog
|| prog
== &_mesa_DummyProgram
) {
546 fprog
= (struct fragment_program
*)
547 ctx
->Driver
.NewProgram(ctx
, target
, id
);
549 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "glLoadProgramNV");
552 _mesa_HashInsert(ctx
->Shared
->Programs
, id
, fprog
);
554 _mesa_parse_nv_fragment_program(ctx
, target
, program
, len
, fprog
);
557 _mesa_error(ctx
, GL_INVALID_ENUM
, "glLoadProgramNV(target)");
564 * Set a program parameter register.
565 * \note Called from the GL API dispatcher.
568 _mesa_ProgramParameter4dNV(GLenum target
, GLuint index
,
569 GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
571 _mesa_ProgramParameter4fNV(target
, index
,
572 (GLfloat
)x
, (GLfloat
)y
, (GLfloat
)z
, (GLfloat
)w
);
577 * Set a program parameter register.
578 * \note Called from the GL API dispatcher.
581 _mesa_ProgramParameter4dvNV(GLenum target
, GLuint index
,
582 const GLdouble
*params
)
584 _mesa_ProgramParameter4fNV(target
, index
,
585 (GLfloat
)params
[0], (GLfloat
)params
[1],
586 (GLfloat
)params
[2], (GLfloat
)params
[3]);
591 * Set a program parameter register.
592 * \note Called from the GL API dispatcher.
595 _mesa_ProgramParameter4fNV(GLenum target
, GLuint index
,
596 GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
598 GET_CURRENT_CONTEXT(ctx
);
599 ASSERT_OUTSIDE_BEGIN_END(ctx
);
601 if (target
== GL_VERTEX_PROGRAM_NV
&& ctx
->Extensions
.NV_vertex_program
) {
602 if (index
< MAX_NV_VERTEX_PROGRAM_PARAMS
) {
603 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
604 ASSIGN_4V(ctx
->VertexProgram
.Parameters
[index
], x
, y
, z
, w
);
607 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramParameterNV(index)");
612 _mesa_error(ctx
, GL_INVALID_ENUM
, "glProgramParameterNV");
619 * Set a program parameter register.
620 * \note Called from the GL API dispatcher.
623 _mesa_ProgramParameter4fvNV(GLenum target
, GLuint index
,
624 const GLfloat
*params
)
626 _mesa_ProgramParameter4fNV(target
, index
,
627 params
[0], params
[1], params
[2], params
[3]);
633 * Set a sequence of program parameter registers.
634 * \note Called from the GL API dispatcher.
637 _mesa_ProgramParameters4dvNV(GLenum target
, GLuint index
,
638 GLuint num
, const GLdouble
*params
)
640 GET_CURRENT_CONTEXT(ctx
);
641 ASSERT_OUTSIDE_BEGIN_END(ctx
);
643 if (target
== GL_VERTEX_PROGRAM_NV
&& ctx
->Extensions
.NV_vertex_program
) {
645 if (index
+ num
> MAX_NV_VERTEX_PROGRAM_PARAMS
) {
646 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramParameters4dvNV");
649 for (i
= 0; i
< num
; i
++) {
650 ctx
->VertexProgram
.Parameters
[index
+ i
][0] = (GLfloat
) params
[0];
651 ctx
->VertexProgram
.Parameters
[index
+ i
][1] = (GLfloat
) params
[1];
652 ctx
->VertexProgram
.Parameters
[index
+ i
][2] = (GLfloat
) params
[2];
653 ctx
->VertexProgram
.Parameters
[index
+ i
][3] = (GLfloat
) params
[3];
658 _mesa_error(ctx
, GL_INVALID_ENUM
, "glProgramParameters4dvNV");
665 * Set a sequence of program parameter registers.
666 * \note Called from the GL API dispatcher.
669 _mesa_ProgramParameters4fvNV(GLenum target
, GLuint index
,
670 GLuint num
, const GLfloat
*params
)
672 GET_CURRENT_CONTEXT(ctx
);
673 ASSERT_OUTSIDE_BEGIN_END(ctx
);
675 if (target
== GL_VERTEX_PROGRAM_NV
&& ctx
->Extensions
.NV_vertex_program
) {
677 if (index
+ num
> MAX_NV_VERTEX_PROGRAM_PARAMS
) {
678 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramParameters4fvNV");
681 for (i
= 0; i
< num
; i
++) {
682 COPY_4V(ctx
->VertexProgram
.Parameters
[index
+ i
], params
);
687 _mesa_error(ctx
, GL_INVALID_ENUM
, "glProgramParameters4fvNV");
695 * Setup tracking of matrices into program parameter registers.
696 * \note Called from the GL API dispatcher.
699 _mesa_TrackMatrixNV(GLenum target
, GLuint address
,
700 GLenum matrix
, GLenum transform
)
702 GET_CURRENT_CONTEXT(ctx
);
703 ASSERT_OUTSIDE_BEGIN_END(ctx
);
705 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
707 if (target
== GL_VERTEX_PROGRAM_NV
&& ctx
->Extensions
.NV_vertex_program
) {
709 /* addr must be multiple of four */
710 _mesa_error(ctx
, GL_INVALID_VALUE
, "glTrackMatrixNV(address)");
720 case GL_MODELVIEW_PROJECTION_NV
:
729 /* OK, fallthrough */
732 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTrackMatrixNV(matrix)");
739 case GL_TRANSPOSE_NV
:
740 case GL_INVERSE_TRANSPOSE_NV
:
741 /* OK, fallthrough */
744 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTrackMatrixNV(transform)");
748 ctx
->VertexProgram
.TrackMatrix
[address
/ 4] = matrix
;
749 ctx
->VertexProgram
.TrackMatrixTransform
[address
/ 4] = transform
;
752 _mesa_error(ctx
, GL_INVALID_ENUM
, "glTrackMatrixNV(target)");
759 _mesa_ProgramNamedParameter4fNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
760 GLfloat x
, GLfloat y
, GLfloat z
, GLfloat w
)
762 struct program
*prog
;
763 struct fragment_program
*fragProg
;
766 GET_CURRENT_CONTEXT(ctx
);
767 ASSERT_OUTSIDE_BEGIN_END(ctx
);
769 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
);
771 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
772 if (!prog
|| prog
->Target
!= GL_FRAGMENT_PROGRAM_NV
) {
773 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glProgramNamedParameterNV");
778 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramNamedParameterNV(len)");
782 fragProg
= (struct fragment_program
*) prog
;
783 v
= _mesa_lookup_parameter_value(fragProg
->Base
.Parameters
, len
,
793 _mesa_error(ctx
, GL_INVALID_VALUE
, "glProgramNamedParameterNV(name)");
798 _mesa_ProgramNamedParameter4fvNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
801 _mesa_ProgramNamedParameter4fNV(id
, len
, name
, v
[0], v
[1], v
[2], v
[3]);
806 _mesa_ProgramNamedParameter4dNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
807 GLdouble x
, GLdouble y
, GLdouble z
, GLdouble w
)
809 _mesa_ProgramNamedParameter4fNV(id
, len
, name
, (GLfloat
)x
, (GLfloat
)y
,
810 (GLfloat
)z
, (GLfloat
)w
);
815 _mesa_ProgramNamedParameter4dvNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
818 _mesa_ProgramNamedParameter4fNV(id
, len
, name
,
819 (GLfloat
)v
[0], (GLfloat
)v
[1],
820 (GLfloat
)v
[2], (GLfloat
)v
[3]);
825 _mesa_GetProgramNamedParameterfvNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
828 struct program
*prog
;
829 struct fragment_program
*fragProg
;
832 GET_CURRENT_CONTEXT(ctx
);
834 if (!ctx
->_CurrentProgram
)
835 ASSERT_OUTSIDE_BEGIN_END(ctx
);
837 prog
= (struct program
*) _mesa_HashLookup(ctx
->Shared
->Programs
, id
);
838 if (!prog
|| prog
->Target
!= GL_FRAGMENT_PROGRAM_NV
) {
839 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glGetProgramNamedParameterNV");
844 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetProgramNamedParameterNV");
848 fragProg
= (struct fragment_program
*) prog
;
849 v
= _mesa_lookup_parameter_value(fragProg
->Base
.Parameters
,
859 _mesa_error(ctx
, GL_INVALID_VALUE
, "glGetProgramNamedParameterNV");
864 _mesa_GetProgramNamedParameterdvNV(GLuint id
, GLsizei len
, const GLubyte
*name
,
867 GLfloat floatParams
[4];
868 _mesa_GetProgramNamedParameterfvNV(id
, len
, name
, floatParams
);
869 COPY_4V(params
, floatParams
);