[Mesa-dev] [PATCH 13/17] main: Support calling driver for GetProgramBinary

Jordan Justen jordan.l.justen at intel.com
Thu Nov 9 06:42:25 UTC 2017


Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 src/mesa/main/dd.h        |  4 ++++
 src/mesa/main/shaderapi.c | 17 +++++++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index 91eff55f84d..c20d8b80e1d 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1137,6 +1137,10 @@ struct dd_function_table {
    void (*GetProgramBinaryLength)(struct gl_context *ctx,
                                   struct gl_shader_program *shProg,
                                   GLint *length);
+   void (*GetProgramBinary)(struct gl_context *ctx,
+                            struct gl_shader_program *shProg,
+                            GLsizei bufSize, GLsizei *length,
+                            GLenum *binaryFormat, GLvoid *binary);
    /*@}*/
 };
 
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index f12825d2536..28711a67f03 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -2200,12 +2200,17 @@ _mesa_GetProgramBinary(GLuint program, GLsizei bufSize, GLsizei *length,
       return;
    }
 
-   *length = 0;
-   _mesa_error(ctx, GL_INVALID_OPERATION,
-               "glGetProgramBinary(driver supports zero binary formats)");
-
-   (void) binaryFormat;
-   (void) binary;
+   assert(ctx->Const.NumProgramBinaryFormats == 0 ||
+          ctx->Driver.GetProgramBinary);
+   if (ctx->Const.NumProgramBinaryFormats == 0) {
+      *length = 0;
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glGetProgramBinary(driver supports zero binary formats)");
+   } else {
+      ctx->Driver.GetProgramBinary(ctx, shProg, bufSize, length,
+                                   binaryFormat, binary);
+      assert(*length == 0 || *binaryFormat == GL_PROGRAM_BINARY_FORMAT_MESA);
+   }
 }
 
 void GLAPIENTRY
-- 
2.14.1



More information about the mesa-dev mailing list