[Mesa-dev] [PATCH] mesa: implement glTexImage as glTexSubImage when possible

Brian Paul brianp at vmware.com
Mon Jun 11 17:58:08 CEST 2012


On 06/10/2012 11:42 PM, Eric Anholt wrote:
> On Fri,  8 Jun 2012 14:31:52 -0600, Brian Paul<brianp at vmware.com>  wrote:
>> I've now seen a couple apps that replace a whole texture image with a
>> glTexImage() call instead of glTexSubImage().  The later is better
>> because we can skip freeing/allocating texture memory.
>>
>> This patch checks if the new glTexImage's format and size matches the
>> current image.  If so, use the TexSubImage path.
>
> This only makes sense if drivers consistently do blit uploads for
> texsubimage -- otherwise, teximage (which does) is better.  Right now
> i965 only manages to do so for non-depth, GL_TEXTURE_2D textures,
> pre-gen6.  Hopefully that will get fixed now that we've got the 3d blit
> code, so that wouldn't block this patch for us.
>
> For hardware drivers, I expect this to be no change or a loss, though.
> Do you have any numbers for any driver, including software?

Most apps that want to replace a whole texture image will be using 
glTexSubImage() already.  I've seen many apps, examples and texts that 
use/recommend this approach.  So it seems to me that using this path 
in an infrequent/corner case shouldn't have any downside (in principle 
at least).

This change lets of skip some texture state validation and memory 
free/alloc so it should be a win, modulo the blit issue.

-Brian


More information about the mesa-dev mailing list