From 8a7e729632a9c7e9f0fa84e3686904bd0cc2ecc5 Mon Sep 17 00:00:00 2001 From: jsmall-nvidia Date: Wed, 20 Nov 2019 13:25:44 -0500 Subject: Added -ir-compression & fixes for ir compression issues (#1129) * Added ir-compression option. * Fix issues around ir-compression. * Fix typo in test name. --- source/core/slang-riff.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'source/core') diff --git a/source/core/slang-riff.h b/source/core/slang-riff.h index 1622f60f4..535eaffc2 100644 --- a/source/core/slang-riff.h +++ b/source/core/slang-riff.h @@ -12,9 +12,26 @@ namespace Slang // http://fileformats.archiveteam.org/wiki/RIFF // http://www.fileformat.info/format/riff/egff.htm + typedef uint32_t FourCC; -#define SLANG_FOUR_CC(c0, c1, c2, c3) FourCC((uint32_t(c0) << 0) | (uint32_t(c1) << 8) | (uint32_t(c2) << 16) | (uint32_t(c3) << 24)) +/* Use of macros to construct and extract from FourCC means the FourCC ordering can be fixed for endian differences. */ + +#if SLANG_LITTLE_ENDIAN + +#define SLANG_FOUR_CC(c0, c1, c2, c3) ((FourCC(c0) << 0) | (FourCC(c1) << 8) | (FourCC(c2) << 16) | (FourCC(c3) << 24)) + +#define SLANG_FOUR_CC_GET_FIRST_CHAR(x) char((x) & 0xff) +#define SLANG_FOUR_CC_REPLACE_FIRST_CHAR(x, c) (((x) & 0xffffff00) | FourCC(c)) + +#else + +#define SLANG_FOUR_CC(c0, c1, c2, c3) ((FourCC(c0) << 24) | (FourCC(c1) << 16) | (FourCC(c2) << 8) | (FourCC(c3) << 0)) + +#define SLANG_FOUR_CC_GET_FIRST_CHAR(x) char((x) >> 24) +#define SLANG_FOUR_CC_REPLACE_FIRST_CHAR(x, c) (((x) & 0x00ffffff) | (FourCC(c) << 24)) + +#endif enum { -- cgit v1.2.3