On first compile... - brw_prepare_wm_prog populates the key with depth_compare_func = 0 and searches the cache. No hit. - It then sets depth_compare_func and searches the cache again. No hit. (This is an additional cost.) - It resets depth_compare_func to 0 and compiles. - During compilation, emit_texture_gen5 will set key->depth_compare_func only if manual shadow comparisons are required (otherwise it stays 0). - The newly compiled shader is added to the cache.
Subsequently... - For most shaders: - brw_prepare_wm_prog searches the cache with depth_compare_func = 0. The shader is immediately found (no additional cost). - If manual compares are required: - brw_prepare_wm_prog searches the cache with depth_compare_func = 0. No hit. It then depth_compare_func and searches again. If we've seen this DepthFunc before, we find the shader. Total cost is two cache searches. If we haven't seen DepthFunc before, compile. --- src/mesa/drivers/dri/i965/brw_wm.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index 1aebd12..ffbc3b3 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -484,6 +484,14 @@ static void brw_prepare_wm_prog(struct brw_context *brw) &key, sizeof(key), &brw->wm.prog_data); if (brw->wm.prog_bo == NULL) { + key->depth_compare_func = ctx->Depth.Func; + brw->wm.prog_bo = brw_search_cache(&brw->cache, BRW_WM_PROG, + &key, sizeof(key), + &brw->wm.prog_data); + } + + if (brw->wm.prog_bo == NULL) { + key->depth_compare_func = 0; bool success = do_wm_prog(brw, ctx->Shader.CurrentFragmentProgram, fp, &key); assert(success); -- 1.7.5.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev