mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-05 17:40:39 +00:00
Only reupload all cubemap faces for the first glTexImage2D call
* We need a workaround for cubemaps where our redundant-glTexImage2D call has dropped a glTexImage2D on level 0 of another cubemap face that should be 'initialising' it. What we do is just upload all faces. Initial contents will then replace the contents. * However, this assumes there will be initial contents to replace. If we only have a set of cubemap uploads because the cubemap was uploaded within the captured frame, we can't do this replicate each time or the last face uploaded will be splatted across all. Instead we check to see if this is the first glTexImage2D call on a level, and only replicate in that case.
This commit is contained in:
@@ -2341,6 +2341,8 @@ bool WrappedOpenGL::Serialise_glTextureImage2DEXT(SerialiserType &ser, GLuint te
|
||||
internalformat = intFmt;
|
||||
|
||||
ResourceId liveId = GetResourceManager()->GetID(texture);
|
||||
|
||||
uint32_t mipsValid = m_Textures[liveId].mipsValid;
|
||||
m_Textures[liveId].mipsValid |= 1 << level;
|
||||
|
||||
if(level == 0) // assume level 0 will always get a glTexImage call
|
||||
@@ -2367,12 +2369,8 @@ bool WrappedOpenGL::Serialise_glTextureImage2DEXT(SerialiserType &ser, GLuint te
|
||||
GL.glGetIntegerv(eGL_UNPACK_ALIGNMENT, &align);
|
||||
GL.glPixelStorei(eGL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
if(TextureBinding(target) != eGL_TEXTURE_BINDING_CUBE_MAP)
|
||||
{
|
||||
GL.glTextureImage2DEXT(texture.name, target, level, internalformat, width, height, border,
|
||||
format, type, pixels);
|
||||
}
|
||||
else
|
||||
if(TextureBinding(target) == eGL_TEXTURE_BINDING_CUBE_MAP &&
|
||||
mipsValid != m_Textures[liveId].mipsValid)
|
||||
{
|
||||
GLenum ts[] = {
|
||||
eGL_TEXTURE_CUBE_MAP_POSITIVE_X, eGL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
||||
@@ -2381,8 +2379,7 @@ bool WrappedOpenGL::Serialise_glTextureImage2DEXT(SerialiserType &ser, GLuint te
|
||||
};
|
||||
|
||||
// special case handling for cubemaps, as we might have skipped the 'allocation' teximage
|
||||
// chunks to avoid
|
||||
// serialising tons of 'data upload' teximage chunks. Sigh.
|
||||
// chunks to avoid serialising tons of 'data upload' teximage chunks. Sigh.
|
||||
// Any further chunks & initial data can overwrite this, but cubemaps must be square so all
|
||||
// parameters will be the same.
|
||||
for(size_t i = 0; i < ARRAY_COUNT(ts); i++)
|
||||
@@ -2391,6 +2388,11 @@ bool WrappedOpenGL::Serialise_glTextureImage2DEXT(SerialiserType &ser, GLuint te
|
||||
format, type, pixels);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.glTextureImage2DEXT(texture.name, target, level, internalformat, width, height, border,
|
||||
format, type, pixels);
|
||||
}
|
||||
|
||||
if(unpackbuf)
|
||||
GL.glBindBuffer(eGL_PIXEL_UNPACK_BUFFER, unpackbuf);
|
||||
@@ -3148,6 +3150,8 @@ bool WrappedOpenGL::Serialise_glCompressedTextureImage2DEXT(SerialiserType &ser,
|
||||
}
|
||||
|
||||
ResourceId liveId = GetResourceManager()->GetID(texture);
|
||||
|
||||
uint32_t mipsValid = m_Textures[liveId].mipsValid;
|
||||
m_Textures[liveId].mipsValid |= 1 << level;
|
||||
|
||||
if(level == 0) // assume level 0 will always get a glTexImage call
|
||||
@@ -3172,12 +3176,8 @@ bool WrappedOpenGL::Serialise_glCompressedTextureImage2DEXT(SerialiserType &ser,
|
||||
GL.glGetIntegerv(eGL_UNPACK_ALIGNMENT, &align);
|
||||
GL.glPixelStorei(eGL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
if(TextureBinding(target) != eGL_TEXTURE_BINDING_CUBE_MAP)
|
||||
{
|
||||
GL.glCompressedTextureImage2DEXT(texture.name, target, level, internalformat, width, height,
|
||||
border, imageSize, databuf);
|
||||
}
|
||||
else
|
||||
if(TextureBinding(target) == eGL_TEXTURE_BINDING_CUBE_MAP &&
|
||||
mipsValid != m_Textures[liveId].mipsValid)
|
||||
{
|
||||
GLenum ts[] = {
|
||||
eGL_TEXTURE_CUBE_MAP_POSITIVE_X, eGL_TEXTURE_CUBE_MAP_NEGATIVE_X,
|
||||
@@ -3195,6 +3195,11 @@ bool WrappedOpenGL::Serialise_glCompressedTextureImage2DEXT(SerialiserType &ser,
|
||||
border, imageSize, databuf);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.glCompressedTextureImage2DEXT(texture.name, target, level, internalformat, width, height,
|
||||
border, imageSize, databuf);
|
||||
}
|
||||
|
||||
if(unpackbuf)
|
||||
GL.glBindBuffer(eGL_PIXEL_UNPACK_BUFFER, unpackbuf);
|
||||
|
||||
Reference in New Issue
Block a user