summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlejandro Piñeiro <[email protected]>2019-02-13 12:11:47 +0100
committerAlejandro Piñeiro <[email protected]>2019-02-21 11:47:51 +0100
commit675eabb56069795a2dbcc55ced7e77cfe4e93b92 (patch)
treecd8d3f0acdb7189c2c680f6ff7dd8feb81e28394 /src
parent705723e6bef61b3937d5a4928e58b63d4c70f18c (diff)
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)
Diffstat (limited to 'src')
-rw-r--r--src/intel/blorp/blorp_blit.c2
-rw-r--r--src/intel/blorp/blorp_clear.c10
-rw-r--r--src/intel/blorp/blorp_nir_builder.h11
3 files changed, 16 insertions, 7 deletions
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)
{