[Mesa-dev] [PATCH 1/5] glsl: Add support for separate reference Z for shadow samplers

Chris Forbes chrisf at ijw.co.nz
Fri Oct 11 09:51:27 CEST 2013


>As a follow-on, maybe fold _textureCubeArrayShadow() into this function
now that it has support for a separate comparitor parameter?

Yeah, I'll take a look at that.

On Fri, Oct 11, 2013 at 7:56 PM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> On 10/10/2013 12:21 AM, Chris Forbes wrote:
>> ARB_gpu_shader5's textureGather*() functions which take shadow samplers
>> have a separate `refz` parameter rather than adding it to the
>> coordinate.
>>
>> Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
>> ---
>>  src/glsl/builtin_functions.cpp | 20 +++++++++++++++-----
>>  1 file changed, 15 insertions(+), 5 deletions(-)
>>
>> diff --git a/src/glsl/builtin_functions.cpp b/src/glsl/builtin_functions.cpp
>> index db6a0a9..ef8b7bb 100644
>> --- a/src/glsl/builtin_functions.cpp
>> +++ b/src/glsl/builtin_functions.cpp
>> @@ -3383,11 +3383,21 @@ builtin_builder::_texture(ir_texture_opcode opcode,
>>     if (flags & TEX_PROJECT)
>>        tex->projector = swizzle(P, coord_type->vector_elements - 1, 1);
>>
>> -   /* The shadow comparitor is normally in the Z component, but a few types
>> -    * have sufficiently large coordinates that it's in W.
>> -    */
>> -   if (sampler_type->sampler_shadow)
>> -      tex->shadow_comparitor = swizzle(P, MAX2(coord_size, SWIZZLE_Z), 1);
>> +   if (sampler_type->sampler_shadow) {
>> +      if (opcode == ir_tg4) {
>> +         /* gather has refz as a separate parameter, immediately after the
>> +          * coordinate
>> +          */
>
> Interesting.  texture(samplerCubeArrayShadow) is just like this - a vec4
> coordinate and an extra float comparitor.  I handled that in a separate
> function, since it was a unique case, but that's not true anymore.
>
> It probably makes sense to handle Gather here, since you need all the
> offset stuff as well.
>
> As a follow-on, maybe fold _textureCubeArrayShadow() into this function
> now that it has support for a separate comparitor parameter?
>
> Patches 1-3 are:
> Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
>
>> +         ir_variable *refz = in_var(glsl_type::float_type, "refz");
>> +         sig->parameters.push_tail(refz);
>> +         tex->shadow_comparitor = var_ref(refz);
>> +      } else {
>> +         /* The shadow comparitor is normally in the Z component, but a few types
>> +          * have sufficiently large coordinates that it's in W.
>> +          */
>> +         tex->shadow_comparitor = swizzle(P, MAX2(coord_size, SWIZZLE_Z), 1);
>> +      }
>> +   }
>>
>>     if (opcode == ir_txl) {
>>        ir_variable *lod = in_var(glsl_type::float_type, "lod");
>>
>


More information about the mesa-dev mailing list