mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-08-20 05:26:42 +00:00
Handling for old style unsized texture internal formats
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
|
||||
#include "gl_hookset.h"
|
||||
#include "gl_resources.h"
|
||||
|
||||
size_t GetByteSize(GLsizei w, GLsizei h, GLsizei d, GLenum format, GLenum type, int align)
|
||||
@@ -328,6 +328,74 @@ GLenum GetDataType(GLenum internalFormat)
|
||||
return eGL_NONE;
|
||||
}
|
||||
|
||||
GLenum GetSizedFormat(const GLHookSet &gl, GLenum target, GLenum internalFormat)
|
||||
{
|
||||
switch(internalFormat)
|
||||
{
|
||||
case eGL_RED:
|
||||
case eGL_RG:
|
||||
case eGL_RGB:
|
||||
case eGL_RGBA:
|
||||
case eGL_DEPTH_COMPONENT:
|
||||
case eGL_DEPTH_STENCIL:
|
||||
break;
|
||||
default:
|
||||
return internalFormat; // already explicitly sized
|
||||
}
|
||||
|
||||
GLint red, depth;
|
||||
gl.glGetInternalformativ(target, internalFormat, eGL_INTERNALFORMAT_RED_SIZE, sizeof(GLint), &red);
|
||||
gl.glGetInternalformativ(target, internalFormat, eGL_INTERNALFORMAT_DEPTH_SIZE, sizeof(GLint), &depth);
|
||||
|
||||
switch(internalFormat)
|
||||
{
|
||||
case eGL_RED:
|
||||
if(red == 32)
|
||||
return eGL_R32F;
|
||||
else if(red == 16)
|
||||
return eGL_R16;
|
||||
else
|
||||
return eGL_R8;
|
||||
case eGL_RG:
|
||||
if(red == 32)
|
||||
return eGL_RG32F;
|
||||
else if(red == 16)
|
||||
return eGL_RG16;
|
||||
else
|
||||
return eGL_RG8;
|
||||
case eGL_RGB:
|
||||
if(red == 32)
|
||||
return eGL_RGB32F;
|
||||
else if(red == 16)
|
||||
return eGL_RGB16;
|
||||
else
|
||||
return eGL_RGB8;
|
||||
case eGL_RGBA:
|
||||
if(red == 32)
|
||||
return eGL_RGBA32F;
|
||||
else if(red == 16)
|
||||
return eGL_RGBA16;
|
||||
else
|
||||
return eGL_RGBA8;
|
||||
case eGL_DEPTH_COMPONENT:
|
||||
if(depth == 32)
|
||||
return eGL_DEPTH_COMPONENT32F;
|
||||
else if(depth == 16)
|
||||
return eGL_DEPTH_COMPONENT16;
|
||||
else
|
||||
return eGL_DEPTH_COMPONENT24;
|
||||
case eGL_DEPTH_STENCIL:
|
||||
if(depth == 32)
|
||||
return eGL_DEPTH32F_STENCIL8;
|
||||
else
|
||||
return eGL_DEPTH24_STENCIL8;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return internalFormat;
|
||||
}
|
||||
|
||||
bool IsDepthStencilFormat(GLenum internalFormat)
|
||||
{
|
||||
GLenum fmt = GetBaseFormat(internalFormat);
|
||||
|
||||
@@ -29,9 +29,12 @@
|
||||
|
||||
#include "driver/gl/gl_common.h"
|
||||
|
||||
struct GLHookSet;
|
||||
|
||||
size_t GetByteSize(GLsizei w, GLsizei h, GLsizei d, GLenum format, GLenum type, int align);
|
||||
GLenum GetBaseFormat(GLenum internalFormat);
|
||||
GLenum GetDataType(GLenum internalFormat);
|
||||
GLenum GetSizedFormat(const GLHookSet &gl, GLenum target, GLenum internalFormat);
|
||||
|
||||
bool IsDepthStencilFormat(GLenum internalFormat);
|
||||
bool IsUIntFormat(GLenum internalFormat);
|
||||
|
||||
@@ -1016,7 +1016,7 @@ bool WrappedOpenGL::Serialise_glTextureImage1DEXT(GLuint texture, GLenum target,
|
||||
m_Textures[liveId].depth = 1;
|
||||
m_Textures[liveId].curType = Target;
|
||||
m_Textures[liveId].dimension = 1;
|
||||
m_Textures[liveId].internalFormat = IntFormat;
|
||||
m_Textures[liveId].internalFormat = GetSizedFormat(m_Real, target, IntFormat);
|
||||
}
|
||||
|
||||
m_Real.glTextureImage1DEXT(GetResourceManager()->GetLiveResource(id).name, Target, Level, IntFormat, Width, Border, Format, Type, buf);
|
||||
@@ -1060,7 +1060,7 @@ void WrappedOpenGL::glTextureImage1DEXT(GLuint texture, GLenum target, GLint lev
|
||||
m_Textures[texId].depth = 1;
|
||||
m_Textures[texId].curType = target;
|
||||
m_Textures[texId].dimension = 1;
|
||||
m_Textures[texId].internalFormat = (GLenum)internalformat;
|
||||
m_Textures[texId].internalFormat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1097,7 +1097,7 @@ void WrappedOpenGL::glTexImage1D(GLenum target, GLint level, GLint internalforma
|
||||
m_Textures[texId].depth = 1;
|
||||
m_Textures[texId].curType = target;
|
||||
m_Textures[texId].dimension = 1;
|
||||
m_Textures[texId].internalFormat = (GLenum)internalformat;
|
||||
m_Textures[texId].internalFormat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1134,7 +1134,7 @@ bool WrappedOpenGL::Serialise_glTextureImage2DEXT(GLuint texture, GLenum target,
|
||||
m_Textures[liveId].depth = 1;
|
||||
m_Textures[liveId].curType = Target;
|
||||
m_Textures[liveId].dimension = 2;
|
||||
m_Textures[liveId].internalFormat = IntFormat;
|
||||
m_Textures[liveId].internalFormat = GetSizedFormat(m_Real, target, IntFormat);
|
||||
}
|
||||
|
||||
m_Real.glTextureImage2DEXT(GetResourceManager()->GetLiveResource(id).name, Target, Level, IntFormat, Width, Height, Border, Format, Type, buf);
|
||||
@@ -1178,7 +1178,7 @@ void WrappedOpenGL::glTextureImage2DEXT(GLuint texture, GLenum target, GLint lev
|
||||
m_Textures[texId].depth = 1;
|
||||
m_Textures[texId].curType = target;
|
||||
m_Textures[texId].dimension = 2;
|
||||
m_Textures[texId].internalFormat = (GLenum)internalformat;
|
||||
m_Textures[texId].internalFormat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1215,7 +1215,7 @@ void WrappedOpenGL::glTexImage2D(GLenum target, GLint level, GLint internalforma
|
||||
m_Textures[texId].depth = 1;
|
||||
m_Textures[texId].curType = target;
|
||||
m_Textures[texId].dimension = 2;
|
||||
m_Textures[texId].internalFormat = (GLenum)internalformat;
|
||||
m_Textures[texId].internalFormat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1253,7 +1253,7 @@ bool WrappedOpenGL::Serialise_glTextureImage3DEXT(GLuint texture, GLenum target,
|
||||
m_Textures[liveId].depth = Depth;
|
||||
m_Textures[liveId].curType = Target;
|
||||
m_Textures[liveId].dimension = 3;
|
||||
m_Textures[liveId].internalFormat = IntFormat;
|
||||
m_Textures[liveId].internalFormat = GetSizedFormat(m_Real, target, IntFormat);
|
||||
}
|
||||
|
||||
m_Real.glTextureImage3DEXT(GetResourceManager()->GetLiveResource(id).name, Target, Level, IntFormat, Width, Height, Depth, Border, Format, Type, buf);
|
||||
@@ -1297,7 +1297,7 @@ void WrappedOpenGL::glTextureImage3DEXT(GLuint texture, GLenum target, GLint lev
|
||||
m_Textures[texId].depth = depth;
|
||||
m_Textures[texId].curType = target;
|
||||
m_Textures[texId].dimension = 3;
|
||||
m_Textures[texId].internalFormat = (GLenum)internalformat;
|
||||
m_Textures[texId].internalFormat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1334,7 +1334,7 @@ void WrappedOpenGL::glTexImage3D(GLenum target, GLint level, GLint internalforma
|
||||
m_Textures[texId].depth = depth;
|
||||
m_Textures[texId].curType = target;
|
||||
m_Textures[texId].dimension = 3;
|
||||
m_Textures[texId].internalFormat = (GLenum)internalformat;
|
||||
m_Textures[texId].internalFormat = GetSizedFormat(m_Real, target, (GLenum)internalformat);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user