summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/radeonsi
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2013-07-30 22:29:29 +0200
committerMarek Olšák <[email protected]>2013-08-17 01:48:25 +0200
commit6d4755a4d75436fb117b28d18fa19d2461b6621d (patch)
treeaff559258cfc1ee36108ca1fcf31b88641fdc218 /src/gallium/drivers/radeonsi
parent07955d4f2b969efb59b9c35c1fba5a0cae2cdc55 (diff)
radeonsi: implement GL_SAMPLE_ALPHA_TO_ONE
Reviewed-by: Michel Dänzer <[email protected]>
Diffstat (limited to 'src/gallium/drivers/radeonsi')
-rw-r--r--src/gallium/drivers/radeonsi/radeonsi_pipe.h1
-rw-r--r--src/gallium/drivers/radeonsi/radeonsi_shader.c14
-rw-r--r--src/gallium/drivers/radeonsi/radeonsi_shader.h1
-rw-r--r--src/gallium/drivers/radeonsi/si_state.c12
-rw-r--r--src/gallium/drivers/radeonsi/si_state.h3
5 files changed, 30 insertions, 1 deletions
diff --git a/src/gallium/drivers/radeonsi/radeonsi_pipe.h b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
index fa6a5399880..b909323cdfd 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_pipe.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_pipe.h
@@ -154,6 +154,7 @@ struct r600_context {
struct si_vertex_element *vertex_elements;
struct pipe_framebuffer_state framebuffer;
unsigned fb_log_samples;
+ unsigned fb_cb0_is_integer;
unsigned pa_sc_line_stipple;
unsigned pa_su_sc_mode_cntl;
/* for saving when using blitter */
diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c b/src/gallium/drivers/radeonsi/radeonsi_shader.c
index 6bf4b05ec87..cbe10ccaa1f 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.c
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c
@@ -561,6 +561,17 @@ static void si_alpha_test(struct lp_build_tgsi_context *bld_base,
}
}
+static void si_alpha_to_one(struct lp_build_tgsi_context *bld_base,
+ unsigned index)
+{
+ struct si_shader_context *si_shader_ctx = si_shader_context(bld_base);
+
+ /* set alpha to one */
+ LLVMBuildStore(bld_base->base.gallivm->builder,
+ bld_base->base.one,
+ si_shader_ctx->radeon_bld.soa.outputs[index][3]);
+}
+
static void si_llvm_emit_clipvertex(struct lp_build_tgsi_context * bld_base,
LLVMValueRef (*pos)[9], unsigned index)
{
@@ -707,6 +718,9 @@ handle_semantic:
param_count++;
} else {
target = V_008DFC_SQ_EXP_MRT + color_count;
+ if (si_shader_ctx->shader->key.ps.alpha_to_one) {
+ si_alpha_to_one(bld_base, index);
+ }
if (color_count == 0 &&
si_shader_ctx->shader->key.ps.alpha_func != PIPE_FUNC_ALWAYS)
si_alpha_test(bld_base, index);
diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.h b/src/gallium/drivers/radeonsi/radeonsi_shader.h
index 2d4468a2f37..d12892b3b6a 100644
--- a/src/gallium/drivers/radeonsi/radeonsi_shader.h
+++ b/src/gallium/drivers/radeonsi/radeonsi_shader.h
@@ -124,6 +124,7 @@ union si_shader_key {
unsigned color_two_side:1;
unsigned alpha_func:3;
unsigned flatshade:1;
+ unsigned alpha_to_one:1;
float alpha_ref;
} ps;
struct {
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index ccd826e0ec6..6e286e4792c 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -255,6 +255,8 @@ static void *si_create_blend_state_mode(struct pipe_context *ctx,
if (blend == NULL)
return NULL;
+ blend->alpha_to_one = state->alpha_to_one;
+
color_control = S_028808_MODE(mode);
if (state->logicop_enable) {
color_control |= S_028808_ROP3(state->logicop_func | (state->logicop_func << 4));
@@ -520,6 +522,7 @@ static void *si_create_rs_state(struct pipe_context *ctx,
}
rs->two_side = state->light_twoside;
+ rs->multisample_enable = state->multisample;
rs->clip_plane_enable = state->clip_plane_enable;
polygon_dual_mode = (state->fill_front != PIPE_POLYGON_MODE_FILL ||
@@ -2247,6 +2250,8 @@ static void si_set_framebuffer_state(struct pipe_context *ctx,
si_set_msaa_state(rctx, pm4, nr_samples);
rctx->fb_log_samples = util_logbase2(nr_samples);
+ rctx->fb_cb0_is_integer = state->nr_cbufs &&
+ util_format_is_pure_integer(state->cbufs[0]->format);
si_pm4_set_state(rctx, framebuffer, pm4);
si_update_fb_rs_state(rctx);
@@ -2281,9 +2286,16 @@ static INLINE void si_shader_selector_key(struct pipe_context *ctx,
if (sel->fs_write_all)
key->ps.nr_cbufs = rctx->framebuffer.nr_cbufs;
key->ps.export_16bpc = rctx->export_16bpc;
+
if (rctx->queued.named.rasterizer) {
key->ps.color_two_side = rctx->queued.named.rasterizer->two_side;
key->ps.flatshade = rctx->queued.named.rasterizer->flatshade;
+
+ if (rctx->queued.named.blend) {
+ key->ps.alpha_to_one = rctx->queued.named.blend->alpha_to_one &&
+ rctx->queued.named.rasterizer->multisample_enable &&
+ !rctx->fb_cb0_is_integer;
+ }
}
if (rctx->queued.named.dsa) {
key->ps.alpha_func = rctx->queued.named.dsa->alpha_func;
diff --git a/src/gallium/drivers/radeonsi/si_state.h b/src/gallium/drivers/radeonsi/si_state.h
index bc121048f2c..fc9aa221959 100644
--- a/src/gallium/drivers/radeonsi/si_state.h
+++ b/src/gallium/drivers/radeonsi/si_state.h
@@ -40,7 +40,7 @@ struct si_atom {
struct si_state_blend {
struct si_pm4_state pm4;
uint32_t cb_target_mask;
- uint32_t cb_color_control;
+ bool alpha_to_one;
};
struct si_state_viewport {
@@ -52,6 +52,7 @@ struct si_state_rasterizer {
struct si_pm4_state pm4;
bool flatshade;
bool two_side;
+ bool multisample_enable;
unsigned sprite_coord_enable;
unsigned pa_sc_line_stipple;
unsigned pa_su_sc_mode_cntl;