<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, May 17, 2017 at 5:42 AM, Pohjolainen, Topi <span dir="ltr"><<a href="mailto:topi.pohjolainen@gmail.com" target="_blank">topi.pohjolainen@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On Tue, May 16, 2017 at 03:45:19PM -0700, Jason Ekstrand wrote:<br>
> Gen5 and earlier can't do non-normalized coordinates so we need to<br>
> compensate in the shader. Fortunately, it's pretty easy plumb through.<br>
> ---<br>
> src/intel/blorp/blorp_blit.c | 27 ++++++++++++++++++++++-----<br>
> src/intel/blorp/blorp_priv.h | 6 ++++++<br>
> 2 files changed, 28 insertions(+), 5 deletions(-)<br>
><br>
> diff --git a/src/intel/blorp/blorp_blit.c b/src/intel/blorp/blorp_blit.c<br>
> index 144bfb3..23e33de 100644<br>
> --- a/src/intel/blorp/blorp_blit.c<br>
> +++ b/src/intel/blorp/blorp_blit.c<br>
> @@ -55,6 +55,7 @@ struct brw_blorp_blit_vars {<br>
> nir_variable *v_src_z;<br>
> nir_variable *v_src_offset;<br>
> nir_variable *v_dst_offset;<br>
> + nir_variable *v_src_inv_size;<br>
><br>
> /* gl_FragCoord */<br>
> nir_variable *frag_coord;<br>
> @@ -79,6 +80,7 @@ brw_blorp_blit_vars_init(nir_<wbr>builder *b, struct brw_blorp_blit_vars *v,<br>
> LOAD_INPUT(src_z, glsl_uint_type())<br>
> LOAD_INPUT(src_offset, glsl_vector_type(GLSL_TYPE_<wbr>UINT, 2))<br>
> LOAD_INPUT(dst_offset, glsl_vector_type(GLSL_TYPE_<wbr>UINT, 2))<br>
> + LOAD_INPUT(src_inv_size, glsl_vector_type(GLSL_TYPE_<wbr>FLOAT, 2))<br>
><br>
> #undef LOAD_INPUT<br>
><br>
> @@ -198,10 +200,15 @@ blorp_create_nir_tex_instr(<wbr>nir_builder *b, struct brw_blorp_blit_vars *v,<br>
><br>
> static nir_ssa_def *<br>
> blorp_nir_tex(nir_builder *b, struct brw_blorp_blit_vars *v,<br>
> - nir_ssa_def *pos, nir_alu_type dst_type)<br>
> + const struct brw_blorp_blit_prog_key *key, nir_ssa_def *pos)<br>
> {<br>
> + /* If the sampler requires normalized coordinates, we need to compensate. */<br>
> + if (key->src_coords_normalized)<br>
> + pos = nir_fmul(b, pos, nir_load_var(b, v->v_src_inv_size));<br>
> +<br>
> nir_tex_instr *tex =<br>
> - blorp_create_nir_tex_instr(b, v, nir_texop_tex, pos, 2, dst_type);<br>
> + blorp_create_nir_tex_instr(b, v, nir_texop_tex, pos, 2,<br>
> + key->texture_data_type);<br>
><br>
> assert(pos->num_components == 2);<br>
> tex->sampler_dim = GLSL_SAMPLER_DIM_2D;<br>
> @@ -1188,7 +1195,7 @@ brw_blorp_build_nir_shader(<wbr>struct blorp_context *blorp, void *mem_ctx,<br>
> src_pos = nir_ishl(&b, src_pos, nir_imm_int(&b, 1));<br>
> src_pos = nir_iadd(&b, src_pos, nir_imm_int(&b, 1));<br>
> src_pos = nir_i2f32(&b, src_pos);<br>
> - color = blorp_nir_tex(&b, &v, src_pos, key->texture_data_type);<br>
> + color = blorp_nir_tex(&b, &v, key, src_pos);<br>
> } else {<br>
> /* Gen7+ hardware doesn't automaticaly blend. */<br>
> color = blorp_nir_manual_blend_<wbr>average(&b, &v, src_pos, key->src_samples,<br>
> @@ -1200,7 +1207,7 @@ brw_blorp_build_nir_shader(<wbr>struct blorp_context *blorp, void *mem_ctx,<br>
> color = blorp_nir_manual_blend_<wbr>bilinear(&b, src_pos, key->src_samples, key, &v);<br>
> } else {<br>
> if (key->bilinear_filter) {<br>
> - color = blorp_nir_tex(&b, &v, src_pos, key->texture_data_type);<br>
> + color = blorp_nir_tex(&b, &v, key, src_pos);<br>
> } else {<br>
> /* We're going to use texelFetch, so we need integers */<br>
> if (src_pos->num_components == 2) {<br>
> @@ -2056,9 +2063,19 @@ blorp_blit(struct blorp_batch *batch,<br>
> wm_prog_key.y_scale = params.src.surf.samples / wm_prog_key.x_scale;<br>
><br>
> if (filter == GL_LINEAR &&<br>
> - params.src.surf.samples <= 1 && params.dst.surf.samples <= 1)<br>
> + params.src.surf.samples <= 1 && params.dst.surf.samples <= 1) {<br>
> wm_prog_key.bilinear_filter = true;<br>
><br>
> + if (batch->blorp->isl_dev->info-><wbr>gen < 6) {<br>
> + /* Gen4-5 don't support non-normalized texture coordinates */<br>
> + wm_prog_key.src_coords_<wbr>normalized = true;<br>
> + params.wm_inputs.src_inv_size[<wbr>0] =<br>
> + 1.0f / minify(params.src.surf.<wbr>logical_level0_px.width, src_level);<br>
> + params.wm_inputs.src_inv_size[<wbr>1] =<br>
> + 1.0f / minify(params.src.surf.<wbr>logical_level0_px.height, src_level);<br>
> + }<br>
> + }<br>
> +<br>
> if ((params.src.surf.usage & ISL_SURF_USAGE_DEPTH_BIT) == 0 &&<br>
> (params.src.surf.usage & ISL_SURF_USAGE_STENCIL_BIT) == 0 &&<br>
> !isl_format_has_int_channel(<wbr>params.src.surf.format) &&<br>
> diff --git a/src/intel/blorp/blorp_priv.h b/src/intel/blorp/blorp_priv.h<br>
> index c61ab08..39da5af 100644<br>
> --- a/src/intel/blorp/blorp_priv.h<br>
> +++ b/src/intel/blorp/blorp_priv.h<br>
> @@ -124,6 +124,9 @@ struct brw_blorp_wm_inputs<br>
> struct blorp_surf_offset src_offset;<br>
> struct blorp_surf_offset dst_offset;<br>
><br>
> + /* (1/width, 1/height) for the source surface */<br>
> + float src_inv_size[2];<br>
> +<br>
<br>
</div></div>There is still the "pad[1]" in the end which I think is now correct, before<br>
it should have been "pad[3]", right? It aligns to vec4.</blockquote><div><br></div><div>Yes<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Do we really need<br>
that anymore...<span class=""><br></span></blockquote><div><br></div><div>Maybe? The real requirement is that we can't have a single element of wm_inputs cross a vec4 boundary because of the way that inputs are loaded. I think having the pad[1] is good for documenting that if nothing else.<br><br></div><div>--Jason<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">
> /* Minimum layer setting works for all the textures types but texture_3d<br>
> * for which the setting has no effect. Use the z-coordinate instead.<br>
> */<br>
> @@ -228,6 +231,9 @@ struct brw_blorp_blit_prog_key<br>
> /* Number of bits per channel in the source image. */<br>
> uint8_t src_bpc;<br>
><br>
> + /* True if the source requires normalized coordinates */<br>
> + bool src_coords_normalized;<br>
> +<br>
> /* Number of samples per pixel that have been configured in the render<br>
> * target.<br>
> */<br>
> --<br>
> 2.5.0.400.gff86faf<br>
><br>
</span>> ______________________________<wbr>_________________<br>
> mesa-dev mailing list<br>
> <a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</blockquote></div><br></div></div>