PDA

View Full Version : No luck with 3D sparse textures - am I missing something?



kzuiderveld
11-13-2014, 05:05 PM
Platform: Linux Ubuntu, NVIDIA 970 GTX, driver 343.22, using glew 1.11.

Consider the following test function:


static bool demoSparseTextureProblem()
{
const int kDim = 256;
GLint xPage, yPage, zPage;
// get internal size of pages for 3D texture
glGetInternalformativ(GL_TEXTURE_3D,GL_R8, GL_VIRTUAL_PAGE_SIZE_X_ARB,
1, &xPage);
glGetInternalformativ(GL_TEXTURE_3D,GL_R8, GL_VIRTUAL_PAGE_SIZE_Y_ARB,
1, &yPage);
glGetInternalformativ(GL_TEXTURE_3D,GL_R8, GL_VIRTUAL_PAGE_SIZE_Z_ARB,
1, &zPage);
cout << "Page size: " << xPage << ',' << yPage << ',' << zPage << '\n';

GLuint texID = 0;
glGenTextures(1,&texID);
glBindTexture(GL_TEXTURE_3D,texID);

glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_SPARSE_ARB, GL_TRUE);

glTexStorage3D(GL_TEXTURE_3D, 1, GL_R8, kDim, kDim, kDim);

for (int z = 0; z < kDim; z += zPage)
{
for (int y = 0; y < kDim; y += yPage)
{
for (int x = 0; x < kDim; x += xPage)
{
glTexPageCommitmentARB(GL_TEXTURE_3D, 0,
x, y, z, x + xPage,
y + yPage, z + zPage,
GL_TRUE);
if (glGetError() != GL_NO_ERROR)
{
std::cout << "Error commit at (" << x << ',' << y << ','
<< z << ")\n";
}
}
}
}

glDeleteTextures(1,&texID);
}


With a texture size of 256, commitment of any page with coordinates >= 128 is not successful. With texture size of 128, any page with coordinates >=64 gives an error.

Am I doing something wrong or might this be a driver/glew bug?

Help really appreciated, thanks!

Dark Photon
11-13-2014, 05:25 PM
Please use
... or ... blocks around code fragments. It makes it much more readable. Thanks. (I fixed it for you)

Ummm... Haven't used that extension myself, but take a look at the prototype for glTextureCommitmentARB() from ARB_sparse_texture (https://www.opengl.org/registry/specs/ARB/sparse_texture.txt):


void TexPageCommitmentARB( enum target, int level,
int xoffset, int yoffset, int zoffset,
sizei width, sizei height, sizei depth,
boolean commit);


Specifically, the width, height, and depth parameters. ;)

kzuiderveld
11-13-2014, 06:33 PM
Specifically, the width, height, and depth parameters. ;)

Yeah, I see what you mean :-) I'll try it out tomorrow, but presumably that is what I was doing wrong.

Thanks for your help!