28#define DECLARE(a, b, c, blender_enum, d, e, f, g, h) blender_enum = int(DataFormat::blender_enum),
30#define GPU_VERTEX_FORMAT_EXPAND(impl) \
31 SNORM_8_8_8_8_(impl) \
34 SNORM_16_16_16_16_(impl) \
36 UNORM_8_8_8_8_(impl) \
39 UNORM_16_16_16_16_(impl) \
44 SINT_16_16_16_16_(impl) \
48 SINT_32_32_32_(impl) \
49 SINT_32_32_32_32_(impl) \
54 UINT_16_16_16_16_(impl) \
58 UINT_32_32_32_(impl) \
59 UINT_32_32_32_32_(impl) \
62 SFLOAT_16_16_16_16_(impl) \
66 SFLOAT_32_32_32_(impl) \
67 SFLOAT_32_32_32_32_(impl) \
69 SNORM_10_10_10_2_(impl) \
70 UNORM_10_10_10_2_(impl) \
78#define DECLARE(a, b, c, blender_enum, d, e, f, g, h) \
79 blender_enum##_DEPRECATED = int(DataFormat::blender_enum),
82#define GPU_VERTEX_DEPRECATED_FORMAT_EXPAND(impl) \
87 SNORM_16_16_16_(impl) \
92 UNORM_16_16_16_(impl) \
97 SINT_16_16_16_(impl) \
110#define GPU_VERTEX_FORMAT_EXPAND_TYPED(impl) \
111 SINT_8_8_8_8_(impl) \
114 SINT_16_16_16_16_(impl) \
118 SINT_32_32_32_(impl) \
119 SINT_32_32_32_32_(impl) \
121 UINT_8_8_8_8_(impl) \
124 UINT_16_16_16_16_(impl) \
128 UINT_32_32_32_(impl) \
129 UINT_32_32_32_32_(impl) \
132 SFLOAT_32_32_(impl) \
133 SFLOAT_32_32_32_(impl) \
134 SFLOAT_32_32_32_32_(impl) \
143#define ATTR_TYPE_MAPPING(_type, b, c, blender_enum, d, e, f, g, h) \
144 template<> struct AttrType<_type> { \
145 static constexpr VertAttrType type = VertAttrType::blender_enum; \
150#undef ATTR_TYPE_MAPPING
217 "We use uchar as index inside the name buffer "
218 "so GPU_VERT_ATTR_NAMES_BUF_LEN needs to be "
219 "smaller than GPUVertFormat->name_offset and "
220 "GPUVertAttr->names maximum value");
243#define GPU_VERTEX_FORMAT_ADD_ATTR(attr) \
244 format.attribute_add(#attr, gpu::AttrType<decltype(attr)>::type, offsetof(VertT, attr)); \
245 BLI_STATIC_ASSERT(offsetof(VertT, attr) < 255, #attr " has offset greater than 255") \
246 BLI_STATIC_ASSERT(offsetof(VertT, attr) % 4 == 0, #attr " is not aligned to 4 bytes")
248#define _ATTR_EXPAND1(a) GPU_VERTEX_FORMAT_ADD_ATTR(a)
249#define _ATTR_EXPAND2(a, b) \
251 GPU_VERTEX_FORMAT_ADD_ATTR(b)
252#define _ATTR_EXPAND3(a, b, c) \
253 _ATTR_EXPAND2(a, b) \
254 GPU_VERTEX_FORMAT_ADD_ATTR(c)
255#define _ATTR_EXPAND4(a, b, c, d) \
256 _ATTR_EXPAND3(a, b, c) \
257 GPU_VERTEX_FORMAT_ADD_ATTR(d)
258#define _ATTR_EXPAND5(a, b, c, d, e) \
259 _ATTR_EXPAND4(a, b, c, d) \
260 GPU_VERTEX_FORMAT_ADD_ATTR(e)
261#define _ATTR_EXPAND6(a, b, c, d, e, f) \
262 _ATTR_EXPAND5(a, b, c, d, e) \
263 GPU_VERTEX_FORMAT_ADD_ATTR(f)
264#define _ATTR_EXPAND7(a, b, c, d, e, f, g) \
265 _ATTR_EXPAND6(a, b, c, d, e, f) \
266 GPU_VERTEX_FORMAT_ADD_ATTR(g)
267#define _ATTR_EXPAND8(a, b, c, d, e, f, g, h) \
268 _ATTR_EXPAND7(a, b, c, d, e, f, g) \
269 GPU_VERTEX_FORMAT_ADD_ATTR(h)
270#define _ATTR_EXPAND9(a, b, c, d, e, f, g, h, i) \
271 _ATTR_EXPAND8(a, b, c, d, e, f, g, h) \
272 GPU_VERTEX_FORMAT_ADD_ATTR(i)
273#define _ATTR_EXPAND10(a, b, c, d, e, f, g, h, i, j) \
274 _ATTR_EXPAND9(a, b, c, d, e, f, g, h, i) \
275 GPU_VERTEX_FORMAT_ADD_ATTR(j)
276#define _ATTR_EXPAND11(a, b, c, d, e, f, g, h, i, j, k) \
277 _ATTR_EXPAND10(a, b, c, d, e, f, g, h, i, j) \
278 GPU_VERTEX_FORMAT_ADD_ATTR(k)
279#define _ATTR_EXPAND12(a, b, c, d, e, f, g, h, i, j, k, l) \
280 _ATTR_EXPAND11(a, b, c, d, e, f, g, h, i, j, k) \
281 GPU_VERTEX_FORMAT_ADD_ATTR(l)
282#define _ATTR_EXPAND13(a, b, c, d, e, f, g, h, i, j, k, l, m) \
283 _ATTR_EXPAND12(a, b, c, d, e, f, g, h, i, j, k, l) \
284 GPU_VERTEX_FORMAT_ADD_ATTR(m)
285#define _ATTR_EXPAND14(a, b, c, d, e, f, g, h, i, j, k, l, m, n) \
286 _ATTR_EXPAND13(a, b, c, d, e, f, g, h, i, j, k, l, m) \
287 GPU_VERTEX_FORMAT_ADD_ATTR(n)
288#define _ATTR_EXPAND15(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) \
289 _ATTR_EXPAND14(a, b, c, d, e, f, g, h, i, j, k, l, m, n) \
290 GPU_VERTEX_FORMAT_ADD_ATTR(o)
291#define _ATTR_EXPAND16(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p) \
292 _ATTR_EXPAND15(a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) \
293 GPU_VERTEX_FORMAT_ADD_ATTR(p)
296#define GPU_VERTEX_FORMAT_ADD_ATTR_EXPAND(...) VA_NARGS_CALL_OVERLOAD(_ATTR_EXPAND, __VA_ARGS__)
298#define GPU_VERTEX_FORMAT_FUNC(_VertT, ...) \
299 static GPUVertFormat &format() \
301 using VertT = _VertT; \
302 static GPUVertFormat format = {}; \
303 if (format.attr_len == 0) { \
304 GPU_VERTEX_FORMAT_ADD_ATTR_EXPAND(__VA_ARGS__) \
305 format.stride = sizeof(VertT); \
306 BLI_STATIC_ASSERT(sizeof(VertT) < 1024, "Vertex format is too big") \
307 format.packed = true; \
308 BLI_STATIC_ASSERT_ALIGN(VertT, 4) \
400 return format->names + attr->
names[n_idx];
int format_component_len(const DataFormat format)
int to_bytesize(const DataFormat format)
constexpr DataFormat to_data_format(TextureFormat format)
BLI_STATIC_ASSERT(ARRAY_SIZE(data_mode_strings)==CTX_MODE_NUM+1, "Must have a string for each context mode") const char *CTX_data_mode_string(const bContext *C)
void GPU_vertformat_alias_add(GPUVertFormat *, StringRef alias)
int GPU_vertformat_attr_id_get(const GPUVertFormat *, StringRef name)
static constexpr int GPU_MAX_SAFE_ATTR_NAME
static constexpr int GPU_VERT_FORMAT_MAX_NAMES
void GPU_vertformat_from_shader(GPUVertFormat *format, const gpu::Shader *shader)
BLI_INLINE const char * GPU_vertformat_attr_name_get(const GPUVertFormat *format, const GPUVertAttr *attr, uint n_idx)
void GPU_vertformat_deinterleave(GPUVertFormat *format)
GPUVertFormat GPU_vertformat_from_attribute(StringRef name, gpu::VertAttrType type)
static constexpr int GPU_VERT_ATTR_NAMES_BUF_LEN
@ GPU_FETCH_INT_TO_FLOAT_UNIT
void GPU_vertformat_safe_attr_name(StringRef attr_name, char *r_safe_name, uint max_len)
static constexpr int GPU_VERT_ATTR_MAX_NAMES
uint GPU_vertformat_attr_add_legacy(GPUVertFormat *, StringRef name, GPUVertCompType, uint comp_len, GPUVertFetchMode)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
void GPU_vertformat_copy(GPUVertFormat *dest, const GPUVertFormat &src)
void GPU_vertformat_clear(GPUVertFormat *)
static constexpr int GPU_VERT_ATTR_MAX_LEN
void GPU_vertformat_multiload_enable(GPUVertFormat *format, int load_count)
void GPU_vertformat_attr_rename(GPUVertFormat *format, int attr, const char *new_name)
GPUVertFetchMode fetch_mode() const
GPUVertCompType comp_type() const
struct blender::GPUVertAttr::Type type
uchar names[GPU_VERT_ATTR_MAX_NAMES]