r600: move structs for legacy cmdbuf into cmdbuf C file.
[mesa.git] / src / mesa / drivers / dri / r600 / r600_cmdbuf.c
index 65930ff589f77f7e03861f0703ed5766630014aa..5e1504872d627881e5ccfa995acb34b8c8f02ea4 100644 (file)
@@ -52,6 +52,21 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "radeon_mipmap_tree.h"
 #include "radeon_reg.h"
 
+struct r600_cs_manager_legacy
+{
+    struct radeon_cs_manager    base;
+    struct radeon_context       *ctx;
+    /* hack for scratch stuff */
+    uint32_t                    pending_age;
+    uint32_t                    pending_count;
+};
+
+struct r600_cs_reloc_legacy {
+    struct radeon_cs_reloc  base;
+    uint32_t                cindices;
+    uint32_t                *indices;
+    uint32_t                *reloc_indices;
+};
 
 
 static struct radeon_cs * r600_cs_create(struct radeon_cs_manager *csm,
@@ -192,9 +207,9 @@ static int r600_cs_begin(struct radeon_cs *cs,
 
     if (cs->cdw + ndw > cs->ndw) {
         uint32_t tmp, *ptr;
-       int num = (ndw > 0x3FF) ? ndw : 0x3FF;
+       int num = (ndw > 0x400) ? ndw : 0x400;
 
-        tmp = (cs->cdw + 1 + num) & (~num);
+        tmp = (cs->cdw + num + 0x3FF) & (~0x3FF);
         ptr = (uint32_t*)realloc(cs->packets, 4 * tmp);
         if (ptr == NULL) {
             return -ENOMEM;
@@ -229,6 +244,14 @@ static int r600_cs_end(struct radeon_cs *cs,
         return -EPIPE;
     }
 
+    if (cs->cdw > cs->ndw) {
+           fprintf(stderr, "CS section overflow at (%s,%s,%d) cdw %d ndw %d\n",
+                   cs->section_file, cs->section_func, cs->section_line,cs->cdw,cs->ndw);
+           fprintf(stderr, "CS section end at (%s,%s,%d)\n",
+                   file, func, line);
+           assert(0);
+    }
+
     return 0;
 }
 
@@ -246,7 +269,7 @@ static int r600_cs_process_relocs(struct radeon_cs *cs,
     relocs = (struct r600_cs_reloc_legacy *)cs->relocs;
 restart:
     for (i = 0; i < cs->crelocs; i++) {
-            uint32_t soffset, eoffset, asicoffset;
+            uint32_t soffset, eoffset;
 
             r = radeon_bo_legacy_validate(relocs[i].base.bo,
                                          &soffset, &eoffset);
@@ -254,24 +277,12 @@ restart:
                    goto restart;
             }
             if (r) {
-                   fprintf(stderr, "validated %p [0x%08X, 0x%08X]\n",
+                   fprintf(stderr, "invalid bo(%p) [0x%08X, 0x%08X]\n",
                            relocs[i].base.bo, soffset, eoffset);
                    return r;
             }
-            asicoffset = soffset;
 
            for (j = 0; j < relocs[i].cindices; j++) {
-                   if (asicoffset >= eoffset) {
-                           /*                radeon_bo_debug(relocs[i].base.bo, 12); */
-                           fprintf(stderr, "validated %p [0x%08X, 0x%08X]\n",
-                                   relocs[i].base.bo, soffset, eoffset);
-                           fprintf(stderr, "above end: %p 0x%08X 0x%08X\n",
-                                   relocs[i].base.bo,
-                                   cs->packets[relocs[i].indices[j]],
-                                   eoffset);
-                           exit(0);
-                           return -EINVAL;
-                   }
                    /* pkt3 nop header in ib chunk */
                    cs->packets[relocs[i].reloc_indices[j]] = 0xC0001000;
                    /* reloc index in ib chunk */
@@ -279,7 +290,7 @@ restart:
            }
 
            /* asic offset in reloc chunk */ /* see alex drm r600_nomm_relocate */
-           reloc_chunk[offset_dw] = asicoffset;
+           reloc_chunk[offset_dw] = soffset;
            reloc_chunk[offset_dw + 3] = 0;
 
            offset_dw += 4;