unsigned i, mask = 0;
/* if backend_map query is supported by the kernel */
- if (ctx->radeon->backend_map_valid) {
+ if (ctx->radeon->info.r600_backend_map_valid) {
unsigned num_tile_pipes = r600_get_num_tile_pipes(ctx->radeon);
unsigned backend_map = r600_get_backend_map(ctx->radeon);
unsigned item_width, item_mask;
goto err;
/* initialize buffer with zeroes */
- results = r600_bo_map(ctx->radeon, buffer, PB_USAGE_CPU_WRITE, NULL);
+ results = r600_bo_map(ctx->radeon, buffer, ctx->cs, PIPE_TRANSFER_WRITE);
if (results) {
memset(results, 0, ctx->max_db * 4 * 4);
r600_bo_unmap(ctx->radeon, buffer);
ctx->pm4[ctx->pm4_cdwords++] = r600_context_bo_reloc(ctx, buffer);
/* execute */
- r600_context_flush(ctx);
+ r600_context_flush(ctx, 0);
/* analyze results */
- results = r600_bo_map(ctx->radeon, buffer, PB_USAGE_CPU_READ, NULL);
+ results = r600_bo_map(ctx->radeon, buffer, ctx->cs, PIPE_TRANSFER_READ);
if (results) {
for(i = 0; i < ctx->max_db; i++) {
/* at least highest bit will be set if backend is used */
free(ctx->range);
free(ctx->blocks);
free(ctx->bo);
- free(ctx->pm4);
ctx->radeon->ws->cs_destroy(ctx->cs);
memset(ctx, 0, sizeof(struct r600_context));
goto out_err;
}
ctx->pm4_ndwords = RADEON_CTX_MAX_PM4;
- ctx->pm4 = calloc(ctx->pm4_ndwords, 4);
- if (ctx->pm4 == NULL) {
- r = -ENOMEM;
- goto out_err;
- }
+ ctx->pm4 = ctx->cs->buf;
r600_init_cs(ctx);
/* save 16dwords space for fence mecanism */
if ((ctx->pm4_dirty_cdwords + ndwords + ctx->pm4_cdwords) > ctx->pm4_ndwords) {
/* need to flush */
- r600_context_flush(ctx);
+ r600_context_flush(ctx, 0);
}
ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_SURFACE_SYNC, 3, ctx->predicate_drawing);
if (!dirty) {
if (is_vertex) {
- if (block->reloc[1].bo->bo->handle != state->bo[0]->bo->handle)
+ if (block->reloc[1].bo->bo->buf != state->bo[0]->bo->buf)
dirty |= R600_BLOCK_STATUS_RESOURCE_DIRTY;
} else {
- if ((block->reloc[1].bo->bo->handle != state->bo[0]->bo->handle) ||
- (block->reloc[2].bo->bo->handle != state->bo[1]->bo->handle))
+ if ((block->reloc[1].bo->bo->buf != state->bo[0]->bo->buf) ||
+ (block->reloc[2].bo->bo->buf != state->bo[1]->bo->buf))
dirty |= R600_BLOCK_STATUS_RESOURCE_DIRTY;
}
}
if ((ctx->pm4_dirty_cdwords + ndwords + ctx->pm4_cdwords) > ctx->pm4_ndwords) {
/* need to flush */
- r600_context_flush(ctx);
+ r600_context_flush(ctx, 0);
}
/* at that point everythings is flushed and ctx->pm4_cdwords = 0 */
if ((ctx->pm4_dirty_cdwords + ndwords) > ctx->pm4_ndwords) {
ctx->pm4_dirty_cdwords = 0;
}
-void r600_context_flush(struct r600_context *ctx)
+void r600_context_flush(struct r600_context *ctx, unsigned flags)
{
- struct drm_radeon_cs drmib = {};
- struct drm_radeon_cs_chunk chunks[2];
- uint64_t chunk_array[2];
- int r;
struct r600_block *enable_block = NULL;
if (ctx->pm4_cdwords == ctx->init_dwords)
ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_EVENT_WRITE, 0, 0);
ctx->pm4[ctx->pm4_cdwords++] = EVENT_TYPE(EVENT_TYPE_PS_PARTIAL_FLUSH) | EVENT_INDEX(4);
-#if 1
- /* emit cs */
- drmib.num_chunks = 2;
- drmib.chunks = (uint64_t)(uintptr_t)chunk_array;
- chunks[0].chunk_id = RADEON_CHUNK_ID_IB;
- chunks[0].length_dw = ctx->pm4_cdwords;
- chunks[0].chunk_data = (uint64_t)(uintptr_t)ctx->pm4;
- chunks[1].chunk_id = RADEON_CHUNK_ID_RELOCS;
- chunks[1].length_dw = ctx->creloc * sizeof(struct r600_reloc) / 4;
- chunks[1].chunk_data = (uint64_t)(uintptr_t)ctx->reloc;
- chunk_array[0] = (uint64_t)(uintptr_t)&chunks[0];
- chunk_array[1] = (uint64_t)(uintptr_t)&chunks[1];
- r = drmCommandWriteRead(ctx->radeon->info.fd, DRM_RADEON_CS, &drmib,
- sizeof(struct drm_radeon_cs));
- if (r) {
- fprintf(stderr, "radeon: The kernel rejected CS, "
- "see dmesg for more information.\n");
- }
-#else
- *ctx->radeon->cfence = ctx->radeon->fence;
-#endif
+ /* Flush the CS. */
+ ctx->cs->cdw = ctx->pm4_cdwords;
+ ctx->radeon->ws->cs_flush(ctx->cs, flags);
+
+ /* We need to get the pointer to the other CS,
+ * the command streams are double-buffered. */
+ ctx->pm4 = ctx->cs->buf;
/* restart */
for (int i = 0; i < ctx->creloc; i++) {
ctx->pm4_dirty_cdwords = 0;
ctx->pm4_cdwords = 0;
ctx->flags = 0;
- ctx->radeon->ws->cs_flush(ctx->cs, 0);
r600_init_cs(ctx);
if ((ctx->pm4_dirty_cdwords + ndwords + ctx->pm4_cdwords) > ctx->pm4_ndwords) {
/* need to flush */
- r600_context_flush(ctx);
+ r600_context_flush(ctx, 0);
}
ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_EVENT_WRITE, 0, 0);
u32 *results, *current_result;
if (wait)
- results = r600_bo_map(ctx->radeon, query->buffer, PIPE_TRANSFER_READ, NULL);
+ results = r600_bo_map(ctx->radeon, query->buffer, ctx->cs, PIPE_TRANSFER_READ);
else
- results = r600_bo_map(ctx->radeon, query->buffer, PIPE_TRANSFER_DONTBLOCK | PIPE_TRANSFER_READ, NULL);
+ results = r600_bo_map(ctx->radeon, query->buffer, ctx->cs, PIPE_TRANSFER_DONTBLOCK | PIPE_TRANSFER_READ);
if (!results)
return FALSE;
if ((required_space + ctx->pm4_cdwords) > ctx->pm4_ndwords) {
/* need to flush */
- r600_context_flush(ctx);
+ r600_context_flush(ctx, 0);
}
if (query->type == PIPE_QUERY_OCCLUSION_COUNTER) {
query->queries_emitted = 1;
} else {
if (++query->queries_emitted > query->buffer_size / query->result_size / 2)
- r600_context_flush(ctx);
+ r600_context_flush(ctx, 0);
}
}
/* collect current results if query buffer is full */
if (new_results_end == query->results_start) {
if (!(query->state & R600_QUERY_STATE_FLUSHED))
- r600_context_flush(ctx);
+ r600_context_flush(ctx, 0);
r600_query_result(ctx, query, TRUE);
}
u32 *results;
int i;
- results = r600_bo_map(ctx->radeon, query->buffer, PIPE_TRANSFER_WRITE, NULL);
+ results = r600_bo_map(ctx->radeon, query->buffer, ctx->cs, PIPE_TRANSFER_WRITE);
if (results) {
results = (u32*)((char*)results + query->results_end);
memset(results, 0, query->result_size);
{
if (operation == PREDICATION_OP_CLEAR) {
if (ctx->pm4_cdwords + 3 > ctx->pm4_ndwords)
- r600_context_flush(ctx);
+ r600_context_flush(ctx, 0);
ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_SET_PREDICATION, 1, 0);
ctx->pm4[ctx->pm4_cdwords++] = 0;
count /= query->result_size;
if (ctx->pm4_cdwords + 5 * count > ctx->pm4_ndwords)
- r600_context_flush(ctx);
+ r600_context_flush(ctx, 0);
op = PRED_OP(operation) | PREDICATION_DRAW_VISIBLE |
(flag_wait ? PREDICATION_HINT_WAIT : PREDICATION_HINT_NOWAIT_DRAW);
uint64_t *result = (uint64_t*)vresult;
if (!(query->state & R600_QUERY_STATE_FLUSHED)) {
- r600_context_flush(ctx);
+ r600_context_flush(ctx, 0);
}
if (!r600_query_result(ctx, query, wait))
return FALSE;