Skip to content

Commit ae5a755

Browse files
author
kevyuu
committed
Add some comment in quantization cache
1 parent c7caf76 commit ae5a755

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

include/nbl/asset/utils/CDirQuantCacheBase.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -429,11 +429,16 @@ class CDirQuantCacheBase : public virtual core::IReferenceCounted, public impl::
429429
retval.w = mask.w ? val2.w : val1.w;
430430
return retval;
431431
};
432-
432+
;
433+
// create all one bits
433434
const hlsl::uint32_t4 xorflag((0x1u << (quantizationBits + 1u)) - 1u);
435+
436+
// for positive number xoring with 0 keep its value
437+
// for negative number we xor with all one which will flip the bits, then we add one later. Flipping the bits then adding one will turn positive number into negative number
434438
auto restoredAsVec = quantized.getValue() ^ switch_vec(hlsl::uint32_t4(0u), hlsl::uint32_t4(xorflag), negativeMask);
435439
restoredAsVec += switch_vec(hlsl::uint32_t4(0u), hlsl::uint32_t4(1u), negativeMask);
436-
return value_type_t<CacheFormat>(restoredAsVec & xorflag);
440+
441+
return value_type_t<CacheFormat>(restoredAsVec);
437442
}
438443

439444
template<uint32_t dimensions, uint32_t quantizationBits>
@@ -446,7 +451,7 @@ class CDirQuantCacheBase : public virtual core::IReferenceCounted, public impl::
446451

447452
//
448453
hlsl::vector<hlsl::float32_t, dimensions> fittingVector;
449-
hlsl::vector<hlsl::float32_t, dimensions> floorOffset;
454+
hlsl::vector<hlsl::float32_t, dimensions> floorOffset = {};
450455
constexpr uint32_t cornerCount = (0x1u<<(dimensions-1u))-1u;
451456
hlsl::vector<hlsl::float32_t, dimensions> corners[cornerCount] = {};
452457
{

0 commit comments

Comments
 (0)