diff options
Diffstat (limited to 'intern/gawain/src/gwn_vertex_format.c')
-rw-r--r-- | intern/gawain/src/gwn_vertex_format.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/intern/gawain/src/gwn_vertex_format.c b/intern/gawain/src/gwn_vertex_format.c index c180c304d28..122de12ec6e 100644 --- a/intern/gawain/src/gwn_vertex_format.c +++ b/intern/gawain/src/gwn_vertex_format.c @@ -25,13 +25,13 @@ void GWN_vertformat_clear(Gwn_VertFormat* format) #if TRUST_NO_ONE memset(format, 0, sizeof(Gwn_VertFormat)); #else - format->attrib_ct = 0; + format->attr_len = 0; format->packed = false; format->name_offset = 0; - format->name_ct = 0; + format->name_len = 0; for (unsigned i = 0; i < GWN_VERT_ATTR_MAX_LEN; i++) - format->attribs[i].name_ct = 0; + format->attribs[i].name_len = 0; #endif } @@ -40,8 +40,8 @@ void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src) // copy regular struct fields memcpy(dest, src, sizeof(Gwn_VertFormat)); - for (unsigned i = 0; i < dest->attrib_ct; i++) - for (unsigned j = 0; j < dest->attribs[i].name_ct; j++) + for (unsigned i = 0; i < dest->attr_len; i++) + for (unsigned j = 0; j < dest->attribs[i].name_len; j++) dest->attribs[i].name[j] = (char *)dest + (src->attribs[i].name[j] - ((char *)src)); } @@ -77,7 +77,7 @@ static unsigned attrib_sz(const Gwn_VertAttr *a) if (a->comp_type == GWN_COMP_I10) return 4; // always packed as 10_10_10_2 - return a->comp_ct * comp_sz(a->comp_type); + return a->comp_len * comp_sz(a->comp_type); } static unsigned attrib_align(const Gwn_VertAttr *a) @@ -86,19 +86,19 @@ static unsigned attrib_align(const Gwn_VertAttr *a) return 4; // always packed as 10_10_10_2 unsigned c = comp_sz(a->comp_type); - if (a->comp_ct == 3 && c <= 2) + if (a->comp_len == 3 && c <= 2) return 4 * c; // AMD HW can't fetch these well, so pad it out (other vendors too?) else return c; // most fetches are ok if components are naturally aligned } -unsigned vertex_buffer_size(const Gwn_VertFormat* format, unsigned vertex_ct) +unsigned vertex_buffer_size(const Gwn_VertFormat* format, unsigned vertex_len) { #if TRUST_NO_ONE assert(format->packed && format->stride > 0); #endif - return format->stride * vertex_ct; + return format->stride * vertex_len; } static const char* copy_attrib_name(Gwn_VertFormat* format, const char* name) @@ -130,13 +130,13 @@ static const char* copy_attrib_name(Gwn_VertFormat* format, const char* name) return name_copy; } -unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_VertCompType comp_type, unsigned comp_ct, Gwn_VertFetchMode fetch_mode) +unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_VertCompType comp_type, unsigned comp_len, Gwn_VertFetchMode fetch_mode) { #if TRUST_NO_ONE - assert(format->name_ct < GWN_VERT_ATTR_MAX_LEN); // there's room for more - assert(format->attrib_ct < GWN_VERT_ATTR_MAX_LEN); // there's room for more + assert(format->name_len < GWN_VERT_ATTR_MAX_LEN); // there's room for more + assert(format->attr_len < GWN_VERT_ATTR_MAX_LEN); // there's room for more assert(!format->packed); // packed means frozen/locked - assert((comp_ct >= 1 && comp_ct <= 4) || comp_ct == 8 || comp_ct == 12 || comp_ct == 16); + assert((comp_len >= 1 && comp_len <= 4) || comp_len == 8 || comp_len == 12 || comp_len == 16); switch (comp_type) { case GWN_COMP_F32: @@ -146,25 +146,25 @@ unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_V case GWN_COMP_I10: // 10_10_10 format intended for normals (xyz) or colors (rgb) // extra component packed.w can be manually set to { -2, -1, 0, 1 } - assert(comp_ct == 3 || comp_ct == 4); + assert(comp_len == 3 || comp_len == 4); assert(fetch_mode == GWN_FETCH_INT_TO_FLOAT_UNIT); // not strictly required, may relax later break; default: // integer types can be kept as int or converted/normalized to float assert(fetch_mode != GWN_FETCH_FLOAT); // only support float matrices (see Batch_update_program_bindings) - assert(comp_ct != 8 && comp_ct != 12 && comp_ct != 16); + assert(comp_len != 8 && comp_len != 12 && comp_len != 16); } #endif - format->name_ct++; // multiname support + format->name_len++; // multiname support - const unsigned attrib_id = format->attrib_ct++; + const unsigned attrib_id = format->attr_len++; Gwn_VertAttr* attrib = format->attribs + attrib_id; - attrib->name[attrib->name_ct++] = copy_attrib_name(format, name); + attrib->name[attrib->name_len++] = copy_attrib_name(format, name); attrib->comp_type = comp_type; attrib->gl_comp_type = convert_comp_type_to_gl(comp_type); - attrib->comp_ct = (comp_type == GWN_COMP_I10) ? 4 : comp_ct; // system needs 10_10_10_2 to be 4 or BGRA + attrib->comp_len = (comp_type == GWN_COMP_I10) ? 4 : comp_len; // system needs 10_10_10_2 to be 4 or BGRA attrib->sz = attrib_sz(attrib); attrib->offset = 0; // offsets & stride are calculated later (during pack) attrib->fetch_mode = fetch_mode; @@ -174,13 +174,13 @@ unsigned GWN_vertformat_attr_add(Gwn_VertFormat* format, const char* name, Gwn_V void GWN_vertformat_alias_add(Gwn_VertFormat* format, const char* alias) { - Gwn_VertAttr* attrib = format->attribs + (format->attrib_ct - 1); + Gwn_VertAttr* attrib = format->attribs + (format->attr_len - 1); #if TRUST_NO_ONE - assert(format->name_ct < GWN_VERT_ATTR_MAX_LEN); // there's room for more - assert(attrib->name_ct < GWN_VERT_ATTR_MAX_NAMES); + assert(format->name_len < GWN_VERT_ATTR_MAX_LEN); // there's room for more + assert(attrib->name_len < GWN_VERT_ATTR_MAX_NAMES); #endif - format->name_ct++; // multiname support - attrib->name[attrib->name_ct++] = copy_attrib_name(format, alias); + format->name_len++; // multiname support + attrib->name[attrib->name_len++] = copy_attrib_name(format, alias); } unsigned padding(unsigned offset, unsigned alignment) @@ -220,7 +220,7 @@ void VertexFormat_pack(Gwn_VertFormat* format) show_pack(0, a0->sz, 0); #endif - for (unsigned a_idx = 1; a_idx < format->attrib_ct; ++a_idx) + for (unsigned a_idx = 1; a_idx < format->attr_len; ++a_idx) { Gwn_VertAttr* a = format->attribs + a_idx; unsigned mid_padding = padding(offset, attrib_align(a)); |