A bug in gl3plus rendersystem?

Anything and everything that's related to OGRE or the wider graphics field that doesn't fit into the other forums.
Post Reply
peanutandchestnut
Kobold
Posts: 36
Joined: Tue Nov 11, 2014 9:29 am
x 2

A bug in gl3plus rendersystem?

Post by peanutandchestnut »

Subclass of HardwardBuffer in gl3plus implement lockimpl like this:

Code: Select all

    void* GL3PlusHardwareUniformBuffer::lockImpl(size_t offset,
                                                 size_t length,
                                                 LockOptions options)
    {
        if (mIsLocked)
        {
            OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
                        "Invalid attempt to lock a uniform buffer that has already been locked",
                        "GL3PlusHardwareUniformBuffer::lock");
        }
        
        GLenum access = 0;
        void* retPtr = 0;
        
        // Use glMapBuffer
        OGRE_CHECK_GL_ERROR(glBindBuffer(GL_UNIFORM_BUFFER, mBufferId));
        
        if (mUsage & HBU_WRITE_ONLY)
        {
            access |= GL_MAP_WRITE_BIT;
            access |= GL_MAP_FLUSH_EXPLICIT_BIT;
            if(options == HBL_DISCARD)
            {
                // Discard the buffer
                access |= GL_MAP_INVALIDATE_RANGE_BIT;
            }
        }
        else if (options == HBL_READ_ONLY)
            access |= GL_MAP_READ_BIT;
        else
            access |= GL_MAP_READ_BIT | GL_MAP_WRITE_BIT;

        access |= GL_MAP_UNSYNCHRONIZED_BIT;
        
        void* pBuffer;
        OGRE_CHECK_GL_ERROR(pBuffer = glMapBufferRange(GL_UNIFORM_BUFFER, offset, length, access));
        
        if(pBuffer == 0)
        {
            OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR, 
                        "Uniform Buffer: Out of memory",
                        "GL3PlusHardwareUniformBuffer::lock");
        }
        
        // return offsetted
        retPtr = static_cast<void*>(static_cast<unsigned char*>(pBuffer) + offset);

		mIsLocked = true;
        return retPtr;
    }

The retPtr is offseted twice, one in glMapBufferRange, one before return.
It happens in all subclass of HardwareBuffer in gl3plus.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: A bug in gl3plus rendersystem?

Post by dark_sylinc »

Mmmm.... looks like a bug. Is it crashing or you found it via code review?
peanutandchestnut
Kobold
Posts: 36
Joined: Tue Nov 11, 2014 9:29 am
x 2

Re: A bug in gl3plus rendersystem?

Post by peanutandchestnut »

Code review.
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: A bug in gl3plus rendersystem?

Post by dark_sylinc »

Fixed. Thank you!

Fix also backported to default branch (1.x)
Post Reply