Fix buffer age implementaion bug.
authorRichard Li <richardradeon@gmail.com>
Wed, 8 Jul 2009 18:49:48 +0000 (14:49 -0400)
committerRichard Li <richardradeon@gmail.com>
Wed, 8 Jul 2009 18:49:48 +0000 (14:49 -0400)
src/mesa/drivers/dri/r600/r600_cmdbuf.c
src/mesa/drivers/dri/radeon/radeon_bo_legacy.c

index 9f26b257d00130750a0a04f31529dd4837d36741..0035910792091941695d557dad4bd2b97c0c001c 100644 (file)
@@ -378,7 +378,36 @@ static int r600_cs_emit(struct radeon_cs *cs)
     /* TODO : put chip level things here if need. */
     /* csm->ctx->vtbl.emit_cs_header(cs, csm->ctx); */
 
-    /* TODO : append buffer age */
+    BATCH_LOCALS(csm->ctx);
+    drm_radeon_getparam_t gp;
+    uint32_t              current_scratchx_age;
+
+    gp.param = RADEON_PARAM_LAST_CLEAR;
+    gp.value = (int *)&current_scratchx_age;
+    r = drmCommandWriteRead(cs->csm->fd, 
+                            DRM_RADEON_GETPARAM,
+                            &gp, 
+                            sizeof(gp));
+    if (r) 
+    {
+        fprintf(stderr, "%s: drmRadeonGetParam: %d\n", __FUNCTION__, r);
+        exit(1);
+    }
+
+    csm->pending_age = 0;
+    csm->pending_count = 1;
+
+    current_scratchx_age++;
+    csm->pending_age = current_scratchx_age;
+
+    BEGIN_BATCH_NO_AUTOSTATE(2);
+    R600_OUT_BATCH(0x2142); /* scratch 2 */
+    R600_OUT_BATCH(current_scratchx_age);
+    END_BATCH();
+    COMMIT_BATCH();
+
+    //TODO ioctl to get back cs id assigned in drm
+    //csm->pending_age = cs_id_back;
     
     r = r600_cs_process_relocs(cs, &(reloc_chunk[0]), &length_dw_reloc_chunk);
     if (r) {
index 276926ce69d0ba509c895932ff498ab954dcb9ee..ae5f0c4cfe75189b4402bcb1f57b5af3730908bf 100644 (file)
@@ -171,7 +171,9 @@ static void legacy_get_current_age(struct bo_manager_legacy *boml)
     unsigned char *RADEONMMIO = NULL;
     int r;
 
-    if (IS_R300_CLASS(boml->screen)) {
+    if (   IS_R300_CLASS(boml->screen) 
+        || IS_R600_CLASS(boml->screen) ) 
+    {
        gp.param = RADEON_PARAM_LAST_CLEAR;
        gp.value = (int *)&boml->current_age;
        r = drmCommandWriteRead(boml->base.fd, DRM_RADEON_GETPARAM,
@@ -180,7 +182,8 @@ static void legacy_get_current_age(struct bo_manager_legacy *boml)
                 fprintf(stderr, "%s: drmRadeonGetParam: %d\n", __FUNCTION__, r);
          exit(1);
        }
-    } else {
+    } 
+    else {
         RADEONMMIO = boml->screen->mmio.map;
         boml->current_age = boml->screen->scratch[3];
         boml->current_age = INREG(RADEON_GUI_SCRATCH_REG3);