diff options
author | Campbell Barton <ideasman42@gmail.com> | 2018-07-08 14:05:41 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2018-07-08 14:05:41 +0300 |
commit | 804205babe212972dd800c5a2f6d9ebfb64feefb (patch) | |
tree | 14fb50ce24a26e30f52448afc063401116889e40 /intern | |
parent | 392ed710d62ce496491566f9743ad9e66737072a (diff) |
Cleanup: rename 'ct' to 'len' for gawain
Diffstat (limited to 'intern')
-rw-r--r-- | intern/gawain/gawain/gwn_batch.h | 6 | ||||
-rw-r--r-- | intern/gawain/gawain/gwn_element.h | 10 | ||||
-rw-r--r-- | intern/gawain/gawain/gwn_immediate.h | 8 | ||||
-rw-r--r-- | intern/gawain/gawain/gwn_shader_interface.h | 2 | ||||
-rw-r--r-- | intern/gawain/gawain/gwn_vertex_buffer.h | 12 | ||||
-rw-r--r-- | intern/gawain/gawain/gwn_vertex_format.h | 10 | ||||
-rw-r--r-- | intern/gawain/gawain/gwn_vertex_format_private.h | 2 | ||||
-rw-r--r-- | intern/gawain/src/gwn_attr_binding.c | 4 | ||||
-rw-r--r-- | intern/gawain/src/gwn_batch.c | 32 | ||||
-rw-r--r-- | intern/gawain/src/gwn_buffer_id.cpp | 6 | ||||
-rw-r--r-- | intern/gawain/src/gwn_element.c | 48 | ||||
-rw-r--r-- | intern/gawain/src/gwn_immediate.c | 146 | ||||
-rw-r--r-- | intern/gawain/src/gwn_shader_interface.c | 32 | ||||
-rw-r--r-- | intern/gawain/src/gwn_vertex_array_id.cpp | 4 | ||||
-rw-r--r-- | intern/gawain/src/gwn_vertex_buffer.c | 42 | ||||
-rw-r--r-- | intern/gawain/src/gwn_vertex_format.c | 50 |
16 files changed, 207 insertions, 207 deletions
diff --git a/intern/gawain/gawain/gwn_batch.h b/intern/gawain/gawain/gwn_batch.h index e0cf66637f6..cf7b0c9f1b5 100644 --- a/intern/gawain/gawain/gwn_batch.h +++ b/intern/gawain/gawain/gwn_batch.h @@ -149,9 +149,9 @@ typedef struct BatchWithOwnVertexBufferAndElementList { Gwn_VertBuf verts; // link batch.verts to this } BatchWithOwnVertexBufferAndElementList; -Gwn_Batch* create_BatchWithOwnVertexBuffer(Gwn_PrimType, Gwn_VertFormat*, unsigned v_ct, Gwn_IndexBuf*); -Gwn_Batch* create_BatchWithOwnElementList(Gwn_PrimType, Gwn_VertBuf*, unsigned prim_ct); -Gwn_Batch* create_BatchWithOwnVertexBufferAndElementList(Gwn_PrimType, Gwn_VertFormat*, unsigned v_ct, unsigned prim_ct); +Gwn_Batch* create_BatchWithOwnVertexBuffer(Gwn_PrimType, Gwn_VertFormat*, unsigned v_len, Gwn_IndexBuf*); +Gwn_Batch* create_BatchWithOwnElementList(Gwn_PrimType, Gwn_VertBuf*, unsigned prim_len); +Gwn_Batch* create_BatchWithOwnVertexBufferAndElementList(Gwn_PrimType, Gwn_VertFormat*, unsigned v_len, unsigned prim_len); // verts: shared, own // elem: none, shared, own Gwn_Batch* create_BatchInGeneral(Gwn_PrimType, VertexBufferStuff, ElementListStuff); diff --git a/intern/gawain/gawain/gwn_element.h b/intern/gawain/gawain/gwn_element.h index 4bd0c34675a..53a54cdfd76 100644 --- a/intern/gawain/gawain/gwn_element.h +++ b/intern/gawain/gawain/gwn_element.h @@ -24,7 +24,7 @@ typedef enum { } Gwn_IndexBufType; typedef struct Gwn_IndexBuf { - unsigned index_ct; + unsigned index_len; #if GWN_TRACK_INDEX_RANGE Gwn_IndexBufType index_type; uint32_t gl_index_type; @@ -41,8 +41,8 @@ unsigned GWN_indexbuf_size_get(const Gwn_IndexBuf*); typedef struct Gwn_IndexBufBuilder { unsigned max_allowed_index; - unsigned max_index_ct; - unsigned index_ct; + unsigned max_index_len; + unsigned index_len; Gwn_PrimType prim_type; unsigned* data; bool use_prim_restart; @@ -50,10 +50,10 @@ typedef struct Gwn_IndexBufBuilder { // supports all primitive types. -void GWN_indexbuf_init_ex(Gwn_IndexBufBuilder*, Gwn_PrimType, unsigned index_ct, unsigned vertex_ct, bool use_prim_restart); +void GWN_indexbuf_init_ex(Gwn_IndexBufBuilder*, Gwn_PrimType, unsigned index_len, unsigned vertex_len, bool use_prim_restart); // supports only GWN_PRIM_POINTS, GWN_PRIM_LINES and GWN_PRIM_TRIS. -void GWN_indexbuf_init(Gwn_IndexBufBuilder*, Gwn_PrimType, unsigned prim_ct, unsigned vertex_ct); +void GWN_indexbuf_init(Gwn_IndexBufBuilder*, Gwn_PrimType, unsigned prim_len, unsigned vertex_len); void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder*, unsigned v); void GWN_indexbuf_add_primitive_restart(Gwn_IndexBufBuilder*); diff --git a/intern/gawain/gawain/gwn_immediate.h b/intern/gawain/gawain/gwn_immediate.h index 35f9c9d9e2c..c3ea2b911a0 100644 --- a/intern/gawain/gawain/gwn_immediate.h +++ b/intern/gawain/gawain/gwn_immediate.h @@ -23,8 +23,8 @@ Gwn_VertFormat* immVertexFormat(void); // returns a cleared vertex format, ready void immBindProgram(uint32_t program, const Gwn_ShaderInterface*); // every immBegin must have a program bound first void immUnbindProgram(void); // call after your last immEnd, or before binding another program -void immBegin(Gwn_PrimType, unsigned vertex_ct); // must supply exactly vertex_ct vertices -void immBeginAtMost(Gwn_PrimType, unsigned max_vertex_ct); // can supply fewer vertices +void immBegin(Gwn_PrimType, unsigned vertex_len); // must supply exactly vertex_len vertices +void immBeginAtMost(Gwn_PrimType, unsigned max_vertex_len); // can supply fewer vertices void immEnd(void); // finishes and draws #if IMM_BATCH_COMBO @@ -32,8 +32,8 @@ void immEnd(void); // finishes and draws // immBegin a batch, then use standard immFunctions as usual. // immEnd will finalize the batch instead of drawing. // Then you can draw it as many times as you like! Partially replaces the need for display lists. -Gwn_Batch* immBeginBatch(Gwn_PrimType, unsigned vertex_ct); -Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType, unsigned vertex_ct); +Gwn_Batch* immBeginBatch(Gwn_PrimType, unsigned vertex_len); +Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType, unsigned vertex_len); #endif diff --git a/intern/gawain/gawain/gwn_shader_interface.h b/intern/gawain/gawain/gwn_shader_interface.h index ee3d51fb3cc..b27b12c18d8 100644 --- a/intern/gawain/gawain/gwn_shader_interface.h +++ b/intern/gawain/gawain/gwn_shader_interface.h @@ -65,7 +65,7 @@ typedef struct Gwn_ShaderInterface { Gwn_ShaderInput* builtin_uniforms[GWN_NUM_UNIFORMS]; char* name_buffer; struct Gwn_Batch** batches; // references to batches using this interface - unsigned batches_ct; + unsigned batches_len; } Gwn_ShaderInterface; Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program_id); diff --git a/intern/gawain/gawain/gwn_vertex_buffer.h b/intern/gawain/gawain/gwn_vertex_buffer.h index b92e4a87698..0eac4838e65 100644 --- a/intern/gawain/gawain/gwn_vertex_buffer.h +++ b/intern/gawain/gawain/gwn_vertex_buffer.h @@ -17,7 +17,7 @@ // How to create a Gwn_VertBuf: // 1) verts = GWN_vertbuf_create() or GWN_vertbuf_init(verts) // 2) GWN_vertformat_attr_add(verts->format, ...) -// 3) GWN_vertbuf_data_alloc(verts, vertex_ct) <-- finalizes/packs vertex format +// 3) GWN_vertbuf_data_alloc(verts, vertex_len) <-- finalizes/packs vertex format // 4) GWN_vertbuf_attr_fill(verts, pos, application_pos_buffer) // Is Gwn_VertBuf always used as part of a Gwn_Batch? @@ -31,8 +31,8 @@ typedef enum { typedef struct Gwn_VertBuf { Gwn_VertFormat format; - unsigned vertex_ct; // number of verts we want to draw - unsigned vertex_alloc; // number of verts data + unsigned vertex_len; /* number of verts we want to draw */ + unsigned vertex_alloc; /* number of verts data */ bool dirty; unsigned char* data; // NULL indicates data in VRAM (unmapped) uint32_t vbo_id; // 0 indicates not yet allocated @@ -54,9 +54,9 @@ void GWN_vertbuf_init_with_format_ex(Gwn_VertBuf*, const Gwn_VertFormat*, Gwn_Us GWN_vertbuf_init_with_format_ex(verts, format, GWN_USAGE_STATIC) unsigned GWN_vertbuf_size_get(const Gwn_VertBuf*); -void GWN_vertbuf_data_alloc(Gwn_VertBuf*, unsigned v_ct); -void GWN_vertbuf_data_resize(Gwn_VertBuf*, unsigned v_ct); -void GWN_vertbuf_vertex_count_set(Gwn_VertBuf*, unsigned v_ct); +void GWN_vertbuf_data_alloc(Gwn_VertBuf*, unsigned v_len); +void GWN_vertbuf_data_resize(Gwn_VertBuf*, unsigned v_len); +void GWN_vertbuf_vertex_count_set(Gwn_VertBuf*, unsigned v_len); // The most important set_attrib variant is the untyped one. Get it right first. // It takes a void* so the app developer is responsible for matching their app data types diff --git a/intern/gawain/gawain/gwn_vertex_format.h b/intern/gawain/gawain/gwn_vertex_format.h index 503c2d03c42..a4593e4615b 100644 --- a/intern/gawain/gawain/gwn_vertex_format.h +++ b/intern/gawain/gawain/gwn_vertex_format.h @@ -42,16 +42,16 @@ typedef struct Gwn_VertAttr { Gwn_VertFetchMode fetch_mode; Gwn_VertCompType comp_type; unsigned gl_comp_type; - unsigned comp_ct; // 1 to 4 or 8 or 12 or 16 + unsigned comp_len; // 1 to 4 or 8 or 12 or 16 unsigned sz; // size in bytes, 1 to 64 unsigned offset; // from beginning of vertex, in bytes - unsigned name_ct; // up to GWN_VERT_ATTR_MAX_NAMES + unsigned name_len; // up to GWN_VERT_ATTR_MAX_NAMES const char* name[GWN_VERT_ATTR_MAX_NAMES]; } Gwn_VertAttr; typedef struct Gwn_VertFormat { - unsigned attrib_ct; // 0 to 16 (GWN_VERT_ATTR_MAX_LEN) - unsigned name_ct; // total count of active vertex attrib + unsigned attr_len; // 0 to 16 (GWN_VERT_ATTR_MAX_LEN) + unsigned name_len; // total count of active vertex attrib unsigned stride; // stride in bytes, 1 to 256 unsigned name_offset; bool packed; @@ -62,7 +62,7 @@ typedef struct Gwn_VertFormat { void GWN_vertformat_clear(Gwn_VertFormat*); void GWN_vertformat_copy(Gwn_VertFormat* dest, const Gwn_VertFormat* src); -unsigned GWN_vertformat_attr_add(Gwn_VertFormat*, const char* name, Gwn_VertCompType, unsigned comp_ct, Gwn_VertFetchMode); +unsigned GWN_vertformat_attr_add(Gwn_VertFormat*, const char* name, Gwn_VertCompType, unsigned comp_len, Gwn_VertFetchMode); void GWN_vertformat_alias_add(Gwn_VertFormat*, const char* alias); // format conversion diff --git a/intern/gawain/gawain/gwn_vertex_format_private.h b/intern/gawain/gawain/gwn_vertex_format_private.h index c1a0f734eda..90cd8412e53 100644 --- a/intern/gawain/gawain/gwn_vertex_format_private.h +++ b/intern/gawain/gawain/gwn_vertex_format_private.h @@ -13,4 +13,4 @@ void VertexFormat_pack(Gwn_VertFormat*); unsigned padding(unsigned offset, unsigned alignment); -unsigned vertex_buffer_size(const Gwn_VertFormat*, unsigned vertex_ct); +unsigned vertex_buffer_size(const Gwn_VertFormat*, unsigned vertex_len); diff --git a/intern/gawain/src/gwn_attr_binding.c b/intern/gawain/src/gwn_attr_binding.c index 7647a927b1e..c702a0ae99d 100644 --- a/intern/gawain/src/gwn_attr_binding.c +++ b/intern/gawain/src/gwn_attr_binding.c @@ -52,10 +52,10 @@ void get_attrib_locations(const Gwn_VertFormat* format, Gwn_AttrBinding* binding { AttribBinding_clear(binding); - for (unsigned a_idx = 0; a_idx < format->attrib_ct; ++a_idx) + for (unsigned a_idx = 0; a_idx < format->attr_len; ++a_idx) { const Gwn_VertAttr* a = format->attribs + a_idx; - for (unsigned n_idx = 0; n_idx < a->name_ct; ++n_idx) + for (unsigned n_idx = 0; n_idx < a->name_len; ++n_idx) { const Gwn_ShaderInput* input = GWN_shaderinterface_attr(shaderface, a->name[n_idx]); diff --git a/intern/gawain/src/gwn_batch.c b/intern/gawain/src/gwn_batch.c index adc72e171c0..62342cfc42f 100644 --- a/intern/gawain/src/gwn_batch.c +++ b/intern/gawain/src/gwn_batch.c @@ -168,9 +168,9 @@ int GWN_batch_vertbuf_add_ex( if (batch->verts[v] == NULL) { #if TRUST_NO_ONE - // for now all VertexBuffers must have same vertex_ct - assert(verts->vertex_ct == batch->verts[0]->vertex_ct); - // in the near future we will enable instanced attribs which have their own vertex_ct + // for now all VertexBuffers must have same vertex_len + assert(verts->vertex_len == batch->verts[0]->vertex_len); + // in the near future we will enable instanced attribs which have their own vertex_len #endif batch->verts[v] = verts; // TODO: mark dirty so we can keep attrib bindings up-to-date @@ -336,30 +336,30 @@ static void create_bindings(Gwn_VertBuf* verts, const Gwn_ShaderInterface* inter { const Gwn_VertFormat* format = &verts->format; - const unsigned attrib_ct = format->attrib_ct; + const unsigned attr_len = format->attr_len; const unsigned stride = format->stride; GWN_vertbuf_use(verts); - for (unsigned a_idx = 0; a_idx < attrib_ct; ++a_idx) + for (unsigned a_idx = 0; a_idx < attr_len; ++a_idx) { const Gwn_VertAttr* a = format->attribs + a_idx; const GLvoid* pointer = (const GLubyte*)0 + a->offset + v_first * stride; - for (unsigned n_idx = 0; n_idx < a->name_ct; ++n_idx) + for (unsigned n_idx = 0; n_idx < a->name_len; ++n_idx) { const Gwn_ShaderInput* input = GWN_shaderinterface_attr(interface, a->name[n_idx]); if (input == NULL) continue; - if (a->comp_ct == 16 || a->comp_ct == 12 || a->comp_ct == 8) + if (a->comp_len == 16 || a->comp_len == 12 || a->comp_len == 8) { #if TRUST_NO_ONE assert(a->fetch_mode == GWN_FETCH_FLOAT); assert(a->gl_comp_type == GL_FLOAT); #endif - for (int i = 0; i < a->comp_ct / 4; ++i) + for (int i = 0; i < a->comp_len / 4; ++i) { glEnableVertexAttribArray(input->location + i); glVertexAttribDivisor(input->location + i, (use_instancing) ? 1 : 0); @@ -376,13 +376,13 @@ static void create_bindings(Gwn_VertBuf* verts, const Gwn_ShaderInterface* inter { case GWN_FETCH_FLOAT: case GWN_FETCH_INT_TO_FLOAT: - glVertexAttribPointer(input->location, a->comp_ct, a->gl_comp_type, GL_FALSE, stride, pointer); + glVertexAttribPointer(input->location, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer); break; case GWN_FETCH_INT_TO_FLOAT_UNIT: - glVertexAttribPointer(input->location, a->comp_ct, a->gl_comp_type, GL_TRUE, stride, pointer); + glVertexAttribPointer(input->location, a->comp_len, a->gl_comp_type, GL_TRUE, stride, pointer); break; case GWN_FETCH_INT: - glVertexAttribIPointer(input->location, a->comp_ct, a->gl_comp_type, stride, pointer); + glVertexAttribIPointer(input->location, a->comp_len, a->gl_comp_type, stride, pointer); } } } @@ -564,7 +564,7 @@ void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool fo { // Infer length if vertex count is not given if (v_count == 0) - v_count = batch->inst->vertex_ct; + v_count = batch->inst->vertex_len; if (batch->elem) { @@ -574,21 +574,21 @@ void GWN_batch_draw_range_ex(Gwn_Batch* batch, int v_first, int v_count, bool fo primitive_restart_enable(el); #if GWN_TRACK_INDEX_RANGE - glDrawElementsInstancedBaseVertex(batch->gl_prim_type, el->index_ct, el->gl_index_type, 0, v_count, el->base_index); + glDrawElementsInstancedBaseVertex(batch->gl_prim_type, el->index_len, el->gl_index_type, 0, v_count, el->base_index); #else - glDrawElementsInstanced(batch->gl_prim_type, el->index_ct, GL_UNSIGNED_INT, 0, v_count); + glDrawElementsInstanced(batch->gl_prim_type, el->index_len, GL_UNSIGNED_INT, 0, v_count); #endif if (el->use_prim_restart) primitive_restart_disable(); } else - glDrawArraysInstanced(batch->gl_prim_type, 0, batch->verts[0]->vertex_ct, v_count); + glDrawArraysInstanced(batch->gl_prim_type, 0, batch->verts[0]->vertex_len, v_count); } else { // Infer length if vertex count is not given if (v_count == 0) - v_count = (batch->elem) ? batch->elem->index_ct : batch->verts[0]->vertex_ct; + v_count = (batch->elem) ? batch->elem->index_len : batch->verts[0]->vertex_len; if (batch->elem) { diff --git a/intern/gawain/src/gwn_buffer_id.cpp b/intern/gawain/src/gwn_buffer_id.cpp index 64bad855ca7..13473f1f28d 100644 --- a/intern/gawain/src/gwn_buffer_id.cpp +++ b/intern/gawain/src/gwn_buffer_id.cpp @@ -39,11 +39,11 @@ GLuint GWN_buf_id_alloc() orphan_mutex.lock(); if (!orphaned_buffer_ids.empty()) { - const auto orphaned_buffer_ct = (unsigned)orphaned_buffer_ids.size(); + const auto orphaned_buffer_len = (unsigned)orphaned_buffer_ids.size(); #if ORPHAN_DEBUG - printf("deleting %u orphaned VBO%s\n", orphaned_buffer_ct, orphaned_buffer_ct == 1 ? "" : "s"); + printf("deleting %u orphaned VBO%s\n", orphaned_buffer_len, orphaned_buffer_len == 1 ? "" : "s"); #endif - glDeleteBuffers(orphaned_buffer_ct, orphaned_buffer_ids.data()); + glDeleteBuffers(orphaned_buffer_len, orphaned_buffer_ids.data()); orphaned_buffer_ids.clear(); } orphan_mutex.unlock(); diff --git a/intern/gawain/src/gwn_element.c b/intern/gawain/src/gwn_element.c index e2fbb657c78..257338fe089 100644 --- a/intern/gawain/src/gwn_element.c +++ b/intern/gawain/src/gwn_element.c @@ -33,23 +33,23 @@ unsigned GWN_indexbuf_size_get(const Gwn_IndexBuf* elem) [GWN_INDEX_U16] = sizeof(GLushort), [GWN_INDEX_U32] = sizeof(GLuint) }; - return elem->index_ct * table[elem->index_type]; + return elem->index_len * table[elem->index_type]; #else - return elem->index_ct * sizeof(GLuint); + return elem->index_len * sizeof(GLuint); #endif } -void GWN_indexbuf_init_ex(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, unsigned index_ct, unsigned vertex_ct, bool use_prim_restart) +void GWN_indexbuf_init_ex(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, unsigned index_len, unsigned vertex_len, bool use_prim_restart) { builder->use_prim_restart = use_prim_restart; - builder->max_allowed_index = vertex_ct - 1; - builder->max_index_ct = index_ct; - builder->index_ct = 0; // start empty + builder->max_allowed_index = vertex_len - 1; + builder->max_index_len = index_len; + builder->index_len = 0; // start empty builder->prim_type = prim_type; - builder->data = calloc(builder->max_index_ct, sizeof(unsigned)); + builder->data = calloc(builder->max_index_len, sizeof(unsigned)); } -void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, unsigned prim_ct, unsigned vertex_ct) +void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, unsigned prim_len, unsigned vertex_len) { unsigned verts_per_prim = 0; switch (prim_type) @@ -73,29 +73,29 @@ void GWN_indexbuf_init(Gwn_IndexBufBuilder* builder, Gwn_PrimType prim_type, uns return; } - GWN_indexbuf_init_ex(builder, prim_type, prim_ct * verts_per_prim, vertex_ct, false); + GWN_indexbuf_init_ex(builder, prim_type, prim_len * verts_per_prim, vertex_len, false); } void GWN_indexbuf_add_generic_vert(Gwn_IndexBufBuilder* builder, unsigned v) { #if TRUST_NO_ONE assert(builder->data != NULL); - assert(builder->index_ct < builder->max_index_ct); + assert(builder->index_len < builder->max_index_len); assert(v <= builder->max_allowed_index); #endif - builder->data[builder->index_ct++] = v; + builder->data[builder->index_len++] = v; } void GWN_indexbuf_add_primitive_restart(Gwn_IndexBufBuilder* builder) { #if TRUST_NO_ONE assert(builder->data != NULL); - assert(builder->index_ct < builder->max_index_ct); + assert(builder->index_len < builder->max_index_len); assert(builder->use_prim_restart); #endif - builder->data[builder->index_ct++] = GWN_PRIM_RESTART; + builder->data[builder->index_len++] = GWN_PRIM_RESTART; } void GWN_indexbuf_add_point_vert(Gwn_IndexBufBuilder* builder, unsigned v) @@ -147,9 +147,9 @@ void GWN_indexbuf_add_line_adj_verts(Gwn_IndexBufBuilder* builder, unsigned v1, // Everything remains 32 bit while building to keep things simple. // Find min/max after, then convert to smallest index type possible. -static unsigned index_range(const unsigned values[], unsigned value_ct, unsigned* min_out, unsigned* max_out) +static unsigned index_range(const unsigned values[], unsigned value_len, unsigned* min_out, unsigned* max_out) { - if (value_ct == 0) + if (value_len == 0) { *min_out = 0; *max_out = 0; @@ -157,7 +157,7 @@ static unsigned index_range(const unsigned values[], unsigned value_ct, unsigned } unsigned min_value = values[0]; unsigned max_value = values[0]; - for (unsigned i = 1; i < value_ct; ++i) + for (unsigned i = 1; i < value_len; ++i) { const unsigned value = values[i]; if (value == GWN_PRIM_RESTART) @@ -175,7 +175,7 @@ static unsigned index_range(const unsigned values[], unsigned value_ct, unsigned static void squeeze_indices_byte(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* elem) { const unsigned *values = builder->data; - const unsigned index_ct = elem->index_ct; + const unsigned index_len = elem->index_len; // data will never be *larger* than builder->data... // converting in place to avoid extra allocation @@ -189,14 +189,14 @@ static void squeeze_indices_byte(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* ele elem->min_index = 0; elem->max_index -= base; - for (unsigned i = 0; i < index_ct; ++i) + for (unsigned i = 0; i < index_len; ++i) data[i] = (values[i] == GWN_PRIM_RESTART) ? 0xFF : (GLubyte)(values[i] - base); } else { elem->base_index = 0; - for (unsigned i = 0; i < index_ct; ++i) + for (unsigned i = 0; i < index_len; ++i) data[i] = (GLubyte)(values[i]); } } @@ -204,7 +204,7 @@ static void squeeze_indices_byte(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* ele static void squeeze_indices_short(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* elem) { const unsigned *values = builder->data; - const unsigned index_ct = elem->index_ct; + const unsigned index_len = elem->index_len; // data will never be *larger* than builder->data... // converting in place to avoid extra allocation @@ -218,14 +218,14 @@ static void squeeze_indices_short(Gwn_IndexBufBuilder *builder, Gwn_IndexBuf* el elem->min_index = 0; elem->max_index -= base; - for (unsigned i = 0; i < index_ct; ++i) + for (unsigned i = 0; i < index_len; ++i) data[i] = (values[i] == GWN_PRIM_RESTART) ? 0xFFFF : (GLushort)(values[i] - base); } else { elem->base_index = 0; - for (unsigned i = 0; i < index_ct; ++i) + for (unsigned i = 0; i < index_len; ++i) data[i] = (GLushort)(values[i]); } } @@ -245,11 +245,11 @@ void GWN_indexbuf_build_in_place(Gwn_IndexBufBuilder* builder, Gwn_IndexBuf* ele assert(builder->data != NULL); #endif - elem->index_ct = builder->index_ct; + elem->index_len = builder->index_len; elem->use_prim_restart = builder->use_prim_restart; #if GWN_TRACK_INDEX_RANGE - unsigned range = index_range(builder->data, builder->index_ct, &elem->min_index, &elem->max_index); + unsigned range = index_range(builder->data, builder->index_len, &elem->min_index, &elem->max_index); // count the primitive restart index. if (elem->use_prim_restart) diff --git a/intern/gawain/src/gwn_immediate.c b/intern/gawain/src/gwn_immediate.c index b0b587d1b8c..c57564fce06 100644 --- a/intern/gawain/src/gwn_immediate.c +++ b/intern/gawain/src/gwn_immediate.c @@ -34,8 +34,8 @@ typedef struct { GLubyte* buffer_data; unsigned buffer_offset; unsigned buffer_bytes_mapped; - unsigned vertex_ct; - bool strict_vertex_ct; + unsigned vertex_len; + bool strict_vertex_len; Gwn_PrimType prim_type; Gwn_VertFormat vertex_format; @@ -73,7 +73,7 @@ void immInit(void) glBufferData(GL_ARRAY_BUFFER, IMM_BUFFER_SIZE, NULL, GL_DYNAMIC_DRAW); imm.prim_type = GWN_PRIM_NONE; - imm.strict_vertex_ct = true; + imm.strict_vertex_len = true; glBindBuffer(GL_ARRAY_BUFFER, 0); initialized = true; @@ -147,10 +147,10 @@ void immUnbindProgram(void) } #if TRUST_NO_ONE -static bool vertex_count_makes_sense_for_primitive(unsigned vertex_ct, Gwn_PrimType prim_type) +static bool vertex_count_makes_sense_for_primitive(unsigned vertex_len, Gwn_PrimType prim_type) { - // does vertex_ct make sense for this primitive type? - if (vertex_ct == 0) + // does vertex_len make sense for this primitive type? + if (vertex_len == 0) return false; switch (prim_type) @@ -158,38 +158,38 @@ static bool vertex_count_makes_sense_for_primitive(unsigned vertex_ct, Gwn_PrimT case GWN_PRIM_POINTS: return true; case GWN_PRIM_LINES: - return vertex_ct % 2 == 0; + return vertex_len % 2 == 0; case GWN_PRIM_LINE_STRIP: case GWN_PRIM_LINE_LOOP: - return vertex_ct >= 2; + return vertex_len >= 2; case GWN_PRIM_LINE_STRIP_ADJ: - return vertex_ct >= 4; + return vertex_len >= 4; case GWN_PRIM_TRIS: - return vertex_ct % 3 == 0; + return vertex_len % 3 == 0; case GWN_PRIM_TRI_STRIP: case GWN_PRIM_TRI_FAN: - return vertex_ct >= 3; + return vertex_len >= 3; default: return false; } } #endif -void immBegin(Gwn_PrimType prim_type, unsigned vertex_ct) +void immBegin(Gwn_PrimType prim_type, unsigned vertex_len) { #if TRUST_NO_ONE assert(initialized); assert(imm.prim_type == GWN_PRIM_NONE); // make sure we haven't already begun - assert(vertex_count_makes_sense_for_primitive(vertex_ct, prim_type)); + assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type)); #endif imm.prim_type = prim_type; - imm.vertex_ct = vertex_ct; + imm.vertex_len = vertex_len; imm.vertex_idx = 0; imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits; // how many bytes do we need for this draw call? - const unsigned bytes_needed = vertex_buffer_size(&imm.vertex_format, vertex_ct); + const unsigned bytes_needed = vertex_buffer_size(&imm.vertex_format, vertex_len); #if TRUST_NO_ONE assert(bytes_needed <= IMM_BUFFER_SIZE); @@ -234,7 +234,7 @@ void immBegin(Gwn_PrimType prim_type, unsigned vertex_ct) // printf("mapping %u to %u\n", imm.buffer_offset, imm.buffer_offset + bytes_needed - 1); imm.buffer_data = glMapBufferRange(GL_ARRAY_BUFFER, imm.buffer_offset, bytes_needed, - GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | (imm.strict_vertex_ct ? 0 : GL_MAP_FLUSH_EXPLICIT_BIT)); + GL_MAP_WRITE_BIT | GL_MAP_UNSYNCHRONIZED_BIT | (imm.strict_vertex_len ? 0 : GL_MAP_FLUSH_EXPLICIT_BIT)); #if TRUST_NO_ONE assert(imm.buffer_data != NULL); @@ -244,33 +244,33 @@ void immBegin(Gwn_PrimType prim_type, unsigned vertex_ct) imm.vertex_data = imm.buffer_data; } -void immBeginAtMost(Gwn_PrimType prim_type, unsigned vertex_ct) +void immBeginAtMost(Gwn_PrimType prim_type, unsigned vertex_len) { #if TRUST_NO_ONE - assert(vertex_ct > 0); + assert(vertex_len > 0); #endif - imm.strict_vertex_ct = false; - immBegin(prim_type, vertex_ct); + imm.strict_vertex_len = false; + immBegin(prim_type, vertex_len); } #if IMM_BATCH_COMBO -Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, unsigned vertex_ct) +Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, unsigned vertex_len) { #if TRUST_NO_ONE assert(initialized); assert(imm.prim_type == GWN_PRIM_NONE); // make sure we haven't already begun - assert(vertex_count_makes_sense_for_primitive(vertex_ct, prim_type)); + assert(vertex_count_makes_sense_for_primitive(vertex_len, prim_type)); #endif imm.prim_type = prim_type; - imm.vertex_ct = vertex_ct; + imm.vertex_len = vertex_len; imm.vertex_idx = 0; imm.unassigned_attrib_bits = imm.attrib_binding.enabled_bits; Gwn_VertBuf* verts = GWN_vertbuf_create_with_format(&imm.vertex_format); - GWN_vertbuf_data_alloc(verts, vertex_ct); + GWN_vertbuf_data_alloc(verts, vertex_len); imm.buffer_bytes_mapped = GWN_vertbuf_size_get(verts); imm.vertex_data = verts->data; @@ -281,10 +281,10 @@ Gwn_Batch* immBeginBatch(Gwn_PrimType prim_type, unsigned vertex_ct) return imm.batch; } -Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType prim_type, unsigned vertex_ct) +Gwn_Batch* immBeginBatchAtMost(Gwn_PrimType prim_type, unsigned vertex_len) { - imm.strict_vertex_ct = false; - return immBeginBatch(prim_type, vertex_ct); + imm.strict_vertex_len = false; + return immBeginBatch(prim_type, vertex_len); } #endif // IMM_BATCH_COMBO @@ -319,7 +319,7 @@ static void immDrawSetup(void) const unsigned stride = imm.vertex_format.stride; - for (unsigned a_idx = 0; a_idx < imm.vertex_format.attrib_ct; ++a_idx) + for (unsigned a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) { const Gwn_VertAttr* a = imm.vertex_format.attribs + a_idx; @@ -334,13 +334,13 @@ static void immDrawSetup(void) { case GWN_FETCH_FLOAT: case GWN_FETCH_INT_TO_FLOAT: - glVertexAttribPointer(loc, a->comp_ct, a->gl_comp_type, GL_FALSE, stride, pointer); + glVertexAttribPointer(loc, a->comp_len, a->gl_comp_type, GL_FALSE, stride, pointer); break; case GWN_FETCH_INT_TO_FLOAT_UNIT: - glVertexAttribPointer(loc, a->comp_ct, a->gl_comp_type, GL_TRUE, stride, pointer); + glVertexAttribPointer(loc, a->comp_len, a->gl_comp_type, GL_TRUE, stride, pointer); break; case GWN_FETCH_INT: - glVertexAttribIPointer(loc, a->comp_ct, a->gl_comp_type, stride, pointer); + glVertexAttribIPointer(loc, a->comp_len, a->gl_comp_type, stride, pointer); } } @@ -355,20 +355,20 @@ void immEnd(void) #endif unsigned buffer_bytes_used; - if (imm.strict_vertex_ct) + if (imm.strict_vertex_len) { #if TRUST_NO_ONE - assert(imm.vertex_idx == imm.vertex_ct); // with all vertices defined + assert(imm.vertex_idx == imm.vertex_len); // with all vertices defined #endif buffer_bytes_used = imm.buffer_bytes_mapped; } else { #if TRUST_NO_ONE - assert(imm.vertex_idx <= imm.vertex_ct); + assert(imm.vertex_idx <= imm.vertex_len); #endif - // printf("used %u of %u verts,", imm.vertex_idx, imm.vertex_ct); - if (imm.vertex_idx == imm.vertex_ct) + // printf("used %u of %u verts,", imm.vertex_idx, imm.vertex_len); + if (imm.vertex_idx == imm.vertex_len) { buffer_bytes_used = imm.buffer_bytes_mapped; } @@ -377,8 +377,8 @@ void immEnd(void) #if TRUST_NO_ONE assert(imm.vertex_idx == 0 || vertex_count_makes_sense_for_primitive(imm.vertex_idx, imm.prim_type)); #endif - imm.vertex_ct = imm.vertex_idx; - buffer_bytes_used = vertex_buffer_size(&imm.vertex_format, imm.vertex_ct); + imm.vertex_len = imm.vertex_idx; + buffer_bytes_used = vertex_buffer_size(&imm.vertex_format, imm.vertex_len); // unused buffer bytes are available to the next immBegin // printf(" %u of %u bytes\n", buffer_bytes_used, imm.buffer_bytes_mapped); } @@ -393,7 +393,7 @@ void immEnd(void) { if (buffer_bytes_used != imm.buffer_bytes_mapped) { - GWN_vertbuf_data_resize(imm.batch->verts[0], imm.vertex_ct); + GWN_vertbuf_data_resize(imm.batch->verts[0], imm.vertex_len); // TODO: resize only if vertex count is much smaller } @@ -406,10 +406,10 @@ void immEnd(void) { glUnmapBuffer(GL_ARRAY_BUFFER); - if (imm.vertex_ct > 0) + if (imm.vertex_len > 0) { immDrawSetup(); - glDrawArrays(convert_prim_type_to_gl(imm.prim_type), 0, imm.vertex_ct); + glDrawArrays(convert_prim_type_to_gl(imm.prim_type), 0, imm.vertex_len); } glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -421,7 +421,7 @@ void immEnd(void) // prep for next immBegin imm.prim_type = GWN_PRIM_NONE; - imm.strict_vertex_ct = true; + imm.strict_vertex_len = true; } static void setAttribValueBit(unsigned attrib_id) @@ -443,10 +443,10 @@ void immAttrib1f(unsigned attrib_id, float x) Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_F32); - assert(attrib->comp_ct == 1); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 1); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -463,10 +463,10 @@ void immAttrib2f(unsigned attrib_id, float x, float y) Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_F32); - assert(attrib->comp_ct == 2); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 2); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -484,10 +484,10 @@ void immAttrib3f(unsigned attrib_id, float x, float y, float z) Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_F32); - assert(attrib->comp_ct == 3); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 3); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -506,10 +506,10 @@ void immAttrib4f(unsigned attrib_id, float x, float y, float z, float w) Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_F32); - assert(attrib->comp_ct == 4); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 4); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -529,10 +529,10 @@ void immAttrib1u(unsigned attrib_id, unsigned x) Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_U32); - assert(attrib->comp_ct == 1); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 1); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -548,10 +548,10 @@ void immAttrib2i(unsigned attrib_id, int x, int y) Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_I32); - assert(attrib->comp_ct == 2); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 2); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -568,10 +568,10 @@ void immAttrib2s(unsigned attrib_id, short x, short y) Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_I16); - assert(attrib->comp_ct == 2); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 2); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -603,10 +603,10 @@ void immAttrib3ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_U8); - assert(attrib->comp_ct == 3); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 3); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -625,10 +625,10 @@ void immAttrib4ub(unsigned attrib_id, unsigned char r, unsigned char g, unsigned Gwn_VertAttr* attrib = imm.vertex_format.attribs + attrib_id; #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); + assert(attrib_id < imm.vertex_format.attr_len); assert(attrib->comp_type == GWN_COMP_U8); - assert(attrib->comp_ct == 4); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib->comp_len == 4); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -656,8 +656,8 @@ void immAttrib4ubv(unsigned attrib_id, const unsigned char data[4]) void immSkipAttrib(unsigned attrib_id) { #if TRUST_NO_ONE - assert(attrib_id < imm.vertex_format.attrib_ct); - assert(imm.vertex_idx < imm.vertex_ct); + assert(attrib_id < imm.vertex_format.attr_len); + assert(imm.vertex_idx < imm.vertex_len); assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair #endif @@ -668,7 +668,7 @@ static void immEndVertex(void) // and move on to the next vertex { #if TRUST_NO_ONE assert(imm.prim_type != GWN_PRIM_NONE); // make sure we're between a Begin/End pair - assert(imm.vertex_idx < imm.vertex_ct); + assert(imm.vertex_idx < imm.vertex_len); #endif // have all attribs been assigned values? @@ -679,7 +679,7 @@ static void immEndVertex(void) // and move on to the next vertex assert(imm.vertex_idx > 0); // first vertex must have all attribs specified #endif - for (unsigned a_idx = 0; a_idx < imm.vertex_format.attrib_ct; ++a_idx) + for (unsigned a_idx = 0; a_idx < imm.vertex_format.attr_len; ++a_idx) { if ((imm.unassigned_attrib_bits >> a_idx) & 1) { diff --git a/intern/gawain/src/gwn_shader_interface.c b/intern/gawain/src/gwn_shader_interface.c index 16451573bba..d18af234fb0 100644 --- a/intern/gawain/src/gwn_shader_interface.c +++ b/intern/gawain/src/gwn_shader_interface.c @@ -203,19 +203,19 @@ Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) printf("Gwn_ShaderInterface %p, program %d\n", shaderface, program); #endif - GLint max_attrib_name_len, attrib_ct; + GLint max_attrib_name_len, attr_len; glGetProgramiv(program, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max_attrib_name_len); - glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &attrib_ct); + glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &attr_len); - GLint max_ubo_name_len, ubo_ct; + GLint max_ubo_name_len, ubo_len; glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCK_MAX_NAME_LENGTH, &max_ubo_name_len); - glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCKS, &ubo_ct); + glGetProgramiv(program, GL_ACTIVE_UNIFORM_BLOCKS, &ubo_len); - const uint32_t name_buffer_len = attrib_ct * max_attrib_name_len + ubo_ct * max_ubo_name_len; + const uint32_t name_buffer_len = attr_len * max_attrib_name_len + ubo_len * max_ubo_name_len; shaderface->name_buffer = malloc(name_buffer_len); // Attributes - for (uint32_t i = 0; i < attrib_ct; ++i) + for (uint32_t i = 0; i < attr_len; ++i) { Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; @@ -245,7 +245,7 @@ Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) } // Uniform Blocks - for (uint32_t i = 0; i < ubo_ct; ++i) + for (uint32_t i = 0; i < ubo_len; ++i) { Gwn_ShaderInput* input = malloc(sizeof(Gwn_ShaderInput)); GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; @@ -274,8 +274,8 @@ Gwn_ShaderInterface* GWN_shaderinterface_create(int32_t program) } // Batches ref buffer - shaderface->batches_ct = GWN_SHADERINTERFACE_REF_ALLOC_COUNT; - shaderface->batches = calloc(shaderface->batches_ct, sizeof(Gwn_Batch*)); + shaderface->batches_len = GWN_SHADERINTERFACE_REF_ALLOC_COUNT; + shaderface->batches = calloc(shaderface->batches_len, sizeof(Gwn_Batch*)); return shaderface; } @@ -289,7 +289,7 @@ void GWN_shaderinterface_discard(Gwn_ShaderInterface* shaderface) // Free memory used by name_buffer. free(shaderface->name_buffer); // Remove this interface from all linked Batches vao cache. - for (int i = 0; i < shaderface->batches_ct; ++i) + for (int i = 0; i < shaderface->batches_len; ++i) if (shaderface->batches[i] != NULL) gwn_batch_remove_interface_ref(shaderface->batches[i], shaderface); @@ -333,16 +333,16 @@ const Gwn_ShaderInput* GWN_shaderinterface_attr(const Gwn_ShaderInterface* shade void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batch* batch) { int i; // find first unused slot - for (i = 0; i < shaderface->batches_ct; ++i) + for (i = 0; i < shaderface->batches_len; ++i) if (shaderface->batches[i] == NULL) break; - if (i == shaderface->batches_ct) + if (i == shaderface->batches_len) { // Not enough place, realloc the array. - i = shaderface->batches_ct; - shaderface->batches_ct += GWN_SHADERINTERFACE_REF_ALLOC_COUNT; - shaderface->batches = realloc(shaderface->batches, sizeof(Gwn_Batch*) * shaderface->batches_ct); + i = shaderface->batches_len; + shaderface->batches_len += GWN_SHADERINTERFACE_REF_ALLOC_COUNT; + shaderface->batches = realloc(shaderface->batches, sizeof(Gwn_Batch*) * shaderface->batches_len); memset(shaderface->batches + i, 0, sizeof(Gwn_Batch*) * GWN_SHADERINTERFACE_REF_ALLOC_COUNT); } @@ -351,7 +351,7 @@ void GWN_shaderinterface_add_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batc void GWN_shaderinterface_remove_batch_ref(Gwn_ShaderInterface* shaderface, Gwn_Batch* batch) { - for (int i = 0; i < shaderface->batches_ct; ++i) + for (int i = 0; i < shaderface->batches_len; ++i) { if (shaderface->batches[i] == batch) { diff --git a/intern/gawain/src/gwn_vertex_array_id.cpp b/intern/gawain/src/gwn_vertex_array_id.cpp index d4b89a0f62b..70294565e6a 100644 --- a/intern/gawain/src/gwn_vertex_array_id.cpp +++ b/intern/gawain/src/gwn_vertex_array_id.cpp @@ -60,8 +60,8 @@ static void clear_orphans(Gwn_Context* ctx) ctx->orphans_mutex.lock(); if (!ctx->orphaned_vertarray_ids.empty()) { - unsigned orphan_ct = (unsigned)ctx->orphaned_vertarray_ids.size(); - glDeleteVertexArrays(orphan_ct, ctx->orphaned_vertarray_ids.data()); + unsigned orphan_len = (unsigned)ctx->orphaned_vertarray_ids.size(); + glDeleteVertexArrays(orphan_len, ctx->orphaned_vertarray_ids.data()); ctx->orphaned_vertarray_ids.clear(); } ctx->orphans_mutex.unlock(); diff --git a/intern/gawain/src/gwn_vertex_buffer.c b/intern/gawain/src/gwn_vertex_buffer.c index f621b4c01b9..a372c62bd0a 100644 --- a/intern/gawain/src/gwn_vertex_buffer.c +++ b/intern/gawain/src/gwn_vertex_buffer.c @@ -81,11 +81,11 @@ void GWN_vertbuf_discard(Gwn_VertBuf* verts) unsigned GWN_vertbuf_size_get(const Gwn_VertBuf* verts) { - return vertex_buffer_size(&verts->format, verts->vertex_ct); + return vertex_buffer_size(&verts->format, verts->vertex_len); } // create a new allocation, discarding any existing data -void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, unsigned v_ct) +void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, unsigned v_len) { Gwn_VertFormat* format = &verts->format; if (!format->packed) @@ -93,7 +93,7 @@ void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, unsigned v_ct) #if TRUST_NO_ONE // catch any unnecessary use - assert(verts->vertex_alloc != v_ct || verts->data == NULL); + assert(verts->vertex_alloc != v_len || verts->data == NULL); #endif // only create the buffer the 1st time @@ -105,49 +105,49 @@ void GWN_vertbuf_data_alloc(Gwn_VertBuf* verts, unsigned v_ct) free(verts->data); #if VRAM_USAGE - unsigned new_size = vertex_buffer_size(&verts->format, v_ct); + unsigned new_size = vertex_buffer_size(&verts->format, v_len); vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); #endif verts->dirty = true; - verts->vertex_ct = verts->vertex_alloc = v_ct; + verts->vertex_len = verts->vertex_alloc = v_len; verts->data = malloc(sizeof(GLubyte) * GWN_vertbuf_size_get(verts)); } // resize buffer keeping existing data -void GWN_vertbuf_data_resize(Gwn_VertBuf* verts, unsigned v_ct) +void GWN_vertbuf_data_resize(Gwn_VertBuf* verts, unsigned v_len) { #if TRUST_NO_ONE assert(verts->data != NULL); - assert(verts->vertex_alloc != v_ct); + assert(verts->vertex_alloc != v_len); #endif #if VRAM_USAGE - unsigned new_size = vertex_buffer_size(&verts->format, v_ct); + unsigned new_size = vertex_buffer_size(&verts->format, v_len); vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); #endif verts->dirty = true; - verts->vertex_ct = verts->vertex_alloc = v_ct; + verts->vertex_len = verts->vertex_alloc = v_len; verts->data = realloc(verts->data, sizeof(GLubyte) * GWN_vertbuf_size_get(verts)); } // set vertex count but does not change allocation // only this many verts will be uploaded to the GPU and rendered // this is usefull for streaming data -void GWN_vertbuf_vertex_count_set(Gwn_VertBuf* verts, unsigned v_ct) +void GWN_vertbuf_vertex_count_set(Gwn_VertBuf* verts, unsigned v_len) { #if TRUST_NO_ONE assert(verts->data != NULL); // only for dynamic data - assert(v_ct <= verts->vertex_alloc); + assert(v_len <= verts->vertex_alloc); #endif #if VRAM_USAGE - unsigned new_size = vertex_buffer_size(&verts->format, v_ct); + unsigned new_size = vertex_buffer_size(&verts->format, v_len); vbo_memory_usage += new_size - GWN_vertbuf_size_get(verts); #endif - verts->vertex_ct = v_ct; + verts->vertex_len = v_len; } void GWN_vertbuf_attr_set(Gwn_VertBuf* verts, unsigned a_idx, unsigned v_idx, const void* data) @@ -156,7 +156,7 @@ void GWN_vertbuf_attr_set(Gwn_VertBuf* verts, unsigned a_idx, unsigned v_idx, co const Gwn_VertAttr* a = format->attribs + a_idx; #if TRUST_NO_ONE - assert(a_idx < format->attrib_ct); + assert(a_idx < format->attr_len); assert(v_idx < verts->vertex_alloc); assert(verts->data != NULL); #endif @@ -171,7 +171,7 @@ void GWN_vertbuf_attr_fill(Gwn_VertBuf* verts, unsigned a_idx, const void* data) const Gwn_VertAttr* a = format->attribs + a_idx; #if TRUST_NO_ONE - assert(a_idx < format->attrib_ct); + assert(a_idx < format->attr_len); #endif const unsigned stride = a->sz; // tightly packed input data @@ -185,22 +185,22 @@ void GWN_vertbuf_attr_fill_stride(Gwn_VertBuf* verts, unsigned a_idx, unsigned s const Gwn_VertAttr* a = format->attribs + a_idx; #if TRUST_NO_ONE - assert(a_idx < format->attrib_ct); + assert(a_idx < format->attr_len); assert(verts->data != NULL); #endif verts->dirty = true; - const unsigned vertex_ct = verts->vertex_ct; + const unsigned vertex_len = verts->vertex_len; - if (format->attrib_ct == 1 && stride == format->stride) + if (format->attr_len == 1 && stride == format->stride) { // we can copy it all at once - memcpy(verts->data, data, vertex_ct * a->sz); + memcpy(verts->data, data, vertex_len * a->sz); } else { // we must copy it per vertex - for (unsigned v = 0; v < vertex_ct; ++v) + for (unsigned v = 0; v < vertex_len; ++v) memcpy((GLubyte*)verts->data + a->offset + v * format->stride, (const GLubyte*)data + v * stride, a->sz); } } @@ -211,7 +211,7 @@ void GWN_vertbuf_attr_get_raw_data(Gwn_VertBuf* verts, unsigned a_idx, Gwn_VertB const Gwn_VertAttr* a = format->attribs + a_idx; #if TRUST_NO_ONE - assert(a_idx < format->attrib_ct); + assert(a_idx < format->attr_len); assert(verts->data != NULL); #endif 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)); |