[Mesa-dev] [PATCH v3 1/4] nir: set default lod to texture opcodes that needed it but don't provide it
Jason Ekstrand
jason at jlekstrand.net
Thu Oct 19 13:55:47 UTC 2017
On October 18, 2017 11:44:12 PM Samuel Iglesias Gonsálvez
<siglesias at igalia.com> wrote:
> On Wednesday, October 18, 2017 8:11:01 AM CEST Jason Ekstrand wrote:
>> On October 18, 2017 12:54:48 AM Samuel Iglesias Gonsálvez
>>
>> <siglesias at igalia.com> wrote:
>> > v2:
>> > - Use helper to add a new source to the texture instruction.
>> >
>> > Signed-off-by: Samuel Iglesias Gonsálvez <siglesias at igalia.com>
>> > ---
>> >
>> > src/compiler/nir/nir_lower_tex.c | 23 +++++++++++++++++++++++
>> > 1 file changed, 23 insertions(+)
>> >
>> > diff --git a/src/compiler/nir/nir_lower_tex.c
>> > b/src/compiler/nir/nir_lower_tex.c
>> > index 65681decb1c..676c0c21e7a 100644
>> > --- a/src/compiler/nir/nir_lower_tex.c
>> > +++ b/src/compiler/nir/nir_lower_tex.c
>> > @@ -813,6 +813,29 @@ nir_lower_tex_block(nir_block *block, nir_builder *b,
>> >
>> > progress = true;
>> > continue;
>> >
>> > }
>> >
>> > +
>> > + /* TXF, TXS and TXL require a LOD but not everything we implement
>> > using those
>> > + * three opcodes provides one. Provide a default LOD of 0.
>> > + */
>> > + if (tex->op == nir_texop_txf || tex->op == nir_texop_txs ||
>> > + tex->op == nir_texop_txl || tex->op == nir_texop_query_levels
>> > ||
>> > + (tex->op == nir_texop_tex && b->shader->stage !=
>> > MESA_SHADER_FRAGMENT)) {
>> > + int i;
>> > + bool has_lod = false;
>> > + for (i = 0; i < tex->num_srcs; i++) {
>> > + if (tex->src[i].src_type == nir_tex_src_lod) {
>> > + has_lod = true;
>> > + break;
>> > + }
>> > + }
>>
>> Sorry to ask you to delete even more of your patch but this is just
>> nir_tex_instr_src_index(tex, nir_tex_src_lod).
>>
>
> Thanks for the advice! That simplifies a lot the patch, which is always great
> :-)
>
> Now it is like:
>
> + /* TXF, TXS and TXL require a LOD but not everything we implement using
> those
> + * three opcodes provides one. Provide a default LOD of 0.
> + */
> + if ((nir_tex_instr_src_index(tex, nir_tex_src_lod) == -1) &&
> + (tex->op == nir_texop_txf || tex->op == nir_texop_txs ||
> + tex->op == nir_texop_txl || tex->op == nir_texop_query_levels ||
> + (tex->op == nir_texop_tex && b->shader->stage !=
> MESA_SHADER_FRAGMENT))) {
> + b->cursor = nir_before_instr(&tex->instr);
> + nir_tex_instr_add_src(tex, nir_tex_src_lod,
> nir_src_for_ssa(nir_imm_int(b, 0)));
> + progress = true;
> + continue;
> + }
>
>
> I have done this change locally. Does it get your R+1?
Yup
> Sam
>
> P.S: Patch 4 is still unreviewed.
The SPIR-V one? Yeah, I need to pull the CTS CL and look at out.
>> > +
>> > + if (!has_lod) {
>> > + b->cursor = nir_before_instr(&tex->instr);
>> > + nir_tex_instr_add_src(tex, nir_tex_src_lod,
>> > nir_src_for_ssa(nir_imm_int(b, 0)));
>> > + progress = true;
>> > + continue;
>> > + }
>> > + }
>> >
>> > }
>> >
>> > return progress;
>> >
>> > --
>> > 2.14.2
>> >
>> > _______________________________________________
>> > 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