Fix T64913 Eevee: shader compilation does not reset TAA

This tracks the number of compiling shaders and just reset the TAA
if previous number mismatch.
This commit is contained in:
Clément Foucault
2019-06-14 19:12:39 +02:00
parent 486755460a
commit 0707177ab8
5 changed files with 27 additions and 1 deletions

View File

@@ -60,6 +60,7 @@ static void eevee_engine_init(void *ved)
stl->g_data->background_alpha = DRW_state_draw_background() ? 1.0f : 0.0f; stl->g_data->background_alpha = DRW_state_draw_background() ? 1.0f : 0.0f;
stl->g_data->valid_double_buffer = (txl->color_double_buffer != NULL); stl->g_data->valid_double_buffer = (txl->color_double_buffer != NULL);
stl->g_data->valid_taa_history = (txl->taa_history != NULL); stl->g_data->valid_taa_history = (txl->taa_history != NULL);
stl->g_data->queued_shaders_count = 0;
/* Main Buffer */ /* Main Buffer */
DRW_texture_ensure_fullscreen_2d(&txl->color, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_MIPMAP); DRW_texture_ensure_fullscreen_2d(&txl->color, GPU_RGBA16F, DRW_TEX_FILTER | DRW_TEX_MIPMAP);
@@ -145,6 +146,7 @@ void EEVEE_cache_populate(void *vedata, Object *ob)
static void eevee_cache_finish(void *vedata) static void eevee_cache_finish(void *vedata)
{ {
EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure(); EEVEE_ViewLayerData *sldata = EEVEE_view_layer_data_ensure();
EEVEE_PrivateData *g_data = ((EEVEE_Data *)vedata)->stl->g_data;
EEVEE_volumes_cache_finish(sldata, vedata); EEVEE_volumes_cache_finish(sldata, vedata);
EEVEE_materials_cache_finish(sldata, vedata); EEVEE_materials_cache_finish(sldata, vedata);
@@ -153,6 +155,13 @@ static void eevee_cache_finish(void *vedata)
EEVEE_effects_draw_init(sldata, vedata); EEVEE_effects_draw_init(sldata, vedata);
EEVEE_volumes_draw_init(sldata, vedata); EEVEE_volumes_draw_init(sldata, vedata);
/* Restart taa if a shader has finish compiling. */
/* HACK We should use notification of some sort from the compilation job instead. */
if (g_data->queued_shaders_count != g_data->queued_shaders_count_prev) {
g_data->queued_shaders_count_prev = g_data->queued_shaders_count;
EEVEE_temporal_sampling_reset(vedata);
}
} }
/* As renders in an HDR offscreen buffer, we need draw everything once /* As renders in an HDR offscreen buffer, we need draw everything once

View File

@@ -344,6 +344,7 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
if (wo->use_nodes && wo->nodetree) { if (wo->use_nodes && wo->nodetree) {
static float error_col[3] = {1.0f, 0.0f, 1.0f}; static float error_col[3] = {1.0f, 0.0f, 1.0f};
static float queue_col[3] = {0.5f, 0.5f, 0.5f};
struct GPUMaterial *gpumat = EEVEE_material_world_lightprobe_get(scene, wo); struct GPUMaterial *gpumat = EEVEE_material_world_lightprobe_get(scene, wo);
eGPUMaterialStatus status = GPU_material_status(gpumat); eGPUMaterialStatus status = GPU_material_status(gpumat);
@@ -361,6 +362,10 @@ void EEVEE_lightprobes_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedat
DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo); DRW_shgroup_uniform_block(grp, "shadow_block", sldata->shadow_ubo);
DRW_shgroup_call(grp, geom, NULL); DRW_shgroup_call(grp, geom, NULL);
break; break;
case GPU_MAT_QUEUED:
stl->g_data->queued_shaders_count++;
col = queue_col;
break;
default: default:
col = error_col; col = error_col;
break; break;

View File

@@ -1000,6 +1000,7 @@ void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata)
break; break;
case GPU_MAT_QUEUED: case GPU_MAT_QUEUED:
/* TODO Bypass probe compilation. */ /* TODO Bypass probe compilation. */
stl->g_data->queued_shaders_count++;
col = compile_col; col = compile_col;
break; break;
case GPU_MAT_FAILED: case GPU_MAT_FAILED:
@@ -1352,6 +1353,7 @@ static void material_opaque(Material *ma,
break; break;
} }
case GPU_MAT_QUEUED: { case GPU_MAT_QUEUED: {
stl->g_data->queued_shaders_count++;
color_p = compile_col; color_p = compile_col;
metal_p = spec_p = rough_p = ½ metal_p = spec_p = rough_p = ½
break; break;
@@ -1458,6 +1460,7 @@ static void material_transparent(Material *ma,
} }
case GPU_MAT_QUEUED: { case GPU_MAT_QUEUED: {
/* TODO Bypass probe compilation. */ /* TODO Bypass probe compilation. */
stl->g_data->queued_shaders_count++;
color_p = compile_col; color_p = compile_col;
metal_p = spec_p = rough_p = ½ metal_p = spec_p = rough_p = ½
break; break;
@@ -1785,6 +1788,7 @@ void EEVEE_hair_cache_populate(EEVEE_Data *vedata,
break; break;
} }
case GPU_MAT_QUEUED: { case GPU_MAT_QUEUED: {
stl->g_data->queued_shaders_count++;
color_p = compile_col; color_p = compile_col;
metal_p = spec_p = rough_p = ½ metal_p = spec_p = rough_p = ½
break; break;

View File

@@ -840,6 +840,10 @@ typedef struct EEVEE_PrivateData {
/* Color Management */ /* Color Management */
bool use_color_render_settings; bool use_color_render_settings;
/* Compiling shaders count. This is to track if a shader has finished compiling. */
int queued_shaders_count;
int queued_shaders_count_prev;
/* LookDev Settings */ /* LookDev Settings */
int studiolight_index; int studiolight_index;
float studiolight_rot_z; float studiolight_rot_z;

View File

@@ -394,9 +394,13 @@ void EEVEE_volumes_cache_object_add(EEVEE_ViewLayerData *sldata,
} }
struct GPUMaterial *mat = EEVEE_material_mesh_volume_get(scene, ma); struct GPUMaterial *mat = EEVEE_material_mesh_volume_get(scene, ma);
eGPUMaterialStatus status = GPU_material_status(mat);
if (status == GPU_MAT_QUEUED) {
vedata->stl->g_data->queued_shaders_count++;
}
/* If shader failed to compile or is currently compiling. */ /* If shader failed to compile or is currently compiling. */
if (GPU_material_status(mat) != GPU_MAT_SUCCESS) { if (status != GPU_MAT_SUCCESS) {
return; return;
} }