[Mesa-dev] [PATCH 14/15] mesa/sso: Implement _mesa_ActiveShaderProgram

Ian Romanick idr at freedesktop.org
Wed Feb 19 15:24:44 PST 2014


On 02/19/2014 01:44 PM, Jordan Justen wrote:
> On Fri, Feb 7, 2014 at 10:00 PM, Ian Romanick <idr at freedesktop.org> wrote:
>> From: Gregory Hainaut <gregory.hainaut at gmail.com>
>>
>> This was originally included in another patch, but it was split out by
>> Ian Romanick.
>>
>> Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>
>> ---
>>  src/mesa/main/pipelineobj.c | 24 ++++++++++++++++++++++++
>>  1 file changed, 24 insertions(+)
>>
>> diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c
>> index b47dc7a..6e490bd 100644
>> --- a/src/mesa/main/pipelineobj.c
>> +++ b/src/mesa/main/pipelineobj.c
>> @@ -227,6 +227,30 @@ _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;
> 
> Seems like if/else would be more clear for this part.
> 
> If _mesa_lookup_shader_program_err returns NULL, should we exit early?

Yes.  Good catch.  We should also have a piglit test for this.  I don't
think there is one already.

 - Bind a valid program to the pipeline.
 - Try to bind a non-existant, non-zero program.
 - Verify the error is generated.
 - Verify that old program is still bound to the pipeline.

> -Jordan
> 
>> +   struct gl_pipeline_object *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);
>>  }
>>
>>  /**
>> --
>> 1.8.1.4
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 



More information about the mesa-dev mailing list