# GL_TEXTURE_SPARSE_ARB on Nvidia

## Recommended Posts

nattfoedd    266

Hi everyone,

currently I'm working on a project that uses a 3D texture as voxel storage. Everything's working fine so far, but I'd love to optimze my memory usage and since I'm working with GL4.4 anyway I thought I'd give the GL_TEXTURE_SPARSE_ARB extension a try. The extension has been promoted by Cass Everitt (p.34) and Graham Sellers (p.43) multiple times lately, so I hoped I could get it to work too.

Unfortunately I get no result when querying for the virtual page sizes as described in the presentations.

While

glGetIntegerv(GL_MAX_SPARSE_3D_TEXTURE_SIZE_ARB, &maxSize)

returns the expected 2048.

I don't get any number of indices from these..

glGetInternalformativ(GL_TEXTURE_3D, GL_NUM_VIRTUAL_PAGE_SIZES_ARB, GL_RGBA8, sizeof(GLint), &numSizes);
glGetInternalformativ(GL_TEXTURE_3D, GL_VIRTUAL_PAGE_SIZE_X_ARB, GL_RGBA8, numSizes*sizeof(GLint), pageSizesX);

I also tried GL_TEXTURE_2D instead, as used in the slides - the result is no different.

Cass Everitt writes

Note: numIndexes can be 0, so have a plan

Iterate, select suitable pageSizeIndex

so, question is...what to do? This sounds like the extension could still work on my HW and drivers, but I'd need to guess the proper virtual page size index I'd want to use.

Has anybody worked with this yet and knows the page sizes (for Nvidia)? I hope it's just a driver issue on windows...

Thanks in advance on any input on this issue

PS: GPU is a GTX780, driver is the latest 335.23, OS win8.1

Edited by nattfoedd

##### Share on other sites
cippyboy    223

I can confirm that it doesn't work as well, tried texture 2d, texture 2D array, tried doing glTexStorage2D/3D before and after, I'm on 335.23 too and Windows 8.1 with a GTX 650.

##### Share on other sites
cippyboy    223

After about a couple of hours of swearing I realized the code from the slides is just wrong !

Thanks to Christophe Riccio and his samples ( http://ogl-samples.g-truc.net/ ) the code on the slides should've been :

glGetInternalformativ( GL_TEXTURE_2D, GL_RGBA8, GL_VIRTUAL_PAGE_SIZE_X_ARB, 1, &page_sizes_x[0]);

The difference being that it's GL_RGBA8 and then GL_VIRTUAL_PAGE_SIZE_X_ARB and not the other way around !