[Mesa-dev] [PATCH 2/3] nir/lower-tex: add srgb->linear lowering

Eric Anholt eric at anholt.net
Tue Apr 19 19:24:02 UTC 2016


Rob Clark <robdclark at gmail.com> writes:

> On Tue, Apr 19, 2016 at 1:06 PM, Jason Ekstrand <jason at jlekstrand.net> wrote:
>>
>>
>> On Tue, Apr 19, 2016 at 6:58 AM, Rob Clark <robdclark at gmail.com> wrote:
>>>  } nir_lower_tex_options;
>>>
>>>  bool nir_lower_tex(nir_shader *shader,
>>> diff --git a/src/compiler/nir/nir_lower_tex.c
>>> b/src/compiler/nir/nir_lower_tex.c
>>> index 7740e58..6bae3b7 100644
>>> --- a/src/compiler/nir/nir_lower_tex.c
>>> +++ b/src/compiler/nir/nir_lower_tex.c
>>> @@ -275,6 +275,45 @@ swizzle_result(nir_builder *b, nir_tex_instr *tex,
>>> const uint8_t swizzle[4])
>>>                                    swizzled->parent_instr);
>>>  }
>>>
>>> +static void
>>> +linearize_srgb_result(nir_builder *b, nir_tex_instr *tex)
>>> +{
>>> +   assert(tex->dest.is_ssa);
>>> +   assert(nir_tex_instr_dest_size(tex) == 4);
>>> +   assert(nir_alu_type_get_base_type(tex->dest_type) == nir_type_float);
>>> +
>>> +   b->cursor = nir_after_instr(&tex->instr);
>>> +
>>> +   nir_ssa_def *components[4];
>>> +
>>> +   /* first three channels are rgb: */
>>> +   for (unsigned i = 0; i < 3; i++) {
>>
>>
>> Um... NIR is a vector IR.  Why are we looping over channels?  Just do a
>> nir_swizzle to pick off the first three, do the sRGB conversion, and nir_vec
>> them back together with the alpha channel.
>
> oh, hmm, yeah.. used to thinking in scalar

Other than scalar when we should probably be doing vector, this looks
good to me, and I'll totally use it.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160419/5b05dacb/attachment.sig>


More information about the mesa-dev mailing list