i965: Move brw_program_*serialize_nir to brw_program_binary.c
authorJordan Justen <jordan.l.justen@intel.com>
Wed, 28 Feb 2018 09:39:27 +0000 (01:39 -0800)
committerJordan Justen <jordan.l.justen@intel.com>
Tue, 10 Jul 2018 06:02:32 +0000 (23:02 -0700)
This will allow get_program_binary to add the gen program into its
serialization in addition to just the nir program.

Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
src/mesa/drivers/dri/i965/brw_program.c
src/mesa/drivers/dri/i965/brw_program_binary.c

index 915c42bd522a11e9da49d40bf7fee503bbe5c09f..7a85678f86dfedb4533e9be5e8ddc28cc230c612 100644 (file)
@@ -41,7 +41,6 @@
 #include "util/ralloc.h"
 #include "compiler/glsl/ir.h"
 #include "compiler/glsl/glsl_to_nir.h"
-#include "compiler/nir/nir_serialize.h"
 
 #include "brw_program.h"
 #include "brw_context.h"
@@ -839,39 +838,3 @@ brw_assign_common_binding_table_offsets(const struct gen_device_info *devinfo,
    assert(next_binding_table_offset <= BRW_MAX_SURFACES);
    return next_binding_table_offset;
 }
-
-void
-brw_program_serialize_nir(struct gl_context *ctx, struct gl_program *prog)
-{
-   if (prog->driver_cache_blob)
-      return;
-
-   struct blob writer;
-   blob_init(&writer);
-   nir_serialize(&writer, prog->nir);
-   prog->driver_cache_blob = ralloc_size(NULL, writer.size);
-   memcpy(prog->driver_cache_blob, writer.data, writer.size);
-   prog->driver_cache_blob_size = writer.size;
-   blob_finish(&writer);
-}
-
-void
-brw_program_deserialize_nir(struct gl_context *ctx, struct gl_program *prog,
-                            gl_shader_stage stage)
-{
-   if (!prog->nir) {
-      assert(prog->driver_cache_blob && prog->driver_cache_blob_size > 0);
-      const struct nir_shader_compiler_options *options =
-         ctx->Const.ShaderCompilerOptions[stage].NirOptions;
-      struct blob_reader reader;
-      blob_reader_init(&reader, prog->driver_cache_blob,
-                       prog->driver_cache_blob_size);
-      prog->nir = nir_deserialize(NULL, options, &reader);
-   }
-
-   if (prog->driver_cache_blob) {
-      ralloc_free(prog->driver_cache_blob);
-      prog->driver_cache_blob = NULL;
-      prog->driver_cache_blob_size = 0;
-   }
-}
index f1b327de4b36ceef196b2ddecc16c2baac9ec9c5..099279ef37e0cb5adba9133afd53cc7d4a494083 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <stdint.h>
 
+#include "compiler/nir/nir_serialize.h"
 #include "util/build_id.h"
 #include "util/mesa-sha1.h"
 
@@ -60,6 +61,42 @@ brw_get_program_binary_driver_sha1(struct gl_context *ctx, uint8_t *sha1)
    memcpy(sha1, driver_sha1, sizeof(uint8_t) * 20);
 }
 
+void
+brw_program_serialize_nir(struct gl_context *ctx, struct gl_program *prog)
+{
+   if (prog->driver_cache_blob)
+      return;
+
+   struct blob writer;
+   blob_init(&writer);
+   nir_serialize(&writer, prog->nir);
+   prog->driver_cache_blob = ralloc_size(NULL, writer.size);
+   memcpy(prog->driver_cache_blob, writer.data, writer.size);
+   prog->driver_cache_blob_size = writer.size;
+   blob_finish(&writer);
+}
+
+void
+brw_program_deserialize_nir(struct gl_context *ctx, struct gl_program *prog,
+                            gl_shader_stage stage)
+{
+   if (!prog->nir) {
+      assert(prog->driver_cache_blob && prog->driver_cache_blob_size > 0);
+      const struct nir_shader_compiler_options *options =
+         ctx->Const.ShaderCompilerOptions[stage].NirOptions;
+      struct blob_reader reader;
+      blob_reader_init(&reader, prog->driver_cache_blob,
+                       prog->driver_cache_blob_size);
+      prog->nir = nir_deserialize(NULL, options, &reader);
+   }
+
+   if (prog->driver_cache_blob) {
+      ralloc_free(prog->driver_cache_blob);
+      prog->driver_cache_blob = NULL;
+      prog->driver_cache_blob_size = 0;
+   }
+}
+
 /* This is just a wrapper around brw_program_deserialize_nir() as i965
  * doesn't need gl_shader_program like other drivers do.
  */