Jump to content
  • Advertisement
Sign in to follow this  

OpenGL [SOLVED] DXT5 texture compression results in ATI driver crash

This topic is 3151 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Background: I've added DXT1, DXT3 and DXT5 texture support to project written in prehistoric BCB5. Problem: On NVIDIA DXT5 textures are working fine, but on ati on first rendered frame application terminates with error message pointing to atioglxx.dll. Error doesn't show up on drivers version <= 8.12 Code: I use code copied from example found on flipcode:

    AlphaValue fail(0, false);

    std::ifstream file(fileName.c_str(), ios::binary);

    char filecode[5];
    file.read(filecode, 4);
    filecode[4] = 0;

    if(std::string("DDS ") != filecode)
        return fail;

    file.read((char*) &ddsd, sizeof(ddsd));

    DDS_IMAGE_DATA data;

    // This .dds loader supports the loading of compressed formats DXT1, DXT3
    // and DXT5.

    GLuint factor;

    switch( ddsd.ddpfPixelFormat.dwFourCC )
        case FOURCC_DXT1:
            // DXT1's compression ratio is 8:1
            data.format = GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
            factor = 2;

        case FOURCC_DXT3:
            // DXT3's compression ratio is 4:1
            data.format = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
            factor = 4;

        case FOURCC_DXT5:
            // DXT5's compression ratio is 4:1
            data.format = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
            factor = 4;

            return fail;

    GLuint bufferSize = (ddsd.dwMipMapCount > 1 ? ddsd.dwLinearSize * factor : ddsd.dwLinearSize);

    data.pixels = new GLubyte[bufferSize];
    file.read((char*) data.pixels, bufferSize);


    data.width      = ddsd.dwWidth;
    data.height     = ddsd.dwHeight;
    data.numMipMaps = ddsd.dwMipMapCount;

    data.blockSize = (data.format == GL_COMPRESSED_RGB_S3TC_DXT1_EXT ? 8 : 16);

    GLuint id;
    glGenTextures(1, &id);
    glBindTexture(GL_TEXTURE_2D, id);

    SetFiltering(true, fileName.find('#') != std::string::npos);

    GLuint size;
    GLuint offset = 0;

    // Load the mip-map levels
    for(int i = 0; i < data.numMipMaps; i++)
        if(!data.width) data.width = 1;
        if(!data.height) data.height = 1;

        size = ((data.width + 3) / 4) * ((data.height+3)/4) * data.blockSize;

        glCompressedTexImage2D(GL_TEXTURE_2D, i, data.format, data.width,
            data.height, 0, size, data.pixels + offset);

        offset += size;

        // Half the image size for the next mip-map level...
        data.width /= 2;
        data.height /= 2;

    delete[] data.pixels;
    return std::make_pair(id, data.format != GL_COMPRESSED_RGB_S3TC_DXT1_EXT);
Solution: Borland C++ Builder by default doesn't ignore floating point exceptions which are ignored by MSVC. According to this thread: http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=197907&page=1 [Edited by - ShaXbee on March 7, 2010 6:49:22 AM]

Share this post

Link to post
Share on other sites

It seems that textures with size <= 256x256 are working fine. I'm using nvdxt utility to compress images.

[Edited by - ShaXbee on March 7, 2010 5:16:40 AM]

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!