From 675eabb56069795a2dbcc55ced7e77cfe4e93b92 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alejandro=20Pi=C3=B1eiro?= Date: Wed, 13 Feb 2019 12:11:47 +0100 Subject: [PATCH] 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) --- src/intel/blorp/blorp_blit.c | 2 +- src/intel/blorp/blorp_clear.c | 10 ++++------ src/intel/blorp/blorp_nir_builder.h | 11 +++++++++++ 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c index b4bd9aa..9bea4ff 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 0b26755..1ca0c44 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 7f23abd..28c34d1 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) { -- 2.7.4