mesa: Add gl_shader_program param to ProgramBinarySerializeDriverBlob
authorJordan Justen <jordan.l.justen@intel.com>
Thu, 1 Mar 2018 02:29:54 +0000 (18:29 -0800)
committerJordan Justen <jordan.l.justen@intel.com>
Tue, 10 Jul 2018 06:02:33 +0000 (23:02 -0700)
This might be required because some stages might generate different
programs depending on the other stages in the program. For example,
the i965 driver's tessellation control stage depends on the
tessellation evaluation shader.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_program_binary.c
src/mesa/main/dd.h
src/mesa/main/program_binary.c
src/mesa/state_tracker/st_context.c
src/mesa/state_tracker/st_shader_cache.c
src/mesa/state_tracker/st_shader_cache.h

index 2db22f1c08240a74d20a20d40c513f20df7256ed..968fc1d43d66d97f1958215f5e0ae6b20e217e3a 100644 (file)
@@ -340,7 +340,7 @@ brw_init_driver_functions(struct brw_context *brw,
    /* GL_ARB_get_program_binary */
    brw_program_binary_init(brw->screen->deviceID);
    functions->GetProgramBinaryDriverSHA1 = brw_get_program_binary_driver_sha1;
-   functions->ProgramBinarySerializeDriverBlob = brw_program_serialize_nir;
+   functions->ProgramBinarySerializeDriverBlob = brw_serialize_program_binary;
    functions->ProgramBinaryDeserializeDriverBlob =
       brw_deserialize_program_binary;
 
index c9c01b7d56a44c0644447fdc0574c99b1a10d0cd..72be8f2a4d0bf1a81d5c4afe2f161da7ac4c9390 100644 (file)
@@ -1637,6 +1637,9 @@ extern void
 brw_program_binary_init(unsigned device_id);
 extern void
 brw_get_program_binary_driver_sha1(struct gl_context *ctx, uint8_t *sha1);
+void brw_serialize_program_binary(struct gl_context *ctx,
+                                  struct gl_shader_program *sh_prog,
+                                  struct gl_program *prog);
 extern void
 brw_deserialize_program_binary(struct gl_context *ctx,
                                struct gl_shader_program *shProg,
index 20d3a3c8ba52369c01c0468c49c42a424cfaff16..1fe3ffd5bf96257401e103144268632725782268 100644 (file)
@@ -237,6 +237,14 @@ brw_deserialize_program_binary(struct gl_context *ctx,
    brw_program_deserialize_driver_blob(ctx, prog, prog->info.stage);
 }
 
+void
+brw_serialize_program_binary(struct gl_context *ctx,
+                             struct gl_shader_program *sh_prog,
+                             struct gl_program *prog)
+{
+   brw_program_serialize_nir(ctx, prog);
+}
+
 void
 brw_write_blob_program_data(struct blob *binary, gl_shader_stage stage,
                             const void *program,
index 7081d5867000523be5c1cd82763da872ae9ae2fe..78e99bfa235d4f96fcefa0817a2dde6a3cc38cc7 100644 (file)
@@ -1218,6 +1218,7 @@ struct dd_function_table {
    void (*GetProgramBinaryDriverSHA1)(struct gl_context *ctx, uint8_t *sha1);
 
    void (*ProgramBinarySerializeDriverBlob)(struct gl_context *ctx,
+                                            struct gl_shader_program *shProg,
                                             struct gl_program *prog);
 
    void (*ProgramBinaryDeserializeDriverBlob)(struct gl_context *ctx,
index 427a79dc94dfde8bb230135b8d21d23c54a2d96a..7390fef5887abe37ccf5e032ff999782682427f4 100644 (file)
@@ -174,7 +174,8 @@ write_program_payload(struct gl_context *ctx, struct blob *blob,
    for (unsigned stage = 0; stage < MESA_SHADER_STAGES; stage++) {
       struct gl_linked_shader *shader = sh_prog->_LinkedShaders[stage];
       if (shader)
-         ctx->Driver.ProgramBinarySerializeDriverBlob(ctx, shader->Program);
+         ctx->Driver.ProgramBinarySerializeDriverBlob(ctx, sh_prog,
+                                                      shader->Program);
    }
 
    serialize_glsl_program(blob, ctx, sh_prog);
index 488202bbc59fd7f74447a7389a876a38e620e5c0..b7330acfcca9ca6161e499447e9b849bd9025a43 100644 (file)
@@ -760,12 +760,14 @@ st_init_driver_functions(struct pipe_screen *screen,
                                PIPE_SHADER_CAP_PREFERRED_IR);
    if (preferred_ir == PIPE_SHADER_IR_NIR) {
       functions->ShaderCacheSerializeDriverBlob =  st_serialise_nir_program;
-      functions->ProgramBinarySerializeDriverBlob = st_serialise_nir_program;
+      functions->ProgramBinarySerializeDriverBlob =
+         st_serialise_nir_program_binary;
       functions->ProgramBinaryDeserializeDriverBlob =
          st_deserialise_nir_program;
    } else {
       functions->ShaderCacheSerializeDriverBlob =  st_serialise_tgsi_program;
-      functions->ProgramBinarySerializeDriverBlob = st_serialise_tgsi_program;
+      functions->ProgramBinarySerializeDriverBlob =
+         st_serialise_tgsi_program_binary;
       functions->ProgramBinaryDeserializeDriverBlob =
          st_deserialise_tgsi_program;
    }
index 3f8d2d110ce8fce5d116d60388d947b7e9f3884d..c82ce3eaa2d8dc32e199f196e7d68d4659929203 100644 (file)
@@ -414,6 +414,14 @@ st_serialise_tgsi_program(struct gl_context *ctx, struct gl_program *prog)
    st_serialise_ir_program(ctx, prog, false);
 }
 
+void
+st_serialise_tgsi_program_binary(struct gl_context *ctx,
+                                 struct gl_shader_program *shProg,
+                                 struct gl_program *prog)
+{
+   st_serialise_ir_program(ctx, prog, false);
+}
+
 void
 st_deserialise_tgsi_program(struct gl_context *ctx,
                             struct gl_shader_program *shProg,
@@ -428,6 +436,14 @@ st_serialise_nir_program(struct gl_context *ctx, struct gl_program *prog)
    st_serialise_ir_program(ctx, prog, true);
 }
 
+void
+st_serialise_nir_program_binary(struct gl_context *ctx,
+                                struct gl_shader_program *shProg,
+                                struct gl_program *prog)
+{
+   st_serialise_ir_program(ctx, prog, true);
+}
+
 void
 st_deserialise_nir_program(struct gl_context *ctx,
                            struct gl_shader_program *shProg,
index 132dac00c011d8869f98268913c55dd7f3fb8d9c..5b0bff7b2f86699ad1267c4e39cb9afdf9c8969c 100644 (file)
@@ -38,6 +38,11 @@ st_get_program_binary_driver_sha1(struct gl_context *ctx, uint8_t *sha1);
 void
 st_serialise_tgsi_program(struct gl_context *ctx, struct gl_program *prog);
 
+void
+st_serialise_tgsi_program_binary(struct gl_context *ctx,
+                                 struct gl_shader_program *shProg,
+                                 struct gl_program *prog);
+
 void
 st_deserialise_tgsi_program(struct gl_context *ctx,
                             struct gl_shader_program *shProg,
@@ -46,6 +51,11 @@ st_deserialise_tgsi_program(struct gl_context *ctx,
 void
 st_serialise_nir_program(struct gl_context *ctx, struct gl_program *prog);
 
+void
+st_serialise_nir_program_binary(struct gl_context *ctx,
+                                struct gl_shader_program *shProg,
+                                struct gl_program *prog);
+
 void
 st_deserialise_nir_program(struct gl_context *ctx,
                            struct gl_shader_program *shProg,