From 669d8f626f64cee1bc74ef7869aac8585b6dcfe6 Mon Sep 17 00:00:00 2001 From: George Kyriazis Date: Fri, 10 Feb 2017 10:24:32 -0600 Subject: swr: add fetch shader cache For now, the cache key is all of FETCH_COMPILE_STATE. Use new/delete for swr_vertex_element_state, since we have to call the constructors/destructors of the struct elements. Reviewed-by: Bruce Cherniak --- src/gallium/drivers/swr/swr_draw.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) (limited to 'src/gallium/drivers/swr/swr_draw.cpp') diff --git a/src/gallium/drivers/swr/swr_draw.cpp b/src/gallium/drivers/swr/swr_draw.cpp index c4d5e5c4495..4bdd3bbaa3e 100644 --- a/src/gallium/drivers/swr/swr_draw.cpp +++ b/src/gallium/drivers/swr/swr_draw.cpp @@ -141,19 +141,22 @@ swr_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info) } struct swr_vertex_element_state *velems = ctx->velems; - if (!velems->fsFunc - || (velems->fsState.cutIndex != info->restart_index) - || (velems->fsState.bEnableCutIndex != info->primitive_restart)) { - - velems->fsState.cutIndex = info->restart_index; - velems->fsState.bEnableCutIndex = info->primitive_restart; - - /* Create Fetch Shader */ + velems->fsState.cutIndex = info->restart_index; + velems->fsState.bEnableCutIndex = info->primitive_restart; + + swr_jit_fetch_key key; + swr_generate_fetch_key(key, velems); + auto search = velems->map.find(key); + if (search != velems->map.end()) { + velems->fsFunc = search->second; + } else { HANDLE hJitMgr = swr_screen(ctx->pipe.screen)->hJitMgr; velems->fsFunc = JitCompileFetch(hJitMgr, velems->fsState); debug_printf("fetch shader %p\n", velems->fsFunc); assert(velems->fsFunc && "Error: FetchShader = NULL"); + + velems->map.insert(std::make_pair(key, velems->fsFunc)); } SwrSetFetchFunc(ctx->swrContext, velems->fsFunc); -- cgit v1.2.3