[Mesa-dev] [PATCH v2 27/35] i965/blorp: Pass the Z component into all texture operations
Pohjolainen, Topi
topi.pohjolainen at intel.com
Thu Jul 28 08:06:22 UTC 2016
On Tue, Jul 26, 2016 at 03:02:18PM -0700, Jason Ekstrand wrote:
> Multisample array surfaces on IVB don't support the minimum array element
> surface attribute so it needs to come through the sampler message. We may
> as well just pass it through everything.
> ---
> src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 77 +++++++++++++---------------
> 1 file changed, 35 insertions(+), 42 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> index fb81a22..a76d130 100644
> --- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> +++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
> @@ -432,11 +432,11 @@ blorp_nir_discard_if_outside_rect(nir_builder *b, nir_ssa_def *pos,
> }
>
> static nir_tex_instr *
> -blorp_create_nir_tex_instr(nir_shader *shader, nir_texop op,
> - nir_ssa_def *pos, unsigned num_srcs,
> +blorp_create_nir_tex_instr(nir_builder *b, struct brw_blorp_blit_vars *v,
> + nir_texop op, nir_ssa_def *pos, unsigned num_srcs,
> enum brw_reg_type dst_type)
> {
> - nir_tex_instr *tex = nir_tex_instr_create(shader, num_srcs);
> + nir_tex_instr *tex = nir_tex_instr_create(b->shader, num_srcs);
>
> tex->op = op;
>
> @@ -463,22 +463,32 @@ blorp_create_nir_tex_instr(nir_shader *shader, nir_texop op,
> tex->texture_index = 0;
> tex->sampler_index = 0;
>
> + /* To properly handle 3-D and 2-D array textures, we pull the Z component
> + * from a uniform. TODO: This is a bit magic; we should probably make this
This is really something I overlooked when I switched from uniforms to flat
inputs. If you like you could update the comment to talk about flat vertex
input. Anyway, looks good:
Reviewed-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
> + * more explicit in the future.
> + */
> + assert(pos->num_components >= 2);
> + pos = nir_vec3(b, nir_channel(b, pos, 0), nir_channel(b, pos, 1),
> + nir_load_var(b, v->v_src_z));
> +
> + tex->src[0].src_type = nir_tex_src_coord;
> + tex->src[0].src = nir_src_for_ssa(pos);
> + tex->coord_components = 3;
> +
> nir_ssa_dest_init(&tex->instr, &tex->dest, 4, 32, NULL);
>
> return tex;
> }
>
> static nir_ssa_def *
> -blorp_nir_tex(nir_builder *b, nir_ssa_def *pos, enum brw_reg_type dst_type)
> +blorp_nir_tex(nir_builder *b, struct brw_blorp_blit_vars *v,
> + nir_ssa_def *pos, enum brw_reg_type dst_type)
> {
> nir_tex_instr *tex =
> - blorp_create_nir_tex_instr(b->shader, nir_texop_tex, pos, 2, dst_type);
> + blorp_create_nir_tex_instr(b, v, nir_texop_tex, pos, 2, dst_type);
>
> assert(pos->num_components == 2);
> tex->sampler_dim = GLSL_SAMPLER_DIM_2D;
> - tex->coord_components = 2;
> - tex->src[0].src_type = nir_tex_src_coord;
> - tex->src[0].src = nir_src_for_ssa(pos);
> tex->src[1].src_type = nir_tex_src_lod;
> tex->src[1].src = nir_src_for_ssa(nir_imm_int(b, 0));
>
> @@ -492,20 +502,9 @@ blorp_nir_txf(nir_builder *b, struct brw_blorp_blit_vars *v,
> nir_ssa_def *pos, enum brw_reg_type dst_type)
> {
> nir_tex_instr *tex =
> - blorp_create_nir_tex_instr(b->shader, nir_texop_txf, pos, 2, dst_type);
> -
> - /* In order to properly handle 3-D textures, we pull the Z component from
> - * a uniform. TODO: This is a bit magic; we should probably make this
> - * more explicit in the future.
> - */
> - assert(pos->num_components == 2);
> - pos = nir_vec3(b, nir_channel(b, pos, 0), nir_channel(b, pos, 1),
> - nir_load_var(b, v->v_src_z));
> + blorp_create_nir_tex_instr(b, v, nir_texop_txf, pos, 2, dst_type);
>
> tex->sampler_dim = GLSL_SAMPLER_DIM_3D;
> - tex->coord_components = 3;
> - tex->src[0].src_type = nir_tex_src_coord;
> - tex->src[0].src = nir_src_for_ssa(pos);
> tex->src[1].src_type = nir_tex_src_lod;
> tex->src[1].src = nir_src_for_ssa(nir_imm_int(b, 0));
>
> @@ -515,17 +514,14 @@ blorp_nir_txf(nir_builder *b, struct brw_blorp_blit_vars *v,
> }
>
> static nir_ssa_def *
> -blorp_nir_txf_ms(nir_builder *b, nir_ssa_def *pos, nir_ssa_def *mcs,
> - enum brw_reg_type dst_type)
> +blorp_nir_txf_ms(nir_builder *b, struct brw_blorp_blit_vars *v,
> + nir_ssa_def *pos, nir_ssa_def *mcs, enum brw_reg_type dst_type)
> {
> nir_tex_instr *tex =
> - blorp_create_nir_tex_instr(b->shader, nir_texop_txf_ms, pos,
> + blorp_create_nir_tex_instr(b, v, nir_texop_txf_ms, pos,
> mcs != NULL ? 3 : 2, dst_type);
>
> tex->sampler_dim = GLSL_SAMPLER_DIM_MS;
> - tex->coord_components = 2;
> - tex->src[0].src_type = nir_tex_src_coord;
> - tex->src[0].src = nir_src_for_ssa(pos);
>
> tex->src[1].src_type = nir_tex_src_ms_index;
> if (pos->num_components == 2) {
> @@ -546,16 +542,13 @@ blorp_nir_txf_ms(nir_builder *b, nir_ssa_def *pos, nir_ssa_def *mcs,
> }
>
> static nir_ssa_def *
> -blorp_nir_txf_ms_mcs(nir_builder *b, nir_ssa_def *pos)
> +blorp_nir_txf_ms_mcs(nir_builder *b, struct brw_blorp_blit_vars *v, nir_ssa_def *pos)
> {
> nir_tex_instr *tex =
> - blorp_create_nir_tex_instr(b->shader, nir_texop_txf_ms_mcs,
> + blorp_create_nir_tex_instr(b, v, nir_texop_txf_ms_mcs,
> pos, 1, BRW_REGISTER_TYPE_D);
>
> tex->sampler_dim = GLSL_SAMPLER_DIM_MS;
> - tex->coord_components = 2;
> - tex->src[0].src_type = nir_tex_src_coord;
> - tex->src[0].src = nir_src_for_ssa(pos);
>
> nir_builder_instr_insert(b, &tex->instr);
>
> @@ -889,8 +882,8 @@ static inline int count_trailing_one_bits(unsigned value)
> }
>
> static nir_ssa_def *
> -blorp_nir_manual_blend_average(nir_builder *b, nir_ssa_def *pos,
> - unsigned tex_samples,
> +blorp_nir_manual_blend_average(nir_builder *b, struct brw_blorp_blit_vars *v,
> + nir_ssa_def *pos, unsigned tex_samples,
> enum isl_aux_usage tex_aux_usage,
> enum brw_reg_type dst_type)
> {
> @@ -902,7 +895,7 @@ blorp_nir_manual_blend_average(nir_builder *b, nir_ssa_def *pos,
>
> nir_ssa_def *mcs = NULL;
> if (tex_aux_usage == ISL_AUX_USAGE_MCS)
> - mcs = blorp_nir_txf_ms_mcs(b, pos);
> + mcs = blorp_nir_txf_ms_mcs(b, v, pos);
>
> /* We add together samples using a binary tree structure, e.g. for 4x MSAA:
> *
> @@ -944,7 +937,7 @@ blorp_nir_manual_blend_average(nir_builder *b, nir_ssa_def *pos,
> nir_ssa_def *ms_pos = nir_vec3(b, nir_channel(b, pos, 0),
> nir_channel(b, pos, 1),
> nir_imm_int(b, i));
> - texture_data[stack_depth++] = blorp_nir_txf_ms(b, ms_pos, mcs, dst_type);
> + texture_data[stack_depth++] = blorp_nir_txf_ms(b, v, ms_pos, mcs, dst_type);
>
> if (i == 0 && tex_aux_usage == ISL_AUX_USAGE_MCS) {
> /* The Ivy Bridge PRM, Vol4 Part1 p27 (Multisample Control Surface)
> @@ -1064,7 +1057,7 @@ blorp_nir_manual_blend_bilinear(nir_builder *b, nir_ssa_def *pos,
> */
> nir_ssa_def *mcs = NULL;
> if (key->tex_aux_usage == ISL_AUX_USAGE_MCS)
> - mcs = blorp_nir_txf_ms_mcs(b, sample_coords_int);
> + mcs = blorp_nir_txf_ms_mcs(b, v, sample_coords_int);
>
> /* Compute sample index and map the sample index to a sample number.
> * Sample index layout shows the numbering of slots in a rectangular
> @@ -1136,7 +1129,7 @@ blorp_nir_manual_blend_bilinear(nir_builder *b, nir_ssa_def *pos,
> nir_ssa_def *pos_ms = nir_vec3(b, nir_channel(b, sample_coords_int, 0),
> nir_channel(b, sample_coords_int, 1),
> sample);
> - tex_data[i] = blorp_nir_txf_ms(b, pos_ms, mcs, key->texture_data_type);
> + tex_data[i] = blorp_nir_txf_ms(b, v, pos_ms, mcs, key->texture_data_type);
> }
>
> nir_ssa_def *frac_x = nir_channel(b, frac_xy, 0);
> @@ -1418,10 +1411,10 @@ brw_blorp_build_nir_shader(struct brw_context *brw,
> src_pos = nir_ishl(&b, src_pos, nir_imm_int(&b, 1));
> src_pos = nir_iadd(&b, src_pos, nir_imm_int(&b, 1));
> src_pos = nir_i2f(&b, src_pos);
> - color = blorp_nir_tex(&b, src_pos, key->texture_data_type);
> + color = blorp_nir_tex(&b, &v, src_pos, key->texture_data_type);
> } else {
> /* Gen7+ hardware doesn't automaticaly blend. */
> - color = blorp_nir_manual_blend_average(&b, src_pos, key->src_samples,
> + color = blorp_nir_manual_blend_average(&b, &v, src_pos, key->src_samples,
> key->tex_aux_usage,
> key->texture_data_type);
> }
> @@ -1430,7 +1423,7 @@ brw_blorp_build_nir_shader(struct brw_context *brw,
> color = blorp_nir_manual_blend_bilinear(&b, src_pos, key->src_samples, key, &v);
> } else {
> if (key->bilinear_filter) {
> - color = blorp_nir_tex(&b, src_pos, key->texture_data_type);
> + color = blorp_nir_tex(&b, &v, src_pos, key->texture_data_type);
> } else {
> /* We're going to use texelFetch, so we need integers */
> if (src_pos->num_components == 2) {
> @@ -1476,9 +1469,9 @@ brw_blorp_build_nir_shader(struct brw_context *brw,
> } else {
> nir_ssa_def *mcs = NULL;
> if (key->tex_aux_usage == ISL_AUX_USAGE_MCS)
> - mcs = blorp_nir_txf_ms_mcs(&b, src_pos);
> + mcs = blorp_nir_txf_ms_mcs(&b, &v, src_pos);
>
> - color = blorp_nir_txf_ms(&b, src_pos, mcs, key->texture_data_type);
> + color = blorp_nir_txf_ms(&b, &v, src_pos, mcs, key->texture_data_type);
> }
> }
> }
> --
> 2.5.0.400.gff86faf
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list