Convert internal format to sized early, for making copies

* When serialising out initial states of textures, we make a duplicate to
  copy into. Since we use the storage APIs we need a sized format, so let's
  convert the format early so the stored internal format is sized. This
  doesn't cause a behaviour change as the impl is free to choose any sized
  format and we're just reading back the choice, and making it explicit.
This commit is contained in:
baldurk
2014-12-01 23:38:00 +00:00
parent d26b01ae26
commit 2cdb6c6ccf
@@ -371,6 +371,8 @@ bool WrappedOpenGL::Serialise_glTextureView(GLuint texture, GLenum target, GLuin
void WrappedOpenGL::glTextureView(GLuint texture, GLenum target, GLuint origtexture, GLenum internalformat, GLuint minlevel, GLuint numlevels, GLuint minlayer, GLuint numlayers)
{
internalformat = GetSizedFormat(m_Real, target, internalformat);
m_Real.glTextureView(texture, target, origtexture, internalformat, minlevel, numlevels, minlayer, numlayers);
if(m_State >= WRITING)
@@ -1318,7 +1320,7 @@ bool WrappedOpenGL::Serialise_glTextureImage1DEXT(GLuint texture, GLenum target,
m_Textures[liveId].depth = 1;
m_Textures[liveId].curType = TextureTarget(Target);
m_Textures[liveId].dimension = 1;
m_Textures[liveId].internalFormat = GetSizedFormat(m_Real, Target, IntFormat);
m_Textures[liveId].internalFormat = IntFormat;
}
m_Real.glTextureImage1DEXT(GetResourceManager()->GetLiveResource(id).name, Target, Level, IntFormat, Width, Border, Format, Type, buf);
@@ -1331,11 +1333,13 @@ bool WrappedOpenGL::Serialise_glTextureImage1DEXT(GLuint texture, GLenum target,
void WrappedOpenGL::glTextureImage1DEXT(GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const void *pixels)
{
m_Real.glTextureImage1DEXT(texture, target, level, internalformat, width, border, format, type, pixels);
// proxy formats are used for querying texture capabilities, don't serialise these
if(IsProxyTarget((GLenum)internalformat)) return;
internalformat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
m_Real.glTextureImage1DEXT(texture, target, level, internalformat, width, border, format, type, pixels);
if(m_State >= WRITING)
{
GLResourceRecord *record = GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
@@ -1362,17 +1366,19 @@ void WrappedOpenGL::glTextureImage1DEXT(GLuint texture, GLenum target, GLint lev
m_Textures[texId].depth = 1;
m_Textures[texId].curType = TextureTarget(target);
m_Textures[texId].dimension = 1;
m_Textures[texId].internalFormat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
m_Textures[texId].internalFormat = (GLenum)internalformat;
}
}
void WrappedOpenGL::glTexImage1D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels)
{
m_Real.glTexImage1D(target, level, internalformat, width, border, format, type, pixels);
// proxy formats are used for querying texture capabilities, don't serialise these
if(IsProxyTarget((GLenum)internalformat)) return;
internalformat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
m_Real.glTexImage1D(target, level, internalformat, width, border, format, type, pixels);
if(m_State >= WRITING)
{
GLResourceRecord *record = m_TextureRecord[m_TextureUnit];
@@ -1399,7 +1405,7 @@ void WrappedOpenGL::glTexImage1D(GLenum target, GLint level, GLint internalforma
m_Textures[texId].depth = 1;
m_Textures[texId].curType = TextureTarget(target);
m_Textures[texId].dimension = 1;
m_Textures[texId].internalFormat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
m_Textures[texId].internalFormat = (GLenum)internalformat;
}
}
@@ -1436,7 +1442,7 @@ bool WrappedOpenGL::Serialise_glTextureImage2DEXT(GLuint texture, GLenum target,
m_Textures[liveId].depth = 1;
m_Textures[liveId].curType = TextureTarget(Target);
m_Textures[liveId].dimension = 2;
m_Textures[liveId].internalFormat = GetSizedFormat(m_Real, Target, IntFormat);
m_Textures[liveId].internalFormat = IntFormat;
}
m_Real.glTextureImage2DEXT(GetResourceManager()->GetLiveResource(id).name, Target, Level, IntFormat, Width, Height, Border, Format, Type, buf);
@@ -1449,11 +1455,13 @@ bool WrappedOpenGL::Serialise_glTextureImage2DEXT(GLuint texture, GLenum target,
void WrappedOpenGL::glTextureImage2DEXT(GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void *pixels)
{
m_Real.glTextureImage2DEXT(texture, target, level, internalformat, width, height, border, format, type, pixels);
// proxy formats are used for querying texture capabilities, don't serialise these
if(IsProxyTarget((GLenum)internalformat)) return;
internalformat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
m_Real.glTextureImage2DEXT(texture, target, level, internalformat, width, height, border, format, type, pixels);
if(m_State >= WRITING)
{
GLResourceRecord *record = GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
@@ -1480,16 +1488,18 @@ void WrappedOpenGL::glTextureImage2DEXT(GLuint texture, GLenum target, GLint lev
m_Textures[texId].depth = 1;
m_Textures[texId].curType = TextureTarget(target);
m_Textures[texId].dimension = 2;
m_Textures[texId].internalFormat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
m_Textures[texId].internalFormat = (GLenum)internalformat;
}
}
void WrappedOpenGL::glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid * pixels)
{
m_Real.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
// proxy formats are used for querying texture capabilities, don't serialise these
if(IsProxyTarget((GLenum)internalformat)) return;
internalformat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
m_Real.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
if(m_State >= WRITING)
{
@@ -1517,7 +1527,7 @@ void WrappedOpenGL::glTexImage2D(GLenum target, GLint level, GLint internalforma
m_Textures[texId].depth = 1;
m_Textures[texId].curType = TextureTarget(target);
m_Textures[texId].dimension = 2;
m_Textures[texId].internalFormat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
m_Textures[texId].internalFormat = (GLenum)internalformat;
}
}
@@ -1555,7 +1565,7 @@ bool WrappedOpenGL::Serialise_glTextureImage3DEXT(GLuint texture, GLenum target,
m_Textures[liveId].depth = Depth;
m_Textures[liveId].curType = TextureTarget(Target);
m_Textures[liveId].dimension = 3;
m_Textures[liveId].internalFormat = GetSizedFormat(m_Real, Target, IntFormat);
m_Textures[liveId].internalFormat = IntFormat;
}
m_Real.glTextureImage3DEXT(GetResourceManager()->GetLiveResource(id).name, Target, Level, IntFormat, Width, Height, Depth, Border, Format, Type, buf);
@@ -1568,11 +1578,13 @@ bool WrappedOpenGL::Serialise_glTextureImage3DEXT(GLuint texture, GLenum target,
void WrappedOpenGL::glTextureImage3DEXT(GLuint texture, GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void *pixels)
{
m_Real.glTextureImage3DEXT(texture, target, level, internalformat, width, height, depth, border, format, type, pixels);
// proxy formats are used for querying texture capabilities, don't serialise these
if(IsProxyTarget((GLenum)internalformat)) return;
internalformat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
m_Real.glTextureImage3DEXT(texture, target, level, internalformat, width, height, depth, border, format, type, pixels);
if(m_State >= WRITING)
{
GLResourceRecord *record = GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
@@ -1599,17 +1611,19 @@ void WrappedOpenGL::glTextureImage3DEXT(GLuint texture, GLenum target, GLint lev
m_Textures[texId].depth = depth;
m_Textures[texId].curType = TextureTarget(target);
m_Textures[texId].dimension = 3;
m_Textures[texId].internalFormat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
m_Textures[texId].internalFormat = (GLenum)internalformat;
}
}
void WrappedOpenGL::glTexImage3D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid * pixels)
{
m_Real.glTexImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels);
// proxy formats are used for querying texture capabilities, don't serialise these
if(IsProxyTarget((GLenum)internalformat)) return;
internalformat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
m_Real.glTexImage3D(target, level, internalformat, width, height, depth, border, format, type, pixels);
if(m_State >= WRITING)
{
GLResourceRecord *record = m_TextureRecord[m_TextureUnit];
@@ -1636,7 +1650,7 @@ void WrappedOpenGL::glTexImage3D(GLenum target, GLint level, GLint internalforma
m_Textures[texId].depth = depth;
m_Textures[texId].curType = TextureTarget(target);
m_Textures[texId].dimension = 3;
m_Textures[texId].internalFormat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
m_Textures[texId].internalFormat = (GLenum)internalformat;
}
}
@@ -1676,11 +1690,13 @@ bool WrappedOpenGL::Serialise_glCompressedTextureImage1DEXT(GLuint texture, GLen
void WrappedOpenGL::glCompressedTextureImage1DEXT(GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *pixels)
{
m_Real.glCompressedTextureImage1DEXT(texture, target, level, internalformat, width, border, imageSize, pixels);
// proxy formats are used for querying texture capabilities, don't serialise these
if(IsProxyTarget(internalformat)) return;
internalformat = GetSizedFormat(m_Real, target, internalformat);
m_Real.glCompressedTextureImage1DEXT(texture, target, level, internalformat, width, border, imageSize, pixels);
if(m_State >= WRITING)
{
GLResourceRecord *record = GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
@@ -1713,11 +1729,13 @@ void WrappedOpenGL::glCompressedTextureImage1DEXT(GLuint texture, GLenum target,
void WrappedOpenGL::glCompressedTexImage1D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *pixels)
{
m_Real.glCompressedTexImage1D(target, level, internalformat, width, border, imageSize, pixels);
// proxy formats are used for querying texture capabilities, don't serialise these
if(IsProxyTarget(internalformat)) return;
internalformat = GetSizedFormat(m_Real, target, internalformat);
m_Real.glCompressedTexImage1D(target, level, internalformat, width, border, imageSize, pixels);
if(m_State >= WRITING)
{
GLResourceRecord *record = m_TextureRecord[m_TextureUnit];
@@ -1785,11 +1803,13 @@ bool WrappedOpenGL::Serialise_glCompressedTextureImage2DEXT(GLuint texture, GLen
void WrappedOpenGL::glCompressedTextureImage2DEXT(GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid * pixels)
{
m_Real.glCompressedTextureImage2DEXT(texture, target, level, internalformat, width, height, border, imageSize, pixels);
// proxy formats are used for querying texture capabilities, don't serialise these
if(IsProxyTarget(internalformat)) return;
internalformat = GetSizedFormat(m_Real, target, internalformat);
m_Real.glCompressedTextureImage2DEXT(texture, target, level, internalformat, width, height, border, imageSize, pixels);
if(m_State >= WRITING)
{
GLResourceRecord *record = GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
@@ -1822,11 +1842,13 @@ void WrappedOpenGL::glCompressedTextureImage2DEXT(GLuint texture, GLenum target,
void WrappedOpenGL::glCompressedTexImage2D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid * pixels)
{
m_Real.glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, pixels);
// proxy formats are used for querying texture capabilities, don't serialise these
if(IsProxyTarget(internalformat)) return;
internalformat = GetSizedFormat(m_Real, target, internalformat);
m_Real.glCompressedTexImage2D(target, level, internalformat, width, height, border, imageSize, pixels);
if(m_State >= WRITING)
{
GLResourceRecord *record = m_TextureRecord[m_TextureUnit];
@@ -1895,11 +1917,13 @@ bool WrappedOpenGL::Serialise_glCompressedTextureImage3DEXT(GLuint texture, GLen
void WrappedOpenGL::glCompressedTextureImage3DEXT(GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const void *pixels)
{
m_Real.glCompressedTextureImage3DEXT(texture, target, level, internalformat, width, height, depth, border, imageSize, pixels);
// proxy formats are used for querying texture capabilities, don't serialise these
if(IsProxyTarget(internalformat)) return;
internalformat = GetSizedFormat(m_Real, target, internalformat);
m_Real.glCompressedTextureImage3DEXT(texture, target, level, internalformat, width, height, depth, border, imageSize, pixels);
if(m_State >= WRITING)
{
GLResourceRecord *record = GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
@@ -1932,11 +1956,13 @@ void WrappedOpenGL::glCompressedTextureImage3DEXT(GLuint texture, GLenum target,
void WrappedOpenGL::glCompressedTexImage3D(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid * pixels)
{
m_Real.glCompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, pixels);
// proxy formats are used for querying texture capabilities, don't serialise these
if(IsProxyTarget(internalformat)) return;
internalformat = GetSizedFormat(m_Real, target, internalformat);
m_Real.glCompressedTexImage3D(target, level, internalformat, width, height, depth, border, imageSize, pixels);
if(m_State >= WRITING)
{
GLResourceRecord *record = m_TextureRecord[m_TextureUnit];
@@ -1997,11 +2023,13 @@ bool WrappedOpenGL::Serialise_glTextureStorage1DEXT(GLuint texture, GLenum targe
void WrappedOpenGL::glTextureStorage1DEXT(GLuint texture, GLenum target, GLsizei levels, GLenum internalformat, GLsizei width)
{
m_Real.glTextureStorage1DEXT(texture, target, levels, internalformat, width);
// proxy formats are used for querying texture capabilities, don't serialise these
if(IsProxyTarget(internalformat)) return;
internalformat = GetSizedFormat(m_Real, target, internalformat);
m_Real.glTextureStorage1DEXT(texture, target, levels, internalformat, width);
if(m_State >= WRITING)
{
GLResourceRecord *record = GetResourceManager()->GetResourceRecord(TextureRes(GetCtx(), texture));
@@ -2353,11 +2381,13 @@ void WrappedOpenGL::glTexStorage2DMultisample(GLenum target, GLsizei samples, GL
void WrappedOpenGL::glTexImage2DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations)
{
m_Real.glTexImage2DMultisample(target, samples, internalformat, width, height, fixedsamplelocations);
// proxy formats are used for querying texture capabilities, don't serialise these
if(IsProxyTarget(internalformat)) return;
internalformat = GetSizedFormat(m_Real, target, internalformat);
m_Real.glTexImage2DMultisample(target, samples, internalformat, width, height, fixedsamplelocations);
if(m_State >= WRITING)
{
GLResourceRecord *record = m_TextureRecord[m_TextureUnit];
@@ -2491,11 +2521,13 @@ void WrappedOpenGL::glTexStorage3DMultisample(GLenum target, GLsizei samples, GL
void WrappedOpenGL::glTexImage3DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLboolean fixedsamplelocations)
{
m_Real.glTexImage3DMultisample(target, samples, internalformat, width, height, depth, fixedsamplelocations);
// proxy formats are used for querying texture capabilities, don't serialise these
if(IsProxyTarget(internalformat)) return;
internalformat = GetSizedFormat(m_Real, target, internalformat);
m_Real.glTexImage3DMultisample(target, samples, internalformat, width, height, depth, fixedsamplelocations);
if(m_State >= WRITING)
{
GLResourceRecord *record = m_TextureRecord[m_TextureUnit];