From 602b5db72b102b4687b9e5a42edb6478e47e6173 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 1 Aug 2018 16:07:16 +0100 Subject: [PATCH] Re-swizzle D24S8 textures on GL into the order expected for texture data --- renderdoc/driver/gl/gl_replay.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/renderdoc/driver/gl/gl_replay.cpp b/renderdoc/driver/gl/gl_replay.cpp index 1e4dfec53..0b589ce6c 100644 --- a/renderdoc/driver/gl/gl_replay.cpp +++ b/renderdoc/driver/gl/gl_replay.cpp @@ -2517,6 +2517,22 @@ void GLReplay::GetTextureData(ResourceId tex, uint32_t arrayIdx, uint32_t mip, drv.glGetTexImage(target, (GLint)mip, fmt, type, data.data()); } + // packed D24S8 comes out the wrong way around from what we expect, so we re-swizzle it. + if(intFormat == eGL_DEPTH24_STENCIL8) + { + uint32_t *ptr = (uint32_t *)data.data(); + + for(GLsizei y = 0; y < height; y++) + { + for(GLsizei x = 0; x < width; x++) + { + const uint32_t val = *ptr; + *ptr = (val >> 8) | ((val & 0xff) << 24); + ptr++; + } + } + } + // if we're saving to disk we make the decision to vertically flip any non-compressed // images. This is a bit arbitrary, but really origin top-left is common for all disk // formats so we do this flip from bottom-left origin. We only do this for saving to