2 * Mesa 3-D graphics library
4 * Copyright © 2013 Gregory Hainaut <gregory.hainaut@gmail.com>
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
28 * \author Hainaut Gregory <gregory.hainaut@gmail.com>
30 * Implementation of pipeline object related API functions. Based on
31 * GL_ARB_separate_shader_objects extension.
35 #include "main/glheader.h"
36 #include "main/context.h"
37 #include "main/dispatch.h"
38 #include "main/enums.h"
39 #include "main/hash.h"
40 #include "main/mtypes.h"
41 #include "main/pipelineobj.h"
42 #include "main/shaderapi.h"
43 #include "main/shaderobj.h"
44 #include "main/transformfeedback.h"
45 #include "main/uniforms.h"
46 #include "glsl/glsl_parser_extras.h"
47 #include "glsl/ir_uniform.h"
48 #include "program/program.h"
49 #include "program/prog_parameter.h"
50 #include "util/ralloc.h"
53 * Delete a pipeline object.
56 _mesa_delete_pipeline_object(struct gl_context
*ctx
,
57 struct gl_pipeline_object
*obj
)
61 _mesa_reference_shader_program(ctx
, &obj
->_CurrentFragmentProgram
, NULL
);
63 for (i
= 0; i
< MESA_SHADER_STAGES
; i
++)
64 _mesa_reference_shader_program(ctx
, &obj
->CurrentProgram
[i
], NULL
);
66 _mesa_reference_shader_program(ctx
, &obj
->ActiveProgram
, NULL
);
67 mtx_destroy(&obj
->Mutex
);
73 * Allocate and initialize a new pipeline object.
75 static struct gl_pipeline_object
*
76 _mesa_new_pipeline_object(struct gl_context
*ctx
, GLuint name
)
78 struct gl_pipeline_object
*obj
= rzalloc(NULL
, struct gl_pipeline_object
);
81 mtx_init(&obj
->Mutex
, mtx_plain
);
83 obj
->Flags
= _mesa_get_shader_flags();
91 * Initialize pipeline object state for given context.
94 _mesa_init_pipeline(struct gl_context
*ctx
)
96 ctx
->Pipeline
.Objects
= _mesa_NewHashTable();
98 ctx
->Pipeline
.Current
= NULL
;
100 /* Install a default Pipeline */
101 ctx
->Pipeline
.Default
= _mesa_new_pipeline_object(ctx
, 0);
102 _mesa_reference_pipeline_object(ctx
, &ctx
->_Shader
, ctx
->Pipeline
.Default
);
107 * Callback for deleting a pipeline object. Called by _mesa_HashDeleteAll().
110 delete_pipelineobj_cb(GLuint id
, void *data
, void *userData
)
112 struct gl_pipeline_object
*obj
= (struct gl_pipeline_object
*) data
;
113 struct gl_context
*ctx
= (struct gl_context
*) userData
;
114 _mesa_delete_pipeline_object(ctx
, obj
);
119 * Free pipeline state for given context.
122 _mesa_free_pipeline_data(struct gl_context
*ctx
)
124 _mesa_reference_pipeline_object(ctx
, &ctx
->_Shader
, NULL
);
126 _mesa_HashDeleteAll(ctx
->Pipeline
.Objects
, delete_pipelineobj_cb
, ctx
);
127 _mesa_DeleteHashTable(ctx
->Pipeline
.Objects
);
129 _mesa_delete_pipeline_object(ctx
, ctx
->Pipeline
.Default
);
133 * Look up the pipeline object for the given ID.
136 * Either a pointer to the pipeline object with the specified ID or \c NULL for
137 * a non-existent ID. The spec defines ID 0 as being technically
140 struct gl_pipeline_object
*
141 _mesa_lookup_pipeline_object(struct gl_context
*ctx
, GLuint id
)
146 return (struct gl_pipeline_object
*)
147 _mesa_HashLookup(ctx
->Pipeline
.Objects
, id
);
151 * Add the given pipeline object to the pipeline object pool.
154 save_pipeline_object(struct gl_context
*ctx
, struct gl_pipeline_object
*obj
)
157 _mesa_HashInsert(ctx
->Pipeline
.Objects
, obj
->Name
, obj
);
162 * Remove the given pipeline object from the pipeline object pool.
163 * Do not deallocate the pipeline object though.
166 remove_pipeline_object(struct gl_context
*ctx
, struct gl_pipeline_object
*obj
)
169 _mesa_HashRemove(ctx
->Pipeline
.Objects
, obj
->Name
);
174 * Set ptr to obj w/ reference counting.
175 * Note: this should only be called from the _mesa_reference_pipeline_object()
179 _mesa_reference_pipeline_object_(struct gl_context
*ctx
,
180 struct gl_pipeline_object
**ptr
,
181 struct gl_pipeline_object
*obj
)
186 /* Unreference the old pipeline object */
187 GLboolean deleteFlag
= GL_FALSE
;
188 struct gl_pipeline_object
*oldObj
= *ptr
;
190 mtx_lock(&oldObj
->Mutex
);
191 assert(oldObj
->RefCount
> 0);
193 deleteFlag
= (oldObj
->RefCount
== 0);
194 mtx_unlock(&oldObj
->Mutex
);
197 _mesa_delete_pipeline_object(ctx
, oldObj
);
205 /* reference new pipeline object */
206 mtx_lock(&obj
->Mutex
);
207 if (obj
->RefCount
== 0) {
208 /* this pipeline's being deleted (look just above) */
209 /* Not sure this can ever really happen. Warn if it does. */
210 _mesa_problem(NULL
, "referencing deleted pipeline object");
217 mtx_unlock(&obj
->Mutex
);
222 * Bound program to severals stages of the pipeline
225 _mesa_UseProgramStages(GLuint pipeline
, GLbitfield stages
, GLuint program
)
227 GET_CURRENT_CONTEXT(ctx
);
229 struct gl_pipeline_object
*pipe
= _mesa_lookup_pipeline_object(ctx
, pipeline
);
230 struct gl_shader_program
*shProg
= NULL
;
231 GLbitfield any_valid_stages
;
234 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glUseProgramStages(pipeline)");
238 /* Object is created by any Pipeline call but glGenProgramPipelines,
239 * glIsProgramPipeline and GetProgramPipelineInfoLog
241 pipe
->EverBound
= GL_TRUE
;
243 /* Section 2.11.4 (Program Pipeline Objects) of the OpenGL 4.1 spec says:
245 * "If stages is not the special value ALL_SHADER_BITS, and has a bit
246 * set that is not recognized, the error INVALID_VALUE is generated."
248 any_valid_stages
= GL_VERTEX_SHADER_BIT
| GL_FRAGMENT_SHADER_BIT
;
249 if (_mesa_has_geometry_shaders(ctx
))
250 any_valid_stages
|= GL_GEOMETRY_SHADER_BIT
;
251 if (_mesa_has_tessellation(ctx
))
252 any_valid_stages
|= GL_TESS_CONTROL_SHADER_BIT
|
253 GL_TESS_EVALUATION_SHADER_BIT
;
255 if (stages
!= GL_ALL_SHADER_BITS
&& (stages
& ~any_valid_stages
) != 0) {
256 _mesa_error(ctx
, GL_INVALID_VALUE
, "glUseProgramStages(Stages)");
260 /* Section 2.17.2 (Transform Feedback Primitive Capture) of the OpenGL 4.1
263 * "The error INVALID_OPERATION is generated:
267 * - by UseProgramStages if the program pipeline object it refers
268 * to is current and the current transform feedback object is
269 * active and not paused;
271 if (ctx
->_Shader
== pipe
) {
272 if (_mesa_is_xfb_active_and_unpaused(ctx
)) {
273 _mesa_error(ctx
, GL_INVALID_OPERATION
,
274 "glUseProgramStages(transform feedback active)");
280 shProg
= _mesa_lookup_shader_program_err(ctx
, program
,
281 "glUseProgramStages");
285 /* Section 2.11.4 (Program Pipeline Objects) of the OpenGL 4.1 spec
288 * "If the program object named by program was linked without the
289 * PROGRAM_SEPARABLE parameter set, or was not linked successfully,
290 * the error INVALID_OPERATION is generated and the corresponding
291 * shader stages in the pipeline program pipeline object are not
294 if (!shProg
->LinkStatus
) {
295 _mesa_error(ctx
, GL_INVALID_OPERATION
,
296 "glUseProgramStages(program not linked)");
300 if (!shProg
->SeparateShader
) {
301 _mesa_error(ctx
, GL_INVALID_OPERATION
,
302 "glUseProgramStages(program wasn't linked with the "
303 "PROGRAM_SEPARABLE flag)");
308 /* Enable individual stages from the program as requested by the
309 * application. If there is no shader for a requested stage in the
310 * program, _mesa_use_shader_program will enable fixed-function processing
311 * as dictated by the spec.
313 * Section 2.11.4 (Program Pipeline Objects) of the OpenGL 4.1 spec
316 * "If UseProgramStages is called with program set to zero or with a
317 * program object that contains no executable code for the given
318 * stages, it is as if the pipeline object has no programmable stage
319 * configured for the indicated shader stages."
321 if ((stages
& GL_VERTEX_SHADER_BIT
) != 0)
322 _mesa_use_shader_program(ctx
, GL_VERTEX_SHADER
, shProg
, pipe
);
324 if ((stages
& GL_FRAGMENT_SHADER_BIT
) != 0)
325 _mesa_use_shader_program(ctx
, GL_FRAGMENT_SHADER
, shProg
, pipe
);
327 if ((stages
& GL_GEOMETRY_SHADER_BIT
) != 0)
328 _mesa_use_shader_program(ctx
, GL_GEOMETRY_SHADER
, shProg
, pipe
);
330 if ((stages
& GL_TESS_CONTROL_SHADER_BIT
) != 0)
331 _mesa_use_shader_program(ctx
, GL_TESS_CONTROL_SHADER
, shProg
, pipe
);
333 if ((stages
& GL_TESS_EVALUATION_SHADER_BIT
) != 0)
334 _mesa_use_shader_program(ctx
, GL_TESS_EVALUATION_SHADER
, shProg
, pipe
);
338 * Use the named shader program for subsequent glUniform calls (if pipeline
342 _mesa_ActiveShaderProgram(GLuint pipeline
, GLuint program
)
344 GET_CURRENT_CONTEXT(ctx
);
345 struct gl_shader_program
*shProg
= NULL
;
346 struct gl_pipeline_object
*pipe
= _mesa_lookup_pipeline_object(ctx
, pipeline
);
349 shProg
= _mesa_lookup_shader_program_err(ctx
, program
,
350 "glActiveShaderProgram(program)");
356 _mesa_error(ctx
, GL_INVALID_OPERATION
, "glActiveShaderProgram(pipeline)");
360 /* Object is created by any Pipeline call but glGenProgramPipelines,
361 * glIsProgramPipeline and GetProgramPipelineInfoLog
363 pipe
->EverBound
= GL_TRUE
;
365 if ((shProg
!= NULL
) && !shProg
->LinkStatus
) {
366 _mesa_error(ctx
, GL_INVALID_OPERATION
,
367 "glActiveShaderProgram(program %u not linked)", shProg
->Name
);
371 _mesa_reference_shader_program(ctx
, &pipe
->ActiveProgram
, shProg
);
375 * Make program of the pipeline current
378 _mesa_BindProgramPipeline(GLuint pipeline
)
380 GET_CURRENT_CONTEXT(ctx
);
381 struct gl_pipeline_object
*newObj
= NULL
;
383 /* Rebinding the same pipeline object: no change.
385 if (ctx
->_Shader
->Name
== pipeline
)
388 /* Section 2.17.2 (Transform Feedback Primitive Capture) of the OpenGL 4.1
391 * "The error INVALID_OPERATION is generated:
395 * - by BindProgramPipeline if the current transform feedback
396 * object is active and not paused;
398 if (_mesa_is_xfb_active_and_unpaused(ctx
)) {
399 _mesa_error(ctx
, GL_INVALID_OPERATION
,
400 "glBindProgramPipeline(transform feedback active)");
404 /* Get pointer to new pipeline object (newObj)
407 /* non-default pipeline object */
408 newObj
= _mesa_lookup_pipeline_object(ctx
, pipeline
);
410 _mesa_error(ctx
, GL_INVALID_OPERATION
,
411 "glBindProgramPipeline(non-gen name)");
415 /* Object is created by any Pipeline call but glGenProgramPipelines,
416 * glIsProgramPipeline and GetProgramPipelineInfoLog
418 newObj
->EverBound
= GL_TRUE
;
421 _mesa_bind_pipeline(ctx
, newObj
);
425 _mesa_bind_pipeline(struct gl_context
*ctx
,
426 struct gl_pipeline_object
*pipe
)
428 /* First bind the Pipeline to pipeline binding point */
429 _mesa_reference_pipeline_object(ctx
, &ctx
->Pipeline
.Current
, pipe
);
431 /* Section 2.11.3 (Program Objects) of the OpenGL 4.1 spec says:
433 * "If there is a current program object established by UseProgram,
434 * that program is considered current for all stages. Otherwise, if
435 * there is a bound program pipeline object (see section 2.11.4), the
436 * program bound to the appropriate stage of the pipeline object is
437 * considered current."
439 if (&ctx
->Shader
!= ctx
->_Shader
) {
441 /* Bound the pipeline to the current program and
442 * restore the pipeline state
444 _mesa_reference_pipeline_object(ctx
, &ctx
->_Shader
, pipe
);
446 /* Unbind the pipeline */
447 _mesa_reference_pipeline_object(ctx
, &ctx
->_Shader
,
448 ctx
->Pipeline
.Default
);
451 FLUSH_VERTICES(ctx
, _NEW_PROGRAM
| _NEW_PROGRAM_CONSTANTS
);
453 if (ctx
->Driver
.UseProgram
)
454 ctx
->Driver
.UseProgram(ctx
, NULL
);
459 * Delete a set of pipeline objects.
461 * \param n Number of pipeline objects to delete.
462 * \param ids pipeline of \c n pipeline object IDs.
465 _mesa_DeleteProgramPipelines(GLsizei n
, const GLuint
*pipelines
)
467 GET_CURRENT_CONTEXT(ctx
);
471 _mesa_error(ctx
, GL_INVALID_VALUE
, "glDeleteProgramPipelines(n<0)");
475 for (i
= 0; i
< n
; i
++) {
476 struct gl_pipeline_object
*obj
=
477 _mesa_lookup_pipeline_object(ctx
, pipelines
[i
]);
480 assert(obj
->Name
== pipelines
[i
]);
482 /* If the pipeline object is currently bound, the spec says "If an
483 * object that is currently bound is deleted, the binding for that
484 * object reverts to zero and no program pipeline object becomes
487 if (obj
== ctx
->Pipeline
.Current
) {
488 _mesa_BindProgramPipeline(0);
491 /* The ID is immediately freed for re-use */
492 remove_pipeline_object(ctx
, obj
);
494 /* Unreference the pipeline object.
495 * If refcount hits zero, the object will be deleted.
497 _mesa_reference_pipeline_object(ctx
, &obj
, NULL
);
503 * Generate a set of unique pipeline object IDs and store them in \c pipelines.
504 * \param n Number of IDs to generate.
505 * \param pipelines pipeline of \c n locations to store the IDs.
508 create_program_pipelines(struct gl_context
*ctx
, GLsizei n
, GLuint
*pipelines
,
515 func
= dsa
? "glCreateProgramPipelines" : "glGenProgramPipelines";
518 _mesa_error(ctx
, GL_INVALID_VALUE
, "%s (n < 0)", func
);
526 first
= _mesa_HashFindFreeKeyBlock(ctx
->Pipeline
.Objects
, n
);
528 for (i
= 0; i
< n
; i
++) {
529 struct gl_pipeline_object
*obj
;
530 GLuint name
= first
+ i
;
532 obj
= _mesa_new_pipeline_object(ctx
, name
);
534 _mesa_error(ctx
, GL_OUT_OF_MEMORY
, "%s", func
);
539 /* make dsa-allocated objects behave like program objects */
540 obj
->EverBound
= GL_TRUE
;
543 save_pipeline_object(ctx
, obj
);
544 pipelines
[i
] = first
+ i
;
550 _mesa_GenProgramPipelines(GLsizei n
, GLuint
*pipelines
)
552 GET_CURRENT_CONTEXT(ctx
);
554 create_program_pipelines(ctx
, n
, pipelines
, false);
558 _mesa_CreateProgramPipelines(GLsizei n
, GLuint
*pipelines
)
560 GET_CURRENT_CONTEXT(ctx
);
562 create_program_pipelines(ctx
, n
, pipelines
, true);
566 * Determine if ID is the name of an pipeline object.
568 * \param id ID of the potential pipeline object.
569 * \return \c GL_TRUE if \c id is the name of a pipeline object,
570 * \c GL_FALSE otherwise.
573 _mesa_IsProgramPipeline(GLuint pipeline
)
575 GET_CURRENT_CONTEXT(ctx
);
577 struct gl_pipeline_object
*obj
= _mesa_lookup_pipeline_object(ctx
, pipeline
);
581 return obj
->EverBound
;
585 * glGetProgramPipelineiv() - get pipeline shader state.
588 _mesa_GetProgramPipelineiv(GLuint pipeline
, GLenum pname
, GLint
*params
)
590 GET_CURRENT_CONTEXT(ctx
);
591 struct gl_pipeline_object
*pipe
= _mesa_lookup_pipeline_object(ctx
, pipeline
);
593 /* Are geometry shaders available in this context?
595 const bool has_gs
= _mesa_has_geometry_shaders(ctx
);
596 const bool has_tess
= _mesa_has_tessellation(ctx
);;
599 _mesa_error(ctx
, GL_INVALID_OPERATION
,
600 "glGetProgramPipelineiv(pipeline)");
604 /* Object is created by any Pipeline call but glGenProgramPipelines,
605 * glIsProgramPipeline and GetProgramPipelineInfoLog
607 pipe
->EverBound
= GL_TRUE
;
610 case GL_ACTIVE_PROGRAM
:
611 *params
= pipe
->ActiveProgram
? pipe
->ActiveProgram
->Name
: 0;
613 case GL_INFO_LOG_LENGTH
:
614 *params
= pipe
->InfoLog
? strlen(pipe
->InfoLog
) + 1 : 0;
616 case GL_VALIDATE_STATUS
:
617 /* If pipeline is not bound, return initial value 0. */
618 *params
= (ctx
->_Shader
->Name
!= pipe
->Name
) ? 0 : pipe
->Validated
;
620 case GL_VERTEX_SHADER
:
621 *params
= pipe
->CurrentProgram
[MESA_SHADER_VERTEX
]
622 ? pipe
->CurrentProgram
[MESA_SHADER_VERTEX
]->Name
: 0;
624 case GL_TESS_EVALUATION_SHADER
:
627 *params
= pipe
->CurrentProgram
[MESA_SHADER_TESS_EVAL
]
628 ? pipe
->CurrentProgram
[MESA_SHADER_TESS_EVAL
]->Name
: 0;
630 case GL_TESS_CONTROL_SHADER
:
633 *params
= pipe
->CurrentProgram
[MESA_SHADER_TESS_CTRL
]
634 ? pipe
->CurrentProgram
[MESA_SHADER_TESS_CTRL
]->Name
: 0;
636 case GL_GEOMETRY_SHADER
:
639 *params
= pipe
->CurrentProgram
[MESA_SHADER_GEOMETRY
]
640 ? pipe
->CurrentProgram
[MESA_SHADER_GEOMETRY
]->Name
: 0;
642 case GL_FRAGMENT_SHADER
:
643 *params
= pipe
->CurrentProgram
[MESA_SHADER_FRAGMENT
]
644 ? pipe
->CurrentProgram
[MESA_SHADER_FRAGMENT
]->Name
: 0;
650 _mesa_error(ctx
, GL_INVALID_ENUM
, "glGetProgramPipelineiv(pname=%s)",
651 _mesa_enum_to_string(pname
));
655 * Determines whether every stage in a linked program is active in the
656 * specified pipeline.
659 program_stages_all_active(struct gl_pipeline_object
*pipe
,
660 const struct gl_shader_program
*prog
)
668 for (i
= 0; i
< MESA_SHADER_STAGES
; i
++) {
669 if (prog
->_LinkedShaders
[i
]) {
670 if (pipe
->CurrentProgram
[i
]) {
671 if (prog
->Name
!= pipe
->CurrentProgram
[i
]->Name
) {
681 pipe
->InfoLog
= ralloc_asprintf(pipe
,
682 "Program %d is not active for all "
683 "shaders that was linked",
691 program_stages_interleaved_illegally(const struct gl_pipeline_object
*pipe
)
693 struct gl_shader_program
*prev
= NULL
;
696 /* Look for programs bound to stages: A -> B -> A, with any intervening
697 * sequence of unrelated programs or empty stages.
699 for (i
= 0; i
< MESA_SHADER_STAGES
; i
++) {
700 struct gl_shader_program
*cur
= pipe
->CurrentProgram
[i
];
702 /* Empty stages anywhere in the pipe are OK */
703 if (!cur
|| cur
== prev
)
707 /* We've seen an A -> B transition; look at the rest of the pipe
708 * to see if we ever see A again.
710 for (j
= i
+ 1; j
< MESA_SHADER_STAGES
; j
++) {
711 if (pipe
->CurrentProgram
[j
] == prev
)
723 _mesa_validate_program_pipeline(struct gl_context
* ctx
,
724 struct gl_pipeline_object
*pipe
,
729 pipe
->Validated
= GL_FALSE
;
731 /* Release and reset the info log.
733 if (pipe
->InfoLog
!= NULL
)
734 ralloc_free(pipe
->InfoLog
);
736 pipe
->InfoLog
= NULL
;
738 /* Section 2.11.11 (Shader Execution), subheading "Validation," of the
739 * OpenGL 4.1 spec says:
741 * "[INVALID_OPERATION] is generated by any command that transfers
742 * vertices to the GL if:
744 * - A program object is active for at least one, but not all of
745 * the shader stages that were present when the program was
748 * For each possible program stage, verify that the program bound to that
749 * stage has all of its stages active. In other words, if the program
750 * bound to the vertex stage also has a fragment shader, the fragment
751 * shader must also be bound to the fragment stage.
753 for (i
= 0; i
< MESA_SHADER_STAGES
; i
++) {
754 if (!program_stages_all_active(pipe
, pipe
->CurrentProgram
[i
])) {
759 /* Section 2.11.11 (Shader Execution), subheading "Validation," of the
760 * OpenGL 4.1 spec says:
762 * "[INVALID_OPERATION] is generated by any command that transfers
763 * vertices to the GL if:
767 * - One program object is active for at least two shader stages
768 * and a second program is active for a shader stage between two
769 * stages for which the first program was active."
771 if (program_stages_interleaved_illegally(pipe
)) {
774 "Program is active for multiple shader stages with an "
775 "intervening stage provided by another program");
779 /* Section 2.11.11 (Shader Execution), subheading "Validation," of the
780 * OpenGL 4.1 spec says:
782 * "[INVALID_OPERATION] is generated by any command that transfers
783 * vertices to the GL if:
787 * - There is an active program for tessellation control,
788 * tessellation evaluation, or geometry stages with corresponding
789 * executable shader, but there is no active program with
790 * executable vertex shader."
792 if (!pipe
->CurrentProgram
[MESA_SHADER_VERTEX
]
793 && (pipe
->CurrentProgram
[MESA_SHADER_GEOMETRY
] ||
794 pipe
->CurrentProgram
[MESA_SHADER_TESS_CTRL
] ||
795 pipe
->CurrentProgram
[MESA_SHADER_TESS_EVAL
])) {
796 pipe
->InfoLog
= ralloc_strdup(pipe
, "Program lacks a vertex shader");
800 /* Section 2.11.11 (Shader Execution), subheading "Validation," of the
801 * OpenGL 4.1 spec says:
803 * "[INVALID_OPERATION] is generated by any command that transfers
804 * vertices to the GL if:
808 * - There is no current program object specified by UseProgram,
809 * there is a current program pipeline object, and the current
810 * program for any shader stage has been relinked since being
811 * applied to the pipeline object via UseProgramStages with the
812 * PROGRAM_SEPARABLE parameter set to FALSE.
814 for (i
= 0; i
< MESA_SHADER_STAGES
; i
++) {
815 if (pipe
->CurrentProgram
[i
] && !pipe
->CurrentProgram
[i
]->SeparateShader
) {
816 pipe
->InfoLog
= ralloc_asprintf(pipe
,
817 "Program %d was relinked without "
818 "PROGRAM_SEPARABLE state",
819 pipe
->CurrentProgram
[i
]->Name
);
824 /* Section 2.11.11 (Shader Execution), subheading "Validation," of the
825 * OpenGL 4.1 spec says:
827 * "[INVALID_OPERATION] is generated by any command that transfers
828 * vertices to the GL if:
832 * - Any two active samplers in the current program object are of
833 * different types, but refer to the same texture image unit.
835 * - The number of active samplers in the program exceeds the
836 * maximum number of texture image units allowed."
838 if (!_mesa_sampler_uniforms_pipeline_are_valid(pipe
))
841 pipe
->Validated
= GL_TRUE
;
846 _mesa_error(ctx
, GL_INVALID_OPERATION
,
847 "glValidateProgramPipeline failed to validate the pipeline");
853 * Check compatibility of pipeline's program
856 _mesa_ValidateProgramPipeline(GLuint pipeline
)
858 GET_CURRENT_CONTEXT(ctx
);
860 struct gl_pipeline_object
*pipe
= _mesa_lookup_pipeline_object(ctx
, pipeline
);
863 _mesa_error(ctx
, GL_INVALID_OPERATION
,
864 "glValidateProgramPipeline(pipeline)");
868 _mesa_validate_program_pipeline(ctx
, pipe
,
869 (ctx
->_Shader
->Name
== pipe
->Name
));
873 _mesa_GetProgramPipelineInfoLog(GLuint pipeline
, GLsizei bufSize
,
874 GLsizei
*length
, GLchar
*infoLog
)
876 GET_CURRENT_CONTEXT(ctx
);
878 struct gl_pipeline_object
*pipe
= _mesa_lookup_pipeline_object(ctx
, pipeline
);
881 _mesa_error(ctx
, GL_INVALID_VALUE
,
882 "glGetProgramPipelineInfoLog(pipeline)");
887 _mesa_error(ctx
, GL_INVALID_VALUE
,
888 "glGetProgramPipelineInfoLog(bufSize)");
893 _mesa_copy_string(infoLog
, bufSize
, length
, pipe
->InfoLog
);