radeon_bo_legacy.h \
radeon_cs_legacy.h
-DRI_LIB_DEPS += -ldrm_radeon
+DRI_LIB_DEPS += -ldrm-radeon
##### TARGETS #####
OUT_BATCH_REGSEQ(R300_TX_OFFSET_0 + (i * 4), 1);
r300TexObj *t = r300->hw.textures[i];
if (t && !t->image_override) {
- OUT_BATCH_RELOC(t->tile_bits, t->mt->bo, 0, 0);
+ OUT_BATCH_RELOC(t->tile_bits, t->mt->bo, 0,
+ RADEON_GEM_DOMAIN_VRAM, 0, 0);
} else if (!t) {
OUT_BATCH(r300->radeon.radeonScreen->texOffset[0]);
} else {
if (t->bo) {
- OUT_BATCH_RELOC(t->tile_bits, t->bo, 0, 0);
+ OUT_BATCH_RELOC(t->tile_bits, t->bo, 0,
+ RADEON_GEM_DOMAIN_VRAM, 0, 0);
} else {
OUT_BATCH(t->override_offset);
}
BEGIN_BATCH(4);
OUT_BATCH_REGSEQ(R300_RB3D_COLOROFFSET0, 1);
- OUT_BATCH_RELOC(0, rrb->bo, 0, 0);
+ OUT_BATCH_RELOC(0, rrb->bo, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
OUT_BATCH_REGSEQ(R300_RB3D_COLORPITCH0, 1);
OUT_BATCH(cbpitch);
END_BATCH();
BEGIN_BATCH(4);
OUT_BATCH_REGSEQ(R300_ZB_DEPTHOFFSET, 1);
- OUT_BATCH_RELOC(0, rrb->bo, 0, 0);
+ OUT_BATCH_RELOC(0, rrb->bo, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
OUT_BATCH_REGVAL(R300_ZB_DEPTHPITCH, zbpitch);
END_BATCH();
}
/**
* Write a relocated dword to the command buffer.
*/
-#define OUT_BATCH_RELOC(data, bo, offset, flags) \
+#define OUT_BATCH_RELOC(data, bo, offset, rd, wd, flags) \
do { \
if (offset) {\
fprintf(stderr, "(%s:%s:%d) offset : %d\n",\
__FILE__, __FUNCTION__, __LINE__, offset);\
}\
radeon_cs_write_dword(b_l_r300->cmdbuf.cs, offset);\
- radeon_cs_write_reloc(b_l_r300->cmdbuf.cs,bo,0,(bo)->size,flags);\
+ radeon_cs_write_reloc(b_l_r300->cmdbuf.cs, \
+ bo, \
+ offset, \
+ (bo)->size, \
+ rd, \
+ wd, \
+ flags);\
} while(0)
/**
assert(rrb != 0);
BEGIN_BATCH_NO_AUTOSTATE(4);
OUT_BATCH_REGSEQ(R300_RB3D_COLOROFFSET0, 1);
- OUT_BATCH_RELOC(0, rrb->bo, 0, 0);
+ OUT_BATCH_RELOC(0, rrb->bo, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
OUT_BATCH_REGVAL(R300_RB3D_COLORPITCH0, cbpitch);
END_BATCH();
}
}
BEGIN_BATCH_NO_AUTOSTATE(4);
OUT_BATCH_REGSEQ(R300_ZB_DEPTHOFFSET, 1);
- OUT_BATCH_RELOC(0, rrbd->bo, 0, 0);
+ OUT_BATCH_RELOC(0, rrbd->bo, 0, 0, RADEON_GEM_DOMAIN_VRAM, 0);
OUT_BATCH_REGVAL(R300_ZB_DEPTHPITCH, cbpitch);
END_BATCH();
}
if (!rmesa->radeon.radeonScreen->driScreen->dri2.enabled) {
OUT_BATCH_PACKET3(R300_PACKET3_INDX_BUFFER, 2);
OUT_BATCH(R300_EB_UNK1 | (0 << 16) | R300_EB_UNK2);
- OUT_BATCH_RELOC(0, rmesa->state.elt_dma_bo,
- rmesa->state.elt_dma_offset, 0);
+ OUT_BATCH_RELOC(rmesa->state.elt_dma_offset,
+ rmesa->state.elt_dma_bo,
+ rmesa->state.elt_dma_offset,
+ RADEON_GEM_DOMAIN_GTT, 0, 0);
OUT_BATCH(vertex_count);
} else {
OUT_BATCH_PACKET3(R300_PACKET3_INDX_BUFFER, 2);
rmesa->state.elt_dma_bo,
0,
rmesa->state.elt_dma_bo->size,
- 0);
+ RADEON_GEM_DOMAIN_GTT, 0, 0);
}
END_BATCH();
}
voffset = rmesa->state.aos[i + 0].offset +
offset * 4 * rmesa->state.aos[i + 0].stride;
- OUT_BATCH_RELOC(0, rmesa->state.aos[i].bo, voffset, 0);
+ OUT_BATCH_RELOC(voffset,
+ rmesa->state.aos[i].bo,
+ voffset,
+ RADEON_GEM_DOMAIN_GTT,
+ 0, 0);
voffset = rmesa->state.aos[i + 1].offset +
offset * 4 * rmesa->state.aos[i + 1].stride;
- OUT_BATCH_RELOC(0, rmesa->state.aos[i+1].bo, voffset, 0);
+ OUT_BATCH_RELOC(voffset,
+ rmesa->state.aos[i+1].bo,
+ voffset,
+ RADEON_GEM_DOMAIN_GTT,
+ 0, 0);
}
if (nr & 1) {
OUT_BATCH((rmesa->state.aos[nr - 1].components << 0) |
(rmesa->state.aos[nr - 1].stride << 8));
- OUT_BATCH_RELOC(0, rmesa->state.aos[nr - 1].bo,
- rmesa->state.aos[nr - 1].offset + offset * 4 * rmesa->state.aos[nr - 1].stride, 0);
+ voffset = rmesa->state.aos[nr - 1].offset +
+ offset * 4 * rmesa->state.aos[nr - 1].stride;
+ OUT_BATCH_RELOC(voffset,
+ rmesa->state.aos[nr - 1].bo,
+ voffset,
+ RADEON_GEM_DOMAIN_GTT,
+ 0, 0);
}
} else {
for (i = 0; i + 1 < nr; i += 2) {
if (nr & 1) {
OUT_BATCH((rmesa->state.aos[nr - 1].components << 0) |
(rmesa->state.aos[nr - 1].stride << 8));
- OUT_BATCH(rmesa->state.aos[nr - 1].offset + offset * 4 *
- rmesa->state.aos[nr - 1].stride);
+ voffset = rmesa->state.aos[nr - 1].offset +
+ offset * 4 * rmesa->state.aos[nr - 1].stride;
+ OUT_BATCH(voffset);
}
for (i = 0; i + 1 < nr; i += 2) {
- #if 0
- fprintf(stderr, "3D_LOAD_VBPNTR 0x%08X & 0x%08X\n",
- rmesa->state.aos[i+0].bo->handle,
- rmesa->state.aos[i+1].bo->handle);
- #endif
+ voffset = rmesa->state.aos[i + 0].offset +
+ offset * 4 * rmesa->state.aos[i + 0].stride;
radeon_cs_write_reloc(rmesa->cmdbuf.cs,
rmesa->state.aos[i+0].bo,
- 0,
+ voffset,
rmesa->state.aos[i+0].bo->size,
- 0);
+ RADEON_GEM_DOMAIN_GTT,
+ 0, 0);
+ voffset = rmesa->state.aos[i + 1].offset +
+ offset * 4 * rmesa->state.aos[i + 1].stride;
radeon_cs_write_reloc(rmesa->cmdbuf.cs,
rmesa->state.aos[i+1].bo,
- 0,
+ voffset,
rmesa->state.aos[i+1].bo->size,
- 0);
+ RADEON_GEM_DOMAIN_GTT,
+ 0, 0);
}
if (nr & 1) {
+ voffset = rmesa->state.aos[nr - 1].offset +
+ offset * 4 * rmesa->state.aos[nr - 1].stride;
radeon_cs_write_reloc(rmesa->cmdbuf.cs,
rmesa->state.aos[nr-1].bo,
- 0,
+ voffset,
rmesa->state.aos[nr-1].bo->size,
- 0);
+ RADEON_GEM_DOMAIN_GTT,
+ 0, 0);
}
}
END_BATCH();
OUT_BATCH_PACKET3(R300_PACKET3_3D_LOAD_VBPNTR, 2);
OUT_BATCH(1);
OUT_BATCH(vertex_size | (vertex_size << 8));
- OUT_BATCH_RELOC(0, bo, offset, 0);
+ OUT_BATCH_RELOC(offset, bo, offset, RADEON_GEM_DOMAIN_GTT, 0, 0);
END_BATCH();
}
static int cs_write_reloc(struct radeon_cs *cs,
struct radeon_bo *bo,
- uint32_t soffset,
- uint32_t eoffset,
- uint32_t domains)
+ uint32_t start_offset,
+ uint32_t end_offset,
+ uint32_t read_domain,
+ uint32_t write_domain,
+ uint32_t flags)
{
struct cs_reloc_legacy *relocs;
int i;
relocs = (struct cs_reloc_legacy *)cs->relocs;
+ /* check domains */
+ if ((read_domain && write_domain) || (!read_domain && !write_domain)) {
+ /* in one CS a bo can only be in read or write domain but not
+ * in read & write domain at the same sime
+ */
+ return -EINVAL;
+ }
+ if (read_domain == RADEON_GEM_DOMAIN_CPU) {
+ return -EINVAL;
+ }
+ if (write_domain == RADEON_GEM_DOMAIN_CPU) {
+ return -EINVAL;
+ }
/* check reloc window */
- if (eoffset > bo->size) {
+ if (end_offset > bo->size) {
return -EINVAL;
}
- if (soffset > eoffset) {
+ if (start_offset > end_offset) {
return -EINVAL;
}
/* check if bo is already referenced */
uint32_t *indices;
if (relocs[i].base.bo->handle == bo->handle) {
- /* update start offset and size */
- if (eoffset > relocs[i].base.eoffset) {
- relocs[i].base.eoffset = eoffset;
+ /* update start and end offset */
+ if (start_offset < relocs[i].base.start_offset) {
+ relocs[i].base.start_offset = start_offset;
+ }
+ if (end_offset > relocs[i].base.end_offset) {
+ relocs[i].base.end_offset = end_offset;
}
- if (soffset < relocs[i].base.soffset) {
- relocs[i].base.soffset = soffset;
+ /* Check domains must be in read or write. As we check already
+ * checked that in argument one of the read or write domain was
+ * set we only need to check that if previous reloc as the read
+ * domain set then the read_domain should also be set for this
+ * new relocation.
+ */
+ if (relocs[i].base.read_domain && !read_domain) {
+ return -EINVAL;
+ }
+ if (relocs[i].base.write_domain && !write_domain) {
+ return -EINVAL;
}
- relocs[i].base.size = relocs[i].base.eoffset -
- relocs[i].base.soffset;
- relocs[i].base.domains |= domains;
+ relocs[i].base.read_domain |= read_domain;
+ relocs[i].base.write_domain |= write_domain;
+ /* save indice */
relocs[i].cindices += 1;
indices = (uint32_t*)realloc(relocs[i].indices,
relocs[i].cindices * 4);
}
cs->relocs = relocs;
relocs[cs->crelocs].base.bo = bo;
- relocs[cs->crelocs].base.soffset = soffset;
- relocs[cs->crelocs].base.eoffset = eoffset;
- relocs[cs->crelocs].base.size = eoffset - soffset;
- relocs[cs->crelocs].base.domains = domains;
+ relocs[cs->crelocs].base.start_offset = start_offset;
+ relocs[cs->crelocs].base.end_offset = end_offset;
+ relocs[cs->crelocs].base.read_domain = read_domain;
+ relocs[cs->crelocs].base.write_domain = write_domain;
+ relocs[cs->crelocs].base.flags = flags;
relocs[cs->crelocs].indices = (uint32_t*)malloc(4);
if (relocs[cs->crelocs].indices == NULL) {
return -ENOMEM;
for (j = 0; j < relocs[i].cindices; j++) {
uint32_t soffset, eoffset;
- soffset = relocs[i].base.soffset;
- eoffset = relocs[i].base.eoffset;
+ soffset = relocs[i].base.start_offset;
+ eoffset = relocs[i].base.end_offset;
r = radeon_bo_legacy_validate(relocs[i].base.bo,
&soffset, &eoffset);
if (r) {