Fix part of T53497: Eevee stuttering on macOS for the first few seconds of usage.

The problem was that textures were assigned to different slots on different draw
calls, which caused shader specialization/patching by the driver. So the shader
would be compiled over and over until all possible assignments were used.
This commit is contained in:
2018-04-04 11:13:13 +02:00
parent 3f4df3f847
commit fb5a57ab97
2 changed files with 26 additions and 1 deletions

View File

@@ -82,7 +82,24 @@ static void drw_shgroup_uniform_create_ex(DRWShadingGroup *shgroup, int loc,
uni->length = length;
uni->arraysize = arraysize;
BLI_LINKS_PREPEND(shgroup->uniforms, uni);
/* Insert into list sorted by location so that slots are consistenly assigned
* for different draw calls, to avoid shader specialization/patching by the driver. */
DRWUniform *next = shgroup->uniforms;
DRWUniform *prev = NULL;
while (next && loc > next->location) {
prev = next;
next = next->next;
}
if (prev) {
prev->next = uni;
}
else {
shgroup->uniforms = uni;
}
uni->next = next;
}
static void drw_shgroup_builtin_uniform(

View File

@@ -861,6 +861,10 @@ static void release_texture_slots(bool with_persist)
DST.RST.bound_tex_slots[i] = BIND_NONE;
}
}
/* Reset so that slots are consistenly assigned for different shader
* draw calls, to avoid shader specialization/patching by the driver. */
DST.RST.bind_tex_inc = 0;
}
static void release_ubo_slots(bool with_persist)
@@ -874,6 +878,10 @@ static void release_ubo_slots(bool with_persist)
DST.RST.bound_ubo_slots[i] = BIND_NONE;
}
}
/* Reset so that slots are consistenly assigned for different shader
* draw calls, to avoid shader specialization/patching by the driver. */
DST.RST.bind_ubo_inc = 0;
}
static void draw_shgroup(DRWShadingGroup *shgroup, DRWState pass_state)