DRW: Do not update the view ubo for each pass

Only update if the view changes.
This commit is contained in:
Clément Foucault 2019-05-21 22:11:53 +02:00
parent f7c9a33446
commit 6914f7125b
3 changed files with 8 additions and 1 deletions

View File

@ -662,6 +662,7 @@ static void drw_viewport_var_init(void)
}
DST.view_active = DST.view_default;
DST.view_previous = NULL;
}
else {
zero_v3(DST.screenvecs[0]);
@ -670,6 +671,7 @@ static void drw_viewport_var_init(void)
DST.pixsize = 1.0f;
DST.view_default = NULL;
DST.view_active = NULL;
DST.view_previous = NULL;
}
/* fclem: Is this still needed ? */

View File

@ -323,6 +323,7 @@ typedef struct DRWManager {
DRWView *view_default;
DRWView *view_active;
DRWView *view_previous;
uint primary_view_ct;
/** TODO(fclem) Remove this. Only here to support
* shaders without common_view_lib.glsl */

View File

@ -981,7 +981,11 @@ static void drw_draw_pass_ex(DRWPass *pass,
BLI_assert(DST.buffer_finish_called &&
"DRW_render_instance_buffer_finish had not been called before drawing");
drw_update_view();
if (DST.view_previous != DST.view_active || DST.view_active->is_dirty) {
drw_update_view();
DST.view_active->is_dirty = false;
DST.view_previous = DST.view_active;
}
/* GPU_framebuffer_clear calls can change the state outside the DRW module.
* Force reset the affected states to avoid problems later. */