Begin tiler job generation from vertex
authorCafe <cafe@not.applicable>
Tue, 25 Jul 2017 00:00:00 +0000 (00:00 +0000)
committerCafe <cafe@not.applicable>
Tue, 25 Jul 2017 23:16:59 +0000 (23:16 +0000)
re.c

diff --git a/re.c b/re.c
index 06ad2b1753aeef0ea00a46eae16b5d0598a32a00..7e9db73429890f4bf46c046fd14a0e15c5f20744 100644 (file)
--- a/re.c
+++ b/re.c
@@ -2,6 +2,7 @@
 #include <stdlib.h>
 #include <memory.h>
 #include <sys/mman.h>
+#include <stdbool.h>
 
 #include "shim.h"
 #include "jobs.h"
@@ -167,7 +168,7 @@ int job_chain_fragment(int fd) {
        return 0;
 }
 
-uint64_t import_shader(int fd, uint8_t *shader, size_t sz)
+uint64_t import_shader(int fd, uint8_t *shader, size_t sz, bool fragment)
 {
        int pages = 1 + (sz >> PAGE_SHIFT);
 
@@ -179,10 +180,10 @@ uint64_t import_shader(int fd, uint8_t *shader, size_t sz)
 
        /* TODO: munmap */
 
-       return gpu | 5; /* Unknown flag */
+       return gpu | (fragment ? 9 : 5); /* Unknown flag */
 }
 
-int job_chain_vertex(int fd) {
+int job_chain_vertex_tiler(int fd, bool tiler) {
        void* packet = galloc(sizeof(struct job_descriptor_header) + sizeof(struct payload_fragment));
 
        struct job_descriptor_header header = {
@@ -190,7 +191,7 @@ int job_chain_vertex(int fd) {
                .first_incomplete_task = 0,
                .fault_pointer = 0,
                .job_descriptor_size = JOB_32_BIT,
-               .job_type = JOB_TYPE_VERTEX,
+               .job_type = tiler ? JOB_TYPE_TILER : JOB_TYPE_VERTEX,
                .job_barrier = 0, 
                .job_index = atom_count,
                .job_dependency_index_1 = 0,
@@ -198,9 +199,13 @@ int job_chain_vertex(int fd) {
                .next_job = 0 
        };
 
+
+       /* TODO */
+       uint32_t mode_gooks = tiler ? 0x1403000C : 0x14000000;
+
        struct payload_vertex_tiler32 payload = {
                .block1 = {
-                       0x00000003, 0x28000000, 0x14000000, 0x00000000,
+                       0x00000003, 0x28000000, mode_gooks, 0x00000000,
                        0x00000000, 0x00000000, 0x00000000, 0x00000000,
                        0x00000005, 0x00000000, 0x00000000
                },
@@ -214,7 +219,7 @@ int job_chain_vertex(int fd) {
                .unknown4 = (uint32_t) galloc(16),
                .unknown5 = (uint32_t) galloc(32),
                .unknown6 = (uint32_t) galloc(64),
-               .nullForVertex = 0,
+               .nullForVertex = tiler ? (uint32_t) galloc(64) : 0,
                .null4 = 0,
                .fbd = (uint32_t) make_mfbd(),
                .unknown7 = (uint32_t) galloc(64)
@@ -224,9 +229,17 @@ int job_chain_vertex(int fd) {
 
        /* TODO: Integrate an assembler */
 #include "../vertex_shader.h"
-       shader->shader = import_shader(fd, (uint8_t*) vertex_shader, sizeof(vertex_shader));
-       shader->unknown1 = 0x0005000100000000;
-       shader->unknown2 = 0x0000000000420002;
+       shader->shader = import_shader(fd, (uint8_t*) vertex_shader, sizeof(vertex_shader), tiler);
+
+       /* TODO: Decode me! */
+
+       if(tiler) {
+               shader->unknown1 = 0x0007000000000000;
+               shader->unknown2 = 0x0000000000020602;
+       } else {
+               shader->unknown1 = 0x0005000100000000;
+               shader->unknown2 = 0x0000000000420002;
+       }
 
        /* TODO: Vertices should be parametric */
        float vertices[] = {
@@ -293,7 +306,7 @@ int main()
 
        //job_chain_set_value(fd);
        //job_chain_fragment(fd);
-       job_chain_vertex(fd);
+       job_chain_vertex_tiler(fd, true);
 
        /* Hang to prevent the tracer from going bananas */