diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-04-03 08:59:34 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-04-03 09:25:58 +0300 |
commit | 973e1f9d9a967132cc76fbbcd485979ac27e10c5 (patch) | |
tree | 8b7c948cbabcbd9435f7fbaa04f4429cd8e0241a /source/blender/gpu | |
parent | 05dcb007e181c961c0db87c1ce4745ae2d1d0fd0 (diff) |
Cleanup: use term 'attr' instead of 'attrib'
This was already the case in most parts of the GPU API.
Use full name for descriptive-comments.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_shader_interface.h | 4 | ||||
-rw-r--r-- | source/blender/gpu/GPU_vertex_format.h | 6 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_batch.c | 34 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_codegen.c | 4 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader_interface.c | 4 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_vertex_buffer.c | 2 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_vertex_format.c | 36 |
7 files changed, 44 insertions, 46 deletions
diff --git a/source/blender/gpu/GPU_shader_interface.h b/source/blender/gpu/GPU_shader_interface.h index 7a8900997d0..f0c1c4c0b98 100644 --- a/source/blender/gpu/GPU_shader_interface.h +++ b/source/blender/gpu/GPU_shader_interface.h @@ -88,8 +88,8 @@ typedef struct GPUShaderInterface { char *name_buffer; struct GPUBatch **batches; /* references to batches using this interface */ uint batches_len; - /** All enabled attribs in this shader. Used to set default values for unbound attribs. */ - uint16_t enabled_attrib_mask; + /** All enabled attributes in this shader. Used to set default values for unbound attributes. */ + uint16_t enabled_attr_mask; } GPUShaderInterface; GPUShaderInterface *GPU_shaderinterface_create(int32_t program_id); diff --git a/source/blender/gpu/GPU_vertex_format.h b/source/blender/gpu/GPU_vertex_format.h index 7e384d0a692..7adad2ff831 100644 --- a/source/blender/gpu/GPU_vertex_format.h +++ b/source/blender/gpu/GPU_vertex_format.h @@ -39,7 +39,7 @@ extern "C" { #define GPU_VERT_ATTR_NAMES_BUF_LEN 256 #define GPU_VERT_FORMAT_MAX_NAMES 63 /* More than enough, actual max is ~30. */ /* Computed as GPU_VERT_ATTR_NAMES_BUF_LEN / 30 (actual max format name). */ -#define GPU_MAX_SAFE_ATTRIB_NAME 12 +#define GPU_MAX_SAFE_ATTR_NAME 12 typedef enum { GPU_COMP_I8, @@ -94,7 +94,7 @@ typedef struct GPUVertFormat { uint packed : 1; /** Current offset in names[]. */ uint name_offset : 8; - /** Store each attrib in one contiguous buffer region. */ + /** Store each attribute in one contiguous buffer region. */ uint deinterleaved : 1; GPUVertAttr attrs[GPU_VERT_ATTR_MAX_LEN]; @@ -125,7 +125,7 @@ BLI_INLINE const char *GPU_vertformat_attr_name_get(const GPUVertFormat *format, return format->names + attr->names[n_idx]; } -void GPU_vertformat_safe_attrib_name(const char *attrib_name, char *r_safe_name, uint max_len); +void GPU_vertformat_safe_attr_name(const char *attr_name, char *r_safe_name, uint max_len); /* format conversion */ diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index fcfa4b7f0af..b0a24b1f2ff 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -42,7 +42,7 @@ #include <stdlib.h> #include <string.h> -static GLuint g_default_attrib_vbo = 0; +static GLuint g_default_attr_vbo = 0; static void batch_update_program_bindings(GPUBatch *batch, uint i_first); @@ -416,7 +416,7 @@ void gpu_batch_remove_interface_ref(GPUBatch *batch, const GPUShaderInterface *i static void create_bindings(GPUVertBuf *verts, const GPUShaderInterface *interface, - uint16_t *attrib_mask, + uint16_t *attr_mask, uint v_first, const bool use_instancing) { @@ -449,7 +449,7 @@ static void create_bindings(GPUVertBuf *verts, continue; } - *attrib_mask &= ~(1 << input->location); + *attr_mask &= ~(1 << input->location); if (a->comp_len == 16 || a->comp_len == 12 || a->comp_len == 8) { #if TRUST_NO_ONE @@ -492,27 +492,27 @@ static void create_bindings(GPUVertBuf *verts, static void batch_update_program_bindings(GPUBatch *batch, uint i_first) { - uint16_t attrib_mask = batch->interface->enabled_attrib_mask; + uint16_t attr_mask = batch->interface->enabled_attr_mask; - /* Reverse order so first vbos have more prevalence (in term of attrib override). */ + /* Reverse order so first VBO'S have more prevalence (in term of attribute override). */ for (int v = GPU_BATCH_VBO_MAX_LEN - 1; v > -1; v--) { if (batch->verts[v] != NULL) { - create_bindings(batch->verts[v], batch->interface, &attrib_mask, 0, false); + create_bindings(batch->verts[v], batch->interface, &attr_mask, 0, false); } } for (int v = GPU_BATCH_INST_VBO_MAX_LEN - 1; v > -1; v--) { if (batch->inst[v]) { - create_bindings(batch->inst[v], batch->interface, &attrib_mask, i_first, true); + create_bindings(batch->inst[v], batch->interface, &attr_mask, i_first, true); } } - if (attrib_mask != 0 && GLEW_ARB_vertex_attrib_binding) { + if (attr_mask != 0 && GLEW_ARB_vertex_attrib_binding) { for (uint16_t mask = 1, a = 0; a < 16; a++, mask <<= 1) { - if (attrib_mask & mask) { + if (attr_mask & mask) { /* This replaces glVertexAttrib4f(a, 0.0f, 0.0f, 0.0f, 1.0f); with a more modern style. * Fix issues for some drivers (see T75069). */ - glBindVertexBuffer(a, g_default_attrib_vbo, (intptr_t)0, (intptr_t)0); + glBindVertexBuffer(a, g_default_attr_vbo, (intptr_t)0, (intptr_t)0); glEnableVertexAttribArray(a); glVertexAttribFormat(a, 4, GL_FLOAT, GL_FALSE, 0); @@ -712,8 +712,8 @@ void GPU_batch_draw_advanced(GPUBatch *batch, int v_first, int v_count, int i_fi } /* Verify there is enough data do draw. */ - /* TODO(fclem) Nice to have but this is invalid when using procedural drawcalls. - * The right assert would be to check if there is an enabled attrib from each VBO + /* TODO(fclem) Nice to have but this is invalid when using procedural draw-calls. + * The right assert would be to check if there is an enabled attribute from each VBO * and check their length. */ // BLI_assert(i_first + i_count <= (batch->inst ? batch->inst->vertex_len : INT_MAX)); // BLI_assert(v_first + v_count <= @@ -1025,11 +1025,11 @@ void GPU_batch_program_set_imm_shader(GPUBatch *batch) void gpu_batch_init(void) { - if (g_default_attrib_vbo == 0) { - g_default_attrib_vbo = GPU_buf_alloc(); + if (g_default_attr_vbo == 0) { + g_default_attr_vbo = GPU_buf_alloc(); float default_attrib_data[4] = {0.0f, 0.0f, 0.0f, 1.0f}; - glBindBuffer(GL_ARRAY_BUFFER, g_default_attrib_vbo); + glBindBuffer(GL_ARRAY_BUFFER, g_default_attr_vbo); glBufferData(GL_ARRAY_BUFFER, sizeof(float) * 4, default_attrib_data, GL_STATIC_DRAW); glBindBuffer(GL_ARRAY_BUFFER, 0); } @@ -1039,8 +1039,8 @@ void gpu_batch_init(void) void gpu_batch_exit(void) { - GPU_buf_free(g_default_attrib_vbo); - g_default_attrib_vbo = 0; + GPU_buf_free(g_default_attr_vbo); + g_default_attr_vbo = 0; gpu_batch_presets_exit(); } diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c index 211ae0b3897..f279ab2c86c 100644 --- a/source/blender/gpu/intern/gpu_codegen.c +++ b/source/blender/gpu/intern/gpu_codegen.c @@ -689,8 +689,8 @@ static char *code_generate_vertex(GPUNodeGraph *graph, const char *vert_code, bo BLI_dynstr_appendf(ds, "#define att%d %s\n", attr->id, attr_prefix_get(attr->type)); } else { - char attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME]; - GPU_vertformat_safe_attrib_name(attr->name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME); + char attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; + GPU_vertformat_safe_attr_name(attr->name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); BLI_dynstr_appendf(ds, "DEFINE_ATTR(%s, %s%s);\n", gpu_data_type_to_string(attr->gputype), diff --git a/source/blender/gpu/intern/gpu_shader_interface.c b/source/blender/gpu/intern/gpu_shader_interface.c index 349a7217456..b877da3f1d5 100644 --- a/source/blender/gpu/intern/gpu_shader_interface.c +++ b/source/blender/gpu/intern/gpu_shader_interface.c @@ -236,7 +236,7 @@ GPUShaderInterface *GPU_shaderinterface_create(int32_t program) shaderface->name_buffer = MEM_mallocN(name_buffer_len, "name_buffer"); /* Attributes */ - shaderface->enabled_attrib_mask = 0; + shaderface->enabled_attr_mask = 0; for (uint32_t i = 0; i < attr_len; i++) { GPUShaderInput *input = MEM_mallocN(sizeof(GPUShaderInput), "GPUShaderInput Attr"); GLsizei remaining_buffer = name_buffer_len - shaderface->name_buffer_offset; @@ -256,7 +256,7 @@ GPUShaderInterface *GPU_shaderinterface_create(int32_t program) input->location = glGetAttribLocation(program, name); - shaderface->enabled_attrib_mask |= (1 << input->location); + shaderface->enabled_attr_mask |= (1 << input->location); set_input_name(shaderface, input, name, name_len); diff --git a/source/blender/gpu/intern/gpu_vertex_buffer.c b/source/blender/gpu/intern/gpu_vertex_buffer.c index 1df7e68e08b..25daabe601d 100644 --- a/source/blender/gpu/intern/gpu_vertex_buffer.c +++ b/source/blender/gpu/intern/gpu_vertex_buffer.c @@ -196,7 +196,7 @@ void GPU_vertbuf_attr_fill(GPUVertBuf *verts, uint a_idx, const void *data) GPU_vertbuf_attr_fill_stride(verts, a_idx, stride, data); } -/** Fills a whole vertex (all attribs). Data must match packed layout. */ +/** Fills a whole vertex (all attributes). Data must match packed layout. */ void GPU_vertbuf_vert_set(GPUVertBuf *verts, uint v_idx, const void *data) { const GPUVertFormat *format = &verts->format; diff --git a/source/blender/gpu/intern/gpu_vertex_format.c b/source/blender/gpu/intern/gpu_vertex_format.c index 8370bcf4beb..e6a9cb8f2f2 100644 --- a/source/blender/gpu/intern/gpu_vertex_format.c +++ b/source/blender/gpu/intern/gpu_vertex_format.c @@ -207,15 +207,15 @@ void GPU_vertformat_alias_add(GPUVertFormat *format, const char *alias) } /** - * Makes vertex attrib from the next vertices to be accessible in the vertex shader. - * For an attrib named "attr" you can access the next nth vertex using "attrn". - * Use this function after specifying all the attribs in the format. + * Makes vertex attribute from the next vertices to be accessible in the vertex shader. + * For an attribute named "attr" you can access the next nth vertex using "attr{number}". + * Use this function after specifying all the attributes in the format. * * NOTE: This does NOT work when using indexed rendering. - * NOTE: Only works for first attrib name. (this limitation can be changed if needed) + * NOTE: Only works for first attribute name. (this limitation can be changed if needed) * - * WARNING: this function creates a lot of aliases/attribs, make sure to keep the attrib name - * short to avoid overflowing the namebuffer. + * WARNING: this function creates a lot of aliases/attributes, make sure to keep the attribute + * name short to avoid overflowing the name-buffer. * */ void GPU_vertformat_multiload_enable(GPUVertFormat *format, int load_count) { @@ -276,28 +276,26 @@ static void safe_bytes(char out[11], const char data[8]) /* Warning: Always add a prefix to the result of this function as * the generated string can start with a number and not be a valid attribute name. */ -void GPU_vertformat_safe_attrib_name(const char *attrib_name, - char *r_safe_name, - uint UNUSED(max_len)) +void GPU_vertformat_safe_attr_name(const char *attr_name, char *r_safe_name, uint UNUSED(max_len)) { char data[8] = {0}; - uint len = strlen(attrib_name); + uint len = strlen(attr_name); if (len > 8) { /* Start with the first 4 chars of the name; */ for (int i = 0; i < 4; i++) { - data[i] = attrib_name[i]; + data[i] = attr_name[i]; } /* We use a hash to identify each data layer based on its name. * NOTE: This is still prone to hash collision but the risks are very low.*/ /* Start hashing after the first 2 chars. */ - *(uint *)&data[4] = BLI_ghashutil_strhash_p_murmur(attrib_name + 4); + *(uint *)&data[4] = BLI_ghashutil_strhash_p_murmur(attr_name + 4); } else { /* Copy the whole name. Collision is barely possible * (hash would have to be equal to the last 4 bytes). */ - for (int i = 0; i < 8 && attrib_name[i] != '\0'; i++) { - data[i] = attrib_name[i]; + for (int i = 0; i < 8 && attr_name[i] != '\0'; i++) { + data[i] = attr_name[i]; } } /* Convert to safe bytes characters. */ @@ -305,9 +303,9 @@ void GPU_vertformat_safe_attrib_name(const char *attrib_name, /* End the string */ r_safe_name[11] = '\0'; - BLI_assert(GPU_MAX_SAFE_ATTRIB_NAME >= 12); + BLI_assert(GPU_MAX_SAFE_ATTR_NAME >= 12); #if 0 /* For debugging */ - printf("%s > %lx > %s\n", attrib_name, *(uint64_t *)data, r_safe_name); + printf("%s > %lx > %s\n", attr_name, *(uint64_t *)data, r_safe_name); #endif } @@ -316,13 +314,13 @@ void GPU_vertformat_safe_attrib_name(const char *attrib_name, * Use direct buffer access to fill the data. * This is for advanced usage. * - * Deinterleaved data means all attrib data for each attrib - * is stored continuously like this : + * De-interleaved data means all attribute data for each attribute + * is stored continuously like this: * 000011112222 * instead of : * 012012012012 * - * Note this is per attrib deinterleaving, NOT per component. + * Note this is per attribute de-interleaving, NOT per component. * */ void GPU_vertformat_deinterleave(GPUVertFormat *format) { |