Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove formats x macro #13

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
112 changes: 0 additions & 112 deletions include/slang-rhi.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,117 +149,6 @@ class IShaderProgram : public ISlangUnknown
virtual SLANG_NO_THROW slang::TypeReflection* SLANG_MCALL findTypeByName(const char* name) = 0;
};

// TODO: Confirm with Yong that we really want this naming convention
// TODO: Rename to what?
// Dont' change without keeping in sync with Format
// clang-format off
#define SLANG_RHI_FORMAT(x) \
x( Unknown, 0, 0) \
\
x(R32G32B32A32_TYPELESS, 16, 1) \
x(R32G32B32_TYPELESS, 12, 1) \
x(R32G32_TYPELESS, 8, 1) \
x(R32_TYPELESS, 4, 1) \
\
x(R16G16B16A16_TYPELESS, 8, 1) \
x(R16G16_TYPELESS, 4, 1) \
x(R16_TYPELESS, 2, 1) \
\
x(R8G8B8A8_TYPELESS, 4, 1) \
x(R8G8_TYPELESS, 2, 1) \
x(R8_TYPELESS, 1, 1) \
x(B8G8R8A8_TYPELESS, 4, 1) \
\
x(R32G32B32A32_FLOAT, 16, 1) \
x(R32G32B32_FLOAT, 12, 1) \
x(R32G32_FLOAT, 8, 1) \
x(R32_FLOAT, 4, 1) \
\
x(R16G16B16A16_FLOAT, 8, 1) \
x(R16G16_FLOAT, 4, 1) \
x(R16_FLOAT, 2, 1) \
\
x(R32G32B32A32_UINT, 16, 1) \
x(R32G32B32_UINT, 12, 1) \
x(R32G32_UINT, 8, 1) \
x(R32_UINT, 4, 1) \
\
x(R16G16B16A16_UINT, 8, 1) \
x(R16G16_UINT, 4, 1) \
x(R16_UINT, 2, 1) \
\
x(R8G8B8A8_UINT, 4, 1) \
x(R8G8_UINT, 2, 1) \
x(R8_UINT, 1, 1) \
\
x(R32G32B32A32_SINT, 16, 1) \
x(R32G32B32_SINT, 12, 1) \
x(R32G32_SINT, 8, 1) \
x(R32_SINT, 4, 1) \
\
x(R16G16B16A16_SINT, 8, 1) \
x(R16G16_SINT, 4, 1) \
x(R16_SINT, 2, 1) \
\
x(R8G8B8A8_SINT, 4, 1) \
x(R8G8_SINT, 2, 1) \
x(R8_SINT, 1, 1) \
\
x(R16G16B16A16_UNORM, 8, 1) \
x(R16G16_UNORM, 4, 1) \
x(R16_UNORM, 2, 1) \
\
x(R8G8B8A8_UNORM, 4, 1) \
x(R8G8B8A8_UNORM_SRGB, 4, 1) \
x(R8G8_UNORM, 2, 1) \
x(R8_UNORM, 1, 1) \
x(B8G8R8A8_UNORM, 4, 1) \
x(B8G8R8A8_UNORM_SRGB, 4, 1) \
x(B8G8R8X8_UNORM, 4, 1) \
x(B8G8R8X8_UNORM_SRGB, 4, 1) \
\
x(R16G16B16A16_SNORM, 8, 1) \
x(R16G16_SNORM, 4, 1) \
x(R16_SNORM, 2, 1) \
\
x(R8G8B8A8_SNORM, 4, 1) \
x(R8G8_SNORM, 2, 1) \
x(R8_SNORM, 1, 1) \
\
x(D32_FLOAT, 4, 1) \
x(D16_UNORM, 2, 1) \
x(D32_FLOAT_S8_UINT, 8, 1) \
x(R32_FLOAT_X32_TYPELESS, 8, 1) \
\
x(B4G4R4A4_UNORM, 2, 1) \
x(B5G6R5_UNORM, 2, 1) \
x(B5G5R5A1_UNORM, 2, 1) \
\
x(R9G9B9E5_SHAREDEXP, 4, 1) \
x(R10G10B10A2_TYPELESS, 4, 1) \
x(R10G10B10A2_UNORM, 4, 1) \
x(R10G10B10A2_UINT, 4, 1) \
x(R11G11B10_FLOAT, 4, 1) \
\
x(BC1_UNORM, 8, 16) \
x(BC1_UNORM_SRGB, 8, 16) \
x(BC2_UNORM, 16, 16) \
x(BC2_UNORM_SRGB, 16, 16) \
x(BC3_UNORM, 16, 16) \
x(BC3_UNORM_SRGB, 16, 16) \
x(BC4_UNORM, 8, 16) \
x(BC4_SNORM, 8, 16) \
x(BC5_UNORM, 16, 16) \
x(BC5_SNORM, 16, 16) \
x(BC6H_UF16, 16, 16) \
x(BC6H_SF16, 16, 16) \
x(BC7_UNORM, 16, 16) \
x(BC7_UNORM_SRGB, 16, 16) \
\
x(R64_UINT, 8, 1) \
\
x(R64_SINT, 8, 1)

// clang-format on

// TODO: This should be generated from above
Expand Down Expand Up @@ -375,7 +264,6 @@ enum class Format
BC7_UNORM_SRGB,

R64_UINT,

R64_SINT,

_Count,
Expand Down
239 changes: 107 additions & 132 deletions src/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,27 +36,6 @@ bool isRhiDebugLayerEnabled()

/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Global Renderer Functions !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */

#define SLANG_RHI_FORMAT_SIZE(name, blockSizeInBytes, pixelsPerBlock) {blockSizeInBytes, pixelsPerBlock},

static const uint32_t s_formatSizeInfo[][2] = {SLANG_RHI_FORMAT(SLANG_RHI_FORMAT_SIZE)};

static bool _checkFormat()
{
Index value = 0;
Index count = 0;

// Check the values are in the same order
#define SLANG_RHI_FORMAT_CHECK(name, blockSizeInBytes, pixelsPerblock) count += Index(Index(Format::name) == value++);
SLANG_RHI_FORMAT(SLANG_RHI_FORMAT_CHECK)

const bool r = (count == Index(Format::_Count));
SLANG_RHI_ASSERT(r);
return r;
}

// We don't make static because we will get a warning that it's unused
static const bool _checkFormatResult = _checkFormat();

struct FormatInfoMap
{
FormatInfoMap()
Expand All @@ -68,116 +47,118 @@ struct FormatInfoMap
info.channelType = SLANG_SCALAR_TYPE_NONE;
}

set(Format::R32G32B32A32_TYPELESS, "R32G32B32A32_TYPELESS", SLANG_SCALAR_TYPE_UINT32, 4);
set(Format::R32G32B32_TYPELESS, "R32G32B32_TYPELESS", SLANG_SCALAR_TYPE_UINT32, 3);
set(Format::R32G32_TYPELESS, "R32G32_TYPELESS", SLANG_SCALAR_TYPE_UINT32, 2);
set(Format::R32_TYPELESS, "R32_TYPELESS", SLANG_SCALAR_TYPE_UINT32, 1);

set(Format::R16G16B16A16_TYPELESS, "R16G16B16A16_TYPELESS", SLANG_SCALAR_TYPE_UINT16, 4);
set(Format::R16G16_TYPELESS, "R16G16_TYPELESS", SLANG_SCALAR_TYPE_UINT16, 2);
set(Format::R16_TYPELESS, "R16_TYPELESS", SLANG_SCALAR_TYPE_UINT16, 1);

set(Format::R8G8B8A8_TYPELESS, "R8G8B8A8_TYPELESS", SLANG_SCALAR_TYPE_UINT8, 4);
set(Format::R8G8_TYPELESS, "R8G8_TYPELESS", SLANG_SCALAR_TYPE_UINT8, 2);
set(Format::R8_TYPELESS, "R8_TYPELESS", SLANG_SCALAR_TYPE_UINT8, 1);
set(Format::B8G8R8A8_TYPELESS, "B8G8R8A8_TYPELESS", SLANG_SCALAR_TYPE_UINT8, 4);

set(Format::R32G32B32A32_FLOAT, "R32G32B32A32_FLOAT", SLANG_SCALAR_TYPE_FLOAT32, 4);
set(Format::R32G32B32_FLOAT, "R32G32B32_FLOAT", SLANG_SCALAR_TYPE_FLOAT32, 3);
set(Format::R32G32_FLOAT, "R32G32_FLOAT", SLANG_SCALAR_TYPE_FLOAT32, 2);
set(Format::R32_FLOAT, "R32_FLOAT", SLANG_SCALAR_TYPE_FLOAT32, 1);

set(Format::R16G16B16A16_FLOAT, "R16G16B16A16_FLOAT", SLANG_SCALAR_TYPE_FLOAT16, 4);
set(Format::R16G16_FLOAT, "R16G16_FLOAT", SLANG_SCALAR_TYPE_FLOAT16, 2);
set(Format::R16_FLOAT, "R16_FLOAT", SLANG_SCALAR_TYPE_FLOAT16, 1);

set(Format::R64_UINT, "R64_UINT", SLANG_SCALAR_TYPE_UINT64, 1);

set(Format::R32G32B32A32_UINT, "R32G32B32A32_UINT", SLANG_SCALAR_TYPE_UINT32, 4);
set(Format::R32G32B32_UINT, "R32G32B32_UINT", SLANG_SCALAR_TYPE_UINT32, 3);
set(Format::R32G32_UINT, "R32G32_UINT", SLANG_SCALAR_TYPE_UINT32, 2);
set(Format::R32_UINT, "R32_UINT", SLANG_SCALAR_TYPE_UINT32, 1);

set(Format::R16G16B16A16_UINT, "R16G16B16A16_UINT", SLANG_SCALAR_TYPE_UINT16, 4);
set(Format::R16G16_UINT, "R16G16_UINT", SLANG_SCALAR_TYPE_UINT16, 2);
set(Format::R16_UINT, "R16_UINT", SLANG_SCALAR_TYPE_UINT16, 1);

set(Format::R8G8B8A8_UINT, "R8G8B8A8_UINT", SLANG_SCALAR_TYPE_UINT8, 4);
set(Format::R8G8_UINT, "R8G8_UINT", SLANG_SCALAR_TYPE_UINT8, 2);
set(Format::R8_UINT, "R8_UINT", SLANG_SCALAR_TYPE_UINT8, 1);

set(Format::R64_SINT, "R64_SINT", SLANG_SCALAR_TYPE_INT64, 1);

set(Format::R32G32B32A32_SINT, "R32G32B32A32_SINT", SLANG_SCALAR_TYPE_INT32, 4);
set(Format::R32G32B32_SINT, "R32G32B32_SINT", SLANG_SCALAR_TYPE_INT32, 3);
set(Format::R32G32_SINT, "R32G32_SINT", SLANG_SCALAR_TYPE_INT32, 2);
set(Format::R32_SINT, "R32_SINT", SLANG_SCALAR_TYPE_INT32, 1);

set(Format::R16G16B16A16_SINT, "R16G16B16A16_SINT", SLANG_SCALAR_TYPE_INT16, 4);
set(Format::R16G16_SINT, "R16G16_SINT", SLANG_SCALAR_TYPE_INT16, 2);
set(Format::R16_SINT, "R16_SINT", SLANG_SCALAR_TYPE_INT16, 1);

set(Format::R8G8B8A8_SINT, "R8G8B8A8_SINT", SLANG_SCALAR_TYPE_INT8, 4);
set(Format::R8G8_SINT, "R8G8_SINT", SLANG_SCALAR_TYPE_INT8, 2);
set(Format::R8_SINT, "R8_SINT", SLANG_SCALAR_TYPE_INT8, 1);

set(Format::R16G16B16A16_UNORM, "R16G16B16A16_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4);
set(Format::R16G16_UNORM, "R16G16_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 2);
set(Format::R16_UNORM, "R16_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 1);

set(Format::R8G8B8A8_UNORM, "R8G8B8A8_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4);
set(Format::R8G8B8A8_UNORM_SRGB, "R8G8B8A8_UNORM_SRGB", SLANG_SCALAR_TYPE_FLOAT32, 4);
set(Format::R8G8_UNORM, "R8G8_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 2);
set(Format::R8_UNORM, "R8_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 1);
set(Format::B8G8R8A8_UNORM, "B8G8R8A8_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4);
set(Format::B8G8R8A8_UNORM_SRGB, "B8G8R8A8_UNORM_SRGB", SLANG_SCALAR_TYPE_FLOAT32, 4);
set(Format::B8G8R8X8_UNORM, "B8G8R8X8_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4);
set(Format::B8G8R8X8_UNORM_SRGB, "B8G8R8X8_UNORM_SRGB", SLANG_SCALAR_TYPE_FLOAT32, 4);

set(Format::R16G16B16A16_SNORM, "R16G16B16A16_SNORM", SLANG_SCALAR_TYPE_FLOAT32, 4);
set(Format::R16G16_SNORM, "R16G16_SNORM", SLANG_SCALAR_TYPE_FLOAT32, 2);
set(Format::R16_SNORM, "R16_SNORM", SLANG_SCALAR_TYPE_FLOAT32, 1);

set(Format::R8G8B8A8_SNORM, "R8G8B8A8_SNORM", SLANG_SCALAR_TYPE_FLOAT32, 4);
set(Format::R8G8_SNORM, "R8G8_SNORM", SLANG_SCALAR_TYPE_FLOAT32, 2);
set(Format::R8_SNORM, "R8_SNORM", SLANG_SCALAR_TYPE_FLOAT32, 1);

set(Format::D32_FLOAT, "D32_FLOAT", SLANG_SCALAR_TYPE_FLOAT32, 1);
set(Format::D16_UNORM, "D16_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 1);
set(Format::D32_FLOAT_S8_UINT, "D32_FLOAT_S8_UINT", SLANG_SCALAR_TYPE_FLOAT32, 2);
set(Format::R32_FLOAT_X32_TYPELESS, "R32_FLOAT_X32_TYPELESS", SLANG_SCALAR_TYPE_FLOAT32, 2);

set(Format::B4G4R4A4_UNORM, "B4G4R4A4_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4);
set(Format::B5G6R5_UNORM, "B5G6R5_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 3);
set(Format::B5G5R5A1_UNORM, "B5G5R5A1_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4);

set(Format::R9G9B9E5_SHAREDEXP, "R9G9B9E5_SHAREDEXP", SLANG_SCALAR_TYPE_FLOAT32, 3);
set(Format::R10G10B10A2_TYPELESS, "R10G10B10A2_TYPELESS", SLANG_SCALAR_TYPE_FLOAT32, 4);
set(Format::R10G10B10A2_UNORM, "R10G10B10A2_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4);
set(Format::R10G10B10A2_UINT, "R10G10B10A2_UINT", SLANG_SCALAR_TYPE_UINT32, 4);
set(Format::R11G11B10_FLOAT, "R11G11B10_FLOAT", SLANG_SCALAR_TYPE_FLOAT32, 3);

set(Format::BC1_UNORM, "BC1_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4, 4, 4);
set(Format::BC1_UNORM_SRGB, "BC1_UNORM_SRGB", SLANG_SCALAR_TYPE_FLOAT32, 4, 4, 4);
set(Format::BC2_UNORM, "BC2_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4, 4, 4);
set(Format::BC2_UNORM_SRGB, "BC2_UNORM_SRGB", SLANG_SCALAR_TYPE_FLOAT32, 4, 4, 4);
set(Format::BC3_UNORM, "BC3_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4, 4, 4);
set(Format::BC3_UNORM_SRGB, "BC3_UNORM_SRGB", SLANG_SCALAR_TYPE_FLOAT32, 4, 4, 4);
set(Format::BC4_UNORM, "BC4_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 1, 4, 4);
set(Format::BC4_SNORM, "BC4_SNORM", SLANG_SCALAR_TYPE_FLOAT32, 1, 4, 4);
set(Format::BC5_UNORM, "BC5_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 2, 4, 4);
set(Format::BC5_SNORM, "BC5_SNORM", SLANG_SCALAR_TYPE_FLOAT32, 2, 4, 4);
set(Format::BC6H_UF16, "BC6H_UF16", SLANG_SCALAR_TYPE_FLOAT32, 3, 4, 4);
set(Format::BC6H_SF16, "BC6H_SF16", SLANG_SCALAR_TYPE_FLOAT32, 3, 4, 4);
set(Format::BC7_UNORM, "BC7_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4, 4, 4);
set(Format::BC7_UNORM_SRGB, "BC7_UNORM_SRGB", SLANG_SCALAR_TYPE_FLOAT32, 4, 4, 4);
set(Format::R32G32B32A32_TYPELESS, "R32G32B32A32_TYPELESS", SLANG_SCALAR_TYPE_UINT32, 4, 16);
set(Format::R32G32B32_TYPELESS, "R32G32B32_TYPELESS", SLANG_SCALAR_TYPE_UINT32, 3, 12);
set(Format::R32G32_TYPELESS, "R32G32_TYPELESS", SLANG_SCALAR_TYPE_UINT32, 2, 8);
set(Format::R32_TYPELESS, "R32_TYPELESS", SLANG_SCALAR_TYPE_UINT32, 1, 4);

set(Format::R16G16B16A16_TYPELESS, "R16G16B16A16_TYPELESS", SLANG_SCALAR_TYPE_UINT16, 4, 8);
set(Format::R16G16_TYPELESS, "R16G16_TYPELESS", SLANG_SCALAR_TYPE_UINT16, 2, 4);
set(Format::R16_TYPELESS, "R16_TYPELESS", SLANG_SCALAR_TYPE_UINT16, 1, 2);

set(Format::R8G8B8A8_TYPELESS, "R8G8B8A8_TYPELESS", SLANG_SCALAR_TYPE_UINT8, 4, 4);
set(Format::R8G8_TYPELESS, "R8G8_TYPELESS", SLANG_SCALAR_TYPE_UINT8, 2, 2);
set(Format::R8_TYPELESS, "R8_TYPELESS", SLANG_SCALAR_TYPE_UINT8, 1, 1);
set(Format::B8G8R8A8_TYPELESS, "B8G8R8A8_TYPELESS", SLANG_SCALAR_TYPE_UINT8, 4, 4);

set(Format::R32G32B32A32_FLOAT, "R32G32B32A32_FLOAT", SLANG_SCALAR_TYPE_FLOAT32, 4, 16);
set(Format::R32G32B32_FLOAT, "R32G32B32_FLOAT", SLANG_SCALAR_TYPE_FLOAT32, 3, 12);
set(Format::R32G32_FLOAT, "R32G32_FLOAT", SLANG_SCALAR_TYPE_FLOAT32, 2, 8);
set(Format::R32_FLOAT, "R32_FLOAT", SLANG_SCALAR_TYPE_FLOAT32, 1, 4);

set(Format::R16G16B16A16_FLOAT, "R16G16B16A16_FLOAT", SLANG_SCALAR_TYPE_FLOAT16, 4, 8);
set(Format::R16G16_FLOAT, "R16G16_FLOAT", SLANG_SCALAR_TYPE_FLOAT16, 2, 4);
set(Format::R16_FLOAT, "R16_FLOAT", SLANG_SCALAR_TYPE_FLOAT16, 1, 2);

set(Format::R64_UINT, "R64_UINT", SLANG_SCALAR_TYPE_UINT64, 1, 8);

set(Format::R32G32B32A32_UINT, "R32G32B32A32_UINT", SLANG_SCALAR_TYPE_UINT32, 4, 16);
set(Format::R32G32B32_UINT, "R32G32B32_UINT", SLANG_SCALAR_TYPE_UINT32, 3, 12);
set(Format::R32G32_UINT, "R32G32_UINT", SLANG_SCALAR_TYPE_UINT32, 2, 8);
set(Format::R32_UINT, "R32_UINT", SLANG_SCALAR_TYPE_UINT32, 1, 4);

set(Format::R16G16B16A16_UINT, "R16G16B16A16_UINT", SLANG_SCALAR_TYPE_UINT16, 4, 8);
set(Format::R16G16_UINT, "R16G16_UINT", SLANG_SCALAR_TYPE_UINT16, 2, 4);
set(Format::R16_UINT, "R16_UINT", SLANG_SCALAR_TYPE_UINT16, 1, 2);

set(Format::R8G8B8A8_UINT, "R8G8B8A8_UINT", SLANG_SCALAR_TYPE_UINT8, 4, 4);
set(Format::R8G8_UINT, "R8G8_UINT", SLANG_SCALAR_TYPE_UINT8, 2, 2);
set(Format::R8_UINT, "R8_UINT", SLANG_SCALAR_TYPE_UINT8, 1, 1);

set(Format::R64_SINT, "R64_SINT", SLANG_SCALAR_TYPE_INT64, 1, 8);

set(Format::R32G32B32A32_SINT, "R32G32B32A32_SINT", SLANG_SCALAR_TYPE_INT32, 4, 16);
set(Format::R32G32B32_SINT, "R32G32B32_SINT", SLANG_SCALAR_TYPE_INT32, 3, 12);
set(Format::R32G32_SINT, "R32G32_SINT", SLANG_SCALAR_TYPE_INT32, 2, 8);
set(Format::R32_SINT, "R32_SINT", SLANG_SCALAR_TYPE_INT32, 1, 4);

set(Format::R16G16B16A16_SINT, "R16G16B16A16_SINT", SLANG_SCALAR_TYPE_INT16, 4, 8);
set(Format::R16G16_SINT, "R16G16_SINT", SLANG_SCALAR_TYPE_INT16, 2, 4);
set(Format::R16_SINT, "R16_SINT", SLANG_SCALAR_TYPE_INT16, 1, 2);

set(Format::R8G8B8A8_SINT, "R8G8B8A8_SINT", SLANG_SCALAR_TYPE_INT8, 4, 4);
set(Format::R8G8_SINT, "R8G8_SINT", SLANG_SCALAR_TYPE_INT8, 2, 2);
set(Format::R8_SINT, "R8_SINT", SLANG_SCALAR_TYPE_INT8, 1, 1);

set(Format::R16G16B16A16_UNORM, "R16G16B16A16_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4, 8);
set(Format::R16G16_UNORM, "R16G16_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 2, 4);
set(Format::R16_UNORM, "R16_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 1, 2);

set(Format::R8G8B8A8_UNORM, "R8G8B8A8_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4, 4);
set(Format::R8G8B8A8_UNORM_SRGB, "R8G8B8A8_UNORM_SRGB", SLANG_SCALAR_TYPE_FLOAT32, 4, 4);
set(Format::R8G8_UNORM, "R8G8_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 2, 2);
set(Format::R8_UNORM, "R8_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 1, 1);
set(Format::B8G8R8A8_UNORM, "B8G8R8A8_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4, 4);
set(Format::B8G8R8A8_UNORM_SRGB, "B8G8R8A8_UNORM_SRGB", SLANG_SCALAR_TYPE_FLOAT32, 4, 4);
set(Format::B8G8R8X8_UNORM, "B8G8R8X8_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4, 4);
set(Format::B8G8R8X8_UNORM_SRGB, "B8G8R8X8_UNORM_SRGB", SLANG_SCALAR_TYPE_FLOAT32, 4, 4);

set(Format::R16G16B16A16_SNORM, "R16G16B16A16_SNORM", SLANG_SCALAR_TYPE_FLOAT32, 4, 8);
set(Format::R16G16_SNORM, "R16G16_SNORM", SLANG_SCALAR_TYPE_FLOAT32, 2, 4);
set(Format::R16_SNORM, "R16_SNORM", SLANG_SCALAR_TYPE_FLOAT32, 1, 2);

set(Format::R8G8B8A8_SNORM, "R8G8B8A8_SNORM", SLANG_SCALAR_TYPE_FLOAT32, 4, 4);
set(Format::R8G8_SNORM, "R8G8_SNORM", SLANG_SCALAR_TYPE_FLOAT32, 2, 2);
set(Format::R8_SNORM, "R8_SNORM", SLANG_SCALAR_TYPE_FLOAT32, 1, 1);

set(Format::D32_FLOAT, "D32_FLOAT", SLANG_SCALAR_TYPE_FLOAT32, 1, 4);
set(Format::D16_UNORM, "D16_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 1, 2);
set(Format::D32_FLOAT_S8_UINT, "D32_FLOAT_S8_UINT", SLANG_SCALAR_TYPE_FLOAT32, 2, 8);
set(Format::R32_FLOAT_X32_TYPELESS, "R32_FLOAT_X32_TYPELESS", SLANG_SCALAR_TYPE_FLOAT32, 2, 8);

set(Format::B4G4R4A4_UNORM, "B4G4R4A4_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4, 2);
set(Format::B5G6R5_UNORM, "B5G6R5_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 3, 2);
set(Format::B5G5R5A1_UNORM, "B5G5R5A1_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4, 2);

set(Format::R9G9B9E5_SHAREDEXP, "R9G9B9E5_SHAREDEXP", SLANG_SCALAR_TYPE_FLOAT32, 3, 4);
set(Format::R10G10B10A2_TYPELESS, "R10G10B10A2_TYPELESS", SLANG_SCALAR_TYPE_FLOAT32, 4, 4);
set(Format::R10G10B10A2_UNORM, "R10G10B10A2_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4, 4);
set(Format::R10G10B10A2_UINT, "R10G10B10A2_UINT", SLANG_SCALAR_TYPE_UINT32, 4, 4);
set(Format::R11G11B10_FLOAT, "R11G11B10_FLOAT", SLANG_SCALAR_TYPE_FLOAT32, 3, 4);

set(Format::BC1_UNORM, "BC1_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4, 8, 16, 4, 4);
set(Format::BC1_UNORM_SRGB, "BC1_UNORM_SRGB", SLANG_SCALAR_TYPE_FLOAT32, 4, 8, 16, 4, 4);
set(Format::BC2_UNORM, "BC2_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4, 16, 16, 4, 4);
set(Format::BC2_UNORM_SRGB, "BC2_UNORM_SRGB", SLANG_SCALAR_TYPE_FLOAT32, 4, 16, 16, 4, 4);
set(Format::BC3_UNORM, "BC3_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4, 16, 16, 4, 4);
set(Format::BC3_UNORM_SRGB, "BC3_UNORM_SRGB", SLANG_SCALAR_TYPE_FLOAT32, 4, 16, 16, 4, 4);
set(Format::BC4_UNORM, "BC4_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 1, 8, 16, 4, 4);
set(Format::BC4_SNORM, "BC4_SNORM", SLANG_SCALAR_TYPE_FLOAT32, 1, 8, 16, 4, 4);
set(Format::BC5_UNORM, "BC5_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 2, 16, 16, 4, 4);
set(Format::BC5_SNORM, "BC5_SNORM", SLANG_SCALAR_TYPE_FLOAT32, 2, 16, 16, 4, 4);
set(Format::BC6H_UF16, "BC6H_UF16", SLANG_SCALAR_TYPE_FLOAT32, 3, 16, 16, 4, 4);
set(Format::BC6H_SF16, "BC6H_SF16", SLANG_SCALAR_TYPE_FLOAT32, 3, 16, 16, 4, 4);
set(Format::BC7_UNORM, "BC7_UNORM", SLANG_SCALAR_TYPE_FLOAT32, 4, 16, 16, 4, 4);
set(Format::BC7_UNORM_SRGB, "BC7_UNORM_SRGB", SLANG_SCALAR_TYPE_FLOAT32, 4, 16, 16, 4, 4);
}

void set(
Format format,
const char* name,
SlangScalarType type,
Index channelCount,
uint32_t blockSizeInBytes,
uint32_t pixelsPerBlock = 1,
uint32_t blockWidth = 1,
uint32_t blockHeight = 1
)
Expand All @@ -187,9 +168,8 @@ struct FormatInfoMap
info.channelCount = uint8_t(channelCount);
info.channelType = uint8_t(type);

auto sizeInfo = s_formatSizeInfo[Index(format)];
info.blockSizeInBytes = sizeInfo[0];
info.pixelsPerBlock = sizeInfo[1];
info.blockSizeInBytes = blockSizeInBytes;
info.pixelsPerBlock = pixelsPerBlock;
info.blockWidth = blockWidth;
info.blockHeight = blockHeight;
}
Expand All @@ -201,11 +181,6 @@ struct FormatInfoMap

static const FormatInfoMap s_formatInfoMap;

static void _compileTimeAsserts()
{
static_assert(SLANG_COUNT_OF(s_formatSizeInfo) == int(Format::_Count));
}

extern "C"
{
SLANG_RHI_API bool SLANG_MCALL rhiIsCompressedFormat(Format format)
Expand Down