Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-01-28 23:46:25 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-01-29 00:32:25 +0300
commit68cab3aff63aea95830aa082a160200768d0e826 (patch)
tree3a042217ce34d84387cdfcca97316597800396db /source/blender/draw/intern
parenta9c297165878b3c427a20f787cc90a6ada4df253 (diff)
Cleanup: replace attrib w/ attr
Also rename GPUVertexAttribs to GPUVertAttrLayers, avoids confusion with GPUVertAttr which isn't closely related.
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r--source/blender/draw/intern/DRW_render.h20
-rw-r--r--source/blender/draw/intern/draw_cache_impl_curve.c14
-rw-r--r--source/blender/draw/intern/draw_cache_impl_mesh.c40
-rw-r--r--source/blender/draw/intern/draw_cache_impl_particles.c4
-rw-r--r--source/blender/draw/intern/draw_common.c148
-rw-r--r--source/blender/draw/intern/draw_instance_data.c22
-rw-r--r--source/blender/draw/intern/draw_instance_data.h2
-rw-r--r--source/blender/draw/intern/draw_manager.c4
-rw-r--r--source/blender/draw/intern/draw_manager.h17
-rw-r--r--source/blender/draw/intern/draw_manager_data.c35
10 files changed, 158 insertions, 148 deletions
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h
index 5bda5bc58b4..1c55d0f6347 100644
--- a/source/blender/draw/intern/DRW_render.h
+++ b/source/blender/draw/intern/DRW_render.h
@@ -319,21 +319,21 @@ typedef enum {
#define DRW_STATE_DEFAULT (DRW_STATE_WRITE_DEPTH | DRW_STATE_WRITE_COLOR | DRW_STATE_DEPTH_LESS_EQUAL)
typedef enum {
- DRW_ATTRIB_INT,
- DRW_ATTRIB_FLOAT,
-} DRWAttribType;
+ DRW_ATTR_INT,
+ DRW_ATTR_FLOAT,
+} eDRWAttrType;
-typedef struct DRWInstanceAttribFormat {
+typedef struct DRWInstanceAttrFormat {
char name[32];
- DRWAttribType type;
+ eDRWAttrType type;
int components;
-} DRWInstanceAttribFormat;
+} DRWInstanceAttrFormat;
-struct GPUVertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttribFormat attribs[], int arraysize);
+struct GPUVertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttrFormat attrs[], int arraysize);
#define DRW_shgroup_instance_format(format, ...) do { \
if (format == NULL) { \
- DRWInstanceAttribFormat drw_format[] = __VA_ARGS__;\
- format = DRW_shgroup_instance_format_array(drw_format, (sizeof(drw_format) / sizeof(DRWInstanceAttribFormat))); \
+ DRWInstanceAttrFormat drw_format[] = __VA_ARGS__;\
+ format = DRW_shgroup_instance_format_array(drw_format, (sizeof(drw_format) / sizeof(DRWInstanceAttrFormat))); \
} \
} while (0)
@@ -383,7 +383,7 @@ void DRW_shgroup_call_object_add_ex(
void DRW_shgroup_call_object_add_with_callback(
DRWShadingGroup *shgroup, struct GPUBatch *geom, struct Object *ob, struct Material *ma,
DRWCallVisibilityFn *callback, void *user_data);
-/* Used for drawing a batch with instancing without instance attribs. */
+/* Used for drawing a batch with instancing without instance attributes. */
void DRW_shgroup_call_instances_add(
DRWShadingGroup *shgroup, struct GPUBatch *geom, float (*obmat)[4], uint *count);
void DRW_shgroup_call_object_instances_add(
diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c
index b18168a6816..742ca20ba83 100644
--- a/source/blender/draw/intern/draw_cache_impl_curve.c
+++ b/source/blender/draw/intern/draw_cache_impl_curve.c
@@ -304,16 +304,16 @@ static int curve_render_data_normal_len_get(const CurveRenderData *rdata)
static void curve_cd_calc_used_gpu_layers(int *cd_layers, struct GPUMaterial **gpumat_array, int gpumat_array_len)
{
- GPUVertexAttribs gattribs = {{{0}}};
+ GPUVertAttrLayers gpu_attrs = {{{0}}};
for (int i = 0; i < gpumat_array_len; i++) {
struct GPUMaterial *gpumat = gpumat_array[i];
if (gpumat == NULL) {
continue;
}
- GPU_material_vertex_attributes(gpumat, &gattribs);
- for (int j = 0; j < gattribs.totlayer; j++) {
- const char *name = gattribs.layer[j].name;
- int type = gattribs.layer[j].type;
+ GPU_material_vertex_attrs(gpumat, &gpu_attrs);
+ for (int j = 0; j < gpu_attrs.totlayer; j++) {
+ const char *name = gpu_attrs.layer[j].name;
+ int type = gpu_attrs.layer[j].type;
/* Curves cannot have named layers.
* Note: We could relax this assumption later. */
@@ -662,7 +662,7 @@ static void curve_create_edit_curves_nor(CurveRenderData *rdata, GPUVertBuf *vbo
GPUPackedNormal pnor = GPU_normal_convert_i10_v3(nor);
GPUPackedNormal ptan = GPU_normal_convert_i10_v3(bevp->dir);
- /* Only set attribs for one vertex. */
+ /* Only set attributes for one vertex. */
GPU_vertbuf_attr_set(vbo_curves_nor, attr_id.pos, vbo_len_used, bevp->vec);
GPU_vertbuf_attr_set(vbo_curves_nor, attr_id.rad, vbo_len_used, &bevp->radius);
GPU_vertbuf_attr_set(vbo_curves_nor, attr_id.nor, vbo_len_used, &pnor);
@@ -897,7 +897,7 @@ void DRW_curve_batch_cache_create_requested(Object *ob)
Curve *cu = ob->data;
CurveBatchCache *cache = curve_batch_cache_get(cu);
- /* Verify that all surface batches have needed attrib layers. */
+ /* Verify that all surface batches have needed attribute layers. */
/* TODO(fclem): We could be a bit smarter here and only do it per material. */
for (int i = 0; i < cache->mat_len; ++i) {
if ((cache->cd_used & cache->cd_needed) != cache->cd_needed) {
diff --git a/source/blender/draw/intern/draw_cache_impl_mesh.c b/source/blender/draw/intern/draw_cache_impl_mesh.c
index 75ec4fa980f..94d5407983f 100644
--- a/source/blender/draw/intern/draw_cache_impl_mesh.c
+++ b/source/blender/draw/intern/draw_cache_impl_mesh.c
@@ -376,15 +376,15 @@ static void mesh_cd_calc_used_gpu_layers(
const CustomData *cd_ldata = (me->edit_btmesh) ? &me->edit_btmesh->bm->ldata : &me->ldata;
/* See: DM_vertex_attributes_from_gpu for similar logic */
- GPUVertexAttribs gattribs = {{{0}}};
+ GPUVertAttrLayers gpu_attrs = {{{0}}};
for (int i = 0; i < gpumat_array_len; i++) {
GPUMaterial *gpumat = gpumat_array[i];
if (gpumat) {
- GPU_material_vertex_attributes(gpumat, &gattribs);
- for (int j = 0; j < gattribs.totlayer; j++) {
- const char *name = gattribs.layer[j].name;
- int type = gattribs.layer[j].type;
+ GPU_material_vertex_attrs(gpumat, &gpu_attrs);
+ for (int j = 0; j < gpu_attrs.totlayer; j++) {
+ const char *name = gpu_attrs.layer[j].name;
+ int type = gpu_attrs.layer[j].type;
int layer = -1;
if (type == CD_AUTO_FROM_NAME) {
@@ -2101,7 +2101,7 @@ typedef struct MeshBatchCache {
GPUBatch **surf_per_mat;
/* arrays of bool uniform names (and value) that will be use to
- * set srgb conversion for auto attribs.*/
+ * set srgb conversion for auto attributes.*/
char *auto_layer_names;
int *auto_layer_is_srgb;
int auto_layer_len;
@@ -3103,15 +3103,15 @@ static void mesh_create_loop_uv_and_tan(MeshRenderData *rdata, GPUVertBuf *vbo)
GPUVertFormat format = { 0 };
for (uint i = 0; i < uv_len; i++) {
- const char *attrib_name = mesh_render_data_uv_layer_uuid_get(rdata, i);
+ const char *attr_name = mesh_render_data_uv_layer_uuid_get(rdata, i);
#if 0 /* these are clamped. Maybe use them as an option in the future */
- uv_id[i] = GPU_vertformat_attr_add(&format, attrib_name, GPU_COMP_I16, 2, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ uv_id[i] = GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_I16, 2, GPU_FETCH_INT_TO_FLOAT_UNIT);
#else
- uv_id[i] = GPU_vertformat_attr_add(&format, attrib_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ uv_id[i] = GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
#endif
/* Auto Name */
- attrib_name = mesh_render_data_uv_auto_layer_uuid_get(rdata, i);
- GPU_vertformat_alias_add(&format, attrib_name);
+ attr_name = mesh_render_data_uv_auto_layer_uuid_get(rdata, i);
+ GPU_vertformat_alias_add(&format, attr_name);
if (i == rdata->cd.layers.uv_active) {
GPU_vertformat_alias_add(&format, "u");
@@ -3119,18 +3119,18 @@ static void mesh_create_loop_uv_and_tan(MeshRenderData *rdata, GPUVertBuf *vbo)
}
for (uint i = 0; i < tangent_len; i++) {
- const char *attrib_name = mesh_render_data_tangent_layer_uuid_get(rdata, i);
+ const char *attr_name = mesh_render_data_tangent_layer_uuid_get(rdata, i);
#ifdef USE_COMP_MESH_DATA
- tangent_id[i] = GPU_vertformat_attr_add(&format, attrib_name, GPU_COMP_I16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ tangent_id[i] = GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_I16, 4, GPU_FETCH_INT_TO_FLOAT_UNIT);
#else
- tangent_id[i] = GPU_vertformat_attr_add(&format, attrib_name, GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
+ tangent_id[i] = GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_F32, 4, GPU_FETCH_FLOAT);
#endif
if (i == rdata->cd.layers.tangent_active) {
GPU_vertformat_alias_add(&format, "t");
}
}
- /* HACK: Create a dummy attrib in case there is no valid UV/tangent layer. */
+ /* HACK: Create a dummy attribute in case there is no valid UV/tangent layer. */
if (layers_combined_len == 0) {
GPU_vertformat_attr_add(&format, "dummy", GPU_COMP_U8, 1, GPU_FETCH_INT_TO_FLOAT_UNIT);
}
@@ -3218,12 +3218,12 @@ static void mesh_create_loop_vcol(MeshRenderData *rdata, GPUVertBuf *vbo)
GPUVertFormat format = { 0 };
for (uint i = 0; i < vcol_len; i++) {
- const char *attrib_name = mesh_render_data_vcol_layer_uuid_get(rdata, i);
- vcol_id[i] = GPU_vertformat_attr_add(&format, attrib_name, GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
+ const char *attr_name = mesh_render_data_vcol_layer_uuid_get(rdata, i);
+ vcol_id[i] = GPU_vertformat_attr_add(&format, attr_name, GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT);
/* Auto layer */
if (rdata->cd.layers.auto_vcol[i]) {
- attrib_name = mesh_render_data_vcol_auto_layer_uuid_get(rdata, i);
- GPU_vertformat_alias_add(&format, attrib_name);
+ attr_name = mesh_render_data_vcol_auto_layer_uuid_get(rdata, i);
+ GPU_vertformat_alias_add(&format, attr_name);
}
if (i == rdata->cd.layers.vcol_active) {
GPU_vertformat_alias_add(&format, "c");
@@ -4980,7 +4980,7 @@ void DRW_mesh_batch_cache_create_requested(
drw_mesh_weight_state_clear(&wstate);
}
- /* Verify that all surface batches have needed attrib layers. */
+ /* Verify that all surface batches have needed attribute layers. */
/* TODO(fclem): We could be a bit smarter here and only do it per material. */
bool cd_overlap = mesh_cd_layers_type_overlap(cache->cd_vused, cache->cd_lused,
cache->cd_vneeded, cache->cd_lneeded);
diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c
index 4a23bee8d50..e6e262be5ce 100644
--- a/source/blender/draw/intern/draw_cache_impl_particles.c
+++ b/source/blender/draw/intern/draw_cache_impl_particles.c
@@ -1174,8 +1174,8 @@ static void particle_batch_cache_ensure_pos_and_seg(
attr_id.ind = GPU_vertformat_attr_add(&format, "ind", GPU_COMP_I32, 1, GPU_FETCH_INT);
if (psmd) {
- uv_id = MEM_mallocN(sizeof(*uv_id) * num_uv_layers, "UV attrib format");
- col_id = MEM_mallocN(sizeof(*col_id) * num_col_layers, "Col attrib format");
+ uv_id = MEM_mallocN(sizeof(*uv_id) * num_uv_layers, "UV attr format");
+ col_id = MEM_mallocN(sizeof(*col_id) * num_col_layers, "Col attr format");
for (int i = 0; i < num_uv_layers; i++) {
const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_MLOOPUV, i);
diff --git a/source/blender/draw/intern/draw_common.c b/source/blender/draw/intern/draw_common.c
index e54ad6cdffc..28bd39e9090 100644
--- a/source/blender/draw/intern/draw_common.c
+++ b/source/blender/draw/intern/draw_common.c
@@ -318,8 +318,8 @@ DRWShadingGroup *shgroup_dynlines_flat_color(DRWPass *pass)
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_FLAT_COLOR);
DRW_shgroup_instance_format(g_formats.dynlines_color, {
- {"pos", DRW_ATTRIB_FLOAT, 3},
- {"color", DRW_ATTRIB_FLOAT, 4}
+ {"pos", DRW_ATTR_FLOAT, 3},
+ {"color", DRW_ATTR_FLOAT, 4}
});
DRWShadingGroup *grp = DRW_shgroup_line_batch_create_with_format(sh, pass, g_formats.dynlines_color);
@@ -385,8 +385,8 @@ DRWShadingGroup *shgroup_instance_screenspace(
GPUShader *sh = DRW_shader_get_builtin_shader(GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR, shader_slot);
DRW_shgroup_instance_format(g_formats.instance_screenspace, {
- {"world_pos", DRW_ATTRIB_FLOAT, 3},
- {"color", DRW_ATTRIB_FLOAT, 3}
+ {"world_pos", DRW_ATTR_FLOAT, 3},
+ {"color", DRW_ATTR_FLOAT, 3}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom, g_formats.instance_screenspace);
@@ -405,8 +405,8 @@ DRWShadingGroup *shgroup_instance_solid(DRWPass *pass, struct GPUBatch *geom)
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR);
DRW_shgroup_instance_format(g_formats.instance_color, {
- {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16},
- {"color", DRW_ATTRIB_FLOAT, 4}
+ {"InstanceModelMatrix", DRW_ATTR_FLOAT, 16},
+ {"color", DRW_ATTR_FLOAT, 4}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom, g_formats.instance_color);
@@ -420,8 +420,8 @@ DRWShadingGroup *shgroup_instance_wire(DRWPass *pass, struct GPUBatch *geom)
GPUShader *sh = GPU_shader_get_builtin_shader(GPU_SHADER_3D_OBJECTSPACE_VARIYING_COLOR);
DRW_shgroup_instance_format(g_formats.instance_color, {
- {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16},
- {"color", DRW_ATTRIB_FLOAT, 4}
+ {"InstanceModelMatrix", DRW_ATTR_FLOAT, 16},
+ {"color", DRW_ATTR_FLOAT, 4}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom, g_formats.instance_color);
@@ -435,9 +435,9 @@ DRWShadingGroup *shgroup_instance_screen_aligned(
GPUShader *sh = DRW_shader_get_builtin_shader(GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED, shader_slot);
DRW_shgroup_instance_format(g_formats.instance_screen_aligned, {
- {"color", DRW_ATTRIB_FLOAT, 3},
- {"size", DRW_ATTRIB_FLOAT, 1},
- {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16}
+ {"color", DRW_ATTR_FLOAT, 3},
+ {"size", DRW_ATTR_FLOAT, 1},
+ {"InstanceModelMatrix", DRW_ATTR_FLOAT, 16}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(sh, pass, geom, g_formats.instance_screen_aligned);
@@ -453,9 +453,9 @@ DRWShadingGroup *shgroup_instance_scaled(DRWPass *pass, struct GPUBatch *geom, e
GPUShader *sh_inst = DRW_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SCALE, shader_slot);
DRW_shgroup_instance_format(g_formats.instance_scaled, {
- {"color", DRW_ATTRIB_FLOAT, 3},
- {"size", DRW_ATTRIB_FLOAT, 3},
- {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16}
+ {"color", DRW_ATTR_FLOAT, 3},
+ {"size", DRW_ATTR_FLOAT, 3},
+ {"InstanceModelMatrix", DRW_ATTR_FLOAT, 16}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom, g_formats.instance_scaled);
@@ -470,9 +470,9 @@ DRWShadingGroup *shgroup_instance(DRWPass *pass, struct GPUBatch *geom, eDRW_Sha
GPUShader *sh_inst = DRW_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE, shader_slot);
DRW_shgroup_instance_format(g_formats.instance_sized, {
- {"color", DRW_ATTRIB_FLOAT, 4},
- {"size", DRW_ATTRIB_FLOAT, 1},
- {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16}
+ {"color", DRW_ATTR_FLOAT, 4},
+ {"size", DRW_ATTR_FLOAT, 1},
+ {"InstanceModelMatrix", DRW_ATTR_FLOAT, 16}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom, g_formats.instance_sized);
@@ -488,9 +488,9 @@ DRWShadingGroup *shgroup_instance_alpha(DRWPass *pass, struct GPUBatch *geom, eD
GPUShader *sh_inst = DRW_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE, shader_slot);
DRW_shgroup_instance_format(g_formats.instance_sized, {
- {"color", DRW_ATTRIB_FLOAT, 4},
- {"size", DRW_ATTRIB_FLOAT, 1},
- {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16}
+ {"color", DRW_ATTR_FLOAT, 4},
+ {"size", DRW_ATTR_FLOAT, 1},
+ {"InstanceModelMatrix", DRW_ATTR_FLOAT, 16}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom, g_formats.instance_sized);
@@ -513,9 +513,9 @@ DRWShadingGroup *shgroup_instance_empty_axes(DRWPass *pass, struct GPUBatch *geo
}
DRW_shgroup_instance_format(g_formats.instance_sized, {
- {"color", DRW_ATTRIB_FLOAT, 3},
- {"size", DRW_ATTRIB_FLOAT, 1},
- {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16}
+ {"color", DRW_ATTR_FLOAT, 3},
+ {"size", DRW_ATTR_FLOAT, 1},
+ {"InstanceModelMatrix", DRW_ATTR_FLOAT, 16}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_data->empty_axes_sh, pass, geom, g_formats.instance_sized);
@@ -531,9 +531,9 @@ DRWShadingGroup *shgroup_instance_outline(DRWPass *pass, struct GPUBatch *geom,
GPUShader *sh_inst = GPU_shader_get_builtin_shader(GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE);
DRW_shgroup_instance_format(g_formats.instance_outline, {
- {"callId", DRW_ATTRIB_INT, 1},
- {"size", DRW_ATTRIB_FLOAT, 1},
- {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16}
+ {"callId", DRW_ATTR_INT, 1},
+ {"size", DRW_ATTR_FLOAT, 1},
+ {"InstanceModelMatrix", DRW_ATTR_FLOAT, 16}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom, g_formats.instance_outline);
@@ -547,11 +547,11 @@ DRWShadingGroup *shgroup_camera_instance(DRWPass *pass, struct GPUBatch *geom, e
GPUShader *sh_inst = DRW_shader_get_builtin_shader(GPU_SHADER_CAMERA, shader_slot);
DRW_shgroup_instance_format(g_formats.instance_camera, {
- {"color", DRW_ATTRIB_FLOAT, 3},
- {"corners", DRW_ATTRIB_FLOAT, 8},
- {"depth", DRW_ATTRIB_FLOAT, 1},
- {"tria", DRW_ATTRIB_FLOAT, 4},
- {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16}
+ {"color", DRW_ATTR_FLOAT, 3},
+ {"corners", DRW_ATTR_FLOAT, 8},
+ {"depth", DRW_ATTR_FLOAT, 1},
+ {"tria", DRW_ATTR_FLOAT, 4},
+ {"InstanceModelMatrix", DRW_ATTR_FLOAT, 16}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom, g_formats.instance_camera);
@@ -567,10 +567,10 @@ DRWShadingGroup *shgroup_distance_lines_instance(DRWPass *pass, struct GPUBatch
static float point_size = 4.0f;
DRW_shgroup_instance_format(g_formats.instance_distance_lines, {
- {"color", DRW_ATTRIB_FLOAT, 3},
- {"start", DRW_ATTRIB_FLOAT, 1},
- {"end", DRW_ATTRIB_FLOAT, 1},
- {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16}
+ {"color", DRW_ATTR_FLOAT, 3},
+ {"start", DRW_ATTR_FLOAT, 1},
+ {"end", DRW_ATTR_FLOAT, 1},
+ {"InstanceModelMatrix", DRW_ATTR_FLOAT, 16}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom, g_formats.instance_distance_lines);
@@ -586,8 +586,8 @@ DRWShadingGroup *shgroup_spot_instance(DRWPass *pass, struct GPUBatch *geom)
static const int False = false;
DRW_shgroup_instance_format(g_formats.instance_spot, {
- {"color", DRW_ATTRIB_FLOAT, 3},
- {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16}
+ {"color", DRW_ATTR_FLOAT, 3},
+ {"InstanceModelMatrix", DRW_ATTR_FLOAT, 16}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(sh_inst, pass, geom, g_formats.instance_spot);
@@ -608,8 +608,8 @@ DRWShadingGroup *shgroup_instance_bone_axes(DRWPass *pass)
}
DRW_shgroup_instance_format(g_formats.instance_color, {
- {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16},
- {"color", DRW_ATTRIB_FLOAT, 4}
+ {"InstanceModelMatrix", DRW_ATTR_FLOAT, 16},
+ {"color", DRW_ATTR_FLOAT, 4}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(
@@ -631,10 +631,10 @@ DRWShadingGroup *shgroup_instance_bone_envelope_outline(DRWPass *pass)
}
DRW_shgroup_instance_format(g_formats.instance_bone_envelope_outline, {
- {"headSphere", DRW_ATTRIB_FLOAT, 4},
- {"tailSphere", DRW_ATTRIB_FLOAT, 4},
- {"outlineColorSize", DRW_ATTRIB_FLOAT, 4},
- {"xAxis", DRW_ATTRIB_FLOAT, 3}
+ {"headSphere", DRW_ATTR_FLOAT, 4},
+ {"tailSphere", DRW_ATTR_FLOAT, 4},
+ {"outlineColorSize", DRW_ATTR_FLOAT, 4},
+ {"xAxis", DRW_ATTR_FLOAT, 3}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(
@@ -656,9 +656,9 @@ DRWShadingGroup *shgroup_instance_bone_envelope_distance(DRWPass *pass)
}
DRW_shgroup_instance_format(g_formats.instance_bone_envelope_distance, {
- {"headSphere", DRW_ATTRIB_FLOAT, 4},
- {"tailSphere", DRW_ATTRIB_FLOAT, 4},
- {"xAxis", DRW_ATTRIB_FLOAT, 3}
+ {"headSphere", DRW_ATTR_FLOAT, 4},
+ {"tailSphere", DRW_ATTR_FLOAT, 4},
+ {"xAxis", DRW_ATTR_FLOAT, 3}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(
@@ -679,11 +679,11 @@ DRWShadingGroup *shgroup_instance_bone_envelope_solid(DRWPass *pass, bool transp
}
DRW_shgroup_instance_format(g_formats.instance_bone_envelope, {
- {"headSphere", DRW_ATTRIB_FLOAT, 4},
- {"tailSphere", DRW_ATTRIB_FLOAT, 4},
- {"boneColor", DRW_ATTRIB_FLOAT, 3},
- {"stateColor", DRW_ATTRIB_FLOAT, 3},
- {"xAxis", DRW_ATTRIB_FLOAT, 3}
+ {"headSphere", DRW_ATTR_FLOAT, 4},
+ {"tailSphere", DRW_ATTR_FLOAT, 4},
+ {"boneColor", DRW_ATTR_FLOAT, 3},
+ {"stateColor", DRW_ATTR_FLOAT, 3},
+ {"xAxis", DRW_ATTR_FLOAT, 3}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(
@@ -705,9 +705,9 @@ DRWShadingGroup *shgroup_instance_mball_handles(DRWPass *pass)
}
DRW_shgroup_instance_format(g_formats.instance_mball_handles, {
- {"ScaleTranslationMatrix", DRW_ATTRIB_FLOAT, 12},
- {"radius", DRW_ATTRIB_FLOAT, 1},
- {"color", DRW_ATTRIB_FLOAT, 3}
+ {"ScaleTranslationMatrix", DRW_ATTR_FLOAT, 12},
+ {"radius", DRW_ATTR_FLOAT, 1},
+ {"color", DRW_ATTR_FLOAT, 3}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(
@@ -732,8 +732,8 @@ DRWShadingGroup *shgroup_instance_bone_shape_outline(DRWPass *pass, struct GPUBa
}
DRW_shgroup_instance_format(g_formats.instance_bone_outline, {
- {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16},
- {"outlineColorSize", DRW_ATTRIB_FLOAT, 4}
+ {"InstanceModelMatrix", DRW_ATTR_FLOAT, 16},
+ {"outlineColorSize", DRW_ATTR_FLOAT, 4}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(
@@ -754,9 +754,9 @@ DRWShadingGroup *shgroup_instance_bone_shape_solid(DRWPass *pass, struct GPUBatc
}
DRW_shgroup_instance_format(g_formats.instance_bone, {
- {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16},
- {"boneColor", DRW_ATTRIB_FLOAT, 3},
- {"stateColor", DRW_ATTRIB_FLOAT, 3}
+ {"InstanceModelMatrix", DRW_ATTR_FLOAT, 16},
+ {"boneColor", DRW_ATTR_FLOAT, 3},
+ {"stateColor", DRW_ATTR_FLOAT, 3}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(
@@ -777,9 +777,9 @@ DRWShadingGroup *shgroup_instance_bone_sphere_solid(DRWPass *pass, bool transp)
}
DRW_shgroup_instance_format(g_formats.instance_bone, {
- {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16},
- {"boneColor", DRW_ATTRIB_FLOAT, 3},
- {"stateColor", DRW_ATTRIB_FLOAT, 3}
+ {"InstanceModelMatrix", DRW_ATTR_FLOAT, 16},
+ {"boneColor", DRW_ATTR_FLOAT, 3},
+ {"stateColor", DRW_ATTR_FLOAT, 3}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(
@@ -801,8 +801,8 @@ DRWShadingGroup *shgroup_instance_bone_sphere_outline(DRWPass *pass)
}
DRW_shgroup_instance_format(g_formats.instance_bone_outline, {
- {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16},
- {"outlineColorSize", DRW_ATTRIB_FLOAT, 4}
+ {"InstanceModelMatrix", DRW_ATTR_FLOAT, 16},
+ {"outlineColorSize", DRW_ATTR_FLOAT, 4}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(
@@ -824,12 +824,12 @@ DRWShadingGroup *shgroup_instance_bone_stick(DRWPass *pass)
}
DRW_shgroup_instance_format(g_formats.instance_bone_stick, {
- {"boneStart", DRW_ATTRIB_FLOAT, 3},
- {"boneEnd", DRW_ATTRIB_FLOAT, 3},
- {"wireColor", DRW_ATTRIB_FLOAT, 4}, /* TODO port theses to uchar color */
- {"boneColor", DRW_ATTRIB_FLOAT, 4},
- {"headColor", DRW_ATTRIB_FLOAT, 4},
- {"tailColor", DRW_ATTRIB_FLOAT, 4}
+ {"boneStart", DRW_ATTR_FLOAT, 3},
+ {"boneEnd", DRW_ATTR_FLOAT, 3},
+ {"wireColor", DRW_ATTR_FLOAT, 4}, /* TODO port theses to uchar color */
+ {"boneColor", DRW_ATTR_FLOAT, 4},
+ {"headColor", DRW_ATTR_FLOAT, 4},
+ {"tailColor", DRW_ATTR_FLOAT, 4}
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(
@@ -852,10 +852,10 @@ struct DRWShadingGroup *shgroup_instance_bone_dof(struct DRWPass *pass, struct G
}
DRW_shgroup_instance_format(g_formats.instance_bone_dof, {
- {"InstanceModelMatrix", DRW_ATTRIB_FLOAT, 16},
- {"color", DRW_ATTRIB_FLOAT, 4},
- {"amin", DRW_ATTRIB_FLOAT, 2},
- {"amax", DRW_ATTRIB_FLOAT, 2},
+ {"InstanceModelMatrix", DRW_ATTR_FLOAT, 16},
+ {"color", DRW_ATTR_FLOAT, 4},
+ {"amin", DRW_ATTR_FLOAT, 2},
+ {"amax", DRW_ATTR_FLOAT, 2},
});
DRWShadingGroup *grp = DRW_shgroup_instance_create(
diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c
index f129235d86c..8775c4f50a7 100644
--- a/source/blender/draw/intern/draw_instance_data.c
+++ b/source/blender/draw/intern/draw_instance_data.c
@@ -290,24 +290,24 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist)
/** \name Instance Data (DRWInstanceData)
* \{ */
-static DRWInstanceData *drw_instance_data_create(DRWInstanceDataList *idatalist, uint attrib_size)
+static DRWInstanceData *drw_instance_data_create(DRWInstanceDataList *idatalist, uint attr_size)
{
DRWInstanceData *idata = MEM_callocN(sizeof(DRWInstanceData), "DRWInstanceData");
idata->next = NULL;
idata->used = true;
- idata->data_size = attrib_size;
+ idata->data_size = attr_size;
idata->mempool = BLI_mempool_create(sizeof(float) * idata->data_size, 0, 16, 0);
- BLI_assert(attrib_size > 0);
+ BLI_assert(attr_size > 0);
/* Push to linked list. */
- if (idatalist->idata_head[attrib_size - 1] == NULL) {
- idatalist->idata_head[attrib_size - 1] = idata;
+ if (idatalist->idata_head[attr_size - 1] == NULL) {
+ idatalist->idata_head[attr_size - 1] = idata;
}
else {
- idatalist->idata_tail[attrib_size - 1]->next = idata;
+ idatalist->idata_tail[attr_size - 1]->next = idata;
}
- idatalist->idata_tail[attrib_size - 1] = idata;
+ idatalist->idata_tail[attr_size - 1] = idata;
return idata;
}
@@ -325,11 +325,11 @@ void *DRW_instance_data_next(DRWInstanceData *idata)
return BLI_mempool_alloc(idata->mempool);
}
-DRWInstanceData *DRW_instance_data_request(DRWInstanceDataList *idatalist, uint attrib_size)
+DRWInstanceData *DRW_instance_data_request(DRWInstanceDataList *idatalist, uint attr_size)
{
- BLI_assert(attrib_size > 0 && attrib_size <= MAX_INSTANCE_DATA_SIZE);
+ BLI_assert(attr_size > 0 && attr_size <= MAX_INSTANCE_DATA_SIZE);
- DRWInstanceData *idata = idatalist->idata_head[attrib_size - 1];
+ DRWInstanceData *idata = idatalist->idata_head[attr_size - 1];
/* Search for an unused data chunk. */
for (; idata; idata = idata->next) {
@@ -339,7 +339,7 @@ DRWInstanceData *DRW_instance_data_request(DRWInstanceDataList *idatalist, uint
}
}
- return drw_instance_data_create(idatalist, attrib_size);
+ return drw_instance_data_create(idatalist, attr_size);
}
/** \} */
diff --git a/source/blender/draw/intern/draw_instance_data.h b/source/blender/draw/intern/draw_instance_data.h
index 8460d47ad72..5a1cff510fe 100644
--- a/source/blender/draw/intern/draw_instance_data.h
+++ b/source/blender/draw/intern/draw_instance_data.h
@@ -43,7 +43,7 @@ struct DRWShadingGroup;
void *DRW_instance_data_next(DRWInstanceData *idata);
DRWInstanceData *DRW_instance_data_request(
- DRWInstanceDataList *idatalist, uint attrib_size);
+ DRWInstanceDataList *idatalist, uint attr_size);
void DRW_batching_buffer_request(
DRWInstanceDataList *idatalist, GPUVertFormat *format, GPUPrimType type, struct DRWShadingGroup *shgroup,
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 09809a4184c..9d85f952a60 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -1765,7 +1765,7 @@ void DRW_render_gpencil(struct RenderEngine *engine, struct Depsgraph *depsgraph
drw_viewport_var_init();
/* set default viewport */
- gpuPushAttrib(GPU_ENABLE_BIT | GPU_VIEWPORT_BIT);
+ gpuPushAttr(GPU_ENABLE_BIT | GPU_VIEWPORT_BIT);
glDisable(GL_SCISSOR_TEST);
glViewport(0, 0, size[0], size[1]);
@@ -1790,7 +1790,7 @@ void DRW_render_gpencil(struct RenderEngine *engine, struct Depsgraph *depsgraph
glDisable(GL_DEPTH_TEST);
/* Restore Drawing area. */
- gpuPopAttrib();
+ gpuPopAttr();
glEnable(GL_SCISSOR_TEST);
GPU_framebuffer_restore();
diff --git a/source/blender/draw/intern/draw_manager.h b/source/blender/draw/intern/draw_manager.h
index 8882421958b..6ff56728dbe 100644
--- a/source/blender/draw/intern/draw_manager.h
+++ b/source/blender/draw/intern/draw_manager.h
@@ -135,11 +135,16 @@ typedef struct DRWCallState {
} DRWCallState;
typedef enum {
- DRW_CALL_SINGLE, /* A single batch */
- DRW_CALL_RANGE, /* Like single but only draw a range of vertices/indices. */
- DRW_CALL_INSTANCES, /* Draw instances without any instancing attribs. */
- DRW_CALL_GENERATE, /* Uses a callback to draw with any number of batches. */
- DRW_CALL_PROCEDURAL, /* Generate a drawcall without any GPUBatch. */
+ /** A single batch. */
+ DRW_CALL_SINGLE,
+ /** Like single but only draw a range of vertices/indices. */
+ DRW_CALL_RANGE,
+ /** Draw instances without any instancing attributes. */
+ DRW_CALL_INSTANCES,
+ /** Uses a callback to draw with any number of batches. */
+ DRW_CALL_GENERATE,
+ /** Generate a drawcall without any #GPUBatch. */
+ DRW_CALL_PROCEDURAL,
} DRWCallType;
typedef struct DRWCall {
@@ -268,7 +273,7 @@ struct DRWShadingGroup {
DRWPass *pass_parent; /* backlink to pass we're in */
#ifndef NDEBUG
- char attribs_count;
+ char attrs_count;
#endif
#ifdef USE_GPU_SELECT
GPUVertBuf *inst_selectid;
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 00da9425796..5d5d36d90e3 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -608,7 +608,7 @@ void DRW_shgroup_call_dynamic_add_array(DRWShadingGroup *shgroup, const void *at
}
#endif
- BLI_assert(attr_len == shgroup->attribs_count);
+ BLI_assert(attr_len == shgroup->attrs_count);
UNUSED_VARS_NDEBUG(attr_len);
for (int i = 0; i < attr_len; ++i) {
@@ -638,7 +638,7 @@ static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
shgroup->override_selectid = -1;
#endif
#ifndef NDEBUG
- shgroup->attribs_count = 0;
+ shgroup->attrs_count = 0;
#endif
int view_ubo_location = GPU_shader_get_uniform_block(shader, "viewBlock");
@@ -710,7 +710,7 @@ static void drw_shgroup_instance_init(
shgroup->instance_geom = batch;
#ifndef NDEBUG
- shgroup->attribs_count = format->attr_len;
+ shgroup->attrs_count = format->attr_len;
#endif
DRW_instancing_buffer_request(DST.idatalist, format, batch, shgroup,
@@ -738,7 +738,7 @@ static void drw_shgroup_batching_init(
drw_shgroup_init(shgroup, shader);
#ifndef NDEBUG
- shgroup->attribs_count = (format != NULL) ? format->attr_len : 0;
+ shgroup->attrs_count = (format != NULL) ? format->attr_len : 0;
#endif
BLI_assert(format != NULL);
@@ -844,15 +844,16 @@ static DRWShadingGroup *drw_shgroup_material_inputs(DRWShadingGroup *grp, struct
return grp;
}
-GPUVertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttribFormat attribs[], int arraysize)
+GPUVertFormat *DRW_shgroup_instance_format_array(const DRWInstanceAttrFormat attrs[], int arraysize)
{
GPUVertFormat *format = MEM_callocN(sizeof(GPUVertFormat), "GPUVertFormat");
for (int i = 0; i < arraysize; ++i) {
- GPU_vertformat_attr_add(format, attribs[i].name,
- (attribs[i].type == DRW_ATTRIB_INT) ? GPU_COMP_I32 : GPU_COMP_F32,
- attribs[i].components,
- (attribs[i].type == DRW_ATTRIB_INT) ? GPU_FETCH_INT : GPU_FETCH_FLOAT);
+ GPU_vertformat_attr_add(
+ format, attrs[i].name,
+ (attrs[i].type == DRW_ATTR_INT) ? GPU_COMP_I32 : GPU_COMP_F32,
+ attrs[i].components,
+ (attrs[i].type == DRW_ATTR_INT) ? GPU_FETCH_INT : GPU_FETCH_FLOAT);
}
return format;
}
@@ -929,7 +930,7 @@ DRWShadingGroup *DRW_shgroup_instance_create(
DRWShadingGroup *DRW_shgroup_point_batch_create(struct GPUShader *shader, DRWPass *pass)
{
- DRW_shgroup_instance_format(g_pos_format, {{"pos", DRW_ATTRIB_FLOAT, 3}});
+ DRW_shgroup_instance_format(g_pos_format, {{"pos", DRW_ATTR_FLOAT, 3}});
DRWShadingGroup *shgroup = drw_shgroup_create_ex(shader, pass);
shgroup->type = DRW_SHG_POINT_BATCH;
@@ -952,14 +953,16 @@ DRWShadingGroup *DRW_shgroup_line_batch_create_with_format(
DRWShadingGroup *DRW_shgroup_line_batch_create(struct GPUShader *shader, DRWPass *pass)
{
- DRW_shgroup_instance_format(g_pos_format, {{"pos", DRW_ATTRIB_FLOAT, 3}});
+ DRW_shgroup_instance_format(g_pos_format, {{"pos", DRW_ATTR_FLOAT, 3}});
return DRW_shgroup_line_batch_create_with_format(shader, pass, g_pos_format);
}
-/* Very special batch. Use this if you position
+/**
+ * Very special batch. Use this if you position
* your vertices with the vertex shader
- * and dont need any VBO attrib */
+ * and dont need any VBO attribute.
+ */
DRWShadingGroup *DRW_shgroup_empty_tri_batch_create(struct GPUShader *shader, DRWPass *pass, int tri_count)
{
#ifdef USE_GPU_SELECT
@@ -989,13 +992,15 @@ DRWShadingGroup *DRW_shgroup_transform_feedback_create(struct GPUShader *shader,
return shgroup;
}
-/* Specify an external batch instead of adding each attrib one by one. */
+/**
+ * Specify an external batch instead of adding each attribute one by one.
+ */
void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct GPUBatch *batch)
{
BLI_assert(shgroup->type == DRW_SHG_INSTANCE);
BLI_assert(shgroup->instance_count == 0);
/* You cannot use external instancing batch without a dummy format. */
- BLI_assert(shgroup->attribs_count != 0);
+ BLI_assert(shgroup->attrs_count != 0);
shgroup->type = DRW_SHG_INSTANCE_EXTERNAL;
drw_call_calc_orco(NULL, shgroup->instance_orcofac);