diff options
author | Jordan Justen <[email protected]> | 2018-04-09 01:39:18 -0700 |
---|---|---|
committer | Jordan Justen <[email protected]> | 2018-07-09 23:02:33 -0700 |
commit | e426286e21f8a90f40aff2e7617287bfc3306652 (patch) | |
tree | ad85f598a2d12ec873ce6090cb16e706d7035e14 /src/mesa | |
parent | 3a133223b3f10f19bbdab7a6f7da73e55a914185 (diff) |
i965: Regenerate blob without gen program for shader cache
Signed-off-by: Jordan Justen <[email protected]>
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_program_binary.c | 64 |
1 files changed, 63 insertions, 1 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_program_binary.c b/src/mesa/drivers/dri/i965/brw_program_binary.c index 3528847e155..20d3a3c8ba5 100644 --- a/src/mesa/drivers/dri/i965/brw_program_binary.c +++ b/src/mesa/drivers/dri/i965/brw_program_binary.c @@ -68,12 +68,74 @@ enum driver_cache_blob_part { NIR_PART, }; +static bool +blob_parts_valid(void *blob, uint32_t size) +{ + struct blob_reader reader; + blob_reader_init(&reader, blob, size); + + do { + uint32_t part_type = blob_read_uint32(&reader); + if (reader.overrun) + return false; + if (part_type == END_PART) + return reader.current == reader.end; + switch ((enum driver_cache_blob_part)part_type) { + case GEN_PART: + case NIR_PART: + /* Read the uint32_t part-size and skip over it */ + blob_skip_bytes(&reader, blob_read_uint32(&reader)); + if (reader.overrun) + return false; + break; + default: + return false; + } + } while (true); +} + +static bool +blob_has_part(void *blob, uint32_t size, enum driver_cache_blob_part part) +{ + struct blob_reader reader; + blob_reader_init(&reader, blob, size); + + assert(blob_parts_valid(blob, size)); + do { + uint32_t part_type = blob_read_uint32(&reader); + if (part_type == END_PART) + return false; + if (part_type == part) + return true; + blob_skip_bytes(&reader, blob_read_uint32(&reader)); + } while (true); +} + +static bool +driver_blob_is_ready(void *blob, uint32_t size, bool with_gen_program) +{ + if (!blob) { + return false; + } else if (!blob_parts_valid(blob, size)) { + unreachable("Driver blob format is bad!"); + return false; + } else if (blob_has_part(blob, size, GEN_PART) == with_gen_program) { + return true; + } else { + return false; + } +} + void brw_program_serialize_nir(struct gl_context *ctx, struct gl_program *prog) { - if (prog->driver_cache_blob) + if (driver_blob_is_ready(prog->driver_cache_blob, + prog->driver_cache_blob_size, false)) return; + if (prog->driver_cache_blob) + ralloc_free(prog->driver_cache_blob); + struct blob writer; blob_init(&writer); blob_write_uint32(&writer, NIR_PART); |