[Mesa-dev] [PATCH] llvmpipe: Implement stencil export
Dave Airlie
airlied at gmail.com
Tue Jun 2 16:32:50 PDT 2015
On 3 June 2015 at 05:52, <sroland at vmware.com> wrote:
> From: Roland Scheidegger <sroland at vmware.com>
Looks good to me,
Reviewed-by: Dave Airlie <airlied at redhat.com>
>
> Pretty trivial, fixes the issue that we're expected to be able to blit
> stencil surfaces (as the blit just relies on util blitter code which needs
> stencil export to do it).
> 2 piglits skip->pass, 11 fail->pass
> ---
> src/gallium/drivers/llvmpipe/lp_bld_depth.c | 15 ++++++++++++---
> src/gallium/drivers/llvmpipe/lp_bld_depth.h | 1 +
> src/gallium/drivers/llvmpipe/lp_screen.c | 2 +-
> src/gallium/drivers/llvmpipe/lp_state_fs.c | 15 ++++++++++++++-
> src/gallium/drivers/llvmpipe/lp_surface.c | 5 -----
> 5 files changed, 28 insertions(+), 10 deletions(-)
>
> diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.c b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
> index b6c32ff..ef93f98 100644
> --- a/src/gallium/drivers/llvmpipe/lp_bld_depth.c
> +++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
> @@ -825,6 +825,7 @@ lp_build_depth_stencil_test(struct gallivm_state *gallivm,
> LLVMValueRef face,
> LLVMValueRef *z_value,
> LLVMValueRef *s_value,
> + boolean stencil_export,
> boolean do_branch)
> {
> LLVMBuilderRef builder = gallivm->builder;
> @@ -975,9 +976,17 @@ lp_build_depth_stencil_test(struct gallivm_state *gallivm,
> s_bld.int_vec_type, "");
> }
>
> - /* convert scalar stencil refs into vectors */
> - stencil_refs[0] = lp_build_broadcast_scalar(&s_bld, stencil_refs[0]);
> - stencil_refs[1] = lp_build_broadcast_scalar(&s_bld, stencil_refs[1]);
> + if (stencil_export) {
> + /* there's only one value, and spec says to discard additional bits */
> + LLVMValueRef s_max_mask = lp_build_const_int_vec(gallivm, s_bld.type, 255);
> + stencil_refs[0] = lp_build_and(&s_bld, stencil_refs[0], s_max_mask);
> + stencil_refs[1] = stencil_refs[0];
> + }
> + else {
> + /* convert scalar stencil refs into vectors */
> + stencil_refs[0] = lp_build_broadcast_scalar(&s_bld, stencil_refs[0]);
> + stencil_refs[1] = lp_build_broadcast_scalar(&s_bld, stencil_refs[1]);
> + }
>
> s_pass_mask = lp_build_stencil_test(&s_bld, stencil,
> stencil_refs, stencil_vals,
> diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.h b/src/gallium/drivers/llvmpipe/lp_bld_depth.h
> index d169c89..90137ac 100644
> --- a/src/gallium/drivers/llvmpipe/lp_bld_depth.h
> +++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.h
> @@ -68,6 +68,7 @@ lp_build_depth_stencil_test(struct gallivm_state *gallivm,
> LLVMValueRef face,
> LLVMValueRef *z_value,
> LLVMValueRef *s_value,
> + boolean stencil_export,
> boolean do_branch);
>
> void
> diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c
> index 09ac9af..47f1897 100644
> --- a/src/gallium/drivers/llvmpipe/lp_screen.c
> +++ b/src/gallium/drivers/llvmpipe/lp_screen.c
> @@ -165,7 +165,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
> case PIPE_CAP_DEPTH_CLIP_DISABLE:
> return 1;
> case PIPE_CAP_SHADER_STENCIL_EXPORT:
> - return 0;
> + return 1;
> case PIPE_CAP_TGSI_INSTANCEID:
> case PIPE_CAP_VERTEX_ELEMENT_INSTANCE_DIVISOR:
> case PIPE_CAP_START_INSTANCE:
> diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c
> index 35fe7b2..b32d998 100644
> --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c
> +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c
> @@ -295,7 +295,7 @@ generate_fs_loop(struct gallivm_state *gallivm,
> zs_format_desc = util_format_description(key->zsbuf_format);
> assert(zs_format_desc);
>
> - if (!shader->info.base.writes_z) {
> + if (!shader->info.base.writes_z && !shader->info.base.writes_stencil) {
> if (key->alpha.enabled ||
> key->blend.alpha_to_coverage ||
> shader->info.base.uses_kill) {
> @@ -393,6 +393,7 @@ generate_fs_loop(struct gallivm_state *gallivm,
> z, z_fb, s_fb,
> facing,
> &z_value, &s_value,
> + FALSE,
> !simple_shader);
>
> if (depth_mode & EARLY_DEPTH_WRITE) {
> @@ -462,6 +463,10 @@ generate_fs_loop(struct gallivm_state *gallivm,
> int pos0 = find_output_by_semantic(&shader->info.base,
> TGSI_SEMANTIC_POSITION,
> 0);
> + int s_out = find_output_by_semantic(&shader->info.base,
> + TGSI_SEMANTIC_STENCIL,
> + 0);
> + boolean writes_s = FALSE;
>
> if (pos0 != -1 && outputs[pos0][2]) {
> z = LLVMBuildLoad(builder, outputs[pos0][2], "output.z");
> @@ -512,6 +517,13 @@ generate_fs_loop(struct gallivm_state *gallivm,
> }
> }
>
> + if (s_out != -1 && outputs[s_out][1]) {
> + LLVMTypeRef s_type = lp_build_int_vec_type(gallivm, type);
> + stencil_refs[0] = LLVMBuildLoad(builder, outputs[s_out][1], "output.s");
> + stencil_refs[0] = LLVMBuildBitCast(builder, stencil_refs[0], s_type, "");
> + writes_s = TRUE;
> + }
> +
> lp_build_depth_stencil_load_swizzled(gallivm, type,
> zs_format_desc, key->resource_1d,
> depth_ptr, depth_stride,
> @@ -527,6 +539,7 @@ generate_fs_loop(struct gallivm_state *gallivm,
> z, z_fb, s_fb,
> facing,
> &z_value, &s_value,
> + writes_s,
> !simple_shader);
> /* Late Z write */
> if (depth_mode & LATE_DEPTH_WRITE) {
> diff --git a/src/gallium/drivers/llvmpipe/lp_surface.c b/src/gallium/drivers/llvmpipe/lp_surface.c
> index 08f968f..b985877 100644
> --- a/src/gallium/drivers/llvmpipe/lp_surface.c
> +++ b/src/gallium/drivers/llvmpipe/lp_surface.c
> @@ -139,11 +139,6 @@ static void lp_blit(struct pipe_context *pipe,
> return; /* done */
> }
>
> - if (info.mask & PIPE_MASK_S) {
> - debug_printf("llvmpipe: cannot blit stencil, skipping\n");
> - info.mask &= ~PIPE_MASK_S;
> - }
> -
> if (!util_blitter_is_blit_supported(lp->blitter, &info)) {
> debug_printf("llvmpipe: blit unsupported %s -> %s\n",
> util_format_short_name(info.src.resource->format),
> --
> 1.9.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
More information about the mesa-dev
mailing list