1 Reply Latest reply on Nov 9, 2011 5:18 AM by messerli_mike

    problem with PBO

    shivmitra

      I am having problem with using pixel buffer object for uploading data to textures . My code works fine in ATI machine but doesn't work in machine having

       

      Renderer Name     Intel(R) HD Graphics Family
      Renderer Version     3.0.0 - Build 8.15.10.2321
      Renderer Type     Installable client

       

      I wanted to know whether there are some known issues related to this driver or my i m doing something wrong in my code . Please see the code snippet below . I checked before posting and gl_arb_pixel_buffer_object extension was available , and the glTexSubImage2d call was giving error GL_INVALID_OPERATION .

       

       

      GLuint InitializeTexturePBO(CPUInt16 bufferSize)
      {
           GLuint pbo;
           (*m_glGenBuffersARB)(1,&pbo);
           (*m_glBindBufferARB)(GL_PIXEL_UNPACK_BUFFER_ARB, pbo);
           (*m_glBufferDataARB)(GL_PIXEL_UNPACK_BUFFER_ARB, 
                bufferSize , NULL , GL_STREAM_DRAW_ARB);
           (*m_glBindBufferARB)(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
           return pbo;
      }
      void* GetPBOBufferPointer(unsigned int identifier ,int width , int height)
      {
           (*m_glBindBufferARB)(GL_PIXEL_UNPACK_BUFFER_ARB, identifier );
           (*m_glBufferDataARB)(GL_PIXEL_UNPACK_BUFFER_ARB, width*height*4 ,
            0, GL_STREAM_DRAW_ARB);
           return (void*)(*m_glMapBufferARB)(GL_PIXEL_UNPACK_BUFFER_ARB,
           GL_WRITE_ONLY_ARB);
      }
      
      
      void UnmapPBOBuffer()
      {
           if(!m_glUnmapBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB))
                       throw CustomException();
           (*m_glBindBufferARB)(GL_PIXEL_UNPACK_BUFFER_ARB, 0);
           
      }

       

       

       

       

      I call them in this order ->

       

      InitializeTexturePBO(); // removed the arguments
      GetPBOBufferPointer(); // take this pointer and decode video frames at this location
      glBindTexture(GL_TEXTURE_2D , textureObjectList[sourceID]);
      glTexSubImage2D(GL_TEXTURE_2D,0,0,0,ToInt16(m_videoSourceInfos[sourceID]->m_sourceParams.m_videoDimensions.m_width),
      ToInt16(m_videoSourceInfos[sourceID]->m_sourceParams.m_videoDimensions.m_height),GL_BGRA_EXT,GL_UNSIGNED_BYTE,
      0);
      UnmapPBOBuffer();

       

       

        • 1. Re: problem with PBO
          messerli_mike

          Perhaps you could try to unmap the buffer before using the buffer data.

           

          Here is what the OpenGL Reference says about glMapBuffer / glUnmapBuffer:

           

          "... A mapped data store must be unmapped with glUnmapBuffer before its buffer

          object is used. Otherwise an error will be generated by any GL command that

          attempts to dereference the buffer object´s data store. ..."

           

          From the code snippet you provided it seems like you

           

          1. call your function GetPBOBufferPointer which maps the buffer

          2. write some data to the buffer

          3. bind your texture,

          4. call glTexSubImage2D

          5. and only then unmap and "unbind" the buffer object.

           

          So you could try the following:

           

          1. call your function GetPBOBufferPointer which maps the buffer

          2. write some data to the buffer

          3. unmap the buffer

          4. bind your texture

          5. call glTexSubImage2D

          6. and then "unbind" the buffer object

           

          Since I haven´t used PBOs myself, I could as well be completely off here.