main: add binary support to GetProgramBinary
authorJordan Justen <jordan.l.justen@intel.com>
Sat, 4 Nov 2017 23:47:25 +0000 (16:47 -0700)
committerTimothy Arceri <tarceri@itsqueeze.com>
Fri, 8 Dec 2017 05:59:25 +0000 (16:59 +1100)
V2: call generic _mesa_get_program_binary() helper rather than driver
    function directly to allow greater code sharing.

Signed-off-by: Timothy Arceri <tarceri@itsqueeze.com>
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> (v1)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com> (v1)
Reviewed-by: Tapani Pälli <tapani.palli@intel.com>
src/mesa/main/shaderapi.c

index 82a7fde697b60829722bc158370fd0c99449e619..b728b320ac41fbd8e6e439aca4ad64c5480dab35 100644 (file)
@@ -2199,12 +2199,15 @@ _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;
+   if (ctx->Const.NumProgramBinaryFormats == 0) {
+      *length = 0;
+      _mesa_error(ctx, GL_INVALID_OPERATION,
+                  "glGetProgramBinary(driver supports zero binary formats)");
+   } else {
+      _mesa_get_program_binary(ctx, shProg, bufSize, length, binaryFormat,
+                               binary);
+      assert(*length == 0 || *binaryFormat == GL_PROGRAM_BINARY_FORMAT_MESA);
+   }
 }
 
 void GLAPIENTRY