diff options
author | George Kyriazis <[email protected]> | 2017-02-10 10:24:32 -0600 |
---|---|---|
committer | Tim Rowley <[email protected]> | 2017-02-23 16:36:13 -0600 |
commit | 669d8f626f64cee1bc74ef7869aac8585b6dcfe6 (patch) | |
tree | 981ce7c2e5a1b0c00c65745c71f60ef0f1d1a35d /src/gallium/drivers/swr/swr_draw.cpp | |
parent | 987d8037cabaafaeba2cb8b82cb7fa7290dc4464 (diff) |
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 <[email protected]>
Diffstat (limited to 'src/gallium/drivers/swr/swr_draw.cpp')
-rw-r--r-- | src/gallium/drivers/swr/swr_draw.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
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); |