cancel
Showing results for 
Search instead for 
Did you mean: 

OpenGL & Vulkan

hilo
Journeyman III

Problem with 3D texture generation.

Hi,

I have been working on a small OpenGl demo program on my A8-7600 Kaveri APU, in Qt5.4.

I would set a huge (1024x1024x1024 = 1Gbyte) byte array (volume) as single channel 3D texture.

On top of that, I would like to see the free memory after texture allocation.

Unfortunately the results confuse me, so any advise/explanation is welcome!

Here is the relevant code fragment:


void Widget::initializeGL()

    if (glewInit() != GLEW_OK) exit( EXIT_FAILURE );

    qDebug() << versionString; qDebug() << rendererString;

    ati_meminfo();

    glGenTextures( 1, &texture);

    glBindTexture(GL_TEXTURE_3D, texture);

    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_CLAMP);

    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_CLAMP);

    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_CLAMP);

    glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    glTexPaframeteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

    glTexImage3D( GL_TEXTURE_3D, 0, GL_R8UI, 1024, 1024, 1024, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, data );

    HandleGLError();

    ati_meminfo();

}

void Widget::HandleGLError()

{

    GLenum error;

    int i = 1;

    while ((error = glGetError()) != GL_NO_ERROR)

    {

        qDebug("GL ERROR: %i, %s", i , gluErrorString(error));

        ++i;

    }

}

void Widget::ati_meminfo()

{

    GLint param[4] = {-1, -1, -1, -1};

    if ( GL_ATI_meminfo)

    {

     glGetIntegerv(GL_TEXTURE_FREE_MEMORY_ATI, param);

     qDebug("TEXTURE_FREE_MEMORY_ATI");

     qDebug("  Total memory free in the pool: %i Kbyte", param[0]);

     qDebug("  Largest available free block in the pool: %i Kbyte", param[1]);

     qDebug("  Total auxiliary memory free: %i Kbyte", param[2]);

     qDebug("  Largest auxiliary free block: %i Kbyte", param[3]);

     HandleGLError();

    }   

}


First case, Ubuntu 14.04:

Texture allocation is OK I think, because I can render the texture well. No GL error at all. But memory allocation query show NO memory allocation.

"4.4.13283 Compatibility Profile Context 14.501.1003"

"AMD Radeon(TM) R7 Graphics   "

TEXTURE_FREE_MEMORY_ATI     < before texture generation

  Total memory free in the pool: 1882239 Kbyte

  Largest available free block in the pool: 1700688 Kbyte

  Total auxiliary memory free: 1987760 Kbyte

  Largest auxiliary free block: 11612 Kbyte

TEXTURE_FREE_MEMORY_ATI     < after texture generation

  Total memory free in the pool: 1882239 Kbyte

  Largest available free block in the pool: 1700688 Kbyte

  Total auxiliary memory free: 1987824 Kbyte

  Largest auxiliary free block: 11612 Kbyte

Perhaps this method of memory monitoring is incorrect??

The 2nd case is Windows7, and this is more interesting, because the same code throw errors, and can not build/render the texture..

"4.4.13283 Compatibility Profile Context 14.501.1003.0"

"AMD Radeon(TM) R7 Graphics"

TEXTURE_FREE_MEMORY_ATI

  Total memory free in the pool: 2084864 Kbyte

  Largest available free block in the pool: 1822720 Kbyte

  Total auxiliary memory free: 2096128 Kbyte

  Largest auxiliary free block: 2096128 Kbyte

GL ERROR: 1, invalid enumerant

GL ERROR: 1, out of memory

TEXTURE_FREE_MEMORY_ATI

  Total memory free in the pool: 2084864 Kbyte

  Largest available free block in the pool: 1822720 Kbyte

  Total auxiliary memory free: 2096128 Kbyte

  Largest auxiliary free block: 2096128 Kbyte

GL ERROR: 1, invalid enumerant

1, Looks like TEXTURE_FREE_MEMORY_ATI tag is invalid, but then I get memory info.

2, Even if I have more free memory than in Linux case, I can not allocate the texture..

3, No memory usage as in the Linux case.. Hmm.

Any idea what is behind the win7 failure?

Thank you for your help in advance!

0 Likes
Reply
3 Replies
jzhou
Staff
Staff

Re: Problem with 3D texture generation.

I think you need call glFlush() after create texture, i.e.:

....

glTexImage3D( GL_TEXTURE_3D, 0, GL_R8UI, 1024, 1024, 1024, 0, GL_RED_INTEGER, GL_UNSIGNED_BYTE, data );

glFlush();

HandleGLError();

ati_meminfo();

....


On windows, please make sure there is ATI_meminfo extension firstly. ATI_meminfo is only available on workstation card. I don't think A8-7600 Kaveri APU is a workstation card.

So you can't use this extension on win7 with your APU.

hilo
Journeyman III

Re: Problem with 3D texture generation.

Hi jzhou,

First, thank you for your help!

Unfortunately add a glFlush(); command to the code did not help the situation.

Win7 version still suffers GL ERROR: 1, out of memory, and no texture, even if the code is correct on Ubuntu.

( The GPU has 2 Gbyte allocated RAM in both op. system, so this error msg. is quite a surprise..)

Regarding ATI_meminfo:You are absolutely right!

Based on your hint, I have checked the system with OpenGL extensions viewer tool by realtech, and Kaveri does not support this extension according the tool. ( Even If the reported numbers look really valid at first sight, and that makes me fool. )

0 Likes
Reply
jzhou
Staff
Staff

Re: Problem with 3D texture generation.

Hi hilo,

I will have a close look when I have time.

0 Likes
Reply