Signed-off-by: Tapani Pälli <tapani.pa...@intel.com> --- src/mesa/main/shaderapi.c | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-)
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 61ac0e3..582dfe2 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -57,6 +57,7 @@ #include "../glsl/ir.h" #include "../glsl/ir_uniform.h" #include "../glsl/program.h" +#include "../glsl/shader_cache.h" /** Define this to enable shader substitution (see below) */ #define SHADER_SUBST 0 @@ -1618,8 +1619,25 @@ _mesa_GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei *length, if (length != NULL) *length = 0; - (void) binaryFormat; - (void) binary; + size_t size = 0; + char *data = mesa_program_serialize(shProg, &size); + + /* we have more data that can fit to user given buffer */ + if (size > bufSize) { + _mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__); + free(data); + return; + } + + if (data) + memcpy(binary, data, size); + + free(data); + + if (length != NULL) + *length = size; + + *binaryFormat = 0; } void GLAPIENTRY @@ -1633,10 +1651,27 @@ _mesa_ProgramBinary(GLuint program, GLenum binaryFormat, if (!shProg) return; - (void) binaryFormat; - (void) binary; - (void) length; - _mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__); + if (length <= 0) + goto errors; + + /* free possible existing data and initialize structure */ + _mesa_free_shader_program_data(ctx, shProg); + _mesa_init_shader_program(ctx, shProg); + + /* fill structure from a binary blob */ + if (mesa_program_deserialize(shProg, binary, length)) + goto errors; + + assert(shProg->LinkStatus == GL_TRUE); + + return; + +errors: + /* on error set link status to false and clear the info log */ + shProg->LinkStatus = GL_FALSE; + if (shProg->InfoLog) + ralloc_free(shProg->InfoLog); + shProg->InfoLog = ralloc_strdup(shProg, ""); } -- 1.8.5.3 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev