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.
This commit is contained in:
Campbell Barton 2020-04-03 16:59:34 +11:00
parent 05dcb007e1
commit 973e1f9d9a
26 changed files with 110 additions and 113 deletions

View File

@ -99,7 +99,7 @@ static void blf_batch_draw_init(void)
GPU_vertbuf_attr_get_raw_data(g_batch.verts, g_batch.glyph_size_loc, &g_batch.glyph_size_step);
g_batch.glyph_len = 0;
/* A dummy vbo containing 4 points, attribs are not used. */
/* A dummy VBO containing 4 points, attributes are not used. */
GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format);
GPU_vertbuf_data_alloc(vbo, 4);

View File

@ -212,7 +212,7 @@ uniform vec4 layerTint;
uniform float layerOpacity; /* Used for onion skin. */
uniform float strokeIndexOffset = 0.0;
/* All of these attribs are quad loaded the same way
/* All of these attributes are quad loaded the same way
* as GL_LINES_ADJACENCY would feed a geometry shader:
* - ma reference the previous adjacency point.
* - ma1 reference the current line first point.
@ -236,7 +236,7 @@ in vec4 uv2;
in vec4 col1;
in vec4 col2;
in vec4 fcol1;
/* WARNING: Max attrib count is actually 14 because OSX OpenGL implementation
/* WARNING: Max attribute count is actually 14 because OSX OpenGL implementation
* considers gl_VertexID and gl_InstanceID as vertex attribute. (see T74536) */
# define stroke_id1 ma1.y
# define point_id1 ma1.z
@ -389,7 +389,7 @@ void stroke_vertex()
mat4 model_mat = model_matrix_get();
/* Avoid using a vertex attrib for quad positioning. */
/* Avoid using a vertex attribute for quad positioning. */
float x = float(gl_VertexID & 1) * 2.0 - 1.0; /* [-1..1] */
float y = float(gl_VertexID & 2) - 1.0; /* [-1..1] */

View File

@ -254,7 +254,7 @@ static void overlay_edit_mesh_add_ob_to_pass(OVERLAY_PrivateData *pd, Object *ob
if (has_skin_roots) {
circle = DRW_cache_circle_get();
skin_roots = DRW_mesh_batch_cache_get_edit_skin_roots(ob->data);
DRW_shgroup_call_instances_with_attribs(skin_roots_shgrp, ob, circle, skin_roots);
DRW_shgroup_call_instances_with_attrs(skin_roots_shgrp, ob, circle, skin_roots);
}
}
@ -292,15 +292,15 @@ void OVERLAY_edit_mesh_cache_populate(OVERLAY_Data *vedata, Object *ob)
struct GPUBatch *normal_geom = DRW_cache_normal_arrow_get();
if (vnormals_do) {
geom = DRW_mesh_batch_cache_get_edit_vnors(ob->data);
DRW_shgroup_call_instances_with_attribs(pd->edit_mesh_normals_grp, ob, normal_geom, geom);
DRW_shgroup_call_instances_with_attrs(pd->edit_mesh_normals_grp, ob, normal_geom, geom);
}
if (lnormals_do) {
geom = DRW_mesh_batch_cache_get_edit_lnors(ob->data);
DRW_shgroup_call_instances_with_attribs(pd->edit_mesh_normals_grp, ob, normal_geom, geom);
DRW_shgroup_call_instances_with_attrs(pd->edit_mesh_normals_grp, ob, normal_geom, geom);
}
if (fnormals_do) {
geom = DRW_mesh_batch_cache_get_edit_facedots(ob->data);
DRW_shgroup_call_instances_with_attribs(pd->edit_mesh_normals_grp, ob, normal_geom, geom);
DRW_shgroup_call_instances_with_attrs(pd->edit_mesh_normals_grp, ob, normal_geom, geom);
}
}

View File

@ -205,7 +205,7 @@ void OVERLAY_particle_cache_populate(OVERLAY_Data *vedata, Object *ob)
grp = DRW_shgroup_create_sub(pd->particle_shapes_grp);
DRW_shgroup_uniform_vec4_copy(grp, "color", color);
shape = DRW_cache_particles_get_prim(draw_as);
DRW_shgroup_call_instances_with_attribs(grp, NULL, shape, geom);
DRW_shgroup_call_instances_with_attrs(grp, NULL, shape, geom);
break;
}
}

View File

@ -713,7 +713,7 @@ GPUShader *OVERLAY_shader_edit_mesh_normal(void)
datatoc_edit_mesh_normal_vert_glsl,
NULL},
.frag = (const char *[]){datatoc_gpu_shader_flat_color_frag_glsl, NULL},
.defs = (const char *[]){sh_cfg->def, "#define INSTANCED_ATTRIB\n", NULL},
.defs = (const char *[]){sh_cfg->def, "#define INSTANCED_ATTR\n", NULL},
});
}
return sh_data->edit_mesh_normals;
@ -750,7 +750,7 @@ GPUShader *OVERLAY_shader_edit_mesh_skin_root(void)
datatoc_edit_mesh_skin_root_vert_glsl,
NULL},
.frag = (const char *[]){datatoc_gpu_shader_flat_color_frag_glsl, NULL},
.defs = (const char *[]){sh_cfg->def, "#define INSTANCED_ATTRIB\n", NULL},
.defs = (const char *[]){sh_cfg->def, "#define INSTANCED_ATTR\n", NULL},
});
}
return sh_data->edit_mesh_skin_root;
@ -1269,7 +1269,7 @@ GPUShader *OVERLAY_shader_particle_shape(void)
datatoc_particle_vert_glsl,
NULL},
.frag = (const char *[]){datatoc_gpu_shader_flat_color_frag_glsl, NULL},
.defs = (const char *[]){sh_cfg->def, "#define INSTANCED_ATTRIB\n", NULL},
.defs = (const char *[]){sh_cfg->def, "#define INSTANCED_ATTR\n", NULL},
});
}
return sh_data->particle_shape;

View File

@ -21,7 +21,7 @@ void main()
GPU_INTEL_VERTEX_SHADER_WORKAROUND
vec3 nor;
/* Select the right normal by cheking if the generic attrib is used. */
/* Select the right normal by checking if the generic attribute is used. */
if (!all(equal(lnor.xyz, vec3(0)))) {
if (lnor.w < 0.0) {
finalColor = vec4(0.0);

View File

@ -1,7 +1,7 @@
in vec3 pos;
in vec4 color;
in int colorid; /* if equal 0 (i.e: Not specified) use color attrib and stippling. */
in int colorid; /* if equal 0 (i.e: Not specified) use color attribute and stippling. */
noperspective out vec2 stipple_coord;
flat out vec2 stipple_start;

View File

@ -101,8 +101,8 @@ void wire_object_color_get(out vec3 rim_col, out vec3 wire_col)
void main()
{
bool no_attrib = all(equal(nor, vec3(0)));
vec3 wnor = no_attrib ? ViewMatrixInverse[2].xyz : normalize(normal_object_to_world(nor));
bool no_attr = all(equal(nor, vec3(0)));
vec3 wnor = no_attr ? ViewMatrixInverse[2].xyz : normalize(normal_object_to_world(nor));
vec3 wpos = point_object_to_world(pos);
@ -152,7 +152,7 @@ void main()
#endif
/* Cull flat edges below threshold. */
if (!no_attrib && (get_edge_sharpness(wd) < 0.0)) {
if (!no_attr && (get_edge_sharpness(wd) < 0.0)) {
edgeStart = vec2(-1.0);
}

View File

@ -404,11 +404,11 @@ void DRW_shgroup_call_instances(DRWShadingGroup *shgroup,
Object *ob,
struct GPUBatch *geom,
uint count);
/* Warning: Only use with Shaders that have INSTANCED_ATTRIB defined. */
void DRW_shgroup_call_instances_with_attribs(DRWShadingGroup *shgroup,
Object *ob,
struct GPUBatch *geom,
struct GPUBatch *inst_attributes);
/* Warning: Only use with Shaders that have INSTANCED_ATTR defined. */
void DRW_shgroup_call_instances_with_attrs(DRWShadingGroup *shgroup,
Object *ob,
struct GPUBatch *geom,
struct GPUBatch *inst_attributes);
void DRW_shgroup_call_sculpt(DRWShadingGroup *sh, Object *ob, bool wire, bool mask, bool vcol);
void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **sh, Object *ob, bool vcol);

View File

@ -1775,10 +1775,10 @@ static void *extract_uv_init(const MeshRenderData *mr, void *buf)
for (int i = 0; i < MAX_MTFACE; i++) {
if (uv_layers & (1 << i)) {
char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME];
char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
const char *layer_name = CustomData_get_layer_name(cd_ldata, CD_MLOOPUV, i);
GPU_vertformat_safe_attrib_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME);
GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
/* UV layer name. */
BLI_snprintf(attr_name, sizeof(attr_name), "u%s", attr_safe_name);
GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@ -1882,9 +1882,9 @@ static void extract_tan_ex(const MeshRenderData *mr, GPUVertBuf *vbo, const bool
for (int i = 0; i < MAX_MTFACE; i++) {
if (tan_layers & (1 << i)) {
char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME];
char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
const char *layer_name = CustomData_get_layer_name(cd_ldata, CD_MLOOPUV, i);
GPU_vertformat_safe_attrib_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME);
GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
/* Tangent layer name. */
BLI_snprintf(attr_name, sizeof(attr_name), "t%s", attr_safe_name);
GPU_vertformat_attr_add(&format, attr_name, comp_type, 4, fetch_mode);
@ -1959,9 +1959,9 @@ static void extract_tan_ex(const MeshRenderData *mr, GPUVertBuf *vbo, const bool
}
if (use_orco_tan) {
char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME];
char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
const char *layer_name = CustomData_get_layer_name(cd_ldata, CD_TANGENT, 0);
GPU_vertformat_safe_attrib_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME);
GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
BLI_snprintf(attr_name, sizeof(*attr_name), "t%s", attr_safe_name);
GPU_vertformat_attr_add(&format, attr_name, comp_type, 4, fetch_mode);
GPU_vertformat_alias_add(&format, "t");
@ -2090,9 +2090,9 @@ static void *extract_vcol_init(const MeshRenderData *mr, void *buf)
for (int i = 0; i < 8; i++) {
if (vcol_layers & (1 << i)) {
char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME];
char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
const char *layer_name = CustomData_get_layer_name(cd_ldata, CD_MLOOPCOL, i);
GPU_vertformat_safe_attrib_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME);
GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
BLI_snprintf(attr_name, sizeof(attr_name), "c%s", attr_safe_name);
GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_U16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
@ -2164,7 +2164,7 @@ static void *extract_orco_init(const MeshRenderData *mr, void *buf)
static GPUVertFormat format = {0};
if (format.attr_len == 0) {
/* FIXME(fclem): We use the last component as a way to differentiate from generic vertex
* attribs. This is a substantial waste of Vram and should be done another way.
* attributes. This is a substantial waste of Vram and should be done another way.
* Unfortunately, at the time of writing, I did not found any other "non disruptive"
* alternative. */
GPU_vertformat_attr_add(&format, "orco", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
@ -2192,7 +2192,7 @@ static void extract_orco_loop_bmesh(const MeshRenderData *UNUSED(mr),
MeshExtract_Orco_Data *orco_data = (MeshExtract_Orco_Data *)data;
float *loop_orco = orco_data->vbo_data[l];
copy_v3_v3(loop_orco, orco_data->orco[BM_elem_index_get(loop->v)]);
loop_orco[3] = 0.0; /* Tag as not a generic attrib */
loop_orco[3] = 0.0; /* Tag as not a generic attribute. */
}
static void extract_orco_loop_mesh(const MeshRenderData *UNUSED(mr),
@ -2205,7 +2205,7 @@ static void extract_orco_loop_mesh(const MeshRenderData *UNUSED(mr),
MeshExtract_Orco_Data *orco_data = (MeshExtract_Orco_Data *)data;
float *loop_orco = orco_data->vbo_data[l];
copy_v3_v3(loop_orco, orco_data->orco[mloop->v]);
loop_orco[3] = 0.0; /* Tag as not a generic attrib */
loop_orco[3] = 0.0; /* Tag as not a generic attribute. */
}
static void extract_orco_finish(const MeshRenderData *UNUSED(mr), void *UNUSED(buf), void *data)

View File

@ -174,7 +174,8 @@ static GPUVertFormat *gpencil_stroke_format(void)
GPU_vertformat_attr_add(&format, "ma", GPU_COMP_I32, 4, GPU_FETCH_INT);
GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
GPU_vertformat_attr_add(&format, "uv", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
/* IMPORTANT: This means having only 4 attributes to fit into GPU module limit of 16 attrib. */
/* IMPORTANT: This means having only 4 attributes
* to fit into GPU module limit of 16 attributes. */
GPU_vertformat_multiload_enable(&format, 4);
}
return &format;
@ -208,7 +209,8 @@ static GPUVertFormat *gpencil_color_format(void)
if (format.attr_len == 0) {
GPU_vertformat_attr_add(&format, "col", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
GPU_vertformat_attr_add(&format, "fcol", GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
/* IMPORTANT: This means having only 4 attributes to fit into GPU module limit of 16 attrib. */
/* IMPORTANT: This means having only 4 attributes
* to fit into GPU module limit of 16 attributes. */
GPU_vertformat_multiload_enable(&format, 4);
}
return &format;

View File

@ -561,7 +561,7 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, int mode)
mesh_batch_cache_discard_uvedit_select(cache);
break;
case BKE_MESH_BATCH_DIRTY_SELECT_PAINT:
/* Paint mode selection flag is packed inside the nor attrib.
/* Paint mode selection flag is packed inside the nor attribute.
* Note that it can be slow if auto smooth is enabled. (see T63946) */
FOREACH_MESH_BUFFER_CACHE (cache, mbufcache) {
GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.lines_paint_mask);
@ -1173,10 +1173,10 @@ void DRW_mesh_batch_cache_create_requested(
MeshBufferCache *mbufcache = &cache->final;
/* Init batches and request VBOs & IBOs */
/* Initialize batches and request VBO's & IBO's. */
if (DRW_batch_requested(cache->batch.surface, GPU_PRIM_TRIS)) {
DRW_ibo_request(cache->batch.surface, &mbufcache->ibo.tris);
/* Order matters. First ones override latest vbos' attribs. */
/* Order matters. First ones override latest VBO's attributes. */
DRW_vbo_request(cache->batch.surface, &mbufcache->vbo.lnor);
DRW_vbo_request(cache->batch.surface, &mbufcache->vbo.pos_nor);
if (cache->cd_used.uv != 0) {
@ -1209,7 +1209,7 @@ void DRW_mesh_batch_cache_create_requested(
}
if (DRW_batch_requested(cache->batch.wire_loops, GPU_PRIM_LINES)) {
DRW_ibo_request(cache->batch.wire_loops, &mbufcache->ibo.lines_paint_mask);
/* Order matters. First ones override latest vbos' attribs. */
/* Order matters. First ones override latest VBO's attributes. */
DRW_vbo_request(cache->batch.wire_loops, &mbufcache->vbo.lnor);
DRW_vbo_request(cache->batch.wire_loops, &mbufcache->vbo.pos_nor);
}
@ -1241,7 +1241,7 @@ void DRW_mesh_batch_cache_create_requested(
else {
DRW_ibo_request(cache->surface_per_mat[i], &mbufcache->ibo.tris);
}
/* Order matters. First ones override latest vbos' attribs. */
/* Order matters. First ones override latest VBO's attributes. */
DRW_vbo_request(cache->surface_per_mat[i], &mbufcache->vbo.lnor);
DRW_vbo_request(cache->surface_per_mat[i], &mbufcache->vbo.pos_nor);
if (cache->cd_used.uv != 0) {

View File

@ -877,9 +877,9 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit
GPU_vertbuf_data_alloc(cache->proc_uv_buf[i], cache->strands_len);
GPU_vertbuf_attr_get_raw_data(cache->proc_uv_buf[i], uv_id, &uv_step[i]);
char attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME];
char attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i);
GPU_vertformat_safe_attrib_name(name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME);
GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
int n = 0;
BLI_snprintf(cache->uv_layer_names[i][n++], MAX_LAYER_NAME_LEN, "u%s", attr_safe_name);
@ -898,9 +898,9 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit
GPU_vertbuf_data_alloc(cache->proc_col_buf[i], cache->strands_len);
GPU_vertbuf_attr_get_raw_data(cache->proc_col_buf[i], col_id, &col_step[i]);
char attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME];
char attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPCOL, i);
GPU_vertformat_safe_attrib_name(name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME);
GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
int n = 0;
BLI_snprintf(cache->col_layer_names[i][n++], MAX_LAYER_NAME_LEN, "c%s", attr_safe_name);
@ -1164,9 +1164,9 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit,
for (int i = 0; i < num_uv_layers; i++) {
char uuid[32], attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME];
char uuid[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i);
GPU_vertformat_safe_attrib_name(name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME);
GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
BLI_snprintf(uuid, sizeof(uuid), "u%s", attr_safe_name);
uv_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
@ -1177,9 +1177,9 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit,
}
for (int i = 0; i < num_col_layers; i++) {
char uuid[32], attr_safe_name[GPU_MAX_SAFE_ATTRIB_NAME];
char uuid[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPCOL, i);
GPU_vertformat_safe_attrib_name(name, attr_safe_name, GPU_MAX_SAFE_ATTRIB_NAME);
GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME);
BLI_snprintf(uuid, sizeof(uuid), "c%s", attr_safe_name);
col_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_U16, 4, GPU_FETCH_FLOAT);

View File

@ -25,7 +25,7 @@
#define __DRAW_HAIR_PRIVATE_H__
#define MAX_LAYER_NAME_CT 4 /* u0123456789, u, au, a0123456789 */
#define MAX_LAYER_NAME_LEN GPU_MAX_SAFE_ATTRIB_NAME + 2
#define MAX_LAYER_NAME_LEN GPU_MAX_SAFE_ATTR_NAME + 2
#define MAX_THICKRES 2 /* see eHairType */
#define MAX_HAIR_SUBDIV 4 /* see hair_subdiv rna */

View File

@ -210,7 +210,7 @@ typedef struct DRWCommandDrawInstance {
GPUBatch *batch;
DRWResourceHandle handle;
uint inst_count;
uint use_attribs; /* bool */
uint use_attrs; /* bool */
} DRWCommandDrawInstance;
typedef struct DRWCommandDrawInstanceRange {

View File

@ -657,17 +657,14 @@ static void drw_command_draw_range(
cmd->vert_count = count;
}
static void drw_command_draw_instance(DRWShadingGroup *shgroup,
GPUBatch *batch,
DRWResourceHandle handle,
uint count,
bool use_attrib)
static void drw_command_draw_instance(
DRWShadingGroup *shgroup, GPUBatch *batch, DRWResourceHandle handle, uint count, bool use_attr)
{
DRWCommandDrawInstance *cmd = drw_command_create(shgroup, DRW_CMD_DRAW_INSTANCE);
cmd->batch = batch;
cmd->handle = handle;
cmd->inst_count = count;
cmd->use_attribs = use_attrib;
cmd->use_attrs = use_attr;
}
static void drw_command_draw_intance_range(
@ -841,10 +838,10 @@ void DRW_shgroup_call_instances(DRWShadingGroup *shgroup,
drw_command_draw_instance(shgroup, geom, handle, count, false);
}
void DRW_shgroup_call_instances_with_attribs(DRWShadingGroup *shgroup,
Object *ob,
struct GPUBatch *geom,
struct GPUBatch *inst_attributes)
void DRW_shgroup_call_instances_with_attrs(DRWShadingGroup *shgroup,
Object *ob,
struct GPUBatch *geom,
struct GPUBatch *inst_attributes)
{
BLI_assert(geom != NULL);
BLI_assert(inst_attributes != NULL);

View File

@ -1376,7 +1376,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
0,
0,
cmd->instance.inst_count,
cmd->instance.use_attribs == 0);
cmd->instance.use_attrs == 0);
break;
case DRW_CMD_DRAW_RANGE:
draw_call_single_do(shgroup,

View File

@ -77,12 +77,12 @@ uniform int resourceChunk;
uniform int baseInstance;
# endif
# if defined(IN_PLACE_INSTANCES) || defined(INSTANCED_ATTRIB)
# if defined(IN_PLACE_INSTANCES) || defined(INSTANCED_ATTR)
/* When drawing instances of an object at the same position. */
# define instanceId 0
# elif defined(GPU_DEPRECATED_AMD_DRIVER)
/* A driver bug make it so that when using an attribute with GL_INT_2_10_10_10_REV as format,
* the gl_InstanceID is incremented by the 2 bit component of the attrib.
* the gl_InstanceID is incremented by the 2 bit component of the attribute.
* Ignore gl_InstanceID then. */
# define instanceId 0
# else
@ -124,7 +124,7 @@ flat in int resourceIDFrag;
/* Breaking this across multiple lines causes issues for some older GLSL compilers. */
/* clang-format off */
#if !defined(GPU_INTEL) && !defined(GPU_DEPRECATED_AMD_DRIVER) && !defined(OS_MAC) && !defined(INSTANCED_ATTRIB)
#if !defined(GPU_INTEL) && !defined(GPU_DEPRECATED_AMD_DRIVER) && !defined(OS_MAC) && !defined(INSTANCED_ATTR)
/* clang-format on */
struct ObjectMatrices {
mat4 drw_modelMatrix;

View File

@ -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);

View File

@ -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 */

View File

@ -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();
}

View File

@ -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),

View File

@ -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);

View File

@ -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;

View File

@ -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)
{

View File

@ -1938,12 +1938,12 @@ struct ImBuf *imb_load_openexr(const unsigned char *mem,
IMB_metadata_ensure(&ibuf->metadata);
for (iter = header.begin(); iter != header.end(); iter++) {
const StringAttribute *attrib = file->header(0).findTypedAttribute<StringAttribute>(
const StringAttribute *attr = file->header(0).findTypedAttribute<StringAttribute>(
iter.name());
/* not all attributes are string attributes so we might get some NULLs here */
if (attrib) {
IMB_metadata_set_field(ibuf->metadata, iter.name(), attrib->value().c_str());
if (attr) {
IMB_metadata_set_field(ibuf->metadata, iter.name(), attr->value().c_str());
ibuf->flags |= IB_metadata;
}
}