[Mesa-dev] [PATCH 14/25] intel/blorp: Handle NIR clear inputs the same way as blit inputs
Jason Ekstrand
jason at jlekstrand.net
Sat Oct 22 17:50:45 UTC 2016
By using offsetof() we can ensure that adding fiels to wm_inputs is always
safe as long as we maintain alignment.
---
src/intel/blorp/blorp_blit.c | 8 +-------
src/intel/blorp/blorp_clear.c | 6 ++----
src/intel/blorp/blorp_priv.h | 14 ++++++++++++++
3 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c
index 9baf3ad..3e30f4c 100644
--- a/src/intel/blorp/blorp_blit.c
+++ b/src/intel/blorp/blorp_blit.c
@@ -67,13 +67,7 @@ brw_blorp_blit_vars_init(nir_builder *b, struct brw_blorp_blit_vars *v,
assert(!key->use_kill || !(key->blend && key->blit_scaled));
#define LOAD_INPUT(name, type)\
- v->v_##name = nir_variable_create(b->shader, nir_var_shader_in, \
- type, #name); \
- v->v_##name->data.interpolation = INTERP_MODE_FLAT; \
- v->v_##name->data.location = VARYING_SLOT_VAR0 + \
- offsetof(struct brw_blorp_wm_inputs, name) / (4 * sizeof(float)); \
- v->v_##name->data.location_frac = \
- (offsetof(struct brw_blorp_wm_inputs, name) / sizeof(float)) % 4;
+ v->v_##name = BLORP_CREATE_NIR_INPUT(b->shader, name, type);
LOAD_INPUT(discard_rect, glsl_vec4_type())
LOAD_INPUT(rect_grid, glsl_vec4_type())
diff --git a/src/intel/blorp/blorp_clear.c b/src/intel/blorp/blorp_clear.c
index 43e3fd2..3d752ac 100644
--- a/src/intel/blorp/blorp_clear.c
+++ b/src/intel/blorp/blorp_clear.c
@@ -60,10 +60,8 @@ blorp_params_get_clear_kernel(struct blorp_context *blorp,
nir_builder_init_simple_shader(&b, mem_ctx, MESA_SHADER_FRAGMENT, NULL);
b.shader->info.name = ralloc_strdup(b.shader, "BLORP-clear");
- nir_variable *v_color = nir_variable_create(b.shader, nir_var_shader_in,
- glsl_vec4_type(), "v_color");
- v_color->data.location = VARYING_SLOT_VAR0;
- v_color->data.interpolation = INTERP_MODE_FLAT;
+ nir_variable *v_color =
+ BLORP_CREATE_NIR_INPUT(b.shader, clear_color, glsl_vec4_type());
nir_variable *frag_color = nir_variable_create(b.shader, nir_var_shader_out,
glsl_vec4_type(),
diff --git a/src/intel/blorp/blorp_priv.h b/src/intel/blorp/blorp_priv.h
index c41b4c6..f4f80b9 100644
--- a/src/intel/blorp/blorp_priv.h
+++ b/src/intel/blorp/blorp_priv.h
@@ -122,6 +122,8 @@ struct blorp_surf_offset {
struct brw_blorp_wm_inputs
{
+ uint32_t clear_color[4];
+
struct brw_blorp_discard_rect discard_rect;
struct brw_blorp_rect_grid rect_grid;
struct brw_blorp_coord_transform coord_transform[2];
@@ -138,6 +140,18 @@ struct brw_blorp_wm_inputs
uint32_t pad[1];
};
+#define BLORP_CREATE_NIR_INPUT(shader, name, type) ({ \
+ nir_variable *input = nir_variable_create((shader), nir_var_shader_in, \
+ type, #name); \
+ if ((shader)->stage == MESA_SHADER_FRAGMENT) \
+ input->data.interpolation = INTERP_MODE_FLAT; \
+ input->data.location = VARYING_SLOT_VAR0 + \
+ offsetof(struct brw_blorp_wm_inputs, name) / (4 * sizeof(float)); \
+ input->data.location_frac = \
+ (offsetof(struct brw_blorp_wm_inputs, name) / sizeof(float)) % 4; \
+ input; \
+})
+
struct brw_blorp_prog_data
{
bool dispatch_8;
--
2.5.0.400.gff86faf
More information about the mesa-dev
mailing list