Re: [PATCH 1/3] r600: add span support for 2D tiling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 27, 2010 at 8:51 AM, Brian Paul <brianp@xxxxxxxxxx> wrote:
> Alex Deucher wrote:
>>
>> On Thu, May 27, 2010 at 10:55 AM, Matt Turner <mattst88@xxxxxxxxx> wrote:
>>>>
>>>> +static inline GLint r600_log2(GLint n)
>>>> +{
>>>> +       GLint log2 = 0;
>>>> +
>>>> +       while (n >>= 1)
>>>> +               ++log2;
>>>> +       return log2;
>>>> +}
>>>
>>> Does mesa not provide something like this?
>>
>> The only one I could find was a gallium utility function.
>
> There's a logbase2() function in teximage.c but it might not be equivalent.
>
> -Brian
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@xxxxxxxxxxxxxxxxxxxxx
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
>

This code could be written with a faster algorithm requiring  just 13 operations

+               pixel_number |= ((x >> 0) & 1) << 0; // pn[0] = x[0]
+               pixel_number |= ((y >> 0) & 1) << 1; // pn[1] = y[0]
+               pixel_number |= ((x >> 1) & 1) << 2; // pn[2] = x[1]
+               pixel_number |= ((y >> 1) & 1) << 3; // pn[3] = y[1]
+               pixel_number |= ((x >> 2) & 1) << 4; // pn[4] = x[2]
+               pixel_number |= ((y >> 2) & 1) << 5; // pn[5] = y[2]



/* suitable for all 16 bit or greater processors that can do an
unsigned 16 bit or greater multiply */
/*  tested and verified  */

pixel_number = ((((x & 0x07) * 0x1111 & 0x8421) * 0x1249 >> 9) & 0x55 ) |
                             ((((y & 0x07) * 0x1111 & 0x8421) * 0x1249
>> 8) & 0xAA );

Note if it is known that x and y are less than or equal to 7 it can be
done in 11 operations.

Cheers

Conn
-- 

Conn O. Clark

Observation: In formal computer science advances are made
by standing on the shoulders of giants. Linux has proved
that if there are enough of you, you can advance just as
far by stepping on each others toes.
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux