From c47d50ea7b9f65af2c643cae5b30d18cda50ca09 Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 20 Feb 2017 12:00:32 +0000 Subject: [PATCH] Use per-face targets when serialising cubemap images with TexImage --- renderdoc/driver/gl/gl_manager.cpp | 39 +++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-) diff --git a/renderdoc/driver/gl/gl_manager.cpp b/renderdoc/driver/gl/gl_manager.cpp index b6ccb0973..8d50f5b54 100644 --- a/renderdoc/driver/gl/gl_manager.cpp +++ b/renderdoc/driver/gl/gl_manager.cpp @@ -712,14 +712,29 @@ void GLResourceManager::PrepareTextureInitialContents(ResourceId liveid, Resourc } else if(details.dimension == 2) { + GLenum targets[] = { + eGL_TEXTURE_CUBE_MAP_POSITIVE_X, eGL_TEXTURE_CUBE_MAP_NEGATIVE_X, + eGL_TEXTURE_CUBE_MAP_POSITIVE_Y, eGL_TEXTURE_CUBE_MAP_NEGATIVE_Y, + eGL_TEXTURE_CUBE_MAP_POSITIVE_Z, eGL_TEXTURE_CUBE_MAP_NEGATIVE_Z, + }; + gl.glTextureParameteriEXT(tex, details.curType, eGL_TEXTURE_MAX_LEVEL, mips - 1); int w = details.width; int h = details.height; for(int i = 0; i < mips; i++) { - gl.glTextureImage2DEXT(tex, details.curType, i, details.internalFormat, w, h, 0, - baseFormat, dataType, NULL); + if(details.curType != eGL_TEXTURE_CUBE_MAP) + { + gl.glTextureImage2DEXT(tex, details.curType, i, details.internalFormat, w, h, 0, + baseFormat, dataType, NULL); + } + else + { + for(size_t t = 0; t < ARRAY_COUNT(targets); t++) + gl.glTextureImage2DEXT(tex, targets[t], i, details.internalFormat, w, h, 0, + baseFormat, dataType, NULL); + } w = RDCMAX(1, w >> 1); if(details.curType != eGL_TEXTURE_1D_ARRAY) h = RDCMAX(1, h >> 1); @@ -1471,14 +1486,30 @@ bool GLResourceManager::Serialise_InitialState(ResourceId resid, GLResource res) } else if(dim == 2) { + GLenum targets[] = { + eGL_TEXTURE_CUBE_MAP_POSITIVE_X, eGL_TEXTURE_CUBE_MAP_NEGATIVE_X, + eGL_TEXTURE_CUBE_MAP_POSITIVE_Y, eGL_TEXTURE_CUBE_MAP_NEGATIVE_Y, + eGL_TEXTURE_CUBE_MAP_POSITIVE_Z, eGL_TEXTURE_CUBE_MAP_NEGATIVE_Z, + }; + gl.glTextureParameteriEXT(tex, textype, eGL_TEXTURE_MAX_LEVEL, mips - 1); int w = width; int h = height; for(int i = 0; i < mips; i++) { - gl.glTextureImage2DEXT(tex, textype, i, internalformat, w, h, 0, baseFormat, dataType, - NULL); + if(textype != eGL_TEXTURE_CUBE_MAP) + { + gl.glTextureImage2DEXT(tex, textype, i, internalformat, w, h, 0, baseFormat, dataType, + NULL); + } + else + { + for(size_t t = 0; t < ARRAY_COUNT(targets); t++) + gl.glTextureImage2DEXT(tex, targets[t], i, internalformat, w, h, 0, baseFormat, + dataType, NULL); + } + w = RDCMAX(1, w >> 1); if(textype != eGL_TEXTURE_1D_ARRAY) h = RDCMAX(1, h >> 1);