No luck with 3D sparse textures - am I missing something?

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 << '
';

    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 << ")
";
                }
            }
        }
    }

    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!

Please use [noparse]

...

or

...

[/noparse] 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:


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. :wink:

[QUOTE=Dark Photon;1262529]

Specifically, the width, height, and depth parameters. ;)[/QUOTE]

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

Thanks for your help!