From 21e056e5b87d6028a02dc57f16b720f8bb1d6283 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 9 Jan 2019 10:02:18 +0000 Subject: [PATCH] Fix stringification of bitfields with duplicate values * We'd previously subtract the bitfield value twice, leading to underflow and then lots of unknown bits appear to be set. Instead we should clear the bit so that it's safe to apply multiple times. --- renderdoc/api/replay/stringise.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/renderdoc/api/replay/stringise.h b/renderdoc/api/replay/stringise.h index 7e789c417..2af99a1f3 100644 --- a/renderdoc/api/replay/stringise.h +++ b/renderdoc/api/replay/stringise.h @@ -110,28 +110,28 @@ std::string ToStr(const T &el) #define STRINGISE_BITFIELD_BIT(b) \ if(el & b) \ { \ - local -= (uint32_t)b; \ + local &= ~uint32_t(b); \ ret += " | " #b; \ } #define STRINGISE_BITFIELD_CLASS_BIT(b) \ if(el & enumType::b) \ { \ - local -= (uint32_t)enumType::b; \ + local &= ~uint32_t(enumType::b); \ ret += " | " #b; \ } #define STRINGISE_BITFIELD_BIT_NAMED(b, str) \ if(el & b) \ { \ - local -= (uint32_t)b; \ + local &= ~uint32_t(b); \ ret += " | " str; \ } #define STRINGISE_BITFIELD_CLASS_BIT_NAMED(b, str) \ if(el & enumType::b) \ { \ - local -= (uint32_t)enumType::b; \ + local &= ~uint32_t(enumType::b); \ ret += " | " str; \ }