From 7941c3ebb32950c6701cad14c9a6323440beda49 Mon Sep 17 00:00:00 2001 From: Baldur Karlsson Date: Thu, 19 Jun 2014 13:43:47 +0100 Subject: [PATCH] Fixes for querying things out of cubemaps --- renderdoc/driver/gl/gl_replay.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/renderdoc/driver/gl/gl_replay.cpp b/renderdoc/driver/gl/gl_replay.cpp index 98b0c742b..1c658c90b 100644 --- a/renderdoc/driver/gl/gl_replay.cpp +++ b/renderdoc/driver/gl/gl_replay.cpp @@ -334,12 +334,16 @@ FetchTexture GLReplay::GetTexture(ResourceId id) gl.glBindTexture(res.curType, res.resource.name); - // if I call this for levels 1, 2, .. etc. Can I get sizes that aren't mip dimensions? + GLenum levelQueryType = res.curType; + if(levelQueryType == eGL_TEXTURE_CUBE_MAP) + levelQueryType = eGL_TEXTURE_CUBE_MAP_POSITIVE_X; + + // TODO if I call this for levels 1, 2, .. etc. Can I get sizes that aren't mip dimensions? GLint width = 1, height = 1, depth = 1, samples=1; - gl.glGetTexLevelParameteriv(res.curType, 0, eGL_TEXTURE_WIDTH, &width); - gl.glGetTexLevelParameteriv(res.curType, 0, eGL_TEXTURE_HEIGHT, &height); - gl.glGetTexLevelParameteriv(res.curType, 0, eGL_TEXTURE_DEPTH, &depth); - gl.glGetTexLevelParameteriv(res.curType, 0, eGL_TEXTURE_SAMPLES, &samples); + gl.glGetTexLevelParameteriv(levelQueryType, 0, eGL_TEXTURE_WIDTH, &width); + gl.glGetTexLevelParameteriv(levelQueryType, 0, eGL_TEXTURE_HEIGHT, &height); + gl.glGetTexLevelParameteriv(levelQueryType, 0, eGL_TEXTURE_DEPTH, &depth); + gl.glGetTexLevelParameteriv(levelQueryType, 0, eGL_TEXTURE_SAMPLES, &samples); if(res.width == 0) { @@ -382,6 +386,7 @@ FetchTexture GLReplay::GetTexture(ResourceId id) tex.dimension = 2; tex.width = (uint32_t)width; tex.height = (uint32_t)height; + tex.depth = (res.curType == eGL_TEXTURE_CUBE_MAP ? 6 : 1); tex.cubemap = (res.curType == eGL_TEXTURE_CUBE_MAP); tex.msSamp = (res.curType == eGL_TEXTURE_2D_MULTISAMPLE ? samples : 1); break; @@ -391,6 +396,7 @@ FetchTexture GLReplay::GetTexture(ResourceId id) tex.dimension = 2; tex.width = (uint32_t)width; tex.height = (uint32_t)height; + tex.depth = (res.curType == eGL_TEXTURE_CUBE_MAP ? 6 : 1); tex.arraysize = depth; tex.cubemap = (res.curType == eGL_TEXTURE_CUBE_MAP_ARRAY); tex.msSamp = (res.curType == eGL_TEXTURE_2D_MULTISAMPLE_ARRAY ? samples : 1); @@ -427,7 +433,7 @@ FetchTexture GLReplay::GetTexture(ResourceId id) // surely this will be the same for each level... right? that would be insane if it wasn't GLint fmt = 0; - gl.glGetTexLevelParameteriv(res.curType, 0, eGL_TEXTURE_INTERNAL_FORMAT, &fmt); + gl.glGetTexLevelParameteriv(levelQueryType, 0, eGL_TEXTURE_INTERNAL_FORMAT, &fmt); tex.format = MakeResourceFormat(gl, res.curType, (GLenum)fmt);