winsys/radeon: remove cs_write_reloc, add simpler cs_get_reloc

The only difference is that it doesn't write to the CS and only returns
the index.

Reviewed-by: Christian König <christian.koenig@amd.com>
This commit is contained in:
Marek Olšák
2014-04-11 20:34:46 +02:00
parent 927213f33d
commit b2238b3452
4 changed files with 23 additions and 29 deletions
+2 -1
View File
@@ -109,7 +109,8 @@
#define OUT_CS_RELOC(r) do { \
assert((r)); \
assert((r)->cs_buf); \
cs_winsys->cs_write_reloc(cs_copy, (r)->cs_buf); \
OUT_CS(0xc0001000); /* PKT3_NOP */ \
OUT_CS(cs_winsys->cs_get_reloc(cs_copy, (r)->cs_buf) * 4); \
CS_USED_DW(2); \
} while (0)
+2 -2
View File
@@ -1043,8 +1043,8 @@ void r300_emit_vertex_arrays_swtcl(struct r300_context *r300, boolean indexed)
OUT_CS(0);
assert(r300->vbo_cs);
cs_winsys->cs_write_reloc(cs_copy, r300->vbo_cs);
CS_USED_DW(2);
OUT_CS(0xc0001000); /* PKT3_NOP */
OUT_CS(r300->rws->cs_get_reloc(r300->cs, r300->vbo_cs) * 4);
END_CS;
}
+9 -17
View File
@@ -313,6 +313,14 @@ static unsigned radeon_drm_cs_add_reloc(struct radeon_winsys_cs *rcs,
return index;
}
static int radeon_drm_cs_get_reloc(struct radeon_winsys_cs *rcs,
struct radeon_winsys_cs_handle *buf)
{
struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
return radeon_get_reloc(cs->csc, (struct radeon_bo*)buf, NULL);
}
static boolean radeon_drm_cs_validate(struct radeon_winsys_cs *rcs)
{
struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
@@ -359,22 +367,6 @@ static boolean radeon_drm_cs_memory_below_limit(struct radeon_winsys_cs *rcs, ui
return status;
}
static void radeon_drm_cs_write_reloc(struct radeon_winsys_cs *rcs,
struct radeon_winsys_cs_handle *buf)
{
struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
struct radeon_bo *bo = (struct radeon_bo*)buf;
unsigned index = radeon_get_reloc(cs->csc, bo, NULL);
if (index == -1) {
fprintf(stderr, "radeon: Cannot get a relocation in %s.\n", __func__);
return;
}
OUT_CS(&cs->base, 0xc0001000);
OUT_CS(&cs->base, index * RELOC_DWORDS);
}
void radeon_drm_cs_emit_ioctl_oneshot(struct radeon_drm_cs *cs, struct radeon_cs_context *csc)
{
unsigned i;
@@ -650,9 +642,9 @@ void radeon_drm_cs_init_functions(struct radeon_drm_winsys *ws)
ws->base.cs_create = radeon_drm_cs_create;
ws->base.cs_destroy = radeon_drm_cs_destroy;
ws->base.cs_add_reloc = radeon_drm_cs_add_reloc;
ws->base.cs_get_reloc = radeon_drm_cs_get_reloc;
ws->base.cs_validate = radeon_drm_cs_validate;
ws->base.cs_memory_below_limit = radeon_drm_cs_memory_below_limit;
ws->base.cs_write_reloc = radeon_drm_cs_write_reloc;
ws->base.cs_flush = radeon_drm_cs_flush;
ws->base.cs_set_flush_callback = radeon_drm_cs_set_flush;
ws->base.cs_is_buffer_referenced = radeon_bo_is_referenced;
+10 -9
View File
@@ -449,6 +449,16 @@ struct radeon_winsys {
enum radeon_bo_domain domain,
enum radeon_bo_priority priority);
/**
* Return the index of an already-added buffer.
*
* \param cs Command stream
* \param buf Buffer
* \return The buffer index, or -1 if the buffer has not been added.
*/
int (*cs_get_reloc)(struct radeon_winsys_cs *cs,
struct radeon_winsys_cs_handle *buf);
/**
* Return TRUE if there is enough memory in VRAM and GTT for the relocs
* added so far. If the validation fails, all the relocations which have
@@ -469,15 +479,6 @@ struct radeon_winsys {
*/
boolean (*cs_memory_below_limit)(struct radeon_winsys_cs *cs, uint64_t vram, uint64_t gtt);
/**
* Write a relocated dword to a command buffer.
*
* \param cs A command stream the relocation is written to.
* \param buf A winsys buffer to write the relocation for.
*/
void (*cs_write_reloc)(struct radeon_winsys_cs *cs,
struct radeon_winsys_cs_handle *buf);
/**
* Flush a command stream.
*