diff --git a/src/asahi/lib/decode.c b/src/asahi/lib/decode.c index 83290b88485..c9e4c591464 100644 --- a/src/asahi/lib/decode.c +++ b/src/asahi/lib/decode.c @@ -504,6 +504,8 @@ agxdecode_record(struct agxdecode_ctx *ctx, uint64_t va, size_t size, if (hdr.fragment_shader) { agx_unpack(agxdecode_dump_stream, map, FRAGMENT_SHADER_WORD_0, frag_0); + return; // FIXME alyssa: G15 compat + agx_unpack(agxdecode_dump_stream, map + 4, FRAGMENT_SHADER_WORD_1, frag_1); agx_unpack(agxdecode_dump_stream, map + 8, FRAGMENT_SHADER_WORD_2, @@ -544,7 +546,10 @@ agxdecode_record(struct agxdecode_ctx *ctx, uint64_t va, size_t size, PPP_PRINT(map, varying_word_2, VARYING_2, "Varying word 2"); /* PPP print checks we don't read too much, now check we read enough */ - assert(map == (base + size) && "invalid size of PPP update"); + // TODO: alyssa commented this out because we don't know the size for G15 + //assert(map == (base + size) && "invalid size of PPP update"); + if (map != (base + size)) + printf("!!! didn't consume enough bytes of PPP update\n"); } static void dump_to_file(void *data, size_t len, char *name) { @@ -758,13 +763,16 @@ agxdecode_cdm(struct agxdecode_ctx *ctx, const uint8_t *map, uint64_t *link, } static void -agxdecode_vdm_line(struct agxdecode_ctx *ctx, const uint64_t va) +agxdecode_vdm_line(struct agxdecode_ctx *ctx, const uint64_t va, uint64_t max_size) { void *buf; - size_t len = agxdecode_grab_mapped(ctx, va , &buf); - u_hexdump(stdout, buf, 0x16, false); + agxdecode_record(ctx, va, max_size, 1, 0); + size_t len = agxdecode_grab_mapped(ctx, va , &buf); if (*(uint32_t*)buf == 0x00800000) { + agx_unpack(agxdecode_dump_stream, buf + 0x4, FRAGMENT_SHADER_WORD_0, + word_0); + DUMP_UNPACKED(FRAGMENT_SHADER_WORD_0, word_0, "Fragment shader word 0\n"); agx_unpack(agxdecode_dump_stream, buf + 0x10, VDM_STATE_FRAGMENT_SHADER_DWORD_1_G15, word_1); uint64_t shaddr = (uint64_t)word_1.pipeline_hi << 32 | word_1.pipeline_lo; @@ -773,9 +781,12 @@ agxdecode_vdm_line(struct agxdecode_ctx *ctx, const uint64_t va) shaddr); agx_dump_shader(ctx, shaddr, true, "fragment"); } - if (*(uint32_t*)buf == 0xc00) { + /*else if (*(uint32_t*)buf == 0xc00) { agx_unpack(agxdecode_dump_stream, (buf + 0x10), VIEWPORT, viewp); DUMP_UNPACKED(VIEWPORT, viewp, "Viewport\n"); + } */else { + printf("decoded VDM, bytes were:\n"); + u_hexdump(stdout, buf, max_size, false); } } @@ -866,35 +877,38 @@ agxdecode_vdm(struct agxdecode_ctx *ctx, const uint8_t *map, uint64_t *link, VDM_PRINT(vertex_unknown, VERTEX_UNKNOWN, "Vertex unknown"); VDM_PRINT(tessellation_scale, TESSELLATION_SCALE, "Tessellation scale"); - map += 2 * sizeof(uint32_t); - length += 2 * sizeof(uint32_t); + printf("\n"); + u_hexdump(stdout, (void*)map, 1 * sizeof(uint32_t), false); + map += 1 * sizeof(uint32_t); + length += 1 * sizeof(uint32_t); - printf("vdm lines:\n"); - u_hexdump(stdout, (void*)map, 4 * 8 * sizeof(uint32_t), false); + printf("** vdm pointers:\n"); + //u_hexdump(stdout, (void*)map, 4 * 8 * sizeof(uint32_t), false); { for(;;) { - printf("parsing line:\n"); - u_hexdump(stdout, (void*)map, 2 * sizeof(uint32_t), false); + uint32_t ptr = ((uint32_t*)map)[1]; + uint32_t tword = ((uint32_t*)map)[0]; - printf("addr %x\n", ((uint32_t*)map)[0]); - agxdecode_vdm_line(ctx, ((uint32_t*)map)[0]); + printf("\n* parsing vdm pointer (addr %p, word 0x%x): ", (void *)ptr, tword); + u_hexdump(stdout, (void*)map, 2 * sizeof(uint32_t), false); - uint32_t tword = ((uint32_t*)map)[1]; - uint32_t next_block_type = ((uint8_t*)(&((uint32_t*)map)[1]))[3] >> 5; + agxdecode_vdm_line(ctx, ptr, (tword >> 8)*4); map += 2 * sizeof(uint32_t); length += 2 * sizeof(uint32_t); // if (~tword & 0b100000000) + //uint32_t next_block_type = ((uint8_t*)(&((uint32_t*)map)[1]))[3] >> 5; + uint32_t next_block_type = (((uint32_t*)map)[0]) >> 16; if (next_block_type != 0) break; } - map += sizeof(uint32_t); - length += sizeof(uint32_t); + //map += sizeof(uint32_t); + //length += sizeof(uint32_t); - u_hexdump(stdout, (void*)map, 4 * sizeof(uint32_t), false); - printf("length %lx\n", length); + printf("vdm pointer length was %lx\n", length); + //u_hexdump(stdout, (void*)map, 4 * sizeof(uint32_t), false); } #undef VDM_PRINT return length; @@ -1182,13 +1196,16 @@ agxdecode_cmdstream(struct agxdecode_ctx *ctx, unsigned cmdbuf_handle, // *(uint64_t*)(cmdbuf->_map + 0x4e0 + 12) = 0; // *(uint64_t*)(cmdbuf->_map + 0x4f0 + 12) = 0; // *(uint64_t*)(cmdbuf->_map + 0x830 + 12) = 0; + +#if 0 + // this is macos 26 uint32_t *map = cmdbuf->_map + 0x150 + 4; uint64_t *map64 = cmdbuf->_map + 0x170 + 4; -/* - TODO: 14.x compute dumping used this instead: +#else + // this is 14.x (thanks anna) uint32_t *map = cmdbuf->_map + 0x20; uint64_t *map64 = cmdbuf->_map + 0x20 + 8; -*/ +#endif printf("real encoder %llx\n", *map64); // struct agx_bo encoder_bo = alloc_encoder(metal_connection, ctx); @@ -1196,7 +1213,13 @@ agxdecode_cmdstream(struct agxdecode_ctx *ctx, unsigned cmdbuf_handle, uint64_t encoder = *map64;//(uint64_t)map[14] | ((uint64_t)(map[15]) << 32); printf("fake encoder %llx\n", *map64); - u_hexdump(stdout, (void*)cmdbuf->_map, 0x4000, true); +#if 0 + // 26.x + //u_hexdump(stdout, (void*)cmdbuf->_map, 0x4000, true); +#else + // 14.x + u_hexdump(stdout, (void*)cmdbuf->_map, 0x80, true); +#endif if (map[0] == 3) { agxdecode_stateful(ctx, encoder, "Encoder", agxdecode_cdm, verbose, @@ -1353,6 +1376,8 @@ agxdecode_dump_file_open(void) os_get_option("AGXDECODE_DUMP_FILE") ?: "agxdecode.dump"; if (!strcmp(dump_file_base, "stderr")) agxdecode_dump_stream = stderr; + else if (!strcmp(dump_file_base, "stdout")) + agxdecode_dump_stream = stdout; else { char buffer[1024]; snprintf(buffer, sizeof(buffer), "%s.%04d", dump_file_base,