From 97caf5fa04dbd2148378a9e83c0e232f51552ee2 Mon Sep 17 00:00:00 2001 From: Topi Pohjolainen Date: Wed, 28 Jan 2015 16:36:11 +0200 Subject: [PATCH] meta/blit: Write depth only when asked for Implementing an idea from Ken, on i965 the shader program for 2D blits becomes significantly simpler. Before: pln(8) g6<1>F g4<0,1,0>F g2<8,8,1>F { align1 1Q compacted }; pln(8) g7<1>F g4.4<0,1,0>F g2<8,8,1>F { align1 1Q compacted }; send(8) g2<1>UW g6<8,8,1>F sampler (1, 0, 0, 1) mlen 2 rlen 4 { align1 1Q }; mov(8) g123<1>F g2<8,8,1>F { align1 1Q compacted }; mov(8) g124<1>F g3<8,8,1>F { align1 1Q compacted }; mov(8) g125<1>F g4<8,8,1>F { align1 1Q compacted }; mov(8) g126<1>F g5<8,8,1>F { align1 1Q compacted }; mov(8) g127<1>F g2<8,8,1>F { align1 1Q compacted }; nop ; sendc(8) null g123<8,8,1>F render RT write SIMD8 LastRT Surface = 0 mlen 5 rlen 0 { align1 1Q EOT }; After: pln(8) g6<1>F g4<0,1,0>F g2<8,8,1>F { align1 1Q compacted }; pln(8) g7<1>F g4.4<0,1,0>F g2<8,8,1>F { align1 1Q compacted }; send(8) g124<1>UW g6<8,8,1>F sampler (1, 0, 0, 1) mlen 2 rlen 4 { align1 1Q }; sendc(8) null g124<8,8,1>F render RT write SIMD8 LastRT Surface = 0 mlen 4 rlen 0 { align1 1Q EOT }; v2 (Matt): Removed unintended white-space change Signed-off-by: Topi Pohjolainen Reviewed-by: Kenneth Graunke Reviewed-by: Matt Turner --- src/mesa/drivers/common/meta.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c index ec7564ab7c4..84d6337b670 100644 --- a/src/mesa/drivers/common/meta.c +++ b/src/mesa/drivers/common/meta.c @@ -293,10 +293,11 @@ _mesa_meta_setup_blit_shader(struct gl_context *ctx, "void main()\n" "{\n" " gl_FragColor = %s(texSampler, %s);\n" - " gl_FragDepth = gl_FragColor.x;\n" + "%s" "}\n", fs_preprocess, shader->type, fs_input, - shader->func, shader->texcoords); + shader->func, shader->texcoords, + do_depth ? " gl_FragDepth = gl_FragColor.x;\n" : ""); _mesa_meta_compile_and_link_program(ctx, vs_source, fs_source, ralloc_asprintf(mem_ctx, "%s blit", -- 2.30.2