r600g: emit CS using radeon_winsys
authorMarek Olšák <maraeo@gmail.com>
Wed, 3 Aug 2011 23:37:33 +0000 (01:37 +0200)
committerMarek Olšák <maraeo@gmail.com>
Tue, 16 Aug 2011 07:15:10 +0000 (09:15 +0200)
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
src/gallium/drivers/r600/r600.h
src/gallium/winsys/r600/drm/evergreen_hw_context.c
src/gallium/winsys/r600/drm/r600_drm.c
src/gallium/winsys/r600/drm/r600_hw_context.c
src/gallium/winsys/r600/drm/r600_priv.h
src/gallium/winsys/radeon/drm/radeon_drm_cs.c
src/gallium/winsys/radeon/drm/radeon_winsys.h

index 0562b6da31e0fdd99161f67d0b4c392e0d6948f2..84cfa2a17e6dc8910feceb56b303a5b0530b0d28 100644 (file)
@@ -236,16 +236,16 @@ struct r600_context {
        struct list_head        resource_dirty;
        struct list_head        enable_list;
        unsigned                pm4_ndwords;
-       unsigned                pm4_cdwords;
        unsigned                pm4_dirty_cdwords;
        unsigned                ctx_pm4_ndwords;
        unsigned                init_dwords;
 
        unsigned                creloc;
-       unsigned                *reloc;
        struct radeon_bo        **bo;
 
        u32                     *pm4;
+       unsigned                pm4_cdwords;
+
        struct list_head        query_list;
        unsigned                num_query_running;
        unsigned                backend_mask;
index cd63c8db1568d7cc745659e1a1d91920f2cfb62a..29da7bea4c6b0d9a1222aead032824e0f5f118c2 100644 (file)
@@ -995,11 +995,7 @@ int evergreen_context_init(struct r600_context *ctx, struct radeon *radeon)
                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 */
index f0ef55e98d58c087d2c80cb44aba36cc9107fd7e..270a07a3a892e8d429d6ab47334a78d19a29bd2e 100644 (file)
@@ -292,6 +292,9 @@ struct radeon *radeon_create(struct radeon_winsys *ws)
                radeon_get_backend_map(radeon);
        }
 
+       /* XXX disable ioctl thread offloading until the porting is done. */
+       setenv("RADEON_THREAD", "0", 0);
+
        return radeon;
 }
 
index 1950e5831215076f0e4604bed6c9a328e3b0f3db..59450b5ba833202ba6fcf10bcb24d494d2016563 100644 (file)
@@ -776,7 +776,6 @@ void r600_context_fini(struct r600_context *ctx)
        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));
@@ -920,11 +919,7 @@ int r600_context_init(struct r600_context *ctx, struct radeon *radeon)
                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 */
@@ -1492,10 +1487,6 @@ void r600_context_draw(struct r600_context *ctx, const struct r600_draw *draw)
 
 void r600_context_flush(struct r600_context *ctx)
 {
-       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)
@@ -1513,27 +1504,12 @@ void r600_context_flush(struct r600_context *ctx)
        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 * 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, 0);
+       /* 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++) {
@@ -1544,7 +1520,6 @@ void r600_context_flush(struct r600_context *ctx)
        ctx->pm4_dirty_cdwords = 0;
        ctx->pm4_cdwords = 0;
        ctx->flags = 0;
-       ctx->radeon->ws->cs_flush(ctx->cs, 0);
 
        r600_init_cs(ctx);
 
index 5bb515d743e458f602a8858fc9f71b3cee38fa77..83e964b7f69727e4bc254e9921350a77422b9b9a 100644 (file)
@@ -134,10 +134,11 @@ static INLINE unsigned r600_context_bo_reloc(struct r600_context *ctx, struct r6
 
        assert(bo != NULL);
 
-       reloc_index = ctx->radeon->ws->trans_add_reloc(
-                               ctx->cs, bo->cs_buf,
-                               rbo->domains, rbo->domains,
-                               (void**)&ctx->reloc, &ctx->creloc);
+       reloc_index =
+               ctx->radeon->ws->trans_add_reloc(ctx->cs, bo->cs_buf, rbo->domains, rbo->domains);
+
+       if (reloc_index >= ctx->creloc)
+               ctx->creloc = reloc_index+1;
 
        radeon_bo_reference(ctx->radeon, &ctx->bo[reloc_index], bo);
        return reloc_index * 4;
index 9a1e16957d20a8309ffda2b3411202255bb79e13..09befb39b114ac2645439df0eda16bd724b9a34e 100644 (file)
@@ -473,8 +473,7 @@ static boolean radeon_bo_is_referenced(struct radeon_winsys_cs *rcs,
 static unsigned trans_add_reloc(struct radeon_winsys_cs *rcs,
                                struct radeon_winsys_cs_handle *buf,
                                enum radeon_bo_domain rd,
-                                enum radeon_bo_domain wd,
-                               void **reloc_list, unsigned *reloc_count)
+                                enum radeon_bo_domain wd)
 {
        struct radeon_drm_cs *cs = radeon_drm_cs(rcs);
         struct radeon_bo *bo = (struct radeon_bo*)buf;
@@ -487,8 +486,6 @@ static unsigned trans_add_reloc(struct radeon_winsys_cs *rcs,
         if (added_domains & RADEON_DOMAIN_VRAM)
             cs->csc->used_vram += bo->size;
 
-       *reloc_list = cs->csc->relocs;
-       *reloc_count = cs->csc->crelocs;
        return index;
 }
 
index 8e81fa1e3017e877bd133d555b89d0b43de31e70..073b6aad79a450b9a5669a74008956b8e08ec9e0 100644 (file)
@@ -332,8 +332,7 @@ struct radeon_winsys {
     unsigned (*trans_add_reloc)(struct radeon_winsys_cs *cs,
                                struct radeon_winsys_cs_handle *buf,
                                enum radeon_bo_domain rd,
-                                enum radeon_bo_domain wd,
-                               void **reloc_list, unsigned *reloc_count);
+                                enum radeon_bo_domain wd);
 };
 
 #endif