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:
authorClément Foucault <foucault.clem@gmail.com>2019-09-14 00:02:45 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-09-14 00:03:10 +0300
commitfd5c1972cd5c8a826c0d40effb0e2d367389666a (patch)
tree6a093944267ff888e9fb4323bac22d52468ab7ec /source/blender/draw/intern/draw_manager.c
parentc80564ef9f557fadd235b87533b24d126e2138c9 (diff)
Revert "DRW: Refactor to support draw call batching"
This reverts commit ce34a6b0d727bbde6ae373afa8ec6c42bc8980ce.
Diffstat (limited to 'source/blender/draw/intern/draw_manager.c')
-rw-r--r--source/blender/draw/intern/draw_manager.c93
1 files changed, 32 insertions, 61 deletions
diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c
index 66e3905b212..fde7fdfa222 100644
--- a/source/blender/draw/intern/draw_manager.c
+++ b/source/blender/draw/intern/draw_manager.c
@@ -537,11 +537,8 @@ static void drw_viewport_cache_resize(void)
GPU_texture_free(*tex);
}
- BLI_memblock_clear(DST.vmempool->commands, NULL);
- BLI_memblock_clear(DST.vmempool->commands_small, NULL);
- BLI_memblock_clear(DST.vmempool->callbuffers, NULL);
- BLI_memblock_clear(DST.vmempool->obmats, NULL);
- BLI_memblock_clear(DST.vmempool->obinfos, NULL);
+ BLI_memblock_clear(DST.vmempool->calls, NULL);
+ BLI_memblock_clear(DST.vmempool->states, NULL);
BLI_memblock_clear(DST.vmempool->cullstates, NULL);
BLI_memblock_clear(DST.vmempool->shgroups, NULL);
BLI_memblock_clear(DST.vmempool->uniforms, NULL);
@@ -589,28 +586,28 @@ static void drw_context_state_init(void)
}
}
-static void draw_unit_state_create(void)
+static DRWCallState *draw_unit_state_create(void)
{
- DRWObjectInfos *infos = BLI_memblock_alloc(DST.vmempool->obinfos);
- DRWObjectMatrix *mats = BLI_memblock_alloc(DST.vmempool->obmats);
- DRWCullingState *culling = BLI_memblock_alloc(DST.vmempool->cullstates);
+ DRWCallState *state = BLI_memblock_alloc(DST.vmempool->states);
+ state->flag = 0;
+ state->matflag = 0;
- unit_m4(mats->model);
- unit_m4(mats->modelinverse);
+ unit_m4(state->model);
+ unit_m4(state->modelinverse);
- copy_v3_fl(infos->orcotexfac[0], 0.0f);
- copy_v3_fl(infos->orcotexfac[1], 1.0f);
+ copy_v3_fl(state->orcotexfac[0], 0.0f);
+ copy_v3_fl(state->orcotexfac[1], 1.0f);
- infos->ob_index = 0;
- infos->ob_random = 0.0f;
- infos->ob_neg_scale = 1.0f;
- copy_v3_fl(infos->ob_color, 1.0f);
+ state->ob_index = 0;
+ state->ob_random = 0.0f;
+ copy_v3_fl(state->ob_color, 1.0f);
/* TODO(fclem) get rid of this. */
- culling->bsphere.radius = -1.0f;
- culling->user_data = NULL;
+ state->culling = BLI_memblock_alloc(DST.vmempool->cullstates);
+ state->culling->bsphere.radius = -1.0f;
+ state->culling->user_data = NULL;
- DRW_handle_increment(&DST.resource_handle);
+ return state;
}
/* It also stores viewport variable to an immutable place: DST
@@ -635,48 +632,33 @@ static void drw_viewport_var_init(void)
DST.vmempool = GPU_viewport_mempool_get(DST.viewport);
- if (DST.vmempool->commands == NULL) {
- DST.vmempool->commands = BLI_memblock_create(sizeof(DRWCommandChunk));
+ if (DST.vmempool->calls == NULL) {
+ DST.vmempool->calls = BLI_memblock_create(sizeof(DRWCall));
}
- if (DST.vmempool->commands_small == NULL) {
- DST.vmempool->commands_small = BLI_memblock_create(sizeof(DRWCommandSmallChunk));
- }
- if (DST.vmempool->callbuffers == NULL) {
- DST.vmempool->callbuffers = BLI_memblock_create(sizeof(DRWCallBuffer));
- }
- if (DST.vmempool->obmats == NULL) {
- uint chunk_len = sizeof(DRWObjectMatrix) * DRW_RESOURCE_CHUNK_LEN;
- DST.vmempool->obmats = BLI_memblock_create_ex(sizeof(DRWObjectMatrix), chunk_len);
- }
- if (DST.vmempool->obinfos == NULL) {
- uint chunk_len = sizeof(DRWObjectInfos) * DRW_RESOURCE_CHUNK_LEN;
- DST.vmempool->obinfos = BLI_memblock_create_ex(sizeof(DRWObjectInfos), chunk_len);
+ if (DST.vmempool->states == NULL) {
+ DST.vmempool->states = BLI_memblock_create(sizeof(DRWCallState));
}
if (DST.vmempool->cullstates == NULL) {
- uint chunk_len = sizeof(DRWCullingState) * DRW_RESOURCE_CHUNK_LEN;
- DST.vmempool->cullstates = BLI_memblock_create_ex(sizeof(DRWCullingState), chunk_len);
+ DST.vmempool->cullstates = BLI_memblock_create(sizeof(DRWCullingState));
}
if (DST.vmempool->shgroups == NULL) {
DST.vmempool->shgroups = BLI_memblock_create(sizeof(DRWShadingGroup));
}
if (DST.vmempool->uniforms == NULL) {
- DST.vmempool->uniforms = BLI_memblock_create(sizeof(DRWUniformChunk));
+ DST.vmempool->uniforms = BLI_memblock_create(sizeof(DRWUniform));
}
if (DST.vmempool->views == NULL) {
DST.vmempool->views = BLI_memblock_create(sizeof(DRWView));
}
if (DST.vmempool->passes == NULL) {
- uint chunk_len = sizeof(DRWPass) * DRW_RESOURCE_CHUNK_LEN;
- DST.vmempool->passes = BLI_memblock_create_ex(sizeof(DRWPass), chunk_len);
+ DST.vmempool->passes = BLI_memblock_create(sizeof(DRWPass));
}
if (DST.vmempool->images == NULL) {
DST.vmempool->images = BLI_memblock_create(sizeof(GPUTexture *));
}
- DST.resource_handle = 0;
- DST.pass_handle = 0;
-
- draw_unit_state_create();
+ /* Alloc default unit state */
+ DST.unit_state = draw_unit_state_create();
DST.idatalist = GPU_viewport_instance_data_list_get(DST.viewport);
DRW_instance_data_list_reset(DST.idatalist);
@@ -690,6 +672,8 @@ static void drw_viewport_var_init(void)
DST.default_framebuffer = NULL;
DST.vmempool = NULL;
+
+ DST.unit_state = NULL;
}
DST.primary_view_ct = 0;
@@ -732,10 +716,6 @@ static void drw_viewport_var_init(void)
G_draw.view_ubo = DRW_uniformbuffer_create(sizeof(DRWViewUboStorage), NULL);
}
- if (DST.draw_list == NULL) {
- DST.draw_list = GPU_draw_list_create(DRW_DRAWLIST_LEN);
- }
-
memset(DST.object_instance_data, 0x0, sizeof(DST.object_instance_data));
}
@@ -1119,7 +1099,7 @@ static void drw_engines_world_update(Scene *scene)
static void drw_engines_cache_populate(Object *ob)
{
- DST.ob_handle = 0;
+ DST.ob_state = NULL;
/* HACK: DrawData is copied by COW from the duplicated object.
* This is valid for IDs that cannot be instantiated but this
@@ -1937,8 +1917,6 @@ void DRW_render_gpencil(struct RenderEngine *engine, struct Depsgraph *depsgraph
RenderResult *render_result = RE_engine_get_result(engine);
RenderLayer *render_layer = RE_GetRenderLayer(render_result, view_layer->name);
- DST.buffer_finish_called = false;
-
DRW_render_gpencil_to_image(engine, render_layer, &render_rect);
/* Force cache to reset. */
@@ -2049,15 +2027,13 @@ void DRW_render_to_image(RenderEngine *engine, struct Depsgraph *depsgraph)
RE_SetActiveRenderView(render, render_view->name);
drw_view_reset();
engine_type->draw_engine->render_to_image(data, engine, render_layer, &render_rect);
- DST.buffer_finish_called = false;
-
/* grease pencil: render result is merged in the previous render result. */
if (DRW_render_check_grease_pencil(depsgraph)) {
DRW_state_reset();
drw_view_reset();
DRW_render_gpencil_to_image(engine, render_layer, &render_rect);
- DST.buffer_finish_called = false;
}
+ DST.buffer_finish_called = false;
}
RE_engine_end_result(engine, render_result, false, false, false);
@@ -2103,7 +2079,7 @@ void DRW_render_object_iter(
if ((object_type_exclude_viewport & (1 << ob->type)) == 0) {
DST.dupli_parent = data_.dupli_parent;
DST.dupli_source = data_.dupli_object_current;
- DST.ob_handle = 0;
+ DST.ob_state = NULL;
drw_duplidata_load(DST.dupli_source);
if (!DST.dupli_source) {
@@ -2210,7 +2186,6 @@ void DRW_render_instance_buffer_finish(void)
BLI_assert(!DST.buffer_finish_called && "DRW_render_instance_buffer_finish called twice!");
DST.buffer_finish_called = true;
DRW_instance_buffer_finish(DST.idatalist);
- drw_resource_buffer_finish(DST.vmempool);
}
/**
@@ -2234,7 +2209,7 @@ void DRW_draw_select_loop(struct Depsgraph *depsgraph,
Object *obact = OBACT(view_layer);
Object *obedit = OBEDIT_FROM_OBACT(obact);
#ifndef USE_GPU_SELECT
- UNUSED_VARS(scene, view_layer, v3d, ar, rect);
+ UNUSED_VARS(vc, scene, view_layer, v3d, ar, rect);
#else
RegionView3D *rv3d = ar->regiondata;
@@ -2959,10 +2934,6 @@ void DRW_engines_free(void)
MEM_SAFE_FREE(DST.uniform_names.buffer);
- if (DST.draw_list) {
- GPU_draw_list_discard(DST.draw_list);
- }
-
DRW_opengl_context_disable();
}