summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri
diff options
context:
space:
mode:
authorJordan Justen <[email protected]>2018-02-28 16:20:51 -0800
committerJordan Justen <[email protected]>2018-07-09 23:02:33 -0700
commit8e7ee7433e6475156bd1e7be81129985eb0eac01 (patch)
tree690ceca8373b175d903f9039ceb8ae592a9aa951 /src/mesa/drivers/dri
parent05bb4b48495c316bbe3dd4a52456850782029e78 (diff)
i965: Add support for driver cache blob containing the gen program
Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r--src/mesa/drivers/dri/i965/brw_program_binary.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_program_binary.c b/src/mesa/drivers/dri/i965/brw_program_binary.c
index b72dc04ecab..3528847e155 100644
--- a/src/mesa/drivers/dri/i965/brw_program_binary.c
+++ b/src/mesa/drivers/dri/i965/brw_program_binary.c
@@ -29,6 +29,7 @@
#include "brw_context.h"
#include "brw_program.h"
+#include "brw_state.h"
static uint8_t driver_sha1[20];
@@ -63,6 +64,7 @@ brw_get_program_binary_driver_sha1(struct gl_context *ctx, uint8_t *sha1)
enum driver_cache_blob_part {
END_PART,
+ GEN_PART,
NIR_PART,
};
@@ -86,6 +88,38 @@ brw_program_serialize_nir(struct gl_context *ctx, struct gl_program *prog)
blob_finish(&writer);
}
+static bool
+deserialize_gen_program(struct blob_reader *reader, struct gl_context *ctx,
+ struct gl_program *prog, gl_shader_stage stage)
+{
+ struct brw_context *brw = brw_context(ctx);
+
+ union brw_any_prog_key prog_key;
+ blob_copy_bytes(reader, &prog_key, brw_prog_key_size(stage));
+ brw_prog_key_set_id(&prog_key, stage, brw_program(prog)->id);
+
+ enum brw_cache_id cache_id = brw_stage_cache_id(stage);
+
+ const uint8_t *program;
+ struct brw_stage_prog_data *prog_data =
+ ralloc_size(NULL, sizeof(union brw_any_prog_data));
+
+ if (!brw_read_blob_program_data(reader, prog, stage, &program, prog_data)) {
+ ralloc_free(prog_data);
+ return false;
+ }
+
+ uint32_t offset;
+ void *out_prog_data;
+ brw_upload_cache(&brw->cache, cache_id, &prog_key, brw_prog_key_size(stage),
+ program, prog_data->program_size, prog_data,
+ brw_prog_data_size(stage), &offset, &out_prog_data);
+
+ ralloc_free(prog_data);
+
+ return true;
+}
+
void
brw_program_deserialize_driver_blob(struct gl_context *ctx,
struct gl_program *prog,
@@ -103,6 +137,13 @@ brw_program_deserialize_driver_blob(struct gl_context *ctx,
if ((enum driver_cache_blob_part)part_type == END_PART)
break;
switch ((enum driver_cache_blob_part)part_type) {
+ case GEN_PART: {
+ uint32_t gen_size = blob_read_uint32(&reader);
+ assert(!reader.overrun &&
+ (uintptr_t)(reader.end - reader.current) > gen_size);
+ deserialize_gen_program(&reader, ctx, prog, stage);
+ break;
+ }
case NIR_PART: {
uint32_t nir_size = blob_read_uint32(&reader);
assert(!reader.overrun &&