From: Nicolai Hähnle <nicolai.haeh...@amd.com> --- src/gallium/auxiliary/util/u_blitter.c | 54 ++++++++++++---------------------- 1 file changed, 19 insertions(+), 35 deletions(-)
diff --git a/src/gallium/auxiliary/util/u_blitter.c b/src/gallium/auxiliary/util/u_blitter.c index e008100..eb3a97d 100644 --- a/src/gallium/auxiliary/util/u_blitter.c +++ b/src/gallium/auxiliary/util/u_blitter.c @@ -73,34 +73,30 @@ struct blitter_context_priv void *vs_pos_only[4]; /**< Vertex shader which passes pos to the output.*/ void *vs_layered; /**< Vertex shader which sets LAYER = INSTANCEID. */ /* Fragment shaders. */ void *fs_empty; void *fs_write_one_cbuf; void *fs_write_all_cbufs; /* FS which outputs a color from a texture, where the index is PIPE_TEXTURE_* to be sampled. */ - void *fs_texfetch_col[PIPE_MAX_TEXTURE_TYPES]; - void *fs_texfetch_col_uint[PIPE_MAX_TEXTURE_TYPES]; - void *fs_texfetch_col_sint[PIPE_MAX_TEXTURE_TYPES]; + void *fs_texfetch_col[3][PIPE_MAX_TEXTURE_TYPES]; /* FS which outputs a depth from a texture, where the index is PIPE_TEXTURE_* to be sampled. */ void *fs_texfetch_depth[PIPE_MAX_TEXTURE_TYPES]; void *fs_texfetch_depthstencil[PIPE_MAX_TEXTURE_TYPES]; void *fs_texfetch_stencil[PIPE_MAX_TEXTURE_TYPES]; /* FS which outputs one sample from a multisample texture. */ - void *fs_texfetch_col_msaa[PIPE_MAX_TEXTURE_TYPES]; - void *fs_texfetch_col_msaa_uint[PIPE_MAX_TEXTURE_TYPES]; - void *fs_texfetch_col_msaa_sint[PIPE_MAX_TEXTURE_TYPES]; + void *fs_texfetch_col_msaa[3][PIPE_MAX_TEXTURE_TYPES]; void *fs_texfetch_depth_msaa[PIPE_MAX_TEXTURE_TYPES]; void *fs_texfetch_depthstencil_msaa[PIPE_MAX_TEXTURE_TYPES]; void *fs_texfetch_stencil_msaa[PIPE_MAX_TEXTURE_TYPES]; /* FS which outputs an average of all samples. */ void *fs_resolve[PIPE_MAX_TEXTURE_TYPES][NUM_RESOLVE_FRAG_SHADERS][2]; /* Blend state. */ void *blend[PIPE_MASK_RGBA+1][2]; /**< blend state with writemask */ void *blend_clear[GET_CLEAR_BLEND_STATE_IDX(PIPE_CLEAR_COLOR)+1]; @@ -449,39 +445,34 @@ void util_blitter_destroy(struct blitter_context *blitter) if (ctx->vs_layered) pipe->delete_vs_state(pipe, ctx->vs_layered); pipe->delete_vertex_elements_state(pipe, ctx->velem_state); for (i = 0; i < 4; i++) { if (ctx->velem_state_readbuf[i]) { pipe->delete_vertex_elements_state(pipe, ctx->velem_state_readbuf[i]); } } for (i = 0; i < PIPE_MAX_TEXTURE_TYPES; i++) { - if (ctx->fs_texfetch_col[i]) - ctx->delete_fs_state(pipe, ctx->fs_texfetch_col[i]); - if (ctx->fs_texfetch_col_sint[i]) - ctx->delete_fs_state(pipe, ctx->fs_texfetch_col_sint[i]); - if (ctx->fs_texfetch_col_uint[i]) - ctx->delete_fs_state(pipe, ctx->fs_texfetch_col_uint[i]); + for (unsigned type = 0; type < 3; ++type) { + if (ctx->fs_texfetch_col[type][i]) + ctx->delete_fs_state(pipe, ctx->fs_texfetch_col[type][i]); + if (ctx->fs_texfetch_col_msaa[type][i]) + ctx->delete_fs_state(pipe, ctx->fs_texfetch_col_msaa[type][i]); + } + if (ctx->fs_texfetch_depth[i]) ctx->delete_fs_state(pipe, ctx->fs_texfetch_depth[i]); if (ctx->fs_texfetch_depthstencil[i]) ctx->delete_fs_state(pipe, ctx->fs_texfetch_depthstencil[i]); if (ctx->fs_texfetch_stencil[i]) ctx->delete_fs_state(pipe, ctx->fs_texfetch_stencil[i]); - if (ctx->fs_texfetch_col_msaa[i]) - ctx->delete_fs_state(pipe, ctx->fs_texfetch_col_msaa[i]); - if (ctx->fs_texfetch_col_msaa_sint[i]) - ctx->delete_fs_state(pipe, ctx->fs_texfetch_col_msaa_sint[i]); - if (ctx->fs_texfetch_col_msaa_uint[i]) - ctx->delete_fs_state(pipe, ctx->fs_texfetch_col_msaa_uint[i]); if (ctx->fs_texfetch_depth_msaa[i]) ctx->delete_fs_state(pipe, ctx->fs_texfetch_depth_msaa[i]); if (ctx->fs_texfetch_depthstencil_msaa[i]) ctx->delete_fs_state(pipe, ctx->fs_texfetch_depthstencil_msaa[i]); if (ctx->fs_texfetch_stencil_msaa[i]) ctx->delete_fs_state(pipe, ctx->fs_texfetch_stencil_msaa[i]); for (j = 0; j< ARRAY_SIZE(ctx->fs_resolve[i]); j++) for (f = 0; f < 2; f++) if (ctx->fs_resolve[i][j][f]) @@ -874,29 +865,34 @@ static void blitter_set_dst_dimensions(struct blitter_context_priv *ctx, static void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx, enum pipe_format format, enum pipe_texture_target target, unsigned src_nr_samples, unsigned dst_nr_samples, unsigned filter) { struct pipe_context *pipe = ctx->base.pipe; unsigned tgsi_tex = util_pipe_tex_to_tgsi_tex(target, src_nr_samples); enum tgsi_return_type stype; + unsigned type; assert(target < PIPE_MAX_TEXTURE_TYPES); - if (util_format_is_pure_uint(format)) + if (util_format_is_pure_uint(format)) { stype = TGSI_RETURN_TYPE_UINT; - else if (util_format_is_pure_sint(format)) + type = 0; + } else if (util_format_is_pure_sint(format)) { stype = TGSI_RETURN_TYPE_SINT; - else + type = 1; + } else { stype = TGSI_RETURN_TYPE_FLOAT; + type = 2; + } if (src_nr_samples > 1) { void **shader; /* OpenGL requires that integer textures just copy 1 sample instead * of averaging. */ if (dst_nr_samples <= 1 && stype != TGSI_RETURN_TYPE_UINT && stype != TGSI_RETURN_TYPE_SINT) { @@ -918,44 +914,32 @@ static void *blitter_get_fs_texfetch_col(struct blitter_context_priv *ctx, *shader = util_make_fs_msaa_resolve(pipe, tgsi_tex, src_nr_samples, stype); } } } else { /* The destination has multiple samples, we'll do * an MSAA->MSAA copy. */ - if (stype == TGSI_RETURN_TYPE_UINT) - shader = &ctx->fs_texfetch_col_msaa_uint[target]; - else if (stype == TGSI_RETURN_TYPE_SINT) - shader = &ctx->fs_texfetch_col_msaa_sint[target]; - else - shader = &ctx->fs_texfetch_col_msaa[target]; + shader = &ctx->fs_texfetch_col_msaa[type][target]; /* Create the fragment shader on-demand. */ if (!*shader) { assert(!ctx->cached_all_shaders); *shader = util_make_fs_blit_msaa_color(pipe, tgsi_tex, stype); } } return *shader; } else { - void **shader; - - if (stype == TGSI_RETURN_TYPE_UINT) - shader = &ctx->fs_texfetch_col_uint[target]; - else if (stype == TGSI_RETURN_TYPE_SINT) - shader = &ctx->fs_texfetch_col_sint[target]; - else - shader = &ctx->fs_texfetch_col[target]; + void **shader = &ctx->fs_texfetch_col[type][target]; /* 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, stype); } return *shader; -- 2.7.4 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev