From b8a11ad256ddae35314bd870266dfad9fbe68f56 Mon Sep 17 00:00:00 2001 From: Kenneth Graunke Date: Sun, 22 Apr 2018 21:25:51 -0700 Subject: [PATCH] iris: fix blorp prog data crashes --- src/gallium/drivers/iris/iris_program_cache.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/gallium/drivers/iris/iris_program_cache.c b/src/gallium/drivers/iris/iris_program_cache.c index 6c286fd6640..a993a933743 100644 --- a/src/gallium/drivers/iris/iris_program_cache.c +++ b/src/gallium/drivers/iris/iris_program_cache.c @@ -203,7 +203,7 @@ iris_upload_shader(struct iris_context *ice, uint32_t key_size, const void *key, const void *assembly, - const struct brw_stage_prog_data *prog_data) + struct brw_stage_prog_data *prog_data) { struct iris_screen *screen = (void *) ice->ctx.screen; struct gen_device_info *devinfo = &screen->devinfo; @@ -231,6 +231,10 @@ iris_upload_shader(struct iris_context *ice, shader->prog_data = prog_data; + ralloc_steal(shader, shader->prog_data); + ralloc_steal(shader->prog_data, prog_data->param); + ralloc_steal(shader->prog_data, prog_data->pull_param); + /* Store the 3DSTATE shader packets and other derived state. */ ice->vtbl.set_derived_program_state(devinfo, cache_id, shader); @@ -258,10 +262,6 @@ iris_upload_and_bind_shader(struct iris_context *ice, iris_upload_shader(ice, cache_id, key_size_for_cache(cache_id), key, assembly, prog_data); - ralloc_steal(shader, shader->prog_data); - ralloc_steal(shader->prog_data, prog_data->param); - ralloc_steal(shader->prog_data, prog_data->pull_param); - ice->shaders.prog[cache_id] = shader; ice->state.dirty |= dirty_flag_for_cache(cache_id); } @@ -293,7 +293,7 @@ bool iris_blorp_upload_shader(struct blorp_batch *blorp_batch, const void *key, uint32_t key_size, const void *kernel, UNUSED uint32_t kernel_size, - const struct brw_stage_prog_data *prog_data, + const struct brw_stage_prog_data *prog_data_templ, UNUSED uint32_t prog_data_size, uint32_t *kernel_out, void *prog_data_out) { @@ -301,6 +301,9 @@ iris_blorp_upload_shader(struct blorp_batch *blorp_batch, struct iris_context *ice = blorp->driver_ctx; struct iris_batch *batch = blorp_batch->driver_batch; + void *prog_data = ralloc_size(NULL, prog_data_size); + memcpy(prog_data, prog_data_templ, prog_data_size); + struct iris_compiled_shader *shader = iris_upload_shader(ice, IRIS_CACHE_BLORP, key_size, key, kernel, prog_data); -- 2.30.2