diff options
author | Brian Paul <[email protected]> | 2014-10-21 10:22:35 -0600 |
---|---|---|
committer | Brian Paul <[email protected]> | 2014-10-22 17:33:40 -0600 |
commit | 27de89d2667bb154a4334f839397420a11b02bab (patch) | |
tree | f797ac9984dc578bd496f1dceaa3a3ebadcdfb9e /src/gallium/auxiliary/util/u_blitter.c | |
parent | 7a652c41b4de4bdbb954a4ebf6cdb605d197e999 (diff) |
u_blitter: do error checking assertions for shader caching
If the user calls util_blitter_cache_all_shaders() set a flag and assert
that we never try to create any new fragment shaders after that point.
If the assertions fails, it means we missed generating some shader in
util_blitter_cache_all_shaders().
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/util/u_blitter.c')
-rw-r--r-- | src/gallium/auxiliary/util/u_blitter.c | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index f3fe949c2ea..abcacffa41e 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -134,6 +134,7 @@ struct blitter_context_priv boolean has_stream_out; boolean has_stencil_export; boolean has_texture_multisample; + boolean cached_all_shaders; /* The Draw module overrides these functions. * Always create the blitter before Draw. */ @@ -356,6 +357,7 @@ static void bind_fs_empty(struct blitter_context_priv *ctx) struct pipe_context *pipe = ctx->base.pipe; if (!ctx->fs_empty) { + assert(!ctx->cached_all_shaders); ctx->fs_empty = util_make_empty_fragment_shader(pipe); } @@ -367,6 +369,7 @@ static void bind_fs_write_one_cbuf(struct blitter_context_priv *ctx) struct pipe_context *pipe = ctx->base.pipe; if (!ctx->fs_write_one_cbuf) { + assert(!ctx->cached_all_shaders); ctx->fs_write_one_cbuf = util_make_fragment_passthrough_shader(pipe, TGSI_SEMANTIC_GENERIC, TGSI_INTERPOLATE_CONSTANT, FALSE); @@ -380,6 +383,7 @@ static void bind_fs_write_all_cbufs(struct blitter_context_priv *ctx) struct pipe_context *pipe = ctx->base.pipe; if (!ctx->fs_write_all_cbufs) { + assert(!ctx->cached_all_shaders); ctx->fs_write_all_cbufs = util_make_fragment_passthrough_shader(pipe, TGSI_SEMANTIC_GENERIC, TGSI_INTERPOLATE_CONSTANT, TRUE); @@ -850,6 +854,7 @@ static void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx, shader = &ctx->fs_resolve[target][index][filter]; if (!*shader) { + assert(!ctx->cached_all_shaders); if (filter == PIPE_TEX_FILTER_LINEAR) { *shader = util_make_fs_msaa_resolve_bilinear(pipe, tgsi_tex, src_nr_samples, @@ -870,6 +875,7 @@ static void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx, /* Create the fragment shader on-demand. */ if (!*shader) { + assert(!ctx->cached_all_shaders); *shader = util_make_fs_blit_msaa_color(pipe, tgsi_tex); } } @@ -880,6 +886,7 @@ static void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx, /* Create the fragment shader on-demand. */ if (!*shader) { + assert(!ctx->cached_all_shaders); *shader = util_make_fragment_tex_shader(pipe, tgsi_tex, TGSI_INTERPOLATE_LINEAR); } @@ -902,11 +909,10 @@ void *blitter_get_fs_texfetch_depth(struct blitter_context_priv *ctx, /* Create the fragment shader on-demand. */ if (!*shader) { - unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, - nr_samples); - - *shader = - util_make_fs_blit_msaa_depth(pipe, tgsi_tex); + unsigned tgsi_tex; + assert(!ctx->cached_all_shaders); + tgsi_tex = util_pipe_tex_to_tgsi_tex(target, nr_samples); + *shader = util_make_fs_blit_msaa_depth(pipe, tgsi_tex); } return *shader; @@ -915,8 +921,9 @@ void *blitter_get_fs_texfetch_depth(struct blitter_context_priv *ctx, /* Create the fragment shader on-demand. */ if (!*shader) { - unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, 0); - + unsigned tgsi_tex; + assert(!ctx->cached_all_shaders); + tgsi_tex = util_pipe_tex_to_tgsi_tex(target, 0); *shader = util_make_fragment_tex_shader_writedepth(pipe, tgsi_tex, TGSI_INTERPOLATE_LINEAR); @@ -940,11 +947,10 @@ void *blitter_get_fs_texfetch_depthstencil(struct blitter_context_priv *ctx, /* Create the fragment shader on-demand. */ if (!*shader) { - unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, - nr_samples); - - *shader = - util_make_fs_blit_msaa_depthstencil(pipe, tgsi_tex); + unsigned tgsi_tex; + assert(!ctx->cached_all_shaders); + tgsi_tex = util_pipe_tex_to_tgsi_tex(target, nr_samples); + *shader = util_make_fs_blit_msaa_depthstencil(pipe, tgsi_tex); } return *shader; @@ -953,8 +959,9 @@ void *blitter_get_fs_texfetch_depthstencil(struct blitter_context_priv *ctx, /* Create the fragment shader on-demand. */ if (!*shader) { - unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, 0); - + unsigned tgsi_tex; + assert(!ctx->cached_all_shaders); + tgsi_tex = util_pipe_tex_to_tgsi_tex(target, 0); *shader = util_make_fragment_tex_shader_writedepthstencil(pipe, tgsi_tex, TGSI_INTERPOLATE_LINEAR); @@ -978,11 +985,10 @@ void *blitter_get_fs_texfetch_stencil(struct blitter_context_priv *ctx, /* Create the fragment shader on-demand. */ if (!*shader) { - unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, - nr_samples); - - *shader = - util_make_fs_blit_msaa_stencil(pipe, tgsi_tex); + unsigned tgsi_tex; + assert(!ctx->cached_all_shaders); + tgsi_tex = util_pipe_tex_to_tgsi_tex(target, nr_samples); + *shader = util_make_fs_blit_msaa_stencil(pipe, tgsi_tex); } return *shader; @@ -991,8 +997,9 @@ void *blitter_get_fs_texfetch_stencil(struct blitter_context_priv *ctx, /* Create the fragment shader on-demand. */ if (!*shader) { - unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, 0); - + unsigned tgsi_tex; + assert(!ctx->cached_all_shaders); + tgsi_tex = util_pipe_tex_to_tgsi_tex(target, 0); *shader = util_make_fragment_tex_shader_writestencil(pipe, tgsi_tex, TGSI_INTERPOLATE_LINEAR); @@ -1065,6 +1072,8 @@ void util_blitter_cache_all_shaders(struct blitter_context *blitter) } } } + + ctx->cached_all_shaders = TRUE; } static void blitter_set_common_draw_rect_state(struct blitter_context_priv *ctx, |