I will drop this patch. There is up to -15% change in performance for legacy apps. Not worth it.
Marek On Mon, Jan 5, 2015 at 12:18 AM, Marek Olšák <mar...@gmail.com> wrote: > From: Marek Olšák <marek.ol...@amd.com> > > This can be done using the SPI mapping only. If two_side is disabled, > VS COLOR is loaded to both PS COLOR and PS BCOLOR inputs. > > The disadvantage is that the PS always chooses the color according to FACE > even though two_side is disabled. > > Since PS color inputs can only be used in the GL compatibility profile, only > legacy apps should be affected, which is acceptable. > > The PS shader key now only contains states for PS exports. The key can be > eliminated completely by implementing a pixel shader export subroutine, > so that we can stop compiling PS on demand. (it's also necessary for taking > advantage of all the SPI color and Z formats) > --- > src/gallium/drivers/radeonsi/si_pipe.h | 1 + > src/gallium/drivers/radeonsi/si_shader.c | 3 +-- > src/gallium/drivers/radeonsi/si_shader.h | 1 - > src/gallium/drivers/radeonsi/si_state_shaders.c | 27 > ++++++++++++++----------- > 4 files changed, 17 insertions(+), 15 deletions(-) > > diff --git a/src/gallium/drivers/radeonsi/si_pipe.h > b/src/gallium/drivers/radeonsi/si_pipe.h > index ba305e7..00825c1 100644 > --- a/src/gallium/drivers/radeonsi/si_pipe.h > +++ b/src/gallium/drivers/radeonsi/si_pipe.h > @@ -135,6 +135,7 @@ struct si_context { > /* shader information */ > unsigned sprite_coord_enable; > bool flatshade; > + bool color_two_side; > struct si_descriptors vertex_buffers; > struct si_buffer_resources const_buffers[SI_NUM_SHADERS]; > struct si_buffer_resources rw_buffers[SI_NUM_SHADERS]; > diff --git a/src/gallium/drivers/radeonsi/si_shader.c > b/src/gallium/drivers/radeonsi/si_shader.c > index 89099e2..1073723 100644 > --- a/src/gallium/drivers/radeonsi/si_shader.c > +++ b/src/gallium/drivers/radeonsi/si_shader.c > @@ -479,8 +479,7 @@ static void declare_input_fs( > */ > intr_name = interp_param ? "llvm.SI.fs.interp" : > "llvm.SI.fs.constant"; > > - if (decl->Semantic.Name == TGSI_SEMANTIC_COLOR && > - si_shader_ctx->shader->key.ps.color_two_side) { > + if (decl->Semantic.Name == TGSI_SEMANTIC_COLOR) { > LLVMValueRef args[4]; > LLVMValueRef face, is_face_positive; > LLVMValueRef back_attr_number = > diff --git a/src/gallium/drivers/radeonsi/si_shader.h > b/src/gallium/drivers/radeonsi/si_shader.h > index 21692f0..93461be 100644 > --- a/src/gallium/drivers/radeonsi/si_shader.h > +++ b/src/gallium/drivers/radeonsi/si_shader.h > @@ -121,7 +121,6 @@ union si_shader_key { > struct { > unsigned export_16bpc:8; > unsigned last_cbuf:3; > - unsigned color_two_side:1; > unsigned alpha_func:3; > unsigned alpha_to_one:1; > } ps; > diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c > b/src/gallium/drivers/radeonsi/si_state_shaders.c > index 437dd95..282fcf2 100644 > --- a/src/gallium/drivers/radeonsi/si_state_shaders.c > +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c > @@ -360,15 +360,12 @@ static INLINE void si_shader_selector_key(struct > pipe_context *ctx, > 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) { > - key->ps.color_two_side = > sctx->queued.named.rasterizer->two_side; > - > - if (sctx->queued.named.blend) { > - key->ps.alpha_to_one = > sctx->queued.named.blend->alpha_to_one && > - > sctx->queued.named.rasterizer->multisample_enable && > - > !sctx->framebuffer.cb0_is_integer; > - } > + if (sctx->queued.named.rasterizer && > sctx->queued.named.blend) { > + key->ps.alpha_to_one = > sctx->queued.named.blend->alpha_to_one && > + > sctx->queued.named.rasterizer->multisample_enable && > + > !sctx->framebuffer.cb0_is_integer; > } > + > if (sctx->queued.named.dsa) { > key->ps.alpha_func = > sctx->queued.named.dsa->alpha_func; > > @@ -622,6 +619,7 @@ static void si_update_spi_map(struct si_context *sctx) > unsigned index = psinfo->input_semantic_index[i]; > unsigned interpolate = psinfo->input_interpolate[i]; > unsigned param_offset = ps->ps_input_param_offset[i]; > + bool is_bcolor = false; > > if (name == TGSI_SEMANTIC_POSITION || > name == TGSI_SEMANTIC_FACE) > @@ -657,10 +655,13 @@ bcolor: > R_028644_SPI_PS_INPUT_CNTL_0 + param_offset * > 4, > tmp); > > - if (name == TGSI_SEMANTIC_COLOR && > - ps->key.ps.color_two_side) { > - name = TGSI_SEMANTIC_BCOLOR; > + if (name == TGSI_SEMANTIC_COLOR && !is_bcolor) { > param_offset++; > + is_bcolor = true; > + /* If two-sided colors are enabled, load BCOLOR, > + * otherwise load COLOR again. */ > + if (sctx->color_two_side) > + name = TGSI_SEMANTIC_BCOLOR; > goto bcolor; > } > } > @@ -776,9 +777,11 @@ void si_update_shaders(struct si_context *sctx) > > if (si_pm4_state_changed(sctx, ps) || si_pm4_state_changed(sctx, vs) > || > sctx->sprite_coord_enable != rs->sprite_coord_enable || > - sctx->flatshade != rs->flatshade) { > + sctx->flatshade != rs->flatshade || > + sctx->color_two_side != rs->two_side) { > sctx->sprite_coord_enable = rs->sprite_coord_enable; > sctx->flatshade = rs->flatshade; > + sctx->color_two_side = rs->two_side; > si_update_spi_map(sctx); > } > > -- > 2.1.0 > _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev