Results 1 to 5 of 5

Thread: Texture Residency Check (Problem With)

  1. #1
    Junior Member Newbie
    Join Date
    Aug 2003
    Location
    Ashford, Middlesex, UK
    Posts
    9

    Texture Residency Check (Problem With)

    Hi all,

    I'm having some problems with a texture residency check, and was wondering if anyone could shed some light on what's going on.

    glAreTexturesResident() is not available to me, so I'm going the glGetTexParameter() route here. The man page for this function contains the following:

    Code :
    GL_TEXTURE_RESIDENT
    Returns the residence status of the target texture. If the value returned in [i]params[/i] is [B]GL_TRUE[/B], the texture is resident in texture memory.
    I am therefore expecting to see a boolean value returned.

    I'm using a Java binding (LWJGL 0.7-pre2), but it's not interfering with the method call - it gets routed straight through to the driver. My code is as follows:

    Code :
    Image grass = BMP.read("data\\grass.bmp") ;
    ByteBuffer pixels = grass.getPixels() ;
    GL.glGenTextures(intBuf) ;
    id0 = intBuf.get(0) ;
     
    GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1) ;
    GL.glBindTexture(GL.GL_TEXTURE_2D, id0) ;
    GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, 4,
    	grass.getWidth(), grass.getHeight(),
    	0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, pixels) ;
     
    System.out.println("Grass ID = " + id0) ;
    GL.glGetTexParameter(id0, GL.GL_TEXTURE_RESIDENT, intBuf) ;
    System.out.println("Result = " + intBuf.get(0)) ;
    This creates the output:

    Code :
    Grass ID = 1
    Result = 1
    Now at this point I was happy - GL_TRUE is 1, so the texture is resident! But then I went further, with two blocks similar to this:

    Code :
    ByteBuffer pixels =
    	(ByteBuffer)ByteBuffer.allocateDirect(2048 * 2048 * 4)
    	.order(ByteOrder.nativeOrder())
    	.position(0)
    	.limit(2048 * 2048) ;
    GL.glGenTextures(intBuf) ;
    id1 = intBuf.get(0) ;
     
    GL.glPixelStorei(GL.GL_UNPACK_ALIGNMENT, 1) ;
    GL.glBindTexture(GL.GL_TEXTURE_2D, id1) ;
    GL.glTexImage2D(GL.GL_TEXTURE_2D, 0, 4,
    	2048, 2048,
    	0, GL.GL_RGBA, GL.GL_UNSIGNED_BYTE, pixels) ;
     
    System.out.println("id1 = " + id1) ;
    GL.glGetTexParameter(id1, GL.GL_TEXTURE_RESIDENT, intBuf) ;
    System.out.println("Result = " + intBuf.get(0)) ;
    Two of these blocks in addition to the first block give the output:

    Code :
    Grass ID = 1
    Result = 1
    id1 = 2
    Result = 2
    id2 = 3
    Result = 3
    So that's not a boolean coming back. Also, those two pixel arrays are 16MB in size, and I only have 8MB VRAM, so it's not that it's returning the id if it's resident, like glAreTexturesResident does.

    So where have I gone wrong? Have I misinterpreted the proper operation of glGetTexParameter? Am I calling things incorrectly? Or is the driver misbehaving?

    Or have I got things totally mixed up here?

    Cheers,
    Charlie.
    Hellomynameis Charlie Dobbie
    Formerly "Charlie (Guest)"

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: Texture Residency Check (Problem With)

    Spec:
    The residence status of a single bound texture object
    can also be queried by calling GetTexParameteriv or GetTexParameterfv with
    target set to the target to which the texture object is bound, and pname set to
    TEXTURE RESIDENT.
    I don't know the exact syntax for your Java bindings, but that should then look something like this:
    Code :
    GL.glGetTexParameter(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_RESIDENT, intBuf) ;

  3. #3
    Junior Member Newbie
    Join Date
    Aug 2003
    Location
    Ashford, Middlesex, UK
    Posts
    9

    Re: Texture Residency Check (Problem With)

    Hi Zeckensack, thanks for your response.

    Ah, I see, well spotted!

    Well, I've changed that line and given it another go, and it's still producing weird results:

    Texture ID 1, residency = 1
    Texture ID 2, residency = 1
    Texture ID 3, residency = 1

    I'm expecting a boolean return, so that 1 is a GL_TRUE. So they're all resident! Even the two that individually are twice as large as my total VRAM...

    As I can't use glAreTexturesResident() I have to bind each texture before checking residency - doesn't that mean the driver could be uploading the texture data on bind in preperation for use, then lo-and-behold it's resident? But that doesn't explain how the 16MB texture gets in there.

    It's an S3 Savage/IX-MV and supports S3TC, but it's not likely that it compresses things without being asked, is it?

    I'll fill the ByteBuffers with random data and see what it does with that.

    Cheers,
    Charlie.
    Hellomynameis Charlie Dobbie
    Formerly "Charlie (Guest)"

  4. #4
    Junior Member Newbie
    Join Date
    Aug 2003
    Location
    Ashford, Middlesex, UK
    Posts
    9

    Re: Texture Residency Check (Problem With)

    Nope, even with 16MB of random data it's still "resident". Methinks the driver is lying to me...

    Or there's still some error in the code somewhere?

    Cheers,
    Charlie.
    Hellomynameis Charlie Dobbie
    Formerly "Charlie (Guest)"

  5. #5
    Senior Member Regular Contributor
    Join Date
    May 2003
    Location
    Germany
    Posts
    229

    Re: Texture Residency Check (Problem With)

    Mostly older Chipsets (like yours) don't give you reliable infos on the residency of your textures, and as the way you do it is the same that glAreTexturesResident does it (technically), you won't get reliable results on your S3 Savage/IX-MV.

Similar Threads

  1. How to check texture unit?
    By rexguo in forum OpenGL: GLSL
    Replies: 16
    Last Post: 08-24-2009, 05:38 PM
  2. can someone check this code and tell me problem?
    By zeytin in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 08-04-2009, 11:42 AM
  3. Texture Coordinate Sanity Check...
    By imported_bobvodka in forum OpenGL: GLSL
    Replies: 5
    Last Post: 05-31-2006, 06:17 AM
  4. How to check if the texture is resident in memory
    By robert_s in forum OpenGL: Advanced Coding
    Replies: 11
    Last Post: 02-26-2002, 03:39 PM
  5. mipmap level residency
    By zen in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 02-10-2002, 03:50 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean