Commit 7ca72f17 authored by Boris Brezillon's avatar Boris Brezillon Committed by Marge Bot

gallium/util: Fix depth/stencil blit shaders

When loading the depth, we want to store component X of the texel fetch
result into position.Z which can't be expressed without an extra MOV
unless the backend replicates the depth.

Stencil is always expected in the Y component, but some TGSI shaders
assume it will also be available in X, which only works if the backend
replicates the stencil value.

Let's fix those shaders so backend drivers are not forced to replicate
the depth/stencil values.
Signed-off-by: Boris Brezillon's avatarBoris Brezillon <>
Reviewed-by: Erik Faye-Lund 's avatarErik Faye-Lund <>
Part-of: <mesa/mesa!7922>
parent e15fd6c3
......@@ -423,12 +423,12 @@ util_make_fs_blit_zs(struct pipe_context *pipe, unsigned zs_mask,
ureg_load_tex(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_X), coord,
ureg_load_tex(ureg, ureg_writemask(tmp, TGSI_WRITEMASK_Y), coord,
stencil_sampler, tex_target, load_level_zero, use_txf);
stencil = ureg_DECL_output(ureg, TGSI_SEMANTIC_STENCIL, 0);
ureg_MOV(ureg, ureg_writemask(stencil, TGSI_WRITEMASK_Y),
ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_X));
ureg_scalar(ureg_src(tmp), TGSI_SWIZZLE_Y));
......@@ -530,6 +530,7 @@ util_make_fs_blit_msaa_gen(struct pipe_context *pipe,
const char *samp_type,
const char *output_semantic,
const char *output_mask,
const char *swizzle,
const char *conversion_decl,
const char *conversion)
......@@ -545,7 +546,7 @@ util_make_fs_blit_msaa_gen(struct pipe_context *pipe,
"F2U TEMP[0], IN[0]\n"
"TXF TEMP[0], TEMP[0], SAMP[0], %s\n"
"MOV OUT[0]%s, TEMP[0]\n"
"MOV OUT[0]%s, TEMP[0]%s\n"
const char *type = tgsi_texture_names[tgsi_tex];
......@@ -557,7 +558,7 @@ util_make_fs_blit_msaa_gen(struct pipe_context *pipe,
snprintf(text, sizeof(text), shader_templ, type, samp_type,
output_semantic, conversion_decl, type, conversion, output_mask);
output_semantic, conversion_decl, type, conversion, output_mask, swizzle);
if (!tgsi_text_translate(text, tokens, ARRAY_SIZE(tokens))) {
......@@ -608,7 +609,7 @@ util_make_fs_blit_msaa_color(struct pipe_context *pipe,
return util_make_fs_blit_msaa_gen(pipe, tgsi_tex, samp_type,
"COLOR[0]", "", conversion_decl,
"COLOR[0]", "", "", conversion_decl,
......@@ -623,7 +624,7 @@ util_make_fs_blit_msaa_depth(struct pipe_context *pipe,
enum tgsi_texture_type tgsi_tex)
return util_make_fs_blit_msaa_gen(pipe, tgsi_tex, "FLOAT",
"POSITION", ".z", "", "");
"POSITION", ".z", ".xxxx", "", "");
......@@ -637,7 +638,7 @@ util_make_fs_blit_msaa_stencil(struct pipe_context *pipe,
enum tgsi_texture_type tgsi_tex)
return util_make_fs_blit_msaa_gen(pipe, tgsi_tex, "UINT",
"STENCIL", ".y", "", "");
"STENCIL", ".y", "", "", "");
......@@ -660,10 +661,11 @@ util_make_fs_blit_msaa_depthstencil(struct pipe_context *pipe,
"DCL SVIEW[1], %s, UINT\n"
"DCL TEMP[0]\n"
"DCL TEMP[0..1]\n"
"F2U TEMP[0], IN[0]\n"
"TXF OUT[0].z, TEMP[0], SAMP[0], %s\n"
"TXF TEMP[1], TEMP[0], SAMP[0], %s\n"
"MOV OUT[0].z, TEMP[1].xxxx\n"
"TXF OUT[1].y, TEMP[0], SAMP[1], %s\n"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment