8#include "dawn/common/objectid.hxx"
9#include "dawn/debug.hxx"
10#include "dawn/porting/config.hxx"
11#include "dawn/porting/fixedmath.hxx"
45 constexpr static size_t ID_MAX = 0b11111;
46 constexpr static size_t ID_SHIFT = 0;
47 constexpr static size_t _SIZE_MAX = 0b1111111111;
48 constexpr static size_t SIZE_SHIFT = 5;
49 constexpr static size_t RW_MAX = 0b1;
50 constexpr static size_t RW_SHIFT = 15;
51 constexpr static size_t DTYPE_MAX = 0b1111;
52 constexpr static size_t DTYPE_SHIFT = 16;
53 constexpr static size_t CLS_MAX = 0b111111111;
54 constexpr static size_t CLS_SHIFT = 21;
55 constexpr static size_t TYPE_MAX = 0b11;
56 constexpr static size_t TYPE_SHIFT = 30;
146 }
typedef UObjectCfgId;
215 DEBUGASSERT(type <= TYPE_MAX);
216 DEBUGASSERT(cls <= CLS_MAX);
217 DEBUGASSERT(dtype <= DTYPE_MAX);
218 DEBUGASSERT(size <= _SIZE_MAX);
219 DEBUGASSERT(
id <=
ID_MAX);
221 return (((type & TYPE_MAX) << TYPE_SHIFT) | ((cls & CLS_MAX) << CLS_SHIFT) |
222 ((dtype & DTYPE_MAX) << DTYPE_SHIFT) | ((
id &
ID_MAX) << ID_SHIFT) |
223 ((size & _SIZE_MAX) << SIZE_SHIFT) | ((rw & RW_MAX) << RW_SHIFT));
235 return ((objcfg >> ID_SHIFT) &
ID_MAX);
247 return ((objcfg >> SIZE_SHIFT) & _SIZE_MAX);
259 return ((objcfg >> RW_SHIFT) & RW_MAX);
271 return ((objcfg >> DTYPE_SHIFT) & DTYPE_MAX);
283 return ((objcfg >> CLS_SHIFT) & CLS_MAX);
295 return ((objcfg >> TYPE_SHIFT) & TYPE_MAX);
323 std::memcpy(&y, &x,
sizeof(y));
338 std::memcpy(&y, &x,
sizeof(y));
353 std::memcpy(&y, &x,
sizeof(y));
393 std::memcpy(&y, &x,
sizeof(y));
408 std::memcpy(&y, &x,
sizeof(y));
423 std::memcpy(&y, &x,
sizeof(y));
443 reinterpret_cast<uint32_t *
>(
const_cast<SObjectCfgData *
>(&cfg)) + offset);
Configuration management for Dawn objects.
static SObjectCfgItem * objectAtOffset(const SObjectCfgData &cfg, size_t offset)
Get item from offset.
static ObjectCfgId objectCfg(uint8_t type, uint16_t cls, uint8_t dtype, bool rw, uint16_t size, uint8_t id)
Construct 32-bit ConfigID from component fields.
uint32_t ObjectCfgId
ConfigID type - single 32-bit value.
uint32_t ObjectCfgData_t
Configuration data element - single 32-bit word.
static uint16_t objectCfgGetCls(const ObjectCfgId objcfg)
Extract object class from ConfigID.
static float cfgToF(ObjectCfgData_t x)
Convert ObjectCfgData_t to float.
static uint16_t objectCfgGetSize(const ObjectCfgId objcfg)
Extract configuration data size from ConfigID.
static uint8_t objectCfgGetId(const ObjectCfgId objcfg)
Extract configuration identifier from ConfigID.
static ObjectCfgData_t i32ToCfg(int32_t x)
Convert int32_t to ObjectCfgData_t.
static ObjectCfgData_t fToCfg(float x)
Convert float to ObjectCfgData_t.
static uint32_t cfgToU32(ObjectCfgData_t x)
Convert ObjectCfgData_t to uint32_t.
static uint8_t objectCfgGetType(const ObjectCfgId objcfg)
Extract object type from ConfigID.
static uint32_t b16ToCfg(b16_t x)
Convert b16_t to uint32_t.
static size_t ID_MAX
Configuration ID field constants and bit shift positions.
static ObjectCfgData_t u32ToCfg(uint32_t x)
Helper conversion functions: data types to cfg data type.
static uint8_t objectCfgGetDtype(const ObjectCfgId objcfg)
Extract data type from ConfigID.
static b16_t cfgToB16(ObjectCfgData_t x)
Convert ObjectCfgData_t to b16_t.
static SObjectCfgItem * objectCfgFromCfgId(const SObjectCfgData &cfg, ObjectCfgId id)
Get item from configuration ID.
static int32_t cfgtoi32(ObjectCfgData_t x)
Convert ObjectCfgData_t to int32_t.
static size_t getSizeBytes(const SObjectCfgData &cfg)
Get total size in bytes for this object definition.
static bool objectCfgGetRw(const ObjectCfgId objcfg)
Extract read-write access flag from ConfigID.
static ObjectCfgData_t fToB16ToCfg(float x)
Convert float to b16_t and then to ObjectCfgData_t.
Out-of-tree user-extension hooks for Dawn.
Object configuration data container.
SObjectId::UObjectId objid
Object identifier (type, class, dtype, instance).
SObjectCfgItem items
First configuration item (array continues in memory).
uint32_t size
Number of configuration items for this object (0-32).
Single configuration item within object.
UObjectCfgId cfgid
Configuration ID header (type, class, id, size, rw, dtype).
32-bit encoded configuration identifier (union with bit field).
ObjectCfgId v
Raw 32-bit ConfigID value (for storage, comparison).
uint32_t cls
Object class (bits 21-29, max 511).
uint32_t id
Configuration identifier (bits 0-4, max 31).
uint32_t ext
Extension flag (bit 20).
uint32_t size
Configuration data size in 32-bit words (bits 5-14, max 1023).
uint32_t dtype
Configuration data type (bits 16-19).
uint32_t type
Object type (bits 30-31).
uint32_t rw
Read-write access flag (bit 15).
32-bit encoded object identifier (union with bit field).