Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // semantic names
- typedef enum {
- V_POSITION,
- V_NORMAL,
- V_TANGENT,
- V_BITANGENT,
- V_TEXCOORD,
- V_BLEND_INDICES,
- V_BLEND_WEIGHTS,
- V_UNKNOWN,
- V_COUNT = V_UNKNOWN
- } VertexSemantic;
- typedef enum {
- SIGN_BIT = 31,
- FORMAT = 30,
- // Bit range 20-29 unused
- BITS_W = 15,
- BITS_Z = 10,
- BITS_Y = 5,
- BITS_X = 0
- } FormatEncoding;
- typedef enum {
- FLOAT,
- INTEGER
- } ComponentType;
- // helper functions for encoding / decoding Format
- inline uint32_t format(ComponentType type, bool signed_, uint8_t bit_depth_x, uint8_t bit_depth_y, uint8_t bit_depth_z, uint8_t bit_depth_w) {
- return ((uint8_t)signed_) << SIGN_BIT | ((uint8_t)type) << FORMAT | bit_depth_x << BITS_X | bit_depth_y << BITS_Y | bit_depth_z << BITS_Z | bit_depth_w << BITS_W;
- }
- inline uint32_t bits(uint32_t format) {
- return ((format >> BITS_X) & 0x1f) + ((format >> BITS_Y) & 0x1f) + ((format >> BITS_Z) & 0x1f) + ((format >> BITS_W) & 0x1f);
- }
- struct VertexBufferView {
- typedef enum { MAX_CHANNELS = 16 };
- struct Channel {
- uint32_t format;
- uint8_t semantic;
- uint8_t stream;
- uint8_t set;
- bool instance;
- } channels[MAX_CHANNELS];
- uint32_t n_channels;
- };
- struct IndexBufferView {
- // either 2 or 4 depending on if index buffer is 32
- uint8_t stride;
- };
- struct RenderBufferApi
- {
- typedef uint32_t Handle;
- typedef enum { VERTEX_BUFFER_VIEW, INDEX_BUFFER_VIEW } View;
- typedef enum { STATIC, UPDATABLE } Validity;
- Handle (*create_buffer)(uint32_t size, Validity validity, View view, const void *view_desc, const void *data = nullptr);
- void (*update_buffer)(Handle handle, uint32_t size, const void *data = nullptr);
- void (*destroy_buffer)(Handle handle);
- }:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement