From 58ac90e831627f5427f0fd733a121f6903873ad3 Mon Sep 17 00:00:00 2001 From: Michael Rennie Date: Tue, 25 Apr 2017 19:38:56 +0100 Subject: [PATCH] GetSizedFormat better depth decision based on data type, if available. --- renderdoc/driver/gl/gl_resources.cpp | 9 +++++++-- renderdoc/driver/gl/gl_resources.h | 3 ++- renderdoc/driver/gl/wrappers/gl_texture_funcs.cpp | 6 +++--- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/renderdoc/driver/gl/gl_resources.cpp b/renderdoc/driver/gl/gl_resources.cpp index e57310c69..cfbad44c8 100644 --- a/renderdoc/driver/gl/gl_resources.cpp +++ b/renderdoc/driver/gl/gl_resources.cpp @@ -502,7 +502,7 @@ int GetNumMips(const GLHookSet &gl, GLenum target, GLuint tex, GLuint w, GLuint return RDCMAX(1, mips); } -GLenum GetSizedFormat(const GLHookSet &gl, GLenum target, GLenum internalFormat) +GLenum GetSizedFormat(const GLHookSet &gl, GLenum target, GLenum internalFormat, GLenum type) { switch(internalFormat) { @@ -556,7 +556,12 @@ GLenum GetSizedFormat(const GLHookSet &gl, GLenum target, GLenum internalFormat) { // without the query function, just default to sensible defaults red = 8; - depth = 32; + if(type == eGL_FLOAT) + depth = 32; + else if(type == eGL_UNSIGNED_SHORT) + depth = 16; + else + depth = 24; stencil = 8; } diff --git a/renderdoc/driver/gl/gl_resources.h b/renderdoc/driver/gl/gl_resources.h index 383567166..19bc92a73 100644 --- a/renderdoc/driver/gl/gl_resources.h +++ b/renderdoc/driver/gl/gl_resources.h @@ -34,7 +34,8 @@ size_t GetCompressedByteSize(GLsizei w, GLsizei h, GLsizei d, GLenum internalfor size_t GetByteSize(GLsizei w, GLsizei h, GLsizei d, GLenum format, GLenum type); GLenum GetBaseFormat(GLenum internalFormat); GLenum GetDataType(GLenum internalFormat); -GLenum GetSizedFormat(const GLHookSet &gl, GLenum target, GLenum internalFormat); +GLenum GetSizedFormat(const GLHookSet &gl, GLenum target, GLenum internalFormat, + GLenum type = eGL_NONE); void GetFramebufferMipAndLayer(const GLHookSet &gl, GLenum framebuffer, GLenum attachment, GLint *mip, GLint *layer); void GetTextureSwizzle(const GLHookSet &gl, GLuint tex, GLenum target, GLenum *swizzleRGBA); diff --git a/renderdoc/driver/gl/wrappers/gl_texture_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_texture_funcs.cpp index 11fee5a8b..4cb4778ef 100644 --- a/renderdoc/driver/gl/wrappers/gl_texture_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_texture_funcs.cpp @@ -2027,7 +2027,7 @@ void WrappedOpenGL::Common_glTextureImage1DEXT(ResourceId texId, GLenum target, if(IsProxyTarget(target) || internalformat == 0) return; - internalformat = GetSizedFormat(m_Real, target, (GLenum)internalformat); + internalformat = GetSizedFormat(m_Real, target, (GLenum)internalformat, type); bool fromunpackbuf = false; { @@ -2259,7 +2259,7 @@ void WrappedOpenGL::Common_glTextureImage2DEXT(ResourceId texId, GLenum target, if(IsProxyTarget(target) || internalformat == 0) return; - internalformat = GetSizedFormat(m_Real, target, (GLenum)internalformat); + internalformat = GetSizedFormat(m_Real, target, (GLenum)internalformat, type); bool fromunpackbuf = false; { @@ -2473,7 +2473,7 @@ void WrappedOpenGL::Common_glTextureImage3DEXT(ResourceId texId, GLenum target, if(IsProxyTarget(target) || internalformat == 0) return; - internalformat = GetSizedFormat(m_Real, target, (GLenum)internalformat); + internalformat = GetSizedFormat(m_Real, target, (GLenum)internalformat, type); bool fromunpackbuf = false; {