summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2010-06-24 05:54:18 +0200
committerMarek Olšák <[email protected]>2010-06-24 06:10:47 +0200
commit69adebf5945d994485c584c183c148fc2c1373ed (patch)
treec37309cc66b3e64091621db485f5d0ba563a8eb5 /src
parent93bce03b275f66b6b2db410bbef38954de6a617c (diff)
r300g: move AA registers into the new AA state
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/r300/r300_context.c7
-rw-r--r--src/gallium/drivers/r300/r300_context.h10
-rw-r--r--src/gallium/drivers/r300/r300_emit.c31
-rw-r--r--src/gallium/drivers/r300/r300_emit.h2
-rw-r--r--src/gallium/drivers/r300/r300_render.c28
-rw-r--r--src/gallium/drivers/r300/r300_state.c28
-rw-r--r--src/gallium/drivers/r300/r300_state_invariant.c3
7 files changed, 80 insertions, 29 deletions
diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
index 85190eac2b8..46d1ed9dbff 100644
--- a/src/gallium/drivers/r300/r300_context.c
+++ b/src/gallium/drivers/r300/r300_context.c
@@ -73,6 +73,7 @@ static void r300_destroy_context(struct pipe_context* context)
translate_cache_destroy(r300->tran.translate_cache);
+ FREE(r300->aa_state.state);
FREE(r300->blend_color_state.state);
FREE(r300->clip_state.state);
FREE(r300->fb_state.state);
@@ -118,16 +119,17 @@ static void r300_setup_atoms(struct r300_context* r300)
* Some atoms never change size, others change every emit - those have
* the size of 0 here. */
make_empty_list(&r300->atom_list);
- /* XXX unsorted. */
- R300_INIT_ATOM(invariant_state, 71);
/* RB3D (unpipelined), ZB (unpipelined), US, SC. */
R300_INIT_ATOM(gpu_flush, 9);
+ R300_INIT_ATOM(aa_state, 4);
R300_INIT_ATOM(fb_state, 0);
R300_INIT_ATOM(ztop_state, 2);
R300_INIT_ATOM(dsa_state, is_r500 ? 8 : 6);
R300_INIT_ATOM(blend_state, 8);
R300_INIT_ATOM(blend_color_state, is_r500 ? 3 : 2);
R300_INIT_ATOM(scissor_state, 3);
+ /* All sorts of things. */
+ R300_INIT_ATOM(invariant_state, 22);
/* VAP. */
R300_INIT_ATOM(viewport_state, 9);
R300_INIT_ATOM(pvs_flush, 2);
@@ -156,6 +158,7 @@ static void r300_setup_atoms(struct r300_context* r300)
}
/* Some non-CSO atoms need explicit space to store the state locally. */
+ r300->aa_state.state = CALLOC_STRUCT(r300_aa_state);
r300->blend_color_state.state = CALLOC_STRUCT(r300_blend_color_state);
r300->clip_state.state = CALLOC_STRUCT(r300_clip_state);
r300->fb_state.state = CALLOC_STRUCT(pipe_framebuffer_state);
diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
index c5c662afd0f..976ef20510c 100644
--- a/src/gallium/drivers/r300/r300_context.h
+++ b/src/gallium/drivers/r300/r300_context.h
@@ -61,6 +61,13 @@ struct r300_atom {
boolean allow_null_state;
};
+struct r300_aa_state {
+ struct r300_surface *dest;
+
+ uint32_t aa_config;
+ uint32_t aaresolve_ctl;
+};
+
struct r300_blend_state {
uint32_t cb[8];
uint32_t cb_no_readwrite[8];
@@ -111,7 +118,6 @@ struct r300_rs_state {
uint32_t vap_control_status; /* R300_VAP_CNTL_STATUS: 0x2140 */
uint32_t multisample_position_0;/* R300_GB_MSPOS0: 0x4010 */
uint32_t multisample_position_1;/* R300_GB_MSPOS1: 0x4014 */
- uint32_t antialiasing_config; /* R300_GB_AA_CONFIG: 0x4020 */
uint32_t point_size; /* R300_GA_POINT_SIZE: 0x421c */
uint32_t point_minmax; /* R300_GA_POINT_MINMAX: 0x4230 */
uint32_t line_control; /* R300_GA_LINE_CNTL: 0x4234 */
@@ -425,6 +431,8 @@ struct r300_context {
/* Various CSO state objects. */
/* Beginning of atom list. */
struct r300_atom atom_list;
+ /* Anti-aliasing (MSAA) state. */
+ struct r300_atom aa_state;
/* Blend state. */
struct r300_atom blend_state;
/* Blend color state. */
diff --git a/src/gallium/drivers/r300/r300_emit.c b/src/gallium/drivers/r300/r300_emit.c
index dd6cc4d4f84..2a03e5a70f1 100644
--- a/src/gallium/drivers/r300/r300_emit.c
+++ b/src/gallium/drivers/r300/r300_emit.c
@@ -295,6 +295,26 @@ void r300_emit_gpu_flush(struct r300_context *r300, unsigned size, void *state)
END_CS;
}
+void r300_emit_aa_state(struct r300_context *r300, unsigned size, void *state)
+{
+ struct r300_aa_state *aa = (struct r300_aa_state*)state;
+ CS_LOCALS(r300);
+
+ BEGIN_CS(size);
+ OUT_CS_REG(R300_GB_AA_CONFIG, aa->aa_config);
+
+ if (aa->dest) {
+ OUT_CS_REG_SEQ(R300_RB3D_AARESOLVE_OFFSET, 1);
+ OUT_CS_RELOC(aa->dest->buffer, aa->dest->offset, 0, aa->dest->domain, 0);
+
+ OUT_CS_REG_SEQ(R300_RB3D_AARESOLVE_PITCH, 1);
+ OUT_CS_RELOC(aa->dest->buffer, aa->dest->pitch, 0, aa->dest->domain, 0);
+ }
+
+ OUT_CS_REG(R300_RB3D_AARESOLVE_CTL, aa->aaresolve_ctl);
+ END_CS;
+}
+
void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state)
{
struct pipe_framebuffer_state* fb = (struct pipe_framebuffer_state*)state;
@@ -511,7 +531,7 @@ void r300_emit_rs_state(struct r300_context* r300, unsigned size, void* state)
struct r300_rs_state* rs = state;
struct pipe_framebuffer_state* fb = r300->fb_state.state;
float scale, offset;
- unsigned mspos0, mspos1, aa_config;
+ unsigned mspos0, mspos1;
CS_LOCALS(r300);
BEGIN_CS(size);
@@ -520,26 +540,21 @@ void r300_emit_rs_state(struct r300_context* r300, unsigned size, void* state)
/* Multisampling. Depends on framebuffer sample count. */
if (r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0)) {
if (fb->nr_cbufs && fb->cbufs[0]->texture->nr_samples > 1) {
- aa_config = R300_GB_AA_CONFIG_AA_ENABLE;
/* Subsample placement. These may not be optimal. */
switch (fb->cbufs[0]->texture->nr_samples) {
case 2:
- aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_2;
mspos0 = 0x33996633;
mspos1 = 0x6666663;
break;
case 3:
- aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_3;
mspos0 = 0x33936933;
mspos1 = 0x6666663;
break;
case 4:
- aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_4;
mspos0 = 0x33939933;
mspos1 = 0x3966663;
break;
case 6:
- aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_6;
mspos0 = 0x22a2aa22;
mspos1 = 0x2a65672;
break;
@@ -553,14 +568,10 @@ void r300_emit_rs_state(struct r300_context* r300, unsigned size, void* state)
OUT_CS_REG_SEQ(R300_GB_MSPOS0, 2);
OUT_CS(mspos0);
OUT_CS(mspos1);
-
- OUT_CS_REG(R300_GB_AA_CONFIG, aa_config);
} else {
OUT_CS_REG_SEQ(R300_GB_MSPOS0, 2);
OUT_CS(rs->multisample_position_0);
OUT_CS(rs->multisample_position_1);
-
- OUT_CS_REG(R300_GB_AA_CONFIG, rs->antialiasing_config);
}
}
diff --git a/src/gallium/drivers/r300/r300_emit.h b/src/gallium/drivers/r300/r300_emit.h
index 16a2b5e9f17..0d4e1f7a23b 100644
--- a/src/gallium/drivers/r300/r300_emit.h
+++ b/src/gallium/drivers/r300/r300_emit.h
@@ -61,6 +61,8 @@ void r300_emit_fb_state(struct r300_context* r300, unsigned size, void* state);
void r300_emit_gpu_flush(struct r300_context *r300, unsigned size, void *state);
+void r300_emit_aa_state(struct r300_context *r300, unsigned size, void *state);
+
void r300_emit_query_start(struct r300_context *r300, unsigned size, void *state);
void r300_emit_query_end(struct r300_context* r300);
diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
index 0fd05b51ac1..99ad162504c 100644
--- a/src/gallium/drivers/r300/r300_render.c
+++ b/src/gallium/drivers/r300/r300_render.c
@@ -1028,33 +1028,35 @@ static void r300_resource_resolve(struct pipe_context* pipe,
struct pipe_subresource subsrc)
{
struct r300_context* r300 = r300_context(pipe);
- struct r300_surface* destsurf = r300_surface(
- dest->screen->get_tex_surface(dest->screen,
- dest, subdest.face, subdest.level, 0, 0));
+ struct r300_aa_state *aa = (struct r300_aa_state*)r300->aa_state.state;
struct pipe_surface* srcsurf = src->screen->get_tex_surface(src->screen,
src, subsrc.face, subsrc.level, 0, 0);
float color[] = {0, 0, 0, 0};
- CS_LOCALS(r300);
DBG(r300, DBG_DRAW, "r300: Resolving resource...\n");
- OUT_CS_REG_SEQ(R300_RB3D_AARESOLVE_OFFSET, 1);
- OUT_CS_RELOC(destsurf->buffer, destsurf->offset, 0, destsurf->domain, 0);
-
- OUT_CS_REG_SEQ(R300_RB3D_AARESOLVE_PITCH, 1);
- OUT_CS_RELOC(destsurf->buffer, destsurf->pitch, 0, destsurf->domain, 0);
+ /* Enable AA resolve. */
+ aa->dest = r300_surface(
+ dest->screen->get_tex_surface(dest->screen, dest, subdest.face,
+ subdest.level, 0, 0));
- OUT_CS_REG(R300_RB3D_AARESOLVE_CTL,
+ aa->aaresolve_ctl =
R300_RB3D_AARESOLVE_CTL_AARESOLVE_MODE_RESOLVE |
- R300_RB3D_AARESOLVE_CTL_AARESOLVE_ALPHA_AVERAGE);
+ R300_RB3D_AARESOLVE_CTL_AARESOLVE_ALPHA_AVERAGE;
+ r300->aa_state.size = 12;
+ r300->aa_state.dirty = TRUE;
+ /* Resolve the surface. */
r300->context.clear_render_target(pipe,
srcsurf, color, 0, 0, src->width0, src->height0);
- OUT_CS_REG(R300_RB3D_AARESOLVE_CTL, 0x0);
+ /* Disable AA resolve. */
+ aa->aaresolve_ctl = 0;
+ r300->aa_state.size = 4;
+ r300->aa_state.dirty = TRUE;
pipe_surface_reference((struct pipe_surface**)&srcsurf, NULL);
- pipe_surface_reference((struct pipe_surface**)&destsurf, NULL);
+ pipe_surface_reference((struct pipe_surface**)&aa->dest, NULL);
}
void r300_init_render_functions(struct r300_context *r300)
diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
index f2534e473da..9c0f877e814 100644
--- a/src/gallium/drivers/r300/r300_state.c
+++ b/src/gallium/drivers/r300/r300_state.c
@@ -664,6 +664,7 @@ static void
const struct pipe_framebuffer_state* state)
{
struct r300_context* r300 = r300_context(pipe);
+ struct r300_aa_state *aa = (struct r300_aa_state*)r300->aa_state.state;
struct pipe_framebuffer_state *old_state = r300->fb_state.state;
unsigned max_width, max_height, i;
uint32_t zbuffer_bpp = 0;
@@ -687,6 +688,7 @@ static void
}
r300->gpu_flush.dirty = TRUE;
+ r300->aa_state.dirty = TRUE;
r300->fb_state.dirty = TRUE;
/* If nr_cbufs is changed from zero to non-zero or vice versa... */
@@ -725,6 +727,30 @@ static void
}
}
+ /* Set up AA config. */
+ if (r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0)) {
+ if (state->nr_cbufs && state->cbufs[0]->texture->nr_samples > 1) {
+ aa->aa_config = R300_GB_AA_CONFIG_AA_ENABLE;
+
+ switch (state->cbufs[0]->texture->nr_samples) {
+ case 2:
+ aa->aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_2;
+ break;
+ case 3:
+ aa->aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_3;
+ break;
+ case 4:
+ aa->aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_4;
+ break;
+ case 6:
+ aa->aa_config |= R300_GB_AA_CONFIG_NUM_AA_SUBSAMPLES_6;
+ break;
+ }
+ } else {
+ aa->aa_config = 0;
+ }
+ }
+
if (DBG_ON(r300, DBG_FB)) {
fprintf(stderr, "r300: set_framebuffer_state:\n");
for (i = 0; i < state->nr_cbufs; i++) {
@@ -984,7 +1010,7 @@ static void r300_bind_rs_state(struct pipe_context* pipe, void* state)
UPDATE_STATE(state, r300->rs_state);
r300->rs_state.size = 25 + (r300->polygon_offset_enabled ? 5 : 0) +
- (r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0) ? 5 : 0);
+ (r300->rws->get_value(r300->rws, R300_VID_DRM_2_3_0) ? 3 : 0);
if (last_sprite_coord_enable != r300->sprite_coord_enable ||
last_two_sided_color != r300->two_sided_color) {
diff --git a/src/gallium/drivers/r300/r300_state_invariant.c b/src/gallium/drivers/r300/r300_state_invariant.c
index bec6ea1565e..acd20974a00 100644
--- a/src/gallium/drivers/r300/r300_state_invariant.c
+++ b/src/gallium/drivers/r300/r300_state_invariant.c
@@ -38,9 +38,8 @@ void r300_emit_invariant_state(struct r300_context* r300,
{
CS_LOCALS(r300);
- BEGIN_CS(20 + (r300->screen->caps.is_rv350 ? 4 : 0));
+ BEGIN_CS(18 + (r300->screen->caps.is_rv350 ? 4 : 0));
- OUT_CS_REG(R300_RB3D_AARESOLVE_CTL, 0);
OUT_CS_REG(R300_GB_SELECT, 0);
OUT_CS_REG(R300_FG_FOG_BLEND, 0);
OUT_CS_REG(R300_GA_ROUND_MODE, 1);