Skip to content

Commit

Permalink
Set PixelUnpackState to match serialized data for GL Tex APIs
Browse files Browse the repository at this point in the history
The pixel data has been serialized as pure bytes with no padding or packing.

It was already handled in:
glTexSubImage1D
glTexSubImage2D
glTexSubImage3D

glCompressedTexSubImage1D
glCompressedTexSubImage2D
glCompressedTexSubImage1D

Apply the same handling to:
glTexImage1D
glTexImage2D
glTexImage3D

glCompressedTexImage1D
glCompressedTexImage2D
glCompressedTexImage3D

These APIs do not handle a non-zero offset with the GL_PIXEL_UNPACK_BUFFER
  • Loading branch information
Zorro666 committed Nov 6, 2023
1 parent cf004e8 commit b804e99
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions renderdoc/driver/gl/wrappers/gl_texture_funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2763,6 +2763,14 @@ bool WrappedOpenGL::Serialise_glTextureImage1DEXT(SerialiserType &ser, GLuint te
GLint align = 1;
GL.glGetIntegerv(eGL_UNPACK_ALIGNMENT, &align);

PixelUnpackState unpack;
if(pixels)
{
unpack.Fetch(true);
ResetPixelUnpackState(true, 1);
RDCASSERT(!unpackbuf);
}

if(IsLoading(m_State) && m_CurEventID == 0)
{
GL.glBindBuffer(eGL_PIXEL_UNPACK_BUFFER, 0);
Expand All @@ -2775,6 +2783,8 @@ bool WrappedOpenGL::Serialise_glTextureImage1DEXT(SerialiserType &ser, GLuint te
if(unpackbuf)
GL.glBindBuffer(eGL_PIXEL_UNPACK_BUFFER, unpackbuf);
GL.glPixelStorei(eGL_UNPACK_ALIGNMENT, align);
if(pixels)
unpack.Apply(false);

if(IsLoading(m_State) && m_CurEventID > 0)
m_ResourceUses[GetResourceManager()->GetResID(texture)].push_back(
Expand Down Expand Up @@ -3004,6 +3014,14 @@ bool WrappedOpenGL::Serialise_glTextureImage2DEXT(SerialiserType &ser, GLuint te
GLint align = 1;
GL.glGetIntegerv(eGL_UNPACK_ALIGNMENT, &align);

PixelUnpackState unpack;
if(pixels)
{
unpack.Fetch(true);
ResetPixelUnpackState(true, 1);
RDCASSERT(!unpackbuf);
}

if(IsLoading(m_State) && m_CurEventID == 0)
{
GL.glBindBuffer(eGL_PIXEL_UNPACK_BUFFER, 0);
Expand Down Expand Up @@ -3038,6 +3056,8 @@ bool WrappedOpenGL::Serialise_glTextureImage2DEXT(SerialiserType &ser, GLuint te
if(unpackbuf)
GL.glBindBuffer(eGL_PIXEL_UNPACK_BUFFER, unpackbuf);
GL.glPixelStorei(eGL_UNPACK_ALIGNMENT, align);
if(pixels)
unpack.Apply(false);

if(IsLoading(m_State) && m_CurEventID > 0)
m_ResourceUses[GetResourceManager()->GetResID(texture)].push_back(
Expand Down Expand Up @@ -3271,6 +3291,14 @@ bool WrappedOpenGL::Serialise_glTextureImage3DEXT(SerialiserType &ser, GLuint te
GLint align = 1;
GL.glGetIntegerv(eGL_UNPACK_ALIGNMENT, &align);

PixelUnpackState unpack;
if(pixels)
{
unpack.Fetch(true);
ResetPixelUnpackState(true, 1);
RDCASSERT(!unpackbuf);
}

if(IsLoading(m_State) && m_CurEventID == 0)
{
GL.glBindBuffer(eGL_PIXEL_UNPACK_BUFFER, 0);
Expand All @@ -3283,6 +3311,8 @@ bool WrappedOpenGL::Serialise_glTextureImage3DEXT(SerialiserType &ser, GLuint te
if(unpackbuf)
GL.glBindBuffer(eGL_PIXEL_UNPACK_BUFFER, unpackbuf);
GL.glPixelStorei(eGL_UNPACK_ALIGNMENT, align);
if(pixels)
unpack.Apply(false);

if(IsLoading(m_State) && m_CurEventID > 0)
m_ResourceUses[GetResourceManager()->GetResID(texture)].push_back(
Expand Down Expand Up @@ -3526,12 +3556,22 @@ bool WrappedOpenGL::Serialise_glCompressedTextureImage1DEXT(SerialiserType &ser,
GL.glPixelStorei(eGL_UNPACK_ALIGNMENT, 1);
}

PixelUnpackState unpack;
if(pixels)
{
unpack.Fetch(true);
ResetPixelUnpackState(true, 1);
RDCASSERT(!unpackbuf);
}

GL.glCompressedTextureImage1DEXT(texture.name, target, level, internalformat, width, border,
imageSize, databuf);

if(unpackbuf)
GL.glBindBuffer(eGL_PIXEL_UNPACK_BUFFER, unpackbuf);
GL.glPixelStorei(eGL_UNPACK_ALIGNMENT, align);
if(pixels)
unpack.Apply(false);

if(IsLoading(m_State) && m_CurEventID > 0)
m_ResourceUses[GetResourceManager()->GetResID(texture)].push_back(
Expand Down Expand Up @@ -3860,6 +3900,14 @@ bool WrappedOpenGL::Serialise_glCompressedTextureImage2DEXT(SerialiserType &ser,
GLint align = 1;
GL.glGetIntegerv(eGL_UNPACK_ALIGNMENT, &align);

PixelUnpackState unpack;
if(pixels)
{
unpack.Fetch(true);
ResetPixelUnpackState(true, 1);
RDCASSERT(!unpackbuf);
}

if(IsLoading(m_State) && m_CurEventID == 0)
{
GL.glBindBuffer(eGL_PIXEL_UNPACK_BUFFER, 0);
Expand Down Expand Up @@ -3894,6 +3942,8 @@ bool WrappedOpenGL::Serialise_glCompressedTextureImage2DEXT(SerialiserType &ser,
if(unpackbuf)
GL.glBindBuffer(eGL_PIXEL_UNPACK_BUFFER, unpackbuf);
GL.glPixelStorei(eGL_UNPACK_ALIGNMENT, align);
if(pixels)
unpack.Apply(false);

if(IsLoading(m_State) && m_CurEventID > 0)
m_ResourceUses[GetResourceManager()->GetResID(texture)].push_back(
Expand Down Expand Up @@ -4132,6 +4182,14 @@ bool WrappedOpenGL::Serialise_glCompressedTextureImage3DEXT(SerialiserType &ser,
GLint align = 1;
GL.glGetIntegerv(eGL_UNPACK_ALIGNMENT, &align);

PixelUnpackState unpack;
if(pixels)
{
unpack.Fetch(true);
ResetPixelUnpackState(true, 1);
RDCASSERT(!unpackbuf);
}

if(IsLoading(m_State) && m_CurEventID == 0)
{
GL.glBindBuffer(eGL_PIXEL_UNPACK_BUFFER, 0);
Expand All @@ -4144,6 +4202,8 @@ bool WrappedOpenGL::Serialise_glCompressedTextureImage3DEXT(SerialiserType &ser,
if(unpackbuf)
GL.glBindBuffer(eGL_PIXEL_UNPACK_BUFFER, unpackbuf);
GL.glPixelStorei(eGL_UNPACK_ALIGNMENT, align);
if(pixels)
unpack.Apply(false);

if(IsLoading(m_State) && m_CurEventID > 0)
m_ResourceUses[GetResourceManager()->GetResID(texture)].push_back(
Expand Down

0 comments on commit b804e99

Please sign in to comment.