static struct fd2_shader_stateobj * assemble(struct fd2_shader_stateobj *so) { free(so->bin); so->bin = ir2_shader_assemble(so->ir, &so->info); if (!so->bin) goto fail; if (fd_mesa_debug & FD_DBG_DISASM) { DBG("disassemble: type=%d", so->type); disasm_a2xx(so->bin, so->info.sizedwords, 0, so->type); } return so; fail: debug_error("assemble failed!"); delete_shader(so); return NULL; }
static void dump_shaders_a2xx(struct state *state) { int i, sect_size; uint8_t *ptr; /* dump vertex shaders: */ for (i = 0; i < 3; i++) { struct vs_header *vs_hdr = next_sect(state, §_size); struct constant *constants[32]; int j, level = 0; printf("\n"); if (full_dump) { printf("#######################################################\n"); printf("######## VS%d HEADER: (size %d)\n", i, sect_size); dump_hex((void *)vs_hdr, sect_size); } for (j = 0; j < (int)vs_hdr->unknown1 - 1; j++) { constants[j] = next_sect(state, §_size); if (full_dump) { printf("######## VS%d CONST: (size=%d)\n", i, sect_size); dump_constant(constants[j]); dump_hex((char *)constants[j], sect_size); } } ptr = next_sect(state, §_size); printf("######## VS%d SHADER: (size=%d)\n", i, sect_size); if (full_dump) { dump_hex(ptr, sect_size); level = 1; } else { dump_short_summary(state, vs_hdr->unknown1 - 1, constants); } disasm_a2xx((uint32_t *)(ptr + 32), (sect_size - 32) / 4, level+1, SHADER_VERTEX); dump_raw_shader((uint32_t *)(ptr + 32), (sect_size - 32) / 4, i, "vo"); free(ptr); for (j = 0; j < vs_hdr->unknown9; j++) { ptr = next_sect(state, §_size); if (full_dump) { printf("######## VS%d CONST?: (size=%d)\n", i, sect_size); dump_hex(ptr, sect_size); } free(ptr); } for (j = 0; j < vs_hdr->unknown1 - 1; j++) { free(constants[j]); } free(vs_hdr); } /* dump fragment shaders: */ for (i = 0; i < 1; i++) { struct fs_header *fs_hdr = next_sect(state, §_size); struct constant *constants[32]; int j, level = 0; printf("\n"); if (full_dump) { printf("#######################################################\n"); printf("######## FS%d HEADER: (size %d)\n", i, sect_size); dump_hex((void *)fs_hdr, sect_size); } for (j = 0; j < fs_hdr->unknown1 - 1; j++) { constants[j] = next_sect(state, §_size); if (full_dump) { printf("######## FS%d CONST: (size=%d)\n", i, sect_size); dump_constant(constants[j]); dump_hex((char *)constants[j], sect_size); } } ptr = next_sect(state, §_size); printf("######## FS%d SHADER: (size=%d)\n", i, sect_size); if (full_dump) { dump_hex(ptr, sect_size); level = 1; } else { dump_short_summary(state, fs_hdr->unknown1 - 1, constants); } disasm_a2xx((uint32_t *)(ptr + 32), (sect_size - 32) / 4, level+1, SHADER_FRAGMENT); dump_raw_shader((uint32_t *)(ptr + 32), (sect_size - 32) / 4, i, "fo"); free(ptr); for (j = 0; j < fs_hdr->unknown1 - 1; j++) { free(constants[j]); } free(fs_hdr); } }