From ab74df54caef88bb583b9b27110283e11f282abb Mon Sep 17 00:00:00 2001 From: baldurk Date: Mon, 25 Nov 2019 15:50:28 +0000 Subject: [PATCH] Use typecast provided at proxy texture creation time on D3D * When we create proxy textures on D3D we create them as typeless, but this means we might lose the only time we are told about the type interpretation of the texture. If we then later get asked to view the texture as typeless, be sure to use that type info to interpret it, instead of defaulting to UNORM or FLOAT. --- .../driver/d3d11/d3d11_rendertexture.cpp | 22 ++++++++++++++----- renderdoc/driver/d3d11/d3d11_replay.cpp | 2 ++ renderdoc/driver/d3d11/d3d11_replay.h | 1 + 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/renderdoc/driver/d3d11/d3d11_rendertexture.cpp b/renderdoc/driver/d3d11/d3d11_rendertexture.cpp index 54656840f..8d8ab7860 100644 --- a/renderdoc/driver/d3d11/d3d11_rendertexture.cpp +++ b/renderdoc/driver/d3d11/d3d11_rendertexture.cpp @@ -506,8 +506,20 @@ bool D3D11Replay::RenderTextureInternal(TextureDisplay cfg, TexDisplayFlags flag pixelData.FlipY = cfg.flipY ? 1 : 0; - TextureShaderDetails details = GetDebugManager()->GetShaderDetails(cfg.resourceId, cfg.typeCast, - cfg.rawOutput ? true : false); + CompType typeCast = cfg.typeCast; + + // we create all proxy textures as typeless to allow us to cast, but that means if the remote API + // gave us a typed texture and then wants to view it 'typeless' (i.e. as it was created) we need + // to restore that type here. + if(typeCast == CompType::Typeless) + { + auto it = m_ProxyTypeCastDefault.find(cfg.resourceId); + if(it != m_ProxyTypeCastDefault.end()) + typeCast = it->second; + } + + TextureShaderDetails details = + GetDebugManager()->GetShaderDetails(cfg.resourceId, typeCast, cfg.rawOutput ? true : false); int sampleIdx = (int)RDCCLAMP(cfg.subresource.sample, 0U, details.sampleCount - 1); @@ -752,14 +764,12 @@ bool D3D11Replay::RenderTextureInternal(TextureDisplay cfg, TexDisplayFlags flag int srvOffset = 0; - if(IsUIntFormat(details.texFmt) || - (IsTypelessFormat(details.texFmt) && cfg.typeCast == CompType::UInt)) + if(IsUIntFormat(details.texFmt) || (IsTypelessFormat(details.texFmt) && typeCast == CompType::UInt)) { pixelData.OutputDisplayFormat |= TEXDISPLAY_UINT_TEX; srvOffset = 10; } - if(IsIntFormat(details.texFmt) || - (IsTypelessFormat(details.texFmt) && cfg.typeCast == CompType::SInt)) + if(IsIntFormat(details.texFmt) || (IsTypelessFormat(details.texFmt) && typeCast == CompType::SInt)) { pixelData.OutputDisplayFormat |= TEXDISPLAY_SINT_TEX; srvOffset = 20; diff --git a/renderdoc/driver/d3d11/d3d11_replay.cpp b/renderdoc/driver/d3d11/d3d11_replay.cpp index 5069de365..e5be204a8 100644 --- a/renderdoc/driver/d3d11/d3d11_replay.cpp +++ b/renderdoc/driver/d3d11/d3d11_replay.cpp @@ -3471,6 +3471,8 @@ ResourceId D3D11Replay::CreateProxyTexture(const TextureDescription &templateTex m_ProxyResources.push_back(resource); + m_ProxyTypeCastDefault[ret] = templateTex.format.compType; + return ret; } diff --git a/renderdoc/driver/d3d11/d3d11_replay.h b/renderdoc/driver/d3d11/d3d11_replay.h index 223b44206..15e750d49 100644 --- a/renderdoc/driver/d3d11/d3d11_replay.h +++ b/renderdoc/driver/d3d11/d3d11_replay.h @@ -297,6 +297,7 @@ private: } std::vector m_ProxyResources; + std::map m_ProxyTypeCastDefault; struct OutputWindow {