[Mesa-dev] [PATCH 14/17] main: Support calling driver for ProgramBinary

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


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

diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
index c20d8b80e1d..b46f2693b83 100644
--- a/src/mesa/main/dd.h
+++ b/src/mesa/main/dd.h
@@ -1141,6 +1141,10 @@ struct dd_function_table {
                             struct gl_shader_program *shProg,
                             GLsizei bufSize, GLsizei *length,
                             GLenum *binaryFormat, GLvoid *binary);
+   void (*ProgramBinary)(struct gl_context *ctx,
+                         struct gl_shader_program *shProg,
+                         GLenum binaryFormat, const GLvoid *binary,
+                         GLsizei length);
    /*@}*/
 };
 
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 28711a67f03..47a51279353 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -2224,9 +2224,6 @@ _mesa_ProgramBinary(GLuint program, GLenum binaryFormat,
    if (!shProg)
       return;
 
-   (void) binaryFormat;
-   (void) binary;
-
    /* Section 2.3.1 (Errors) of the OpenGL 4.5 spec says:
     *
     *     "If a negative number is provided where an argument of type sizei or
@@ -2237,20 +2234,27 @@ _mesa_ProgramBinary(GLuint program, GLenum binaryFormat,
       return;
    }
 
-   /* The ARB_get_program_binary spec says:
-    *
-    *     "<binaryFormat> and <binary> must be those returned by a previous
-    *     call to GetProgramBinary, and <length> must be the length of the
-    *     program binary as returned by GetProgramBinary or GetProgramiv with
-    *     <pname> PROGRAM_BINARY_LENGTH. Loading the program binary will fail,
-    *     setting the LINK_STATUS of <program> to FALSE, if these conditions
-    *     are not met."
-    *
-    * Since any value of binaryFormat passed "is not one of those specified as
-    * allowable for [this] command, an INVALID_ENUM error is generated."
-    */
-   shProg->data->LinkStatus = linking_failure;
-   _mesa_error(ctx, GL_INVALID_ENUM, "glProgramBinary");
+   assert(ctx->Const.NumProgramBinaryFormats == 0 ||
+          ctx->Driver.ProgramBinary);
+   if (ctx->Const.NumProgramBinaryFormats == 0 ||
+       binaryFormat != GL_PROGRAM_BINARY_FORMAT_MESA) {
+      /* The ARB_get_program_binary spec says:
+       *
+       *     "<binaryFormat> and <binary> must be those returned by a previous
+       *     call to GetProgramBinary, and <length> must be the length of the
+       *     program binary as returned by GetProgramBinary or GetProgramiv with
+       *     <pname> PROGRAM_BINARY_LENGTH. Loading the program binary will fail,
+       *     setting the LINK_STATUS of <program> to FALSE, if these conditions
+       *     are not met."
+       *
+       * Since any value of binaryFormat passed "is not one of those specified as
+       * allowable for [this] command, an INVALID_ENUM error is generated."
+       */
+      shProg->data->LinkStatus = linking_failure;
+      _mesa_error(ctx, GL_INVALID_ENUM, "glProgramBinary");
+   } else {
+      ctx->Driver.ProgramBinary(ctx, shProg, binaryFormat, binary, length);
+   }
 }
 
 
-- 
2.14.1



More information about the mesa-dev mailing list