[Mesa-dev] [PATCH 04/12] sso: implement ActiveShaderProgram & GetProgramPipelineiv
Brian Paul
brianp at vmware.com
Sat Apr 6 07:48:08 PDT 2013
On 04/05/2013 03:27 PM, gregory wrote:
> ---
> src/mesa/main/pipelineobj.c | 73 +++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 73 insertions(+)
>
> diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
> index e50416c..7a56c67 100644
> --- a/src/mesa/main/pipelineobj.c
> +++ b/src/mesa/main/pipelineobj.c
> @@ -233,6 +233,28 @@ _mesa_UseProgramStages (GLuint pipeline, GLbitfield stages, GLuint program)
> void GLAPIENTRY
> _mesa_ActiveShaderProgram (GLuint pipeline, GLuint program)
> {
> + GET_CURRENT_CONTEXT(ctx);
> + struct gl_shader_program *shProg = (program != 0)
> + ? _mesa_lookup_shader_program_err(ctx, program, "glActiveShaderProgram(program)")
> + : NULL;
> +
> + struct gl_shader_state *pipe = lookup_pipeline_object(ctx, pipeline);
> +
> + if (!pipe) {
> + _mesa_error(ctx, GL_INVALID_OPERATION, "glActiveShaderProgram(pipeline)");
> + return;
> + }
> +
> + /* Object is created by any Pipeline call but glGenProgramPipelines, glIsProgramPipeline and GetProgramPipelineInfoLog */
> + pipe->EverBound = GL_TRUE;
> +
> + if ((shProg != NULL)&& !shProg->LinkStatus) {
> + _mesa_error(ctx, GL_INVALID_OPERATION,
> + "glActiveShaderProgram(program %u not linked)", shProg->Name);
> + return;
> + }
> +
> + _mesa_reference_shader_program(ctx,&pipe->ActiveProgram, shProg);
> }
>
> /**
> @@ -350,6 +372,57 @@ _mesa_IsProgramPipeline (GLuint pipeline)
> void GLAPIENTRY
> _mesa_GetProgramPipelineiv (GLuint pipeline, GLenum pname, GLint *params)
> {
> + GET_CURRENT_CONTEXT(ctx);
> + struct gl_shader_state *pipe = lookup_pipeline_object(ctx, pipeline);
> +
> + /* Are geometry shaders available in this context?
> + */
> + const bool has_gs = _mesa_is_desktop_gl(ctx)&& ctx->Extensions.ARB_geometry_shader4;
> +
> + if (!pipe) {
> + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetProgramPipelineiv(pipeline)");
> + return;
> + }
> +
> + /* Object is created by any Pipeline call but glGenProgramPipelines, glIsProgramPipeline and GetProgramPipelineInfoLog */
> + pipe->EverBound = GL_TRUE;
> +
> + switch (pname) {
> + case GL_ACTIVE_PROGRAM:
You don't have to indent the "case" more than "switch". I know we're
not totally consistent about that in Mesa.
> + *params = (pipe->ActiveProgram) ? pipe->ActiveProgram->Name : 0;
Unneeded parens around (pipe->ActiveProgram), and below.
> + return;
> + case GL_INFO_LOG_LENGTH:
> + // TODO
> + *params = 0;
> + return;
> + case GL_VALIDATE_STATUS:
> + *params = pipe->ValidationStatus;
> + return;
> + case GL_VERTEX_SHADER:
> + *params = (pipe->CurrentVertexProgram) ? pipe->CurrentVertexProgram->Name : 0;
> + return;
> + case GL_TESS_EVALUATION_SHADER:
> + /* NOT YET SUPPORTED */
> + break;
> + case GL_TESS_CONTROL_SHADER:
> + /* NOT YET SUPPORTED */
> + break;
> + case GL_GEOMETRY_SHADER:
> + if (!has_gs) break;
> + *params = (pipe->CurrentGeometryProgram) ? pipe->CurrentGeometryProgram->Name : 0;;
> + return;
> + case GL_FRAGMENT_SHADER:
> + *params = (pipe->CurrentFragmentProgram) ? pipe->CurrentFragmentProgram->Name : 0;;
> + return;
> + case GL_COMPUTE_SHADER:
> + /* NOT YET SUPPORTED */
> + break;
> + default:
> + break;
> + }
> +
> + _mesa_error(ctx, GL_INVALID_ENUM, "glGetProgramPipelineiv(pname=%s)",
> + _mesa_lookup_enum_by_nr(pname));
> }
>
> /**
More information about the mesa-dev
mailing list