From 0a0fe7b021ac6c5544e1c2ab3dd16bae4e0f8eb0 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 15 Dec 2022 15:19:41 +0000 Subject: [PATCH] Correctly round generated SNORM data in texture zoo tests --- util/test/demos/texture_zoo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/test/demos/texture_zoo.cpp b/util/test/demos/texture_zoo.cpp index 6f80595f6..b1c47a323 100644 --- a/util/test/demos/texture_zoo.cpp +++ b/util/test/demos/texture_zoo.cpp @@ -75,7 +75,7 @@ void MakePixel(byte *data, const TexConfig &cfg, uint32_t x, uint32_t y, uint32_ else if(cfg.data == DataType::UNorm) h = uint16_t(f * 0xffff); else if(cfg.data == DataType::SNorm) - h = int16_t(f * 0x7fff); + h = f < 0 ? int16_t(roundf(f * 0x8000)) : int16_t(roundf(f * 0x7fff)); memcpy(data, &h, cfg.componentBytes); } else if(cfg.componentBytes == 1) @@ -84,7 +84,7 @@ void MakePixel(byte *data, const TexConfig &cfg, uint32_t x, uint32_t y, uint32_ if(cfg.data == DataType::UNorm) b = uint8_t(f * 0xff); else if(cfg.data == DataType::SNorm) - b = int8_t(f * 0x7f); + b = f < 0 ? int8_t(roundf(f * 0x80)) : int8_t(roundf(f * 0x7f)); memcpy(data, &b, cfg.componentBytes); } else