summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJerome Glisse <jglisse@redhat.com>2010-01-30 23:39:54 +0100
committerJerome Glisse <jglisse@redhat.com>2010-01-30 23:39:54 +0100
commit834fc7e148bc6c105b54073be9150b1130ebcb3b (patch)
treebfac8dc7aeaeb1d6b4c5551b5da4450323449bad
parente75e54bdbd8cfe05c3ba6bc18b7ad65e928cea4b (diff)
add sx atom
-rw-r--r--r600_atom.c143
-rw-r--r--r600_atom_api.h14
-rw-r--r--radeon_atom.h3
-rw-r--r--test.c14
4 files changed, 153 insertions, 21 deletions
diff --git a/r600_atom.c b/r600_atom.c
index 976a14e..fad84b5 100644
--- a/r600_atom.c
+++ b/r600_atom.c
@@ -99,16 +99,16 @@ static int r600_cb_emit(struct radeon_device *rdev,
cb->pkts[16] = radeon_ib_reloc(ib, cb->bo, cb->placements[0] | cb->placements[1]);
cb->pkts[21] = radeon_ib_reloc(ib, cb->bo, cb->placements[0] | cb->placements[1]);
cb->pkts[26] = radeon_ib_reloc(ib, cb->bo, cb->placements[0] | cb->placements[1]);
- cb->pkts[93] = radeon_ib_reloc(ib, cb->vsshader1, RADEON_GEM_DOMAIN_GTT);
- cb->pkts[98] = radeon_ib_reloc(ib, cb->vsshader1, RADEON_GEM_DOMAIN_GTT);
- cb->pkts[111] = radeon_ib_reloc(ib, cb->vsshader1, RADEON_GEM_DOMAIN_GTT);
- cb->pkts[116] = radeon_ib_reloc(ib, cb->vsshader1, RADEON_GEM_DOMAIN_GTT);
- cb->pkts[132] = radeon_ib_reloc(ib, cb->psshader1, RADEON_GEM_DOMAIN_GTT);
- cb->pkts[137] = radeon_ib_reloc(ib, cb->psshader1, RADEON_GEM_DOMAIN_GTT);
- cb->pkts[162] = radeon_ib_reloc(ib, cb->vbo1, RADEON_GEM_DOMAIN_GTT);
- cb->pkts[173] = radeon_ib_reloc(ib, cb->vbo1, RADEON_GEM_DOMAIN_GTT);
- cb->pkts[180] = radeon_ib_reloc(ib, cb->vbo1, RADEON_GEM_DOMAIN_GTT);
- cb->pkts[191] = radeon_ib_reloc(ib, cb->vbo1, RADEON_GEM_DOMAIN_GTT);
+ cb->pkts[84] = radeon_ib_reloc(ib, cb->vsshader1, RADEON_GEM_DOMAIN_GTT);
+ cb->pkts[89] = radeon_ib_reloc(ib, cb->vsshader1, RADEON_GEM_DOMAIN_GTT);
+ cb->pkts[102] = radeon_ib_reloc(ib, cb->vsshader1, RADEON_GEM_DOMAIN_GTT);
+ cb->pkts[107] = radeon_ib_reloc(ib, cb->vsshader1, RADEON_GEM_DOMAIN_GTT);
+ cb->pkts[123] = radeon_ib_reloc(ib, cb->psshader1, RADEON_GEM_DOMAIN_GTT);
+ cb->pkts[128] = radeon_ib_reloc(ib, cb->psshader1, RADEON_GEM_DOMAIN_GTT);
+ cb->pkts[153] = radeon_ib_reloc(ib, cb->vbo1, RADEON_GEM_DOMAIN_GTT);
+ cb->pkts[164] = radeon_ib_reloc(ib, cb->vbo1, RADEON_GEM_DOMAIN_GTT);
+ cb->pkts[171] = radeon_ib_reloc(ib, cb->vbo1, RADEON_GEM_DOMAIN_GTT);
+ cb->pkts[182] = radeon_ib_reloc(ib, cb->vbo1, RADEON_GEM_DOMAIN_GTT);
r = radeon_ib_copy(ib, cb->pkts, atom->npkts);
return r;
}
@@ -1347,6 +1347,108 @@ out_err:
}
/*
+ * r600_sx
+ */
+struct r600_sx {
+ struct radeon_atom atom;
+ u32 pkts[32];
+ struct r600_atoms *atoms;
+ struct radeon_bo *buffer;
+ u32 placements[2];
+};
+
+static void r600_sx_release(struct kref *kref)
+{
+ struct radeon_atom *atom = container_of(kref, struct radeon_atom, kref);
+ struct r600_sx *sx = container_of(atom, struct r600_sx, atom);
+
+ mutex_lock(&sx->atoms->mutex);
+ list_del_init(&sx->atom.list);
+ mutex_unlock(&sx->atoms->mutex);
+ if (sx->buffer)
+ radeon_bo_unref(sx->buffer);
+ kfree(sx);
+}
+
+static int r600_sx_emit(struct radeon_device *rdev,
+ struct radeon_atom *atom,
+ void *data,
+ struct radeon_ib *ib)
+{
+ struct r600_sx *sx = (struct r600_sx *)atom;
+ int r;
+
+ if (sx->buffer)
+ sx->pkts[6] = radeon_ib_reloc(ib, sx->buffer, sx->placements[0] | sx->placements[1]);
+ r = radeon_ib_copy(ib, sx->pkts, atom->npkts);
+ return r;
+}
+
+static int r600_sx_create(struct radeon_device *rdev,
+ struct r600_atoms *atoms,
+ struct drm_radeon_atom *patom,
+ struct radeon_atom **atom)
+{
+ struct drm_r600_sx psx;
+ struct r600_sx *sx;
+ u32 size;
+ int r;
+
+ sx = kmalloc(sizeof(*sx), GFP_KERNEL);
+ if (sx == NULL)
+ return -ENOMEM;
+ /* make sure structure properly initialized */
+ memset(sx, 0, sizeof(*sx));
+ r = radeon_atom_init(&sx->atom, &atoms->idr, &r600_sx_release,
+ &r600_sx_emit, &r600_atom_process_default,
+ sx->pkts);
+ if (r)
+ goto out_err;
+ /* KERNEL use get user data */
+ memcpy(&psx, (void*)(unsigned long)patom->data, sizeof(struct drm_r600_sx));
+ sx->buffer = psx.buffer;
+ sx->placements[0] = psx.placements[0];
+ sx->placements[1] = psx.placements[1];
+ if (sx->buffer) {
+ radeon_bo_ref(sx->buffer);
+ size = radeon_bo_size(sx->buffer);
+ if (psx.offset > size) {
+ dev_err(rdev->dev, "offset into sx past bo end\n");
+ r = -EINVAL;
+ goto out_err;
+ }
+ size -= psx.offset;
+ /* SX_EXPORT_BUFFER_SIZES */
+ sx->pkts[sx->atom.npkts++] = PKT3(PKT3_SET_CONFIG_REG, 3);
+ sx->pkts[sx->atom.npkts++] = 0x00000403;
+ sx->pkts[sx->atom.npkts++] = psx.sx_export_buffer_sizes;
+ sx->pkts[sx->atom.npkts++] = psx.offset;
+ sx->pkts[sx->atom.npkts++] = size;
+ sx->pkts[sx->atom.npkts++] = PKT3(PKT3_NOP, 0);
+ sx->pkts[sx->atom.npkts++] = 0x00000000;
+ }
+ /* SX_MISC */
+ sx->pkts[sx->atom.npkts++] = PKT3(PKT3_SET_CONTEXT_REG, 1);
+ sx->pkts[sx->atom.npkts++] = 0x000000D4;
+ sx->pkts[sx->atom.npkts++] = psx.sx_misc;
+ /* SX_ALPHA_TEST_CONTROL */
+ sx->pkts[sx->atom.npkts++] = PKT3(PKT3_SET_CONTEXT_REG, 1);
+ sx->pkts[sx->atom.npkts++] = 0x00000104;
+ sx->pkts[sx->atom.npkts++] = psx.sx_alpha_test_control;
+ /* SX_ALPHA_REF */
+ sx->pkts[sx->atom.npkts++] = PKT3(PKT3_SET_CONTEXT_REG, 1);
+ sx->pkts[sx->atom.npkts++] = 0x0000010E;
+ sx->pkts[sx->atom.npkts++] = psx.sx_alpha_ref;
+ *atom = &sx->atom;
+fprintf(stderr, "%s %d pkts\n", __func__, (*atom)->npkts);
+ return 0;
+out_err:
+ radeon_atom_put(&sx->atom);
+ *atom = NULL;
+ return r;
+}
+
+/*
* r600 atom core functions
*/
int r600_atom_create(struct radeon_device *rdev,
@@ -1437,6 +1539,13 @@ int r600_atom_create(struct radeon_device *rdev,
atom->type = patom->type;
list_add_tail(&atom->list, &atoms->spi_atoms);
break;
+ case R600_ATOM_SX:
+ r = r600_sx_create(rdev, atoms, patom, &atom);
+ if (r)
+ return r;
+ atom->type = patom->type;
+ list_add_tail(&atom->list, &atoms->sx_atoms);
+ break;
default:
dev_err(rdev->dev, "unknown R600 atom type 0x%08X\n", patom->type);
return -EINVAL;
@@ -1541,7 +1650,7 @@ int r600_batches_queue(struct radeon_device *rdev,
batch->pa == NULL || batch->vport == NULL ||
batch->tp == NULL || batch->cb == NULL ||
batch->db_cntl == NULL || batch->vgt == NULL ||
- batch->spi == NULL) {
+ batch->spi == NULL || batch->sx == NULL) {
kfree(rbatch);
dev_err(rdev->dev, "invalid batch\n");
return -EINVAL;
@@ -1571,6 +1680,8 @@ int r600_batches_queue(struct radeon_device *rdev,
kref_get(&batch->vgt->kref);
rbatch->atoms[i++] = batch->spi;
kref_get(&batch->spi->kref);
+ rbatch->atoms[i++] = batch->sx;
+ kref_get(&batch->sx->kref);
rbatch->atoms[i++] = batch->cb;
kref_get(&batch->cb->kref);
db_cntl = container_of(batch->db_cntl, struct r600_db_cntl, atom);
@@ -1693,6 +1804,7 @@ int r600_atoms_init(struct radeon_device *rdev, struct r600_atoms *atoms)
INIT_LIST_HEAD(&atoms->pa_atoms);
INIT_LIST_HEAD(&atoms->spi_atoms);
INIT_LIST_HEAD(&atoms->sq_atoms);
+ INIT_LIST_HEAD(&atoms->sx_atoms);
INIT_LIST_HEAD(&atoms->tp_atoms);
INIT_LIST_HEAD(&atoms->vgt_atoms);
INIT_LIST_HEAD(&atoms->vport_atoms);
@@ -1779,15 +1891,6 @@ void r600_tflat(struct radeon_atom *atom)
WPKT(PKT3(PKT3_SET_CONTEXT_REG, 1));
WPKT(0x000001E8);
WPKT(0x00000003);
- WPKT(PKT3(PKT3_SET_CONTEXT_REG, 1));
- WPKT(0x000000D4);
- WPKT(0x00000000);
- WPKT(PKT3(PKT3_SET_CONTEXT_REG, 1));
- WPKT(0x00000104);
- WPKT(0x00000000);
- WPKT(PKT3(PKT3_SET_CONTEXT_REG, 1));
- WPKT(0x0000010E);
- WPKT(0x00000000);
WPKT(PKT3(PKT3_SURFACE_SYNC, 3));
WPKT(0x08000000);
WPKT(0x00000001);
diff --git a/r600_atom_api.h b/r600_atom_api.h
index c21d21a..e676c5a 100644
--- a/r600_atom_api.h
+++ b/r600_atom_api.h
@@ -38,6 +38,7 @@ struct drm_radeon_atom {
#define R600_ATOM_DB_CNTL 9
#define R600_ATOM_VGT 10
#define R600_ATOM_SPI 11
+#define R600_ATOM_SX 12
struct drm_r600_cb {
u32 pitch;
@@ -262,6 +263,18 @@ struct drm_r600_spi {
u32 spi_vs_out_id_9;
};
+/* sx - shader export */
+struct drm_r600_sx {
+ u32 sx_alpha_ref;
+ u32 sx_alpha_test_control;
+ u32 sx_export_buffer_sizes;
+ u32 sx_misc;
+ u32 offset;
+ struct radeon_bo *buffer;
+ u32 placements[2];
+};
+
+
struct drm_r600_batch {
struct radeon_atom *vs_constants;
struct radeon_atom *ps_constants;
@@ -275,6 +288,7 @@ struct drm_r600_batch {
struct radeon_atom *db_cntl;
struct radeon_atom *vgt;
struct radeon_atom *spi;
+ struct radeon_atom *sx;
};
diff --git a/radeon_atom.h b/radeon_atom.h
index 58d150d..36805b8 100644
--- a/radeon_atom.h
+++ b/radeon_atom.h
@@ -53,7 +53,7 @@ struct radeon_atom {
};
/* R600 */
-#define R600_BATCH_NATOMS 12
+#define R600_BATCH_NATOMS 13
struct r600_batch {
struct list_head list;
struct list_head pre_flushes;
@@ -82,6 +82,7 @@ struct r600_atoms {
struct list_head pa_atoms;
struct list_head spi_atoms;
struct list_head sq_atoms;
+ struct list_head sx_atoms;
struct list_head tp_atoms;
struct list_head vgt_atoms;
struct list_head vport_atoms;
diff --git a/test.c b/test.c
index 12479f7..ab7448d 100644
--- a/test.c
+++ b/test.c
@@ -64,6 +64,7 @@ int r600_tri_flat(struct radeon *radeon)
struct drm_r600_constants vs_constants;
struct drm_r600_vgt vgt;
struct drm_r600_spi spi;
+ struct drm_r600_sx sx;
struct drm_r600_batch batch;
struct drm_radeon_atom atom;
int r;
@@ -319,6 +320,19 @@ int r600_tri_flat(struct radeon *radeon)
r = radeon_atom_create(rdev, &atom, &batch.spi);
if (r)
return r;
+ /* sx */
+ sx.sx_alpha_ref = 0x00000000;
+ sx.sx_alpha_test_control = 0x00000000;
+ sx.sx_export_buffer_sizes = 0x00000000;
+ sx.sx_misc = 0x00000000;
+ sx.offset = 0x00000000;
+ sx.buffer = NULL;
+ atom.type = R600_ATOM_SX;
+ atom.id = 0;
+ atom.data = (uint64_t)(uintptr_t)&sx;
+ r = radeon_atom_create(rdev, &atom, &batch.sx);
+ if (r)
+ return r;
/* batch */
r = radeon_batches_queue(rdev, &batch);