From: Alejandro PiƱeiro Date: Wed, 13 Feb 2019 11:11:47 +0000 (+0100) Subject: blorp: introduce helper method blorp_nir_init_shader X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=675eabb56069795a2dbcc55ced7e77cfe4e93b92;p=mesa.git blorp: introduce helper method blorp_nir_init_shader This initializes the nir shader that will be used by blorp. Right now it doesn't do too much beyond calling nir_builder_init_simple_shader, and setting a name. More stuff will be added on following patches. v2: there is a case were it is used a VERTEX_SHADER (Alejandro) --- diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c index b4bd9aac19a..9bea4ffbe2c 100644 --- a/src/intel/blorp/blorp_blit.c +++ b/src/intel/blorp/blorp_blit.c @@ -1232,7 +1232,7 @@ brw_blorp_build_nir_shader(struct blorp_context *blorp, void *mem_ctx, (key->dst_samples <= 1)); nir_builder b; - nir_builder_init_simple_shader(&b, mem_ctx, MESA_SHADER_FRAGMENT, NULL); + blorp_nir_init_shader(&b, mem_ctx, MESA_SHADER_FRAGMENT, NULL); struct brw_blorp_blit_vars v; brw_blorp_blit_vars_init(&b, &v, key); diff --git a/src/intel/blorp/blorp_clear.c b/src/intel/blorp/blorp_clear.c index 0b26755e90a..1ca0c44835e 100644 --- a/src/intel/blorp/blorp_clear.c +++ b/src/intel/blorp/blorp_clear.c @@ -63,8 +63,7 @@ blorp_params_get_clear_kernel(struct blorp_batch *batch, void *mem_ctx = ralloc_context(NULL); nir_builder b; - nir_builder_init_simple_shader(&b, mem_ctx, MESA_SHADER_FRAGMENT, NULL); - b.shader->info.name = ralloc_strdup(b.shader, "BLORP-clear"); + blorp_nir_init_shader(&b, mem_ctx, MESA_SHADER_FRAGMENT, "BLORP-clear"); nir_variable *v_color = BLORP_CREATE_NIR_INPUT(b.shader, clear_color, glsl_vec4_type()); @@ -146,8 +145,7 @@ blorp_params_get_layer_offset_vs(struct blorp_batch *batch, void *mem_ctx = ralloc_context(NULL); nir_builder b; - nir_builder_init_simple_shader(&b, mem_ctx, MESA_SHADER_VERTEX, NULL); - b.shader->info.name = ralloc_strdup(b.shader, "BLORP-layer-offset-vs"); + blorp_nir_init_shader(&b, mem_ctx, MESA_SHADER_VERTEX, "BLORP-layer-offset-vs"); const struct glsl_type *uvec4_type = glsl_vector_type(GLSL_TYPE_UINT, 4); @@ -957,8 +955,8 @@ blorp_params_get_mcs_partial_resolve_kernel(struct blorp_batch *batch, void *mem_ctx = ralloc_context(NULL); nir_builder b; - nir_builder_init_simple_shader(&b, mem_ctx, MESA_SHADER_FRAGMENT, NULL); - b.shader->info.name = ralloc_strdup(b.shader, "BLORP-mcs-partial-resolve"); + blorp_nir_init_shader(&b, mem_ctx, MESA_SHADER_FRAGMENT, + "BLORP-mcs-partial-resolve"); nir_variable *v_color = BLORP_CREATE_NIR_INPUT(b.shader, clear_color, glsl_vec4_type()); diff --git a/src/intel/blorp/blorp_nir_builder.h b/src/intel/blorp/blorp_nir_builder.h index 7f23abdef4d..28c34d19da6 100644 --- a/src/intel/blorp/blorp_nir_builder.h +++ b/src/intel/blorp/blorp_nir_builder.h @@ -23,6 +23,17 @@ #include "compiler/nir/nir_builder.h" +static inline void +blorp_nir_init_shader(nir_builder *b, + void *mem_ctx, + gl_shader_stage stage, + const char *name) +{ + nir_builder_init_simple_shader(b, mem_ctx, stage, NULL); + if (name != NULL) + b->shader->info.name = ralloc_strdup(b->shader, name); +} + static inline nir_ssa_def * blorp_nir_frag_coord(nir_builder *b) {