diff options
author | Marek Olšák <[email protected]> | 2017-05-01 17:34:41 +0200 |
---|---|---|
committer | Emil Velikov <[email protected]> | 2017-05-05 19:35:08 +0100 |
commit | 14bbc51e6d72cf79660e558a3aa3cf2dcf3df529 (patch) | |
tree | db982736fd76407a077765a9721218028ac99bcf | |
parent | caa6baa688fe0c73c72842835db106dd62a2b716 (diff) |
radeonsi/gfx9: fix gl_ViewportIndex
v2: remove unnecessary LLVMBuildAnd calls
Cc: 17.1 <[email protected]>
Reviewed-by: Nicolai Hähnle <[email protected]>
(cherry picked from commit f466683cb07796fa89f96ef87a6f076218ae6db8)
-rw-r--r-- | src/gallium/drivers/radeonsi/si_shader.c | 35 | ||||
-rw-r--r-- | src/gallium/drivers/radeonsi/si_state_shaders.c | 13 |
2 files changed, 40 insertions, 8 deletions
diff --git a/src/gallium/drivers/radeonsi/si_shader.c b/src/gallium/drivers/radeonsi/si_shader.c index bbb1c13cf26..ff18272257a 100644 --- a/src/gallium/drivers/radeonsi/si_shader.c +++ b/src/gallium/drivers/radeonsi/si_shader.c @@ -2344,8 +2344,8 @@ handle_semantic: shader->selector->info.writes_layer) { pos_args[1].enabled_channels = shader->selector->info.writes_psize | (shader->selector->info.writes_edgeflag << 1) | - (shader->selector->info.writes_layer << 2) | - (shader->selector->info.writes_viewport_index << 3); + (shader->selector->info.writes_layer << 2); + pos_args[1].valid_mask = 0; /* EXEC mask */ pos_args[1].done = 0; /* last export? */ pos_args[1].target = V_008DFC_SQ_EXP_POS + 1; @@ -2374,11 +2374,34 @@ handle_semantic: ctx->f32, ""); } - if (shader->selector->info.writes_layer) - pos_args[1].out[2] = layer_value; + if (ctx->screen->b.chip_class >= GFX9) { + /* GFX9 has the layer in out.z[10:0] and the viewport + * index in out.z[19:16]. + */ + if (shader->selector->info.writes_layer) + pos_args[1].out[2] = layer_value; + + if (shader->selector->info.writes_viewport_index) { + LLVMValueRef v = viewport_index_value; + + v = bitcast(bld_base, TGSI_TYPE_UNSIGNED, v); + v = LLVMBuildShl(ctx->gallivm.builder, v, + LLVMConstInt(ctx->i32, 16, 0), ""); + v = LLVMBuildOr(ctx->gallivm.builder, v, + bitcast(bld_base, TGSI_TYPE_UNSIGNED, + pos_args[1].out[2]), ""); + pos_args[1].out[2] = bitcast(bld_base, TGSI_TYPE_FLOAT, v); + pos_args[1].enabled_channels |= 1 << 2; + } + } else { + if (shader->selector->info.writes_layer) + pos_args[1].out[2] = layer_value; - if (shader->selector->info.writes_viewport_index) - pos_args[1].out[3] = viewport_index_value; + if (shader->selector->info.writes_viewport_index) { + pos_args[1].out[3] = viewport_index_value; + pos_args[1].enabled_channels |= 1 << 3; + } + } } for (i = 0; i < 4; i++) diff --git a/src/gallium/drivers/radeonsi/si_state_shaders.c b/src/gallium/drivers/radeonsi/si_state_shaders.c index 3a604eb660a..1f0080ffb8b 100644 --- a/src/gallium/drivers/radeonsi/si_state_shaders.c +++ b/src/gallium/drivers/radeonsi/si_state_shaders.c @@ -655,8 +655,17 @@ static void si_shader_vs(struct si_screen *sscreen, struct si_shader *shader, * not sent again. */ if (!gs) { - si_pm4_set_reg(pm4, R_028A40_VGT_GS_MODE, - S_028A40_MODE(enable_prim_id ? V_028A40_GS_SCENARIO_A : 0)); + unsigned mode = 0; + + /* PrimID needs GS scenario A. + * GFX9 also needs it when ViewportIndex is enabled. + */ + if (enable_prim_id || + (sscreen->b.chip_class >= GFX9 && + shader->selector->info.writes_viewport_index)) + mode = V_028A40_GS_SCENARIO_A; + + si_pm4_set_reg(pm4, R_028A40_VGT_GS_MODE, S_028A40_MODE(mode)); si_pm4_set_reg(pm4, R_028A84_VGT_PRIMITIVEID_EN, enable_prim_id); } else { si_pm4_set_reg(pm4, R_028A40_VGT_GS_MODE, si_vgt_gs_mode(gs)); |