5 Replies Latest reply on Oct 19, 2013 4:07 PM by basisunus

    3D texture stride problem

    basisunus

      I'm creating a 3D texture from memory data. Since the data might be very large, I divide the memory block into bricks. The code for creating the texture is like this:

       glGenTextures(1, &m_tex);

       glEnable(GL_TEXTURE_3D);

       glBindTexture(GL_TEXTURE_3D, m_tex);

       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);
       glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

       glPixelStorei(GL_UNPACK_ROW_LENGTH, m_nx);
       glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, m_ny);
       glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

       glTexImage3D(GL_TEXTURE_3D, 0, GL_ALPHA, 256, 256, m_nz, 0, GL_ALPHA, GL_UNSIGNED_BYTE, (unsigned char*)data->GetData());

      In the example, the data block in memory has size m_nx*m_ny*m_nz, and I want to read only a portion of the data, which has size 256*256*m_nz, where 256 is smaller than the actual m_nx and m_ny.

      On my Radeon HD4870, this doesn't work. Furthermore, no matter what number I put for the GL_UNPACK_IMAGE_HEIGHT parameter, the result stays incorrectly the same. This is apparently a stride problem. I'm wondering if anyone had the same problem and could help.

        • Re: 3D texture stride problem
          dennishudr

          For nVidia graphics card, it works.

          AMD graphics card has big issue with GL_UNPACK_IMAGE_HEIGHT

          maybe you can use glTextSubImage3D to fix this issue.

          For programming 3DTexture in OpenGL, I prefer to choose nVidia graphics card.

          Hope it can be fixed in the near future, I will choose more powerful AMD graphics card.

            • Re: 3D texture stride problem
              gsellers

              Hi,

               

              This thread is two years old and has been brought in from the old forums.

               

              If you are still having the same issue as reported here, then we will gladly take a look at it. Have you encountered this issue recently? How did you find this old thread?

               

              Thanks,

               

              Graham

                • Re: 3D texture stride problem
                  dennishudr

                  Yes. I always get this kind of issue that cause some trouble to program with AMD graphics card.

                  Just by some search to find other people complains AMD graphics card for OpenGL conformance.

                  I think this is a known issue for AMD/ATI graphics card.

                  I hope it can be solved in the next version of OpenGL driver,

                  So I will be confident to ask my team to choose AMD graphics card.

                   

                  Thanks.

                    • Re: 3D texture stride problem
                      gsellers

                      Hi,

                       

                      Thanks for the feedback. Feel free to post here (in a new thread) with specifics about any issue that you hit. If you have an example code snippet or a runnable application, we'll definitely take a look at it. Meanwhile, we'll go verify whether this issue still exists and if so, fix it.

                       

                      Cheers,

                        • Re: 3D texture stride problem
                          basisunus

                          Hi,

                           

                          I posted the original question almost 3 years ago. The problem still exists in two graphics cards I'm using now: a Radeon HD7970 and a FirePro M8900 in a Dell Precision M6600 mobile workstation. You can try the code snippet I provided in the first post. I found the 3D texture has to contain more than 8 slices in the Z dimension, otherwise it works properly. Using glTextSubImage3D does fixes the issue on the HD7970, but not the FirePro M8900.