Cleanup: add iterator macros to clang-format
Also rename START to BEGIN (matching BEGIN/END for most iterator macros).
This commit is contained in:
parent
2f149ebbe9
commit
5c74b0964b
@ -191,6 +191,7 @@ ForEachMacros:
|
||||
- FOREACH_MAIN_ID_BEGIN
|
||||
- FOREACH_MAIN_LISTBASE_BEGIN
|
||||
- FOREACH_MAIN_LISTBASE_ID_BEGIN
|
||||
- FOREACH_MESH_BUFFER_CACHE
|
||||
- FOREACH_NODETREE_BEGIN
|
||||
- FOREACH_OBJECT_BEGIN
|
||||
- FOREACH_OBJECT_FLAG_BEGIN
|
||||
@ -213,6 +214,7 @@ ForEachMacros:
|
||||
- GHASH_ITER_INDEX
|
||||
- GPU_SELECT_LOAD_IF_PICKSEL_LIST
|
||||
- GP_EDITABLE_STROKES_BEGIN
|
||||
- GP_EVALUATED_STROKES_BEGIN
|
||||
- GSET_FOREACH_BEGIN
|
||||
- GSET_ITER
|
||||
- GSET_ITER_INDEX
|
||||
@ -236,7 +238,6 @@ ForEachMacros:
|
||||
- LISTBASE_FOREACH_BACKWARD
|
||||
- LISTBASE_FOREACH_MUTABLE
|
||||
- LISTBASE_FOREACH_BACKWARD_MUTABLE
|
||||
- MAN2D_ITER_AXES_BEGIN
|
||||
- MAN_ITER_AXES_BEGIN
|
||||
- NODE_INSTANCE_HASH_ITER
|
||||
- NODE_SOCKET_TYPES_BEGIN
|
||||
@ -244,6 +245,7 @@ ForEachMacros:
|
||||
- NODE_TYPES_BEGIN
|
||||
- PIXEL_LOOPER_BEGIN
|
||||
- PIXEL_LOOPER_BEGIN_CHANNELS
|
||||
- RENDER_PASS_ITER_BEGIN
|
||||
- RNA_BEGIN
|
||||
- RNA_PROP_BEGIN
|
||||
- RNA_STRUCT_BEGIN
|
||||
@ -252,6 +254,7 @@ ForEachMacros:
|
||||
- SCULPT_VERTEX_NEIGHBORS_ITER_BEGIN
|
||||
- SEQP_BEGIN
|
||||
- SEQ_BEGIN
|
||||
- SURFACE_QUAD_ITER_BEGIN
|
||||
- foreach
|
||||
|
||||
# Use once we bump the minimum version to version 8.
|
||||
|
@ -134,7 +134,8 @@ extern char datatoc_gpu_shader_uniform_color_frag_glsl[];
|
||||
render_pass_index_ += 1; \
|
||||
} \
|
||||
} \
|
||||
}
|
||||
} \
|
||||
((void)0)
|
||||
|
||||
/* *********** FUNCTIONS *********** */
|
||||
|
||||
@ -1562,21 +1563,22 @@ static void material_opaque(Material *ma,
|
||||
}
|
||||
}
|
||||
|
||||
RENDER_PASS_ITER_BEGIN(stl->g_data->render_passes, render_pass_index, render_pass_flag)
|
||||
emsg->material_accum_grp[render_pass_index] = DRW_shgroup_material_create(
|
||||
*gpumat, psl->material_accum_pass[render_pass_index]);
|
||||
add_standard_uniforms(emsg->material_accum_grp[render_pass_index],
|
||||
sldata,
|
||||
vedata,
|
||||
ssr_id,
|
||||
&ma->refract_depth,
|
||||
use_diffuse,
|
||||
use_glossy,
|
||||
use_refract,
|
||||
use_ssrefract,
|
||||
false,
|
||||
render_pass_flag);
|
||||
RENDER_PASS_ITER_END(render_pass_index)
|
||||
RENDER_PASS_ITER_BEGIN (stl->g_data->render_passes, render_pass_index, render_pass_flag) {
|
||||
emsg->material_accum_grp[render_pass_index] = DRW_shgroup_material_create(
|
||||
*gpumat, psl->material_accum_pass[render_pass_index]);
|
||||
add_standard_uniforms(emsg->material_accum_grp[render_pass_index],
|
||||
sldata,
|
||||
vedata,
|
||||
ssr_id,
|
||||
&ma->refract_depth,
|
||||
use_diffuse,
|
||||
use_glossy,
|
||||
use_refract,
|
||||
use_ssrefract,
|
||||
false,
|
||||
render_pass_flag);
|
||||
}
|
||||
RENDER_PASS_ITER_END(render_pass_index);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -1605,21 +1607,22 @@ static void material_opaque(Material *ma,
|
||||
DRW_shgroup_uniform_float(emsg->shading_grp, "specular", spec_p, 1);
|
||||
DRW_shgroup_uniform_float(emsg->shading_grp, "roughness", rough_p, 1);
|
||||
|
||||
RENDER_PASS_ITER_BEGIN(stl->g_data->render_passes, render_pass_index, render_pass_flag)
|
||||
DRWShadingGroup *shgrp = EEVEE_default_render_pass_shading_group_get(
|
||||
sldata,
|
||||
vedata,
|
||||
holdout,
|
||||
use_ssr,
|
||||
psl->material_accum_pass[render_pass_index],
|
||||
render_pass_flag);
|
||||
RENDER_PASS_ITER_BEGIN (stl->g_data->render_passes, render_pass_index, render_pass_flag) {
|
||||
DRWShadingGroup *shgrp = EEVEE_default_render_pass_shading_group_get(
|
||||
sldata,
|
||||
vedata,
|
||||
holdout,
|
||||
use_ssr,
|
||||
psl->material_accum_pass[render_pass_index],
|
||||
render_pass_flag);
|
||||
|
||||
DRW_shgroup_uniform_vec3(shgrp, "basecol", color_p, 1);
|
||||
DRW_shgroup_uniform_float(shgrp, "metallic", metal_p, 1);
|
||||
DRW_shgroup_uniform_float(shgrp, "specular", spec_p, 1);
|
||||
DRW_shgroup_uniform_float(shgrp, "roughness", rough_p, 1);
|
||||
emsg->material_accum_grp[render_pass_index] = shgrp;
|
||||
RENDER_PASS_ITER_END(render_pass_index)
|
||||
DRW_shgroup_uniform_vec3(shgrp, "basecol", color_p, 1);
|
||||
DRW_shgroup_uniform_float(shgrp, "metallic", metal_p, 1);
|
||||
DRW_shgroup_uniform_float(shgrp, "specular", spec_p, 1);
|
||||
DRW_shgroup_uniform_float(shgrp, "roughness", rough_p, 1);
|
||||
emsg->material_accum_grp[render_pass_index] = shgrp;
|
||||
}
|
||||
RENDER_PASS_ITER_END(render_pass_index);
|
||||
}
|
||||
|
||||
/* Fallback default depth prepass */
|
||||
@ -1893,28 +1896,29 @@ static void eevee_hair_cache_populate(EEVEE_Data *vedata,
|
||||
DEFAULT_RENDER_PASS_FLAG);
|
||||
|
||||
/* Add the hair to all the render_passes that are enabled */
|
||||
RENDER_PASS_ITER_BEGIN(stl->g_data->render_passes, render_pass_index, render_pass_flag)
|
||||
shgrp = DRW_shgroup_material_hair_create(
|
||||
ob, psys, md, psl->material_accum_pass[render_pass_index], gpumat);
|
||||
if (!use_diffuse && !use_glossy && !use_refract) {
|
||||
/* Small hack to avoid issue when utilTex is needed for
|
||||
* world_normals_get and none of the bsdfs that need it are present.
|
||||
* This binds `utilTex` even if not needed. */
|
||||
DRW_shgroup_uniform_texture(shgrp, "utilTex", e_data.util_tex);
|
||||
}
|
||||
RENDER_PASS_ITER_BEGIN (stl->g_data->render_passes, render_pass_index, render_pass_flag) {
|
||||
shgrp = DRW_shgroup_material_hair_create(
|
||||
ob, psys, md, psl->material_accum_pass[render_pass_index], gpumat);
|
||||
if (!use_diffuse && !use_glossy && !use_refract) {
|
||||
/* Small hack to avoid issue when utilTex is needed for
|
||||
* world_normals_get and none of the bsdfs that need it are present.
|
||||
* This binds `utilTex` even if not needed. */
|
||||
DRW_shgroup_uniform_texture(shgrp, "utilTex", e_data.util_tex);
|
||||
}
|
||||
|
||||
add_standard_uniforms(shgrp,
|
||||
sldata,
|
||||
vedata,
|
||||
&ssr_id,
|
||||
NULL,
|
||||
use_diffuse,
|
||||
use_glossy,
|
||||
use_refract,
|
||||
false,
|
||||
false,
|
||||
render_pass_flag);
|
||||
RENDER_PASS_ITER_END(render_pass_index)
|
||||
add_standard_uniforms(shgrp,
|
||||
sldata,
|
||||
vedata,
|
||||
&ssr_id,
|
||||
NULL,
|
||||
use_diffuse,
|
||||
use_glossy,
|
||||
use_refract,
|
||||
false,
|
||||
false,
|
||||
render_pass_flag);
|
||||
}
|
||||
RENDER_PASS_ITER_END(render_pass_index);
|
||||
|
||||
break;
|
||||
}
|
||||
@ -1940,23 +1944,24 @@ static void eevee_hair_cache_populate(EEVEE_Data *vedata,
|
||||
DRW_shgroup_uniform_float(shgrp, "specular", spec_p, 1);
|
||||
DRW_shgroup_uniform_float(shgrp, "roughness", rough_p, 1);
|
||||
|
||||
RENDER_PASS_ITER_BEGIN(stl->g_data->render_passes, render_pass_index, render_pass_flag)
|
||||
shgrp = EEVEE_default_hair_render_pass_shading_group_get(
|
||||
sldata,
|
||||
vedata,
|
||||
ob,
|
||||
psys,
|
||||
md,
|
||||
holdout,
|
||||
use_ssr,
|
||||
psl->material_accum_pass[render_pass_index],
|
||||
render_pass_flag);
|
||||
RENDER_PASS_ITER_BEGIN (stl->g_data->render_passes, render_pass_index, render_pass_flag) {
|
||||
shgrp = EEVEE_default_hair_render_pass_shading_group_get(
|
||||
sldata,
|
||||
vedata,
|
||||
ob,
|
||||
psys,
|
||||
md,
|
||||
holdout,
|
||||
use_ssr,
|
||||
psl->material_accum_pass[render_pass_index],
|
||||
render_pass_flag);
|
||||
|
||||
DRW_shgroup_uniform_vec3(shgrp, "basecol", color_p, 1);
|
||||
DRW_shgroup_uniform_float(shgrp, "metallic", metal_p, 1);
|
||||
DRW_shgroup_uniform_float(shgrp, "specular", spec_p, 1);
|
||||
DRW_shgroup_uniform_float(shgrp, "roughness", rough_p, 1);
|
||||
RENDER_PASS_ITER_END(render_pass_index)
|
||||
DRW_shgroup_uniform_vec3(shgrp, "basecol", color_p, 1);
|
||||
DRW_shgroup_uniform_float(shgrp, "metallic", metal_p, 1);
|
||||
DRW_shgroup_uniform_float(shgrp, "specular", spec_p, 1);
|
||||
DRW_shgroup_uniform_float(shgrp, "roughness", rough_p, 1);
|
||||
}
|
||||
RENDER_PASS_ITER_END(render_pass_index);
|
||||
}
|
||||
|
||||
/* Shadows */
|
||||
|
@ -406,7 +406,7 @@ static void displist_vertbuf_attr_set_tri_pos_nor_uv(GPUVertBufRaw *pos_step,
|
||||
}
|
||||
}
|
||||
|
||||
#define SURFACE_QUAD_ITER_START(dl) \
|
||||
#define SURFACE_QUAD_ITER_BEGIN(dl) \
|
||||
{ \
|
||||
uint quad[4]; \
|
||||
int quad_index = 0; \
|
||||
@ -446,8 +446,7 @@ static void displist_surf_fnors_ensure(const DispList *dl, float (**fnors)[3])
|
||||
float(*nor_flat)[3] = MEM_mallocN(sizeof(float) * 3 * u_len * v_len, __func__);
|
||||
*fnors = nor_flat;
|
||||
|
||||
SURFACE_QUAD_ITER_START(dl)
|
||||
{
|
||||
SURFACE_QUAD_ITER_BEGIN (dl) {
|
||||
normal_quad_v3(*nor_flat, verts[quad[0]], verts[quad[1]], verts[quad[2]], verts[quad[3]]);
|
||||
nor_flat++;
|
||||
}
|
||||
@ -570,8 +569,7 @@ void DRW_displist_vertbuf_create_loop_pos_and_nor_and_uv_and_tan(ListBase *lb,
|
||||
BKE_displist_tangent_calc(dl, fnors, &tangents);
|
||||
}
|
||||
|
||||
SURFACE_QUAD_ITER_START(dl)
|
||||
{
|
||||
SURFACE_QUAD_ITER_BEGIN (dl) {
|
||||
if (vbo_uv) {
|
||||
surf_uv_quad(dl, quad, uv);
|
||||
}
|
||||
|
@ -436,8 +436,7 @@ static void mesh_batch_cache_check_vertex_group(MeshBatchCache *cache,
|
||||
const struct DRW_MeshWeightState *wstate)
|
||||
{
|
||||
if (!drw_mesh_weight_state_compare(&cache->weight_state, wstate)) {
|
||||
FOREACH_MESH_BUFFER_CACHE(cache, mbufcache)
|
||||
{
|
||||
FOREACH_MESH_BUFFER_CACHE (cache, mbufcache) {
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.weights);
|
||||
}
|
||||
GPU_BATCH_CLEAR_SAFE(cache->batch.surface_weights);
|
||||
@ -460,8 +459,7 @@ static void mesh_batch_cache_discard_shaded_batches(MeshBatchCache *cache)
|
||||
|
||||
static void mesh_batch_cache_discard_shaded_tri(MeshBatchCache *cache)
|
||||
{
|
||||
FOREACH_MESH_BUFFER_CACHE(cache, mbufcache)
|
||||
{
|
||||
FOREACH_MESH_BUFFER_CACHE (cache, mbufcache) {
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.pos_nor);
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.uv);
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.tan);
|
||||
@ -478,8 +476,7 @@ static void mesh_batch_cache_discard_shaded_tri(MeshBatchCache *cache)
|
||||
|
||||
static void mesh_batch_cache_discard_uvedit(MeshBatchCache *cache)
|
||||
{
|
||||
FOREACH_MESH_BUFFER_CACHE(cache, mbufcache)
|
||||
{
|
||||
FOREACH_MESH_BUFFER_CACHE (cache, mbufcache) {
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.stretch_angle);
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.stretch_area);
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.uv);
|
||||
@ -517,8 +514,7 @@ static void mesh_batch_cache_discard_uvedit(MeshBatchCache *cache)
|
||||
|
||||
static void mesh_batch_cache_discard_uvedit_select(MeshBatchCache *cache)
|
||||
{
|
||||
FOREACH_MESH_BUFFER_CACHE(cache, mbufcache)
|
||||
{
|
||||
FOREACH_MESH_BUFFER_CACHE (cache, mbufcache) {
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.edituv_data);
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.fdots_edituv_data);
|
||||
GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.edituv_tris);
|
||||
@ -544,8 +540,7 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, int mode)
|
||||
}
|
||||
switch (mode) {
|
||||
case BKE_MESH_BATCH_DIRTY_SELECT:
|
||||
FOREACH_MESH_BUFFER_CACHE(cache, mbufcache)
|
||||
{
|
||||
FOREACH_MESH_BUFFER_CACHE (cache, mbufcache) {
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.edit_data);
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.fdots_nor);
|
||||
}
|
||||
@ -568,8 +563,7 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, int mode)
|
||||
case BKE_MESH_BATCH_DIRTY_SELECT_PAINT:
|
||||
/* Paint mode selection flag is packed inside the nor attrib.
|
||||
* Note that it can be slow if auto smooth is enabled. (see T63946) */
|
||||
FOREACH_MESH_BUFFER_CACHE(cache, mbufcache)
|
||||
{
|
||||
FOREACH_MESH_BUFFER_CACHE (cache, mbufcache) {
|
||||
GPU_INDEXBUF_DISCARD_SAFE(mbufcache->ibo.lines_paint_mask);
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.pos_nor);
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.lnor);
|
||||
@ -595,8 +589,7 @@ void DRW_mesh_batch_cache_dirty_tag(Mesh *me, int mode)
|
||||
mesh_batch_cache_discard_uvedit(cache);
|
||||
break;
|
||||
case BKE_MESH_BATCH_DIRTY_UVEDIT_SELECT:
|
||||
FOREACH_MESH_BUFFER_CACHE(cache, mbufcache)
|
||||
{
|
||||
FOREACH_MESH_BUFFER_CACHE (cache, mbufcache) {
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.edituv_data);
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbufcache->vbo.fdots_edituv_data);
|
||||
}
|
||||
@ -619,8 +612,7 @@ static void mesh_batch_cache_clear(Mesh *me)
|
||||
if (!cache) {
|
||||
return;
|
||||
}
|
||||
FOREACH_MESH_BUFFER_CACHE(cache, mbufcache)
|
||||
{
|
||||
FOREACH_MESH_BUFFER_CACHE (cache, mbufcache) {
|
||||
GPUVertBuf **vbos = (GPUVertBuf **)&mbufcache->vbo;
|
||||
GPUIndexBuf **ibos = (GPUIndexBuf **)&mbufcache->ibo;
|
||||
for (int i = 0; i < sizeof(mbufcache->vbo) / sizeof(void *); i++) {
|
||||
@ -1060,8 +1052,7 @@ void DRW_mesh_batch_cache_create_requested(
|
||||
* index ranges initialized. So discard ibo.tris in order to recreate it.
|
||||
* This needs to happen before saved_elem_ranges is populated. */
|
||||
if ((batch_requested & MBC_SURF_PER_MAT) != 0 && (cache->batch_ready & MBC_SURF_PER_MAT) == 0) {
|
||||
FOREACH_MESH_BUFFER_CACHE(cache, mbuffercache)
|
||||
{
|
||||
FOREACH_MESH_BUFFER_CACHE (cache, mbuffercache) {
|
||||
GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.tris);
|
||||
}
|
||||
/* Clear all batches that reference ibo.tris. */
|
||||
@ -1098,8 +1089,7 @@ void DRW_mesh_batch_cache_create_requested(
|
||||
* material. */
|
||||
bool cd_overlap = mesh_cd_layers_type_overlap(cache->cd_used, cache->cd_needed);
|
||||
if (cd_overlap == false) {
|
||||
FOREACH_MESH_BUFFER_CACHE(cache, mbuffercache)
|
||||
{
|
||||
FOREACH_MESH_BUFFER_CACHE (cache, mbuffercache) {
|
||||
if ((cache->cd_used.uv & cache->cd_needed.uv) != cache->cd_needed.uv) {
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbuffercache->vbo.uv);
|
||||
cd_uv_update = true;
|
||||
@ -1145,8 +1135,7 @@ void DRW_mesh_batch_cache_create_requested(
|
||||
const bool is_uvsyncsel = ts && (ts->uv_flag & UV_SYNC_SELECTION);
|
||||
if (cd_uv_update || (cache->is_uvsyncsel != is_uvsyncsel)) {
|
||||
cache->is_uvsyncsel = is_uvsyncsel;
|
||||
FOREACH_MESH_BUFFER_CACHE(cache, mbuffercache)
|
||||
{
|
||||
FOREACH_MESH_BUFFER_CACHE (cache, mbuffercache) {
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbuffercache->vbo.edituv_data);
|
||||
GPU_VERTBUF_DISCARD_SAFE(mbuffercache->vbo.fdots_uv);
|
||||
GPU_INDEXBUF_DISCARD_SAFE(mbuffercache->ibo.edituv_tris);
|
||||
|
@ -1052,8 +1052,7 @@ static int gpencil_circle_select_exec(bContext *C, wmOperator *op)
|
||||
rect.ymax = my + radius;
|
||||
|
||||
/* find visible strokes, and select if hit */
|
||||
GP_EVALUATED_STROKES_BEGIN(gpstroke_iter, C, gpl, gps)
|
||||
{
|
||||
GP_EVALUATED_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
|
||||
changed |= gp_stroke_do_circle_sel(gpd,
|
||||
gpl,
|
||||
gps,
|
||||
@ -1180,8 +1179,7 @@ static int gpencil_generic_select_exec(bContext *C,
|
||||
}
|
||||
|
||||
/* select/deselect points */
|
||||
GP_EVALUATED_STROKES_BEGIN(gpstroke_iter, C, gpl, gps)
|
||||
{
|
||||
GP_EVALUATED_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
|
||||
bGPDstroke *gps_active = (gps->runtime.gps_orig) ? gps->runtime.gps_orig : gps;
|
||||
|
||||
bGPDspoint *pt;
|
||||
@ -1473,8 +1471,7 @@ static int gpencil_select_exec(bContext *C, wmOperator *op)
|
||||
|
||||
/* First Pass: Find stroke point which gets hit */
|
||||
/* XXX: maybe we should go from the top of the stack down instead... */
|
||||
GP_EVALUATED_STROKES_BEGIN(gpstroke_iter, C, gpl, gps)
|
||||
{
|
||||
GP_EVALUATED_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
|
||||
bGPDstroke *gps_active = (gps->runtime.gps_orig) ? gps->runtime.gps_orig : gps;
|
||||
bGPDspoint *pt;
|
||||
int i;
|
||||
|
@ -176,8 +176,7 @@ static bool gpencil_uv_transform_init(bContext *C, wmOperator *op, const bool is
|
||||
float center[3] = {0.0f};
|
||||
int i = 0;
|
||||
/* Need use evaluated to get the viewport final position. */
|
||||
GP_EVALUATED_STROKES_BEGIN(gpstroke_iter, C, gpl, gps)
|
||||
{
|
||||
GP_EVALUATED_STROKES_BEGIN (gpstroke_iter, C, gpl, gps) {
|
||||
if (gps->flag & GP_STROKE_SELECT) {
|
||||
float r_center[3];
|
||||
gpencil_stroke_center(gps, r_center);
|
||||
|
@ -67,8 +67,8 @@ static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize, bool mas
|
||||
|
||||
BLI_INLINE int clamp_float_to_int(const float f)
|
||||
{
|
||||
const float min = (float) INT_MIN;
|
||||
const float max = (float) INT_MAX;
|
||||
const float min = (float)INT_MIN;
|
||||
const float max = (float)INT_MAX;
|
||||
|
||||
if (UNLIKELY(f < min)) {
|
||||
return min;
|
||||
|
Loading…
Reference in New Issue
Block a user