From ba9321e7962831890996a91b8245db1dbcf74ee2 Mon Sep 17 00:00:00 2001 From: baldurk Date: Fri, 8 Jul 2016 16:16:01 +0300 Subject: [PATCH] Use macro for extracting swizzle components --- renderdoc/driver/d3d12/d3d12_common.cpp | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/renderdoc/driver/d3d12/d3d12_common.cpp b/renderdoc/driver/d3d12/d3d12_common.cpp index e010e899e..44ee2300a 100644 --- a/renderdoc/driver/d3d12/d3d12_common.cpp +++ b/renderdoc/driver/d3d12/d3d12_common.cpp @@ -67,20 +67,13 @@ string ToStrHelper::Get(const D3D12ComponentMappin { string ret; + // value should always be <= 5, see D3D12_SHADER_COMPONENT_MAPPING + const char mapping[] = {'R', 'G', 'B', 'A', '0', '1', '?', '?'}; + uint32_t swizzle = (uint32_t)el; - uint32_t shift = 0; - uint32_t mask = D3D12_SHADER_COMPONENT_MAPPING_MASK; for(int i = 0; i < 4; i++) - { - // value should always be <= 5, see D3D12_SHADER_COMPONENT_MAPPING - char mapping[] = {'R', 'G', 'B', 'A', '0', '1', '?', '?'}; - - ret += mapping[(swizzle & mask) >> shift]; - - shift += D3D12_SHADER_COMPONENT_MAPPING_SHIFT; - mask <<= D3D12_SHADER_COMPONENT_MAPPING_SHIFT; - } + ret += mapping[D3D12_DECODE_SHADER_4_COMPONENT_MAPPING(swizzle, i)]; return ret; }