Skip to content

Commit 5a5b608

Browse files
make EFormat slightly more legible
1 parent 0df5c4e commit 5a5b608

8 files changed

+1673
-2038
lines changed

include/nbl/asset/format/EFormat.h

Lines changed: 882 additions & 2038 deletions
Large diffs are not rendered by default.
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
using inline_array = std::array<uint8_t,4u>;
2+
switch (_fmt)
3+
{
4+
case EF_R4G4_UNORM_PACK8: [[fallthrough]];
5+
case EF_R4G4B4A4_UNORM_PACK16: [[fallthrough]];
6+
case EF_B4G4R4A4_UNORM_PACK16:
7+
return 4u;
8+
break;
9+
10+
case EF_S8_UINT: [[fallthrough]];
11+
case EF_R8_UNORM: [[fallthrough]];
12+
case EF_R8_SNORM: [[fallthrough]];
13+
case EF_R8_USCALED: [[fallthrough]];
14+
case EF_R8_SSCALED: [[fallthrough]];
15+
case EF_R8_UINT: [[fallthrough]];
16+
case EF_R8_SINT: [[fallthrough]];
17+
case EF_R8_SRGB: [[fallthrough]];
18+
case EF_R8G8_UNORM: [[fallthrough]];
19+
case EF_R8G8_SNORM: [[fallthrough]];
20+
case EF_R8G8_USCALED: [[fallthrough]];
21+
case EF_R8G8_SSCALED: [[fallthrough]];
22+
case EF_R8G8_UINT: [[fallthrough]];
23+
case EF_R8G8_SINT: [[fallthrough]];
24+
case EF_R8G8_SRGB: [[fallthrough]];
25+
case EF_R8G8B8_UNORM: [[fallthrough]];
26+
case EF_R8G8B8_SNORM: [[fallthrough]];
27+
case EF_R8G8B8_USCALED: [[fallthrough]];
28+
case EF_R8G8B8_SSCALED: [[fallthrough]];
29+
case EF_R8G8B8_UINT: [[fallthrough]];
30+
case EF_R8G8B8_SINT: [[fallthrough]];
31+
case EF_R8G8B8_SRGB: [[fallthrough]];
32+
case EF_B8G8R8_UNORM: [[fallthrough]];
33+
case EF_B8G8R8_SNORM: [[fallthrough]];
34+
case EF_B8G8R8_USCALED: [[fallthrough]];
35+
case EF_B8G8R8_SSCALED: [[fallthrough]];
36+
case EF_B8G8R8_UINT: [[fallthrough]];
37+
case EF_B8G8R8_SINT: [[fallthrough]];
38+
case EF_B8G8R8_SRGB: [[fallthrough]];
39+
case EF_R8G8B8A8_UNORM: [[fallthrough]];
40+
case EF_R8G8B8A8_SNORM: [[fallthrough]];
41+
case EF_R8G8B8A8_USCALED: [[fallthrough]];
42+
case EF_R8G8B8A8_SSCALED: [[fallthrough]];
43+
case EF_R8G8B8A8_UINT: [[fallthrough]];
44+
case EF_R8G8B8A8_SINT: [[fallthrough]];
45+
case EF_R8G8B8A8_SRGB: [[fallthrough]];
46+
case EF_B8G8R8A8_UNORM: [[fallthrough]];
47+
case EF_B8G8R8A8_SNORM: [[fallthrough]];
48+
case EF_B8G8R8A8_USCALED: [[fallthrough]];
49+
case EF_B8G8R8A8_SSCALED: [[fallthrough]];
50+
case EF_B8G8R8A8_UINT: [[fallthrough]];
51+
case EF_B8G8R8A8_SINT: [[fallthrough]];
52+
case EF_B8G8R8A8_SRGB: [[fallthrough]];
53+
case EF_A8B8G8R8_UNORM_PACK32: [[fallthrough]];
54+
case EF_A8B8G8R8_SNORM_PACK32: [[fallthrough]];
55+
case EF_A8B8G8R8_USCALED_PACK32: [[fallthrough]];
56+
case EF_A8B8G8R8_SSCALED_PACK32: [[fallthrough]];
57+
case EF_A8B8G8R8_UINT_PACK32: [[fallthrough]];
58+
case EF_A8B8G8R8_SINT_PACK32: [[fallthrough]];
59+
case EF_A8B8G8R8_SRGB_PACK32:
60+
return 8u;
61+
break;
62+
63+
case EF_D16_UNORM: [[fallthrough]];
64+
case EF_R16_UNORM: [[fallthrough]];
65+
case EF_R16_SNORM: [[fallthrough]];
66+
case EF_R16_USCALED: [[fallthrough]];
67+
case EF_R16_SSCALED: [[fallthrough]];
68+
case EF_R16_UINT: [[fallthrough]];
69+
case EF_R16_SINT: [[fallthrough]];
70+
case EF_R16_SFLOAT: [[fallthrough]];
71+
case EF_R16G16_UNORM: [[fallthrough]];
72+
case EF_R16G16_SNORM: [[fallthrough]];
73+
case EF_R16G16_USCALED: [[fallthrough]];
74+
case EF_R16G16_SSCALED: [[fallthrough]];
75+
case EF_R16G16_UINT: [[fallthrough]];
76+
case EF_R16G16_SINT: [[fallthrough]];
77+
case EF_R16G16_SFLOAT: [[fallthrough]];
78+
case EF_R16G16_UNORM: [[fallthrough]];
79+
case EF_R16G16_SNORM: [[fallthrough]];
80+
case EF_R16G16_USCALED: [[fallthrough]];
81+
case EF_R16G16_SSCALED: [[fallthrough]];
82+
case EF_R16G16_UINT: [[fallthrough]];
83+
case EF_R16G16_SINT: [[fallthrough]];
84+
case EF_R16G16_SFLOAT: [[fallthrough]];
85+
case EF_R16G16B16_UNORM: [[fallthrough]];
86+
case EF_R16G16B16_SNORM: [[fallthrough]];
87+
case EF_R16G16B16_USCALED: [[fallthrough]];
88+
case EF_R16G16B16_SSCALED: [[fallthrough]];
89+
case EF_R16G16B16_UINT: [[fallthrough]];
90+
case EF_R16G16B16_SINT: [[fallthrough]];
91+
case EF_R16G16B16_SFLOAT: [[fallthrough]];
92+
case EF_R16G16B16A16_UNORM: [[fallthrough]];
93+
case EF_R16G16B16A16_SNORM: [[fallthrough]];
94+
case EF_R16G16B16A16_USCALED: [[fallthrough]];
95+
case EF_R16G16B16A16_SSCALED: [[fallthrough]];
96+
case EF_R16G16B16A16_UINT: [[fallthrough]];
97+
case EF_R16G16B16A16_SINT: [[fallthrough]];
98+
case EF_R16G16B16A16_SFLOAT:
99+
return 16u;
100+
break;
101+
102+
case EF_D32_SFLOAT: [[fallthrough]];
103+
case EF_R32_UINT: [[fallthrough]];
104+
case EF_R32_SINT: [[fallthrough]];
105+
case EF_R32_SFLOAT: [[fallthrough]];
106+
case EF_R32G32_UINT: [[fallthrough]];
107+
case EF_R32G32_SINT: [[fallthrough]];
108+
case EF_R32G32_SFLOAT: [[fallthrough]];
109+
case EF_R32G32_UINT: [[fallthrough]];
110+
case EF_R32G32_SINT: [[fallthrough]];
111+
case EF_R32G32_SFLOAT: [[fallthrough]];
112+
case EF_R32G32B32_UINT: [[fallthrough]];
113+
case EF_R32G32B32_SINT: [[fallthrough]];
114+
case EF_R32G32B32_SFLOAT: [[fallthrough]];
115+
case EF_R32G32B32A32_UINT: [[fallthrough]];
116+
case EF_R32G32B32A32_SINT: [[fallthrough]];
117+
case EF_R32G32B32A32_SFLOAT:
118+
return 32u;
119+
break;
120+
121+
case EF_R64_UINT: [[fallthrough]];
122+
case EF_R64_SINT: [[fallthrough]];
123+
case EF_R64_SFLOAT: [[fallthrough]];
124+
case EF_R64G64_UINT: [[fallthrough]];
125+
case EF_R64G64_SINT: [[fallthrough]];
126+
case EF_R64G64_SFLOAT: [[fallthrough]];
127+
case EF_R64G64_UINT: [[fallthrough]];
128+
case EF_R64G64_SINT: [[fallthrough]];
129+
case EF_R64G64_SFLOAT: [[fallthrough]];
130+
case EF_R64G64B64_UINT: [[fallthrough]];
131+
case EF_R64G64B64_SINT: [[fallthrough]];
132+
case EF_R64G64B64_SFLOAT: [[fallthrough]];
133+
case EF_R64G64B64A64_UINT: [[fallthrough]];
134+
case EF_R64G64B64A64_SINT: [[fallthrough]];
135+
case EF_R64G64B64A64_SFLOAT:
136+
return 64u;
137+
break;
138+
139+
case EF_X8_D24_UNORM_PACK32:
140+
return inline_array{24,0}[_channel];
141+
break;
142+
143+
case EF_D16_UNORM_S8_UINT:
144+
return inline_array{16,8}[_channel];
145+
break;
146+
147+
case EF_D24_UNORM_S8_UINT:
148+
return inline_array{24,8}[_channel];
149+
break;
150+
151+
case EF_D32_SFLOAT_S8_UINT:
152+
return inline_array{32,8}[_channel];
153+
break;
154+
155+
case EF_R5G6B5_UNORM_PACK16:
156+
case EF_B5G6R5_UNORM_PACK16:
157+
return inline_array{5,6,5}[_channel];
158+
break;
159+
160+
case EF_R5G5B5A1_UNORM_PACK16: [[fallthrough]];
161+
case EF_B5G5R5A1_UNORM_PACK16: [[fallthrough]];
162+
case EF_A1R5G5B5_UNORM_PACK16:
163+
return inline_array{5,6,5,1}[_channel];
164+
break;
165+
166+
case EF_A2R10G10B10_UNORM_PACK32: [[fallthrough]];
167+
case EF_A2R10G10B10_SNORM_PACK32: [[fallthrough]];
168+
case EF_A2R10G10B10_USCALED_PACK32: [[fallthrough]];
169+
case EF_A2R10G10B10_SSCALED_PACK32: [[fallthrough]];
170+
case EF_A2R10G10B10_UINT_PACK32: [[fallthrough]];
171+
case EF_A2R10G10B10_SINT_PACK32: [[fallthrough]];
172+
case EF_A2B10G10R10_UNORM_PACK32: [[fallthrough]];
173+
case EF_A2B10G10R10_SNORM_PACK32: [[fallthrough]];
174+
case EF_A2B10G10R10_USCALED_PACK32: [[fallthrough]];
175+
case EF_A2B10G10R10_SSCALED_PACK32: [[fallthrough]];
176+
case EF_A2B10G10R10_UINT_PACK32: [[fallthrough]];
177+
case EF_A2B10G10R10_SINT_PACK32:
178+
return inline_array{10,10,10,2}[_channel];
179+
break;
180+
181+
case EF_B10G11R11_UFLOAT_PACK32:
182+
return inline_array{10,11,11}[_channel];
183+
break;
184+
case EF_E5B9G9R9_UFLOAT_PACK32:
185+
return 14u;
186+
break;
187+
188+
// TODO: impl block compressed formats
189+
190+
default:
191+
break;
192+
}
193+
return 0u;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
switch (_fclass)
2+
{
3+
case EFC_8_BIT: [[fallthrough]];
4+
case EFC_16_BIT: [[fallthrough]];
5+
case EFC_24_BIT: [[fallthrough]];
6+
case EFC_32_BIT: [[fallthrough]];
7+
case EFC_48_BIT: [[fallthrough]];
8+
case EFC_64_BIT: [[fallthrough]];
9+
case EFC_96_BIT: [[fallthrough]];
10+
case EFC_128_BIT: [[fallthrough]];
11+
case EFC_192_BIT: [[fallthrough]];
12+
case EFC_256_BIT:
13+
return core::vector3du32_SIMD(1u,1u,1u);
14+
default:
15+
_NBL_DEBUG_BREAK_IF(true);
16+
return core::vector3du32_SIMD(0u);
17+
}

0 commit comments

Comments
 (0)