}
}
+
+static int setup_cb_flush(struct r600_context *rctx, struct radeon_state *flush)
+{
+ struct r600_screen *rscreen = rctx->screen;
+ struct r600_resource_texture *rtex;
+ struct r600_resource *rbuffer;
+ struct pipe_surface *surf;
+ int i;
+
+ radeon_state_init(flush, rscreen->rw, R600_STATE_CB_FLUSH, 0, 0);
+
+ for (i = 0; i < rctx->framebuffer->state.framebuffer.nr_cbufs; i++) {
+ surf = rctx->framebuffer->state.framebuffer.cbufs[i];
+
+ rtex = (struct r600_resource_texture*)surf->texture;
+ rbuffer = &rtex->resource;
+ /* just need to the bo to the flush list */
+ flush->bo[i] = radeon_bo_incref(rscreen->rw, rbuffer->bo);
+ flush->placement[i] = RADEON_GEM_DOMAIN_VRAM;
+ }
+ flush->nbo = rctx->framebuffer->state.framebuffer.nr_cbufs;
+ return radeon_state_pm4(flush);
+}
+
+static int setup_db_flush(struct r600_context *rctx, struct radeon_state *flush)
+{
+ struct r600_screen *rscreen = rctx->screen;
+ struct r600_resource_texture *rtex;
+ struct r600_resource *rbuffer;
+ struct pipe_surface *surf;
+ int i;
+
+ surf = rctx->framebuffer->state.framebuffer.zsbuf;
+
+ if (!surf)
+ return 0;
+
+ radeon_state_init(flush, rscreen->rw, R600_STATE_DB_FLUSH, 0, 0);
+ rtex = (struct r600_resource_texture*)surf->texture;
+ rbuffer = &rtex->resource;
+ /* just need to the bo to the flush list */
+ flush->bo[0] = radeon_bo_incref(rscreen->rw, rbuffer->bo);
+ flush->placement[0] = RADEON_GEM_DOMAIN_VRAM;
+
+ flush->nbo = 1;
+ return radeon_state_pm4(flush);
+}
+
int r600_context_hw_states(struct pipe_context *ctx)
{
struct r600_context *rctx = r600_context(ctx);
rctx->vtbl->scissor(rctx, &rctx->hw_states.scissor);
rctx->vtbl->dsa(rctx, &rctx->hw_states.dsa);
rctx->vtbl->cb_cntl(rctx, &rctx->hw_states.cb_cntl);
+
+ /* setup flushes */
+ setup_db_flush(rctx, &rctx->hw_states.db_flush);
+ setup_cb_flush(rctx, &rctx->hw_states.cb_flush);
/* bind states */
radeon_draw_bind(&rctx->draw, &rctx->hw_states.rasterizer);
radeon_draw_bind(&rctx->draw, &rctx->config);
+ radeon_draw_bind(&rctx->draw, &rctx->hw_states.db_flush);
+ radeon_draw_bind(&rctx->draw, &rctx->hw_states.cb_flush);
+
if (rctx->viewport) {
radeon_draw_bind(&rctx->draw, &rctx->viewport->rstate[0]);
}
static int r600_state_pm4_query_begin(struct radeon_state *state);
static int r600_state_pm4_query_end(struct radeon_state *state);
static int r700_state_pm4_config(struct radeon_state *state);
-static int r700_state_pm4_cb0(struct radeon_state *state);
-static int r700_state_pm4_db(struct radeon_state *state);
+static int r600_state_pm4_db_flush(struct radeon_state *state);
+static int r600_state_pm4_cb_flush(struct radeon_state *state);
#include "r600_states.h"
{ R600_STATE_UCP, 1, 0, r600_state_pm4_generic, SUB_NONE(UCP) },
{ R600_STATE_VGT, 1, 0, r600_state_pm4_vgt, SUB_NONE(VGT) },
{ R600_STATE_DRAW, 1, 0, r600_state_pm4_draw, SUB_NONE(DRAW) },
+ { R600_STATE_CB_FLUSH, 1, 0, r600_state_pm4_cb_flush, SUB_NONE(CB_FLUSH) },
+ { R600_STATE_DB_FLUSH, 1, 0, r600_state_pm4_db_flush, SUB_NONE(DB_FLUSH) },
};
#define STYPES_SIZE Elements(r600_stypes)
{
int r;
- r600_state_pm4_with_flush(state, S_0085F0_CB_ACTION_ENA(1) |
- S_0085F0_CB0_DEST_BASE_ENA(1));
r = r600_state_pm4_generic(state);
if (r)
return r;
return 0;
}
-static int r700_state_pm4_cb0(struct radeon_state *state)
-{
- int r;
-
- r600_state_pm4_with_flush(state, S_0085F0_CB_ACTION_ENA(1) |
- S_0085F0_CB0_DEST_BASE_ENA(1));
- r = r600_state_pm4_generic(state);
- if (r)
- return r;
- return 0;
-}
-
static int r600_state_pm4_db(struct radeon_state *state)
{
int r;
- r600_state_pm4_with_flush(state, S_0085F0_DB_ACTION_ENA(1) |
- S_0085F0_DB_DEST_BASE_ENA(1));
r = r600_state_pm4_generic(state);
if (r)
return r;
return 0;
}
-static int r700_state_pm4_db(struct radeon_state *state)
-{
- int r;
-
- r600_state_pm4_with_flush(state, S_0085F0_DB_ACTION_ENA(1) |
- S_0085F0_DB_DEST_BASE_ENA(1));
- r = r600_state_pm4_generic(state);
- if (r)
- return r;
- return 0;
-}
-
static int r600_state_pm4_config(struct radeon_state *state)
{
state->pm4[state->cpm4++] = PKT3(PKT3_START_3D_CMDBUF, 0);
return 0;
}
+static int r600_state_pm4_cb_flush(struct radeon_state *state)
+{
+ if (!state->nbo)
+ return 0;
+
+ r600_state_pm4_with_flush(state, S_0085F0_CB_ACTION_ENA(1) |
+ S_0085F0_CB0_DEST_BASE_ENA(1));
+
+ return 0;
+}
+
+static int r600_state_pm4_db_flush(struct radeon_state *state)
+{
+ if (!state->nbo)
+ return 0;
+
+ r600_state_pm4_with_flush(state, S_0085F0_DB_ACTION_ENA(1) |
+ S_0085F0_DB_DEST_BASE_ENA(1));
+
+ return 0;
+}
+
static int r600_state_pm4_resource(struct radeon_state *state)
{
u32 flags, type, nbo, offset, soffset;
info->pm4 = r700_state_pm4_config;
break;
case R600_STATE_CB0:
- info->pm4 = r700_state_pm4_cb0;
+ info->pm4 = r600_state_pm4_generic;
break;
case R600_STATE_DB:
- info->pm4 = r700_state_pm4_db;
+ info->pm4 = r600_state_pm4_generic;
+ break;
};
}
}