[Mesa-dev] [PATCH 04/11] mesa: Add stub implementations of glGetProgramBinary and glProgramBinary

Ian Romanick idr at freedesktop.org
Fri Jan 4 13:12:59 PST 2013


On 12/20/2012 05:05 PM, Eric Anholt wrote:
> Ian Romanick <idr at freedesktop.org> writes:
>
>> From: Ian Romanick <ian.d.romanick at intel.com>
>
> It looks to me like we really do have to support getting a
> binary with this extension/gles3:
>
> "Any program binary retrieved using GetProgramBinary and submitted us-
> ing ProgramBinary under the same configuration must be successful. Any
> programs loaded successfully by ProgramBinary must be run properly with
> any legal GL state vector."
>
> where I read configuration as "hardware and driver version"  I don't see
> any of the text I would expect if they're letting length == 0 mean
> "sorry, can't save this one".

I thought I had replied to this, but I don't see my e-mail.  Weird. 
Anyway, the spec allows us to expose zero binary formats.  If there are 
no binary formats, any value specified as binaryFormat for 
glProgramBinary must be invalid.  The older ARB_get_shader_binary spec 
uses basically the same method to allow the same cowardly retreat. :)

>> ---
>>   src/mesa/main/shaderapi.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++
>>   src/mesa/main/shaderapi.h |  8 ++++++++
>>   2 files changed, 58 insertions(+)
>>
>> diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
>> index 19fa6fc..550018e 100644
>> --- a/src/mesa/main/shaderapi.c
>> +++ b/src/mesa/main/shaderapi.c
>> @@ -1500,6 +1500,56 @@ _mesa_ShaderBinary(GLint n, const GLuint* shaders, GLenum binaryformat,
>>
>>   #endif /* FEATURE_ES2 */
>>
>> +void GLAPIENTRY
>> +_mesa_GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei *length,
>> +                       GLenum *binaryFormat, GLvoid *binary)
>> +{
>> +   struct gl_shader_program *shProg;
>> +   GET_CURRENT_CONTEXT(ctx);
>> +
>> +   ASSERT_OUTSIDE_BEGIN_END(ctx);
>> +
>> +   shProg = _mesa_lookup_shader_program_err(ctx, program, "glGetProgramBinary");
>> +   if (!shProg)
>> +      return;
>> +
>> +   if (!shProg->LinkStatus) {
>> +      _mesa_error(ctx, GL_INVALID_OPERATION,
>> +		  "glGetProgramBinary(program %u not linked)",
>
> tabs, probably from a copy and paste.

Naturally.  Fixed.

>> +                  shProg->Name);
>> +      return;
>> +   }
>> +
>> +   if (bufSize < 0){
>> +      _mesa_error(ctx, GL_INVALID_VALUE, "glGetProgramBinary(bufSize < 0)");
>> +      return;
>> +   }
>> +
>> +   *length = 0;
>
> "If <length> is NULL, then no length is returned."

Good catch.  I'll fix that.


More information about the mesa-dev mailing list