r600g/compute: Use evergreen_cb() for binding RATs

This commit is contained in:
Tom Stellard 2012-06-27 13:37:05 +00:00
parent 960906d16b
commit da9c8a73ec
5 changed files with 48 additions and 70 deletions

View file

@ -50,7 +50,7 @@ static struct r600_resource_texture * create_pool_texture(struct r600_screen * s
memset(&templ, 0, sizeof(templ));
templ.target = PIPE_TEXTURE_1D;
templ.format = PIPE_FORMAT_R32_UNORM;
templ.format = PIPE_FORMAT_R32_UINT;
templ.bind = PIPE_BIND_CUSTOM;
templ.usage = PIPE_USAGE_IMMUTABLE;
templ.flags = 0;

View file

@ -270,12 +270,20 @@ void evergreen_direct_dispatch(
struct pipe_context *ctx_,
const uint *block_layout, const uint *grid_layout)
{
struct r600_context *ctx = (struct r600_context *)ctx_;
/* This struct r600_context* must be called rctx, because the
* r600_pipe_state_add_reg macro assumes there is a local variable
* of type struct r600_context* called rctx.
*/
struct r600_context *rctx = (struct r600_context *)ctx_;
int i;
struct evergreen_compute_resource* res = get_empty_res(ctx->cs_shader,
struct evergreen_compute_resource* res = get_empty_res(rctx->cs_shader,
COMPUTE_RESOURCE_DISPATCH, 0);
struct r600_pipe_state * cb_state = rctx->states[R600_PIPE_STATE_FRAMEBUFFER];
/* Set CB_TARGET_MASK */
r600_pipe_state_add_reg(cb_state, R_028238_CB_TARGET_MASK, rctx->cb_target_mask);
evergreen_reg_set(res, R_008958_VGT_PRIMITIVE_TYPE, V_008958_DI_PT_POINTLIST);
@ -316,6 +324,7 @@ static void compute_emit_cs(struct r600_context *ctx)
int i;
struct r600_resource *onebo = NULL;
struct r600_pipe_state *cb_state;
/* Initialize all the registers common to both 3D and compute. Some
* 3D only register will be initialized by this atom as well, but
@ -334,6 +343,10 @@ static void compute_emit_cs(struct r600_context *ctx)
*/
r600_emit_atom(ctx, &ctx->start_compute_cs_cmd.atom);
/* Emit cb_state */
cb_state = ctx->states[R600_PIPE_STATE_FRAMEBUFFER];
r600_context_pipe_state_emit(ctx, cb_state, RADEON_CP_PACKET3_COMPUTE_MODE);
for (i = 0; i < get_compute_resource_num(); i++) {
if (ctx->cs_shader->resources[i].enabled) {
int j;

View file

@ -228,6 +228,7 @@ int evergreen_compute_get_gpu_format(
{
case PIPE_FORMAT_R8_UNORM:
case PIPE_FORMAT_R32_UNORM:
case PIPE_FORMAT_R32_UINT:
fmt->format = V_028C70_COLOR_32;
fmt->number_type = V_028C70_NUMBER_UNORM;
fmt->num_format_all = 0;
@ -263,80 +264,41 @@ void evergreen_set_rat(
assert((size & 3) == 0);
assert((start & 0xFF) == 0);
int offset;
struct r600_pipe_state * state = CALLOC_STRUCT(r600_pipe_state);
struct pipe_surface rat_templ;
COMPUTE_DBG("bind rat: %i \n", id);
if (id < 8) {
offset = id*0x3c;
}
else {
offset = 8*0x3c + (id-8)*0x1c;
}
/* Create the RAT surface */
memset(&rat_templ, 0, sizeof(rat_templ));
rat_templ.usage = RADEON_USAGE_READWRITE;
rat_templ.format = PIPE_FORMAT_R32_UINT;
rat_templ.u.tex.level = 0;
rat_templ.u.tex.first_layer = 0;
rat_templ.u.tex.last_layer = 0;
int linear = 0;
/* Add the RAT the list of color buffers */
pipe->ctx->framebuffer.cbufs[id] = pipe->ctx->context.create_surface(
(struct pipe_context *)pipe->ctx,
(struct pipe_resource *)bo, &rat_templ);
if (bo->b.b.height0 <= 1 && bo->b.b.depth0 <= 1
&& bo->b.b.target == PIPE_BUFFER) {
linear = 1;
}
/* Update the number of color buffers */
pipe->ctx->nr_cbufs = MAX2(id + 1, pipe->ctx->nr_cbufs);
struct evergreen_compute_resource* res =
get_empty_res(pipe, COMPUTE_RESOURCE_RAT, id);
/* Update the cb_target_mask
* XXX: I think this is a potential spot for bugs once we start doing
* GL interop. cb_target_mask may be modified in the 3D sections
* of this driver. */
pipe->ctx->cb_target_mask |= (0xf << (id * 4));
evergreen_emit_force_reloc(res);
evergreen_reg_set(res, R_028C64_CB_COLOR0_PITCH, 0); ///TODO: for 2D?
evergreen_reg_set(res, R_028C68_CB_COLOR0_SLICE, 0);
/* Get the CB register writes for the RAT */
evergreen_cb(pipe->ctx, state, &pipe->ctx->framebuffer, id);
struct number_type_and_format fmt;
///default config
if (bo->b.b.format == PIPE_FORMAT_NONE) {
fmt.format = V_028C70_COLOR_32;
fmt.number_type = V_028C70_NUMBER_FLOAT;
} else {
evergreen_compute_get_gpu_format(&fmt, bo);
}
evergreen_reg_set(res,
R_028C70_CB_COLOR0_INFO, S_028C70_RAT(1)
| S_028C70_ARRAY_MODE(V_028C70_ARRAY_LINEAR_ALIGNED)
| S_028C70_FORMAT(fmt.format)
| S_028C70_NUMBER_TYPE(fmt.number_type)
);
evergreen_emit_force_reloc(res);
evergreen_reg_set(res, R_028C74_CB_COLOR0_ATTRIB, S_028C74_NON_DISP_TILING_ORDER(1));
evergreen_emit_force_reloc(res);
if (linear) {
/* XXX: Why are we using size instead of bo->b.b.b.width0 ? */
evergreen_reg_set(res, R_028C78_CB_COLOR0_DIM, size);
} else {
evergreen_reg_set(res, R_028C78_CB_COLOR0_DIM,
S_028C78_WIDTH_MAX(bo->b.b.width0)
| S_028C78_HEIGHT_MAX(bo->b.b.height0));
}
if (id < 8) {
evergreen_reg_set(res, R_028C7C_CB_COLOR0_CMASK, 0);
evergreen_emit_force_reloc(res);
evergreen_reg_set(res, R_028C84_CB_COLOR0_FMASK, 0);
evergreen_emit_force_reloc(res);
}
evergreen_reg_set(res, R_028C60_CB_COLOR0_BASE + offset, start >> 8);
res->bo = bo;
res->usage = RADEON_USAGE_READWRITE;
res->coher_bo_size = size;
/* XXX We are setting nr_cbufs to 1 so we can get the correct
* cb flush flags to be emitted with the SURFACE_SYNC packet.
* In the future we should be adding the pipe_surface for this RAT
* to pipe->ctx->framebuffer.cbufs.
*/
pipe->ctx->framebuffer.nr_cbufs = 1;
/* Add the register blocks to the dirty list */
free(pipe->ctx->states[R600_PIPE_STATE_FRAMEBUFFER]);
pipe->ctx->states[R600_PIPE_STATE_FRAMEBUFFER] = state;
r600_context_pipe_state_set(pipe->ctx, state);
}
void evergreen_set_lds(

View file

@ -1293,7 +1293,7 @@ static void evergreen_set_viewport_state(struct pipe_context *ctx,
r600_context_pipe_state_set(rctx, rstate);
}
static void evergreen_cb(struct r600_context *rctx, struct r600_pipe_state *rstate,
void evergreen_cb(struct r600_context *rctx, struct r600_pipe_state *rstate,
const struct pipe_framebuffer_state *state, int cb)
{
struct r600_screen *rscreen = rctx->screen;

View file

@ -425,6 +425,9 @@ boolean evergreen_is_format_supported(struct pipe_screen *screen,
enum pipe_texture_target target,
unsigned sample_count,
unsigned usage);
void evergreen_cb(struct r600_context *rctx, struct r600_pipe_state *rstate,
const struct pipe_framebuffer_state *state, int cb);
void evergreen_update_dual_export_state(struct r600_context * rctx);