diff options
author | Jason Ekstrand <jason.ekstrand@intel.com> | 2016-10-21 14:15:03 -0700 |
---|---|---|
committer | Jason Ekstrand <jason.ekstrand@intel.com> | 2016-11-16 10:11:29 -0800 |
commit | 21943c35f75d90f464f8495f5282037e1c7c79d0 (patch) | |
tree | 72c87e3045ac88dd1c6ca8bb8ed3caed11c9b3b5 /src/intel/blorp | |
parent | 570a0e844b4be3bc5546b860e9968b55b2f3909d (diff) |
intel/blorp: Handle NIR clear inputs the same way as blit inputs
By using offsetof() we can ensure that adding fiels to wm_inputs is always
safe as long as we maintain alignment.
Signed-off-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Topi Pohjolainen <topi.pohjolainen@intel.com>
Diffstat (limited to 'src/intel/blorp')
-rw-r--r-- | src/intel/blorp/blorp_blit.c | 8 | ||||
-rw-r--r-- | src/intel/blorp/blorp_clear.c | 6 | ||||
-rw-r--r-- | 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 893a4bc4b16..27af21f2548 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 2b8af18019d..e4a4acb1f08 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 1258fa96f1a..04aa152193d 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; \ +}) + static inline unsigned brw_blorp_get_urb_length(const struct brw_wm_prog_data *prog_data) { |