From: Iago Toral Quiroga Date: Tue, 14 Mar 2017 12:12:22 +0000 (+0100) Subject: intel/blorp: make upload_shader() return a bool indicating success or failure X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e2f707ce5b569e40c2a3821149f87659553467f9;p=mesa.git intel/blorp: make upload_shader() return a bool indicating success or failure For now we always return true, follow-up patches will handle fail scenarios. Reviewed-by: Topi Pohjolainen --- diff --git a/src/intel/blorp/blorp.h b/src/intel/blorp/blorp.h index e0687e92614..eab75d70ab9 100644 --- a/src/intel/blorp/blorp.h +++ b/src/intel/blorp/blorp.h @@ -54,7 +54,7 @@ struct blorp_context { bool (*lookup_shader)(struct blorp_context *blorp, const void *key, uint32_t key_size, uint32_t *kernel_out, void *prog_data_out); - void (*upload_shader)(struct blorp_context *blorp, + bool (*upload_shader)(struct blorp_context *blorp, const void *key, uint32_t key_size, const void *kernel, uint32_t kernel_size, const struct brw_stage_prog_data *prog_data, diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c index e650d5e7bf1..280b76ab70c 100644 --- a/src/intel/blorp/blorp_blit.c +++ b/src/intel/blorp/blorp_blit.c @@ -1285,14 +1285,14 @@ brw_blorp_build_nir_shader(struct blorp_context *blorp, void *mem_ctx, return b.shader; } -static void +static bool brw_blorp_get_blit_kernel(struct blorp_context *blorp, struct blorp_params *params, const struct brw_blorp_blit_prog_key *prog_key) { if (blorp->lookup_shader(blorp, prog_key, sizeof(*prog_key), ¶ms->wm_prog_kernel, ¶ms->wm_prog_data)) - return; + return true; void *mem_ctx = ralloc_context(NULL); @@ -1313,12 +1313,14 @@ brw_blorp_get_blit_kernel(struct blorp_context *blorp, program = blorp_compile_fs(blorp, mem_ctx, nir, &wm_key, false, &prog_data, &program_size); - blorp->upload_shader(blorp, prog_key, sizeof(*prog_key), - program, program_size, - &prog_data.base, sizeof(prog_data), - ¶ms->wm_prog_kernel, ¶ms->wm_prog_data); + bool result = + blorp->upload_shader(blorp, prog_key, sizeof(*prog_key), + program, program_size, + &prog_data.base, sizeof(prog_data), + ¶ms->wm_prog_kernel, ¶ms->wm_prog_data); ralloc_free(mem_ctx); + return result; } static void @@ -1821,7 +1823,8 @@ try_blorp_blit(struct blorp_batch *batch, /* For some texture types, we need to pass the layer through the sampler. */ params->wm_inputs.src_z = params->src.z_offset; - brw_blorp_get_blit_kernel(batch->blorp, params, wm_prog_key); + if (!brw_blorp_get_blit_kernel(batch->blorp, params, wm_prog_key)) + return 0; unsigned result = 0; unsigned max_surface_size = get_max_surface_size(devinfo, params); diff --git a/src/intel/blorp/blorp_clear.c b/src/intel/blorp/blorp_clear.c index 627528defac..4e834ba123e 100644 --- a/src/intel/blorp/blorp_clear.c +++ b/src/intel/blorp/blorp_clear.c @@ -40,7 +40,7 @@ struct brw_blorp_const_color_prog_key bool pad[3]; }; -static void +static bool blorp_params_get_clear_kernel(struct blorp_context *blorp, struct blorp_params *params, bool use_replicated_data) @@ -52,7 +52,7 @@ blorp_params_get_clear_kernel(struct blorp_context *blorp, if (blorp->lookup_shader(blorp, &blorp_key, sizeof(blorp_key), ¶ms->wm_prog_kernel, ¶ms->wm_prog_data)) - return; + return true; void *mem_ctx = ralloc_context(NULL); @@ -79,12 +79,14 @@ blorp_params_get_clear_kernel(struct blorp_context *blorp, blorp_compile_fs(blorp, mem_ctx, b.shader, &wm_key, use_replicated_data, &prog_data, &program_size); - blorp->upload_shader(blorp, &blorp_key, sizeof(blorp_key), - program, program_size, - &prog_data.base, sizeof(prog_data), - ¶ms->wm_prog_kernel, ¶ms->wm_prog_data); + bool result = + blorp->upload_shader(blorp, &blorp_key, sizeof(blorp_key), + program, program_size, + &prog_data.base, sizeof(prog_data), + ¶ms->wm_prog_kernel, ¶ms->wm_prog_data); ralloc_free(mem_ctx); + return result; } struct layer_offset_vs_key { @@ -99,7 +101,7 @@ struct layer_offset_vs_key { * no real concept of "base instance", so we have to do it manually in a * vertex shader. */ -static void +static bool blorp_params_get_layer_offset_vs(struct blorp_context *blorp, struct blorp_params *params) { @@ -112,7 +114,7 @@ blorp_params_get_layer_offset_vs(struct blorp_context *blorp, if (blorp->lookup_shader(blorp, &blorp_key, sizeof(blorp_key), ¶ms->vs_prog_kernel, ¶ms->vs_prog_data)) - return; + return true; void *mem_ctx = ralloc_context(NULL); @@ -168,12 +170,14 @@ blorp_params_get_layer_offset_vs(struct blorp_context *blorp, const unsigned *program = blorp_compile_vs(blorp, mem_ctx, b.shader, &vs_prog_data, &program_size); - blorp->upload_shader(blorp, &blorp_key, sizeof(blorp_key), - program, program_size, - &vs_prog_data.base.base, sizeof(vs_prog_data), - ¶ms->vs_prog_kernel, ¶ms->vs_prog_data); + bool result = + blorp->upload_shader(blorp, &blorp_key, sizeof(blorp_key), + program, program_size, + &vs_prog_data.base.base, sizeof(vs_prog_data), + ¶ms->vs_prog_kernel, ¶ms->vs_prog_data); ralloc_free(mem_ctx); + return result; } /* The x0, y0, x1, and y1 parameters must already be populated with the render @@ -319,7 +323,8 @@ blorp_fast_clear(struct blorp_batch *batch, get_fast_clear_rect(batch->blorp->isl_dev, surf->aux_surf, ¶ms.x0, ¶ms.y0, ¶ms.x1, ¶ms.y1); - blorp_params_get_clear_kernel(batch->blorp, ¶ms, true); + if (!blorp_params_get_clear_kernel(batch->blorp, ¶ms, true)) + return; brw_blorp_surface_info_init(batch->blorp, ¶ms.dst, surf, level, start_layer, format, true); @@ -410,8 +415,9 @@ blorp_clear(struct blorp_batch *batch, } } - blorp_params_get_clear_kernel(batch->blorp, ¶ms, - use_simd16_replicated_data); + if (!blorp_params_get_clear_kernel(batch->blorp, ¶ms, + use_simd16_replicated_data)) + return; while (num_layers > 0) { brw_blorp_surface_info_init(batch->blorp, ¶ms.dst, surf, level, @@ -633,7 +639,8 @@ blorp_clear_attachments(struct blorp_batch *batch, * is tiled or not, we have to assume it may be linear. This means no * SIMD16_REPDATA for us. :-( */ - blorp_params_get_clear_kernel(batch->blorp, ¶ms, false); + if (!blorp_params_get_clear_kernel(batch->blorp, ¶ms, false)) + return; } if (clear_depth) { @@ -650,7 +657,9 @@ blorp_clear_attachments(struct blorp_batch *batch, params.stencil_ref = stencil_value; } - blorp_params_get_layer_offset_vs(batch->blorp, ¶ms); + if (!blorp_params_get_layer_offset_vs(batch->blorp, ¶ms)) + return; + params.vs_inputs.base_layer = start_layer; batch->blorp->exec(batch, ¶ms); @@ -717,7 +726,8 @@ blorp_ccs_resolve(struct blorp_batch *batch, * color" message. */ - blorp_params_get_clear_kernel(batch->blorp, ¶ms, true); + if (!blorp_params_get_clear_kernel(batch->blorp, ¶ms, true)) + return; batch->blorp->exec(batch, ¶ms); } diff --git a/src/intel/vulkan/anv_blorp.c b/src/intel/vulkan/anv_blorp.c index 9b9995c95c7..26a9396b142 100644 --- a/src/intel/vulkan/anv_blorp.c +++ b/src/intel/vulkan/anv_blorp.c @@ -49,7 +49,7 @@ lookup_blorp_shader(struct blorp_context *blorp, return true; } -static void +static bool upload_blorp_shader(struct blorp_context *blorp, const void *key, uint32_t key_size, const void *kernel, uint32_t kernel_size, @@ -79,6 +79,8 @@ upload_blorp_shader(struct blorp_context *blorp, *kernel_out = bin->kernel.offset; *(const struct brw_stage_prog_data **)prog_data_out = bin->prog_data; + + return true; } void diff --git a/src/mesa/drivers/dri/i965/brw_blorp.c b/src/mesa/drivers/dri/i965/brw_blorp.c index fdc9dd13cc1..b69cb4fc7b8 100644 --- a/src/mesa/drivers/dri/i965/brw_blorp.c +++ b/src/mesa/drivers/dri/i965/brw_blorp.c @@ -48,7 +48,7 @@ brw_blorp_lookup_shader(struct blorp_context *blorp, key, key_size, kernel_out, prog_data_out); } -static void +static bool brw_blorp_upload_shader(struct blorp_context *blorp, const void *key, uint32_t key_size, const void *kernel, uint32_t kernel_size, @@ -60,6 +60,7 @@ brw_blorp_upload_shader(struct blorp_context *blorp, brw_upload_cache(&brw->cache, BRW_CACHE_BLORP_PROG, key, key_size, kernel, kernel_size, prog_data, prog_data_size, kernel_out, prog_data_out); + return true; } void