[Mesa-dev] [PATCH 2/3] mesa: move gl_texture_image::Width/Height/DepthScale fields to swrast

Brian Paul brianp at vmware.com
Thu Sep 22 14:49:53 PDT 2011


On 09/22/2011 03:13 PM, Eric Anholt wrote:
> On Wed, 21 Sep 2011 18:56:53 -0600, Brian Paul<brian.e.paul at gmail.com>  wrote:
>> From: Brian Paul<brianp at vmware.com>
>>
>> These fields were only used for swrast so move them into
>> swrast_texture_image.
>> diff --git a/src/mesa/swrast/s_texture.c b/src/mesa/swrast/s_texture.c
>> index 14ee0eb..1dcb08c 100644
>> --- a/src/mesa/swrast/s_texture.c
>> +++ b/src/mesa/swrast/s_texture.c
>> @@ -85,6 +85,19 @@ _swrast_alloc_texture_image_buffer(struct gl_context *ctx,
>>      else
>>         swImg->_IsPowerOfTwo = GL_FALSE;
>>
>> +   /* Compute Width/Height/DepthScale for mipmap lod computation */
>> +   if (texImage->TexObject->Target == GL_TEXTURE_RECTANGLE_NV) {
>> +      /* scale = 1.0 since texture coords directly map to texels */
>> +      swImg->WidthScale = 1.0;
>> +      swImg->HeightScale = 1.0;
>> +      swImg->DepthScale = 1.0;
>> +   }
>> +   else {
>> +      swImg->WidthScale = (GLfloat) texImage->Width;
>> +      swImg->HeightScale = (GLfloat) texImage->Height;
>> +      swImg->DepthScale = (GLfloat) texImage->Depth;
>> +   }
>> +
>>      return texImage->Data != NULL;
>>   }
>
> So, what I've been confused about with these patches is: what guarantees
> that this has been called on a hardware driver that might sometimes fall
> back to software?  Several paths use AllocTextureImageBuffer, but
> notably TexImage2D doesn't.
>
> On the other hand, unless I just failed at testing, I couldn't detect
> any regressions, even with no_rast=true.

Hmmm, it looks like we're just getting lucky at the moment.

It looks like the intel driver doesn't override 
AllocTextureImageBuffer() so _swrast_alloc_texture_image_buffer() is 
always getting called.

The swrast code that sets _IsPowerOfTwo, etc should probably be put 
into a separate function that would get called from the intel 
AllocTextureImageBuffer() hook, whenever one is added.

The gallium state tracker doesn't implement AllocTextureImageBuffer() 
either yet.  And none of the core mesa paths that call 
AllocTextureImageBuffer() are hit when using gallium.

With a bit of refactoring I'll be able to trim out a bunch of 
glTexImage() code in the state tracker and re-use what's in core Mesa 
(similar to what you want to do in the intel driver).

-Brian


More information about the mesa-dev mailing list