Write shaders out to disk
authorCafe <cafe@not.applicable>
Wed, 2 Aug 2017 18:08:46 +0000 (18:08 +0000)
committerCafe <cafe@not.applicable>
Wed, 2 Aug 2017 18:08:46 +0000 (18:08 +0000)
src/trace.c

index 9bce195b2b4115bbd3833bbc5ef2a13a7d681140..ba11d95c5fdf4509382d7efa3914ba1a4dff7aae 100644 (file)
@@ -310,9 +310,6 @@ static void chai_trace_hw_chain(uint64_t chain)
                /* Mask out lower 128-bit (instruction word) for flags.
                 *
                 * TODO: Decode flags.
-                *
-                * TODO: Link with cwabbotts-open-gpu-tools to
-                * disassemble on the fly.
                 */
 
                i_shader = fetch_mapped_gpu(v->shader, sizeof(u64));
@@ -324,6 +321,14 @@ static void chai_trace_hw_chain(uint64_t chain)
 
                shader = fetch_mapped_gpu(*i_shader & ~15, 0x880 - 0x540);
                panwrap_log_hexdump_trimmed(shader, 0x880 - 0x540, "\t\t");
+
+               char *fn;
+               asprintf(&fn, "shader_%s.bin", h->job_type == JOB_TYPE_VERTEX ? "Vertex" : "Fragment");
+               FILE *fp = fopen(fn, "wb");
+               fwrite(shader, 1, 0x880 - 0x540, fp);
+               free(fn);
+               fclose(fp);
+               
                relax_mapped_gpu(shader);
                relax_mapped_gpu(i_shader);