radeonsi: don't recompile shaders when changing nr_cbufs from 0 to 1
authorMarek Olšák <marek.olsak@amd.com>
Sat, 4 Oct 2014 18:44:23 +0000 (20:44 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Sun, 12 Oct 2014 21:52:07 +0000 (23:52 +0200)
Both cases are equivalent.

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state.c

index c9e67922c3b2e059075108d2de57540c5c276e4e..5a47055fc72389c4b598a09fe0a7160e38499104 100644 (file)
@@ -1479,8 +1479,8 @@ static void si_llvm_emit_fs_epilogue(struct lp_build_tgsi_context * bld_base)
                                /* Handle FS_COLOR0_WRITES_ALL_CBUFS. */
                                if (shader->selector->info.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS] &&
                                     shader->output[i].sid == 0 &&
-                                   si_shader_ctx->shader->key.ps.nr_cbufs > 1) {
-                                       for (int c = 1; c < si_shader_ctx->shader->key.ps.nr_cbufs; c++) {
+                                   si_shader_ctx->shader->key.ps.last_cbuf > 0) {
+                                       for (int c = 1; c <= si_shader_ctx->shader->key.ps.last_cbuf; c++) {
                                                si_llvm_init_export_args_load(bld_base,
                                                                              si_shader_ctx->radeon_bld.soa.outputs[index],
                                                                              V_008DFC_SQ_EXP_MRT + c, args);
index 76c29fe0f3650a53f591aa14d54b269b081977fb..8468e1a5eb93f31cc024a5b18a471fe6a6c810a0 100644 (file)
@@ -134,7 +134,7 @@ struct si_shader_selector {
 union si_shader_key {
        struct {
                unsigned        export_16bpc:8;
-               unsigned        nr_cbufs:4;
+               unsigned        last_cbuf:3;
                unsigned        color_two_side:1;
                unsigned        alpha_func:3;
                unsigned        flatshade:1;
index 6eec88eb483fb1bb6fc4ed5fd08ec0763048778d..0ef6d97441a5fc6b2e25b7a7327f60fc30fc6456 100644 (file)
@@ -2207,7 +2207,7 @@ static INLINE void si_shader_selector_key(struct pipe_context *ctx,
                }
        } else if (sel->type == PIPE_SHADER_FRAGMENT) {
                if (sel->info.properties[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS])
-                       key->ps.nr_cbufs = sctx->framebuffer.state.nr_cbufs;
+                       key->ps.last_cbuf = MAX2(sctx->framebuffer.state.nr_cbufs, 1) - 1;
                key->ps.export_16bpc = sctx->framebuffer.export_16bpc;
 
                if (sctx->queued.named.rasterizer) {