Fix replay jobs
[chai.git] / re.c
diff --git a/re.c b/re.c
index 9610439133cf65fa88077b33c7b35defcab3f77d..dc064f2443a4d86760b39c41fa598aa4f93b1d61 100644 (file)
--- a/re.c
+++ b/re.c
@@ -14,6 +14,9 @@ int atom_count = 0;
 
 uint64_t framebuffer;
 
+uint64_t last_fragment;
+uint64_t last_tiler;
+
 void *set_value_helper(int fd) {
        void* packet = galloc(sizeof(struct job_descriptor_header) + sizeof(struct payload_set_value));
        void* magic = galloc(16);
@@ -151,11 +154,15 @@ int job_chain_fragment(int fd) {
                .dependency_type = BASE_JD_DEP_TYPE_DATA
        };
 
-       uint64_t resource = framebuffer | BASE_EXT_RES_ACCESS_EXCLUSIVE;
+       printf("Framebuffer: %LX\n", framebuffer);
+       uint64_t* resource = calloc(sizeof(u64), 1);
+       resource[0] = framebuffer | BASE_EXT_RES_ACCESS_EXCLUSIVE;
+
+       /* TODO: free resource */
 
        struct base_jd_atom_v2 job = {
                .jc = (uint32_t) packet,
-               .extres_list = &resource,
+               .extres_list = resource,
                .nr_extres = 1,
                .core_req = BASE_JD_REQ_EXTERNAL_RESOURCES | BASE_JD_REQ_FS,
                .atom_number = ++atom_count,
@@ -168,7 +175,7 @@ int job_chain_fragment(int fd) {
 
        submit_job(fd, job);
 
-       gfree(packet);
+       last_fragment = (uint32_t) packet;
 
        //free_mfbd(mfbd);
 
@@ -361,7 +368,7 @@ int job_chain_vertex_tiler(int fd) {
                .nr_extres = 0,
                .core_req = BASE_JD_REQ_CS | BASE_JD_REQ_T | BASE_JD_REQ_CF | BASE_JD_REQ_COHERENT_GROUP,
                .atom_number = ++atom_count,
-               .prio = BASE_JD_PRIO_MEDIUM
+               .prio = BASE_JD_PRIO_MEDIUM,
                .device_nr = 0
        };
 
@@ -370,21 +377,38 @@ int job_chain_vertex_tiler(int fd) {
 
        submit_job(fd, job);
 
+       last_tiler = (uint32_t) tiler;
+
        return 0;
 }
 
 void job_chain_replay(int fd)
 {
+       struct base_jd_replay_payload *payload;
+
+       payload = (struct base_jd_replay_payload*) galloc(sizeof(*payload));
+
+       payload->tiler_jc_list = last_tiler;
+       payload->fragment_jc = last_fragment;
+       payload->tiler_heap_free = 0x102000000;
+       payload->fragment_hierarchy_mask = 0;
+       payload->tiler_hierarchy_mask = 0;
+       payload->hierarchy_default_weight = 0x10000;
+       payload->tiler_core_req = BASE_JD_REQ_T | BASE_JD_REQ_COHERENT_GROUP;
+       payload->fragment_core_req = BASE_JD_REQ_FS;
+
        struct base_dependency depNoDep = {
                .atom_id = 0,
                .dependency_type = BASE_JD_DEP_TYPE_INVALID
        };
 
-       uint64_t resource = framebuffer | BASE_EXT_RES_ACCESS_EXCLUSIVE;
+       printf("Framebuffer: %LX\n", framebuffer);
+       uint64_t* resource = calloc(sizeof(u64), 1);
+       resource[0] = framebuffer | BASE_EXT_RES_ACCESS_EXCLUSIVE;
 
        struct base_jd_atom_v2 job = {
-               .jc = /* TBD */0,
-               .extres_list = &resource,
+               .jc = (uint32_t) payload,
+               .extres_list = resource,
                .nr_extres = 1,
                .core_req = BASE_JD_REQ_EXTERNAL_RESOURCES | BASE_JD_REQ_SOFT_REPLAY,
                .atom_number = ++atom_count,
@@ -407,10 +431,11 @@ int main()
        size_t fb_size = 29 * 16 * 45 * 16 * 4 * 2;
 
        framebuffer = (uint64_t) (uint32_t) galloc(fb_size);
+       printf("Framebuffer: %LX\n", framebuffer);
        job_chain_vertex_tiler(fd);
        job_chain_fragment(fd);
+       job_chain_replay(fd);
        flush_job_queue(fd);
-       //job_chain_replay(fd);
 
        /* Dump framebuffer to a file */
        uint8_t *fb = (uint8_t*) (uint32_t) framebuffer;