DRW: Codestyle: Remove DRWCallHeader and DRWCallGenerate
This commit is contained in:
parent
64e35f6fd2
commit
725112cce7
|
@ -369,7 +369,7 @@ static void drw_viewport_var_init(void)
|
|||
DST.vmempool = GPU_viewport_mempool_get(DST.viewport);
|
||||
|
||||
if (DST.vmempool->calls == NULL) {
|
||||
DST.vmempool->calls = BLI_mempool_create(MAX2(sizeof(DRWCall), sizeof(DRWCallGenerate)), 0, 512, 0);
|
||||
DST.vmempool->calls = BLI_mempool_create(sizeof(DRWCall), 0, 512, 0);
|
||||
}
|
||||
if (DST.vmempool->states == NULL) {
|
||||
DST.vmempool->states = BLI_mempool_create(sizeof(DRWCallState), 0, 512, BLI_MEMPOOL_ALLOW_ITER);
|
||||
|
|
|
@ -83,13 +83,23 @@
|
|||
* > DRWUniform
|
||||
**/
|
||||
|
||||
typedef struct DRWCallHeader {
|
||||
struct DRWCallHeader *next; /* in reality DRWCall or DRWCallGenerate. */
|
||||
#ifdef USE_GPU_SELECT
|
||||
int select_id;
|
||||
#endif
|
||||
unsigned char type;
|
||||
} DRWCallHeader;
|
||||
/* Used by DRWCallState.flag */
|
||||
enum {
|
||||
DRW_CALL_CULLED = (1 << 0),
|
||||
DRW_CALL_NEGSCALE = (1 << 1),
|
||||
};
|
||||
|
||||
/* Used by DRWCallState.matflag */
|
||||
enum {
|
||||
DRW_CALL_MODELINVERSE = (1 << 0),
|
||||
DRW_CALL_MODELVIEW = (1 << 1),
|
||||
DRW_CALL_MODELVIEWINVERSE = (1 << 2),
|
||||
DRW_CALL_MODELVIEWPROJECTION = (1 << 3),
|
||||
DRW_CALL_NORMALVIEW = (1 << 4),
|
||||
DRW_CALL_NORMALWORLD = (1 << 5),
|
||||
DRW_CALL_ORCOTEXFAC = (1 << 6),
|
||||
DRW_CALL_EYEVEC = (1 << 7),
|
||||
};
|
||||
|
||||
typedef struct DRWCallState {
|
||||
unsigned char flag;
|
||||
|
@ -112,20 +122,42 @@ typedef struct DRWCallState {
|
|||
float eyevec[3];
|
||||
} DRWCallState;
|
||||
|
||||
typedef enum {
|
||||
DRW_CALL_SINGLE, /* A single batch */
|
||||
DRW_CALL_GENERATE, /* Uses a callback to draw with any number of batches. */
|
||||
} DRWCallType;
|
||||
|
||||
typedef struct DRWCall {
|
||||
DRWCallHeader head;
|
||||
struct DRWCall *next;
|
||||
DRWCallState *state;
|
||||
|
||||
Gwn_Batch *geometry;
|
||||
union {
|
||||
struct { /* type == DRW_CALL_SINGLE */
|
||||
Gwn_Batch *geometry;
|
||||
} single;
|
||||
struct { /* type == DRW_CALL_GENERATE */
|
||||
DRWCallGenerateFn *geometry_fn;
|
||||
void *user_data;
|
||||
} generate;
|
||||
};
|
||||
|
||||
DRWCallType type;
|
||||
#ifdef USE_GPU_SELECT
|
||||
int select_id;
|
||||
#endif
|
||||
} DRWCall;
|
||||
|
||||
typedef struct DRWCallGenerate {
|
||||
DRWCallHeader head;
|
||||
DRWCallState *state;
|
||||
|
||||
DRWCallGenerateFn *geometry_fn;
|
||||
void *user_data;
|
||||
} DRWCallGenerate;
|
||||
/* Used by DRWUniform.type */
|
||||
typedef enum {
|
||||
DRW_UNIFORM_BOOL,
|
||||
DRW_UNIFORM_SHORT_TO_INT,
|
||||
DRW_UNIFORM_SHORT_TO_FLOAT,
|
||||
DRW_UNIFORM_INT,
|
||||
DRW_UNIFORM_FLOAT,
|
||||
DRW_UNIFORM_TEXTURE,
|
||||
DRW_UNIFORM_BUFFER,
|
||||
DRW_UNIFORM_BLOCK
|
||||
} DRWUniformType;
|
||||
|
||||
struct DRWUniform {
|
||||
DRWUniform *next; /* single-linked list */
|
||||
|
@ -136,6 +168,15 @@ struct DRWUniform {
|
|||
char arraysize; /* cannot be more than 16 too */
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
DRW_SHG_NORMAL,
|
||||
DRW_SHG_POINT_BATCH,
|
||||
DRW_SHG_LINE_BATCH,
|
||||
DRW_SHG_TRIANGLE_BATCH,
|
||||
DRW_SHG_INSTANCE,
|
||||
DRW_SHG_INSTANCE_EXTERNAL,
|
||||
} DRWShadingGroupType;
|
||||
|
||||
struct DRWShadingGroup {
|
||||
DRWShadingGroup *next;
|
||||
|
||||
|
@ -145,7 +186,7 @@ struct DRWShadingGroup {
|
|||
/* Watch this! Can be nasty for debugging. */
|
||||
union {
|
||||
struct { /* DRW_SHG_NORMAL */
|
||||
DRWCallHeader *first, *last; /* Linked list of DRWCall or DRWCallDynamic depending of type */
|
||||
DRWCall *first, *last; /* Linked list of DRWCall or DRWCallDynamic depending of type */
|
||||
} calls;
|
||||
struct { /* DRW_SHG_***_BATCH */
|
||||
struct Gwn_Batch *batch_geom; /* Result of call batching */
|
||||
|
@ -163,7 +204,7 @@ struct DRWShadingGroup {
|
|||
DRWState state_extra; /* State changes for this batch only (or'd with the pass's state) */
|
||||
DRWState state_extra_disable; /* State changes for this batch only (and'd with the pass's state) */
|
||||
unsigned int stencil_mask; /* Stencil mask to use for stencil test / write operations */
|
||||
int type;
|
||||
DRWShadingGroupType type;
|
||||
|
||||
/* Builtin matrices locations */
|
||||
int model;
|
||||
|
@ -201,52 +242,6 @@ struct DRWPass {
|
|||
char name[MAX_PASS_NAME];
|
||||
};
|
||||
|
||||
/* Used by DRWUniform.type */
|
||||
typedef enum {
|
||||
DRW_UNIFORM_BOOL,
|
||||
DRW_UNIFORM_SHORT_TO_INT,
|
||||
DRW_UNIFORM_SHORT_TO_FLOAT,
|
||||
DRW_UNIFORM_INT,
|
||||
DRW_UNIFORM_FLOAT,
|
||||
DRW_UNIFORM_TEXTURE,
|
||||
DRW_UNIFORM_BUFFER,
|
||||
DRW_UNIFORM_BLOCK
|
||||
} DRWUniformType;
|
||||
|
||||
/* Used by DRWCall.flag */
|
||||
enum {
|
||||
DRW_CALL_SINGLE, /* A single batch */
|
||||
DRW_CALL_GENERATE, /* Uses a callback to draw with any number of batches. */
|
||||
};
|
||||
|
||||
/* Used by DRWCall.state */
|
||||
enum {
|
||||
DRW_CALL_CULLED = (1 << 0),
|
||||
DRW_CALL_NEGSCALE = (1 << 1),
|
||||
};
|
||||
|
||||
/* Used by DRWCall.flag */
|
||||
enum {
|
||||
DRW_CALL_MODELINVERSE = (1 << 0),
|
||||
DRW_CALL_MODELVIEW = (1 << 1),
|
||||
DRW_CALL_MODELVIEWINVERSE = (1 << 2),
|
||||
DRW_CALL_MODELVIEWPROJECTION = (1 << 3),
|
||||
DRW_CALL_NORMALVIEW = (1 << 4),
|
||||
DRW_CALL_NORMALWORLD = (1 << 5),
|
||||
DRW_CALL_ORCOTEXFAC = (1 << 6),
|
||||
DRW_CALL_EYEVEC = (1 << 7),
|
||||
};
|
||||
|
||||
/* Used by DRWShadingGroup.type */
|
||||
enum {
|
||||
DRW_SHG_NORMAL,
|
||||
DRW_SHG_POINT_BATCH,
|
||||
DRW_SHG_LINE_BATCH,
|
||||
DRW_SHG_TRIANGLE_BATCH,
|
||||
DRW_SHG_INSTANCE,
|
||||
DRW_SHG_INSTANCE_EXTERNAL,
|
||||
};
|
||||
|
||||
/* ------------- DRAW MANAGER ------------ */
|
||||
|
||||
#define MAX_CLIP_PLANES 6 /* GL_MAX_CLIP_PLANES is at least 6 */
|
||||
|
|
|
@ -293,13 +293,13 @@ void DRW_shgroup_call_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, float (*obm
|
|||
|
||||
DRWCall *call = BLI_mempool_alloc(DST.vmempool->calls);
|
||||
call->state = drw_call_state_create(shgroup, obmat, NULL);
|
||||
call->head.type = DRW_CALL_SINGLE;
|
||||
call->type = DRW_CALL_SINGLE;
|
||||
#ifdef USE_GPU_SELECT
|
||||
call->head.select_id = DST.select_id;
|
||||
call->select_id = DST.select_id;
|
||||
#endif
|
||||
call->geometry = geom;
|
||||
call->single.geometry = geom;
|
||||
|
||||
BLI_LINKS_APPEND(&shgroup->calls, (DRWCallHeader *)call);
|
||||
BLI_LINKS_APPEND(&shgroup->calls, call);
|
||||
}
|
||||
|
||||
/* These calls can be culled and are optimized for redraw */
|
||||
|
@ -310,13 +310,13 @@ void DRW_shgroup_call_object_add(DRWShadingGroup *shgroup, Gwn_Batch *geom, Obje
|
|||
|
||||
DRWCall *call = BLI_mempool_alloc(DST.vmempool->calls);
|
||||
call->state = drw_call_state_object(shgroup, ob->obmat, ob->data);
|
||||
call->head.type = DRW_CALL_SINGLE;
|
||||
call->type = DRW_CALL_SINGLE;
|
||||
#ifdef USE_GPU_SELECT
|
||||
call->head.select_id = DST.select_id;
|
||||
call->select_id = DST.select_id;
|
||||
#endif
|
||||
call->geometry = geom;
|
||||
call->single.geometry = geom;
|
||||
|
||||
BLI_LINKS_APPEND(&shgroup->calls, (DRWCallHeader *)call);
|
||||
BLI_LINKS_APPEND(&shgroup->calls, call);
|
||||
}
|
||||
|
||||
void DRW_shgroup_call_generate_add(
|
||||
|
@ -327,16 +327,16 @@ void DRW_shgroup_call_generate_add(
|
|||
BLI_assert(geometry_fn != NULL);
|
||||
BLI_assert(shgroup->type == DRW_SHG_NORMAL);
|
||||
|
||||
DRWCallGenerate *call = BLI_mempool_alloc(DST.vmempool->calls);
|
||||
DRWCall *call = BLI_mempool_alloc(DST.vmempool->calls);
|
||||
call->state = drw_call_state_create(shgroup, obmat, NULL);
|
||||
call->head.type = DRW_CALL_GENERATE;
|
||||
call->type = DRW_CALL_GENERATE;
|
||||
#ifdef USE_GPU_SELECT
|
||||
call->head.select_id = DST.select_id;
|
||||
call->select_id = DST.select_id;
|
||||
#endif
|
||||
call->geometry_fn = geometry_fn;
|
||||
call->user_data = user_data;
|
||||
call->generate.geometry_fn = geometry_fn;
|
||||
call->generate.user_data = user_data;
|
||||
|
||||
BLI_LINKS_APPEND(&shgroup->calls, (DRWCallHeader *)call);
|
||||
BLI_LINKS_APPEND(&shgroup->calls, call);
|
||||
}
|
||||
|
||||
static void sculpt_draw_cb(
|
||||
|
|
|
@ -597,7 +597,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
|
|||
|
||||
# define GPU_SELECT_LOAD_IF_PICKSEL_CALL(_call) \
|
||||
if ((G.f & G_PICKSEL) && (_call)) { \
|
||||
GPU_select_load_id((_call)->head.select_id); \
|
||||
GPU_select_load_id((_call)->select_id); \
|
||||
} ((void)0)
|
||||
|
||||
# define GPU_SELECT_LOAD_IF_PICKSEL_LIST(_shgroup, _start, _count) \
|
||||
|
@ -674,7 +674,7 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
|
|||
}
|
||||
else {
|
||||
bool prev_neg_scale = false;
|
||||
for (DRWCall *call = (DRWCall *)shgroup->calls.first; call; call = (DRWCall *)call->head.next) {
|
||||
for (DRWCall *call = shgroup->calls.first; call; call = call->next) {
|
||||
if ((call->state->flag & DRW_CALL_CULLED) != 0)
|
||||
continue;
|
||||
|
||||
|
@ -686,16 +686,14 @@ static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)
|
|||
}
|
||||
|
||||
GPU_SELECT_LOAD_IF_PICKSEL_CALL(call);
|
||||
draw_geometry_prepare(shgroup, call->state);
|
||||
|
||||
if (call->head.type == DRW_CALL_SINGLE) {
|
||||
draw_geometry_prepare(shgroup, call->state);
|
||||
draw_geometry_execute(shgroup, call->geometry);
|
||||
if (call->type == DRW_CALL_SINGLE) {
|
||||
draw_geometry_execute(shgroup, call->single.geometry);
|
||||
}
|
||||
else {
|
||||
BLI_assert(call->head.type == DRW_CALL_GENERATE);
|
||||
DRWCallGenerate *callgen = ((DRWCallGenerate *)call);
|
||||
draw_geometry_prepare(shgroup, callgen->state);
|
||||
callgen->geometry_fn(shgroup, draw_geometry_execute, callgen->user_data);
|
||||
BLI_assert(call->type == DRW_CALL_GENERATE);
|
||||
call->generate.geometry_fn(shgroup, draw_geometry_execute, call->generate.user_data);
|
||||
}
|
||||
}
|
||||
/* Reset state */
|
||||
|
|
Loading…
Reference in New Issue