[Mesa-dev] [RFC PATCH 09/10] i965/clip: Use clip distances for all user clipping

Chris Forbes chrisf at ijw.co.nz
Mon Aug 5 14:59:25 PDT 2013


Actually, that justification sounds like nonsense after thinking about
it a bit more -- we're in SPF mode.

On Tue, Aug 6, 2013 at 9:47 AM, Chris Forbes <chrisf at ijw.co.nz> wrote:
> This is what I started with, but brw_ENDIF destroys the flags.
>
> On Tue, Aug 6, 2013 at 9:40 AM, Paul Berry <stereotype441 at gmail.com> wrote:
>> On 3 August 2013 19:59, Chris Forbes <chrisf at ijw.co.nz> wrote:
>>>
>>> Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
>>> ---
>>>  src/mesa/drivers/dri/i965/brw_clip_tri.c | 7 +++++--
>>>  1 file changed, 5 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/src/mesa/drivers/dri/i965/brw_clip_tri.c
>>> b/src/mesa/drivers/dri/i965/brw_clip_tri.c
>>> index bd3ffb3..4d2eb0a 100644
>>> --- a/src/mesa/drivers/dri/i965/brw_clip_tri.c
>>> +++ b/src/mesa/drivers/dri/i965/brw_clip_tri.c
>>> @@ -241,16 +241,19 @@ load_clip_distance(struct brw_clip_compile *c,
>>> struct brw_indirect vtx,
>>>     brw_AND(p, vec1(brw_null_reg()), c->reg.vertex_src_mask,
>>> brw_imm_ud(1));
>>>     brw_IF(p, BRW_EXECUTE_1);
>>>     {
>>> -      brw_MOV(p, dst, deref_4f(vtx, clip_offset));
>>> +      struct brw_indirect temp_ptr = brw_indirect(7, 0);
>>> +      brw_ADD(p, get_addr_reg(temp_ptr), get_addr_reg(vtx),
>>> c->reg.clipdistance_offset);
>>> +      brw_MOV(p, vec1(dst), deref_1f(temp_ptr, 0));
>>>     }
>>>     brw_ELSE(p);
>>>     {
>>>        brw_MOV(p, dst, deref_4f(vtx, hpos_offset));
>>> +      brw_DP4(p, dst, dst, c->reg.plane_equation);
>>>     }
>>>     brw_ENDIF(p);
>>>
>>>     brw_set_conditionalmod(p, cond);
>>> -   brw_DP4(p, dst, dst, c->reg.plane_equation);
>>> +   brw_CMP(p, brw_null_reg(), cond, vec1(dst), brw_imm_f(0.0f));
>>>  }
>>
>>
>> I think you can use one less instruction if you do this instead:
>>
>>    brw_IF(p, BRW_EXECUTE_1);
>>    {
>>
>>       struct brw_indirect temp_ptr = brw_indirect(7, 0);
>>       brw_ADD(p, get_addr_reg(temp_ptr), get_addr_reg(vtx),
>> c->reg.clipdistance_offset);
>>       brw_set_conditionalmod(p, cond);
>>
>>       brw_MOV(p, vec1(dst), deref_1f(temp_ptr, 0));
>>    }
>>    brw_ELSE(p);
>>    {
>>       brw_MOV(p, dst, deref_4f(vtx, hpos_offset));
>>       brw_set_conditionalmod(p, cond);
>>
>>       brw_DP4(p, dst, dst, c->reg.plane_equation);
>>    }
>>    brw_ENDIF(p);
>>
>> But I haven't tried it so it's possible that it doesn't work for some
>> non-obvious reason :)
>>
>> In any case, this patch is:
>>
>> Reviewed-by: Paul Berry <stereotype441 at gmail.com>


More information about the mesa-dev mailing list