/* dump attr/uniform/sampler/varying/const summary: */ static void dump_short_summary(struct state *state, int nconsts, struct constant **constants) { int i; /* dump attr/uniform/sampler/varying/const summary: */ for (i = 0; i < state->hdr->num_varyings; i++) { dump_varying(state->varyings[i]); } for (i = 0; i < state->hdr->num_attribs; i++) { dump_attribute(state->attribs[i]); } for (i = 0; i < state->hdr->num_uniforms; i++) { dump_uniform(state->uniforms[i]); } for (i = 0; i < state->hdr->num_samplers; i++) { dump_sampler(state->samplers[i]); } for (i = 0; i < nconsts - 1; i++) { if (constants[i]->unknown2 == 0) { dump_constant(constants[i]); } } printf("\n"); }
static void dump_component(struct component *c) { struct constant *constant; struct block *block; int bytes; if (c->nconstants <= UCHAR_MAX && c->bytes <= USHRT_MAX) { dump_op(fop_SHORT_COMPONENT); dump_byte(c->nconstants); dump_short((short)(c->bytes)); } else { dump_op(fop_COMPONENT); dump_int(c->nconstants); dump_int(c->bytes); } if (c->debug_name) dump_literal(c->debug_name); else dump_op(fop_FALSE); dump_integer(c->frame_size); dump_debug_info(c); for (constant = c->constants; constant != NULL; constant = constant->next) dump_constant(constant); bytes = 0; for (block = c->blocks; block != NULL; block = block->next) { int count = block->end - block->bytes; dump_bytes(block->bytes, count); bytes += count; } if (bytes != c->bytes) lose("Planned on writing %d bytes, but ended up writing %d instead.", c->bytes, bytes); }
static void dump_shaders_a3xx(struct state *state) { int i, j; /* dump vertex shaders: */ for (i = 0; i < 2; i++) { int instrs_size, hdr_size, sect_size, nconsts = 0, level = 0, compact = 0; uint8_t *vs_hdr; struct constant *constants[32]; uint8_t *instrs = NULL; vs_hdr = next_sect(state, &hdr_size); /* seems like there are two cases, either: * 1) 152 byte header, * 2) zero or more 32 byte compiler const sections * 3) followed by shader instructions * or, if there are no compiler consts, this can be * all smashed in one large section */ if (hdr_size > 152) { instrs = &vs_hdr[152]; instrs_size = hdr_size - 152; hdr_size = 152; compact = 1; } else { while (1) { void *ptr = next_sect(state, §_size); if (sect_size != 32) { /* end of constants: */ instrs = ptr; instrs_size = sect_size; break; } constants[nconsts++] = ptr; } } printf("\n"); if (full_dump) { printf("#######################################################\n"); printf("######## VS%d HEADER: (size %d)\n", i, hdr_size); dump_hex((void *)vs_hdr, hdr_size); for (j = 0; j < nconsts; j++) { printf("######## VS%d CONST: (size=%d)\n", i, sizeof(constants[i])); dump_constant(constants[j]); dump_hex((char *)constants[j], sizeof(constants[j])); } } printf("######## VS%d SHADER: (size=%d)\n", i, instrs_size); if (full_dump) { dump_hex(instrs, instrs_size); level = 1; } else { dump_short_summary(state, nconsts, constants); } if (!compact) { instrs += 32; instrs_size -= 32; } disasm_a3xx((uint32_t *)instrs, instrs_size / 4, level+1, SHADER_VERTEX); dump_raw_shader((uint32_t *)instrs, instrs_size / 4, i, "vo3"); free(vs_hdr); } /* dump fragment shaders: */ for (i = 0; i < 1; i++) { int instrs_size, hdr_size, sect_size, nconsts = 0, level = 0, compact = 0; uint8_t *fs_hdr; struct constant *constants[32]; uint8_t *instrs = NULL; fs_hdr = next_sect(state, &hdr_size); /* two cases, similar to vertex shader, but magic # is 200.. */ if (hdr_size > 200) { instrs = &fs_hdr[200]; instrs_size = hdr_size - 200; hdr_size = 200; compact = 1; } else { while (1) { void *ptr = next_sect(state, §_size); if (sect_size != 32) { /* end of constants: */ instrs = ptr; instrs_size = sect_size; break; } constants[nconsts++] = ptr; } } printf("\n"); if (full_dump) { printf("#######################################################\n"); printf("######## FS%d HEADER: (size %d)\n", i, hdr_size); dump_hex((void *)fs_hdr, hdr_size); for (j = 0; j < nconsts; j++) { printf("######## FS%d CONST: (size=%d)\n", i, sizeof(constants[i])); dump_constant(constants[j]); dump_hex((char *)constants[j], sizeof(constants[j])); } } printf("######## FS%d SHADER: (size=%d)\n", i, instrs_size); if (full_dump) { dump_hex(instrs, instrs_size); level = 1; } else { dump_short_summary(state, nconsts, constants); } if (!compact) { instrs += 32; instrs_size -= 32; } disasm_a3xx((uint32_t *)instrs, instrs_size / 4, level+1, SHADER_FRAGMENT); dump_raw_shader((uint32_t *)instrs, instrs_size / 4, i, "fo3"); free(fs_hdr); } }
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); } }
static void dump_expr(g95_expr *e) { if (e == NULL) { dumpf("None"); return; } switch(e->type) { case EXPR_NULL: dumpf("null(%L,%S,%d)", &e->where, g95_typename(&e->ts), e->rank); break; case EXPR_OP: dump_intrinsic(e); break; case EXPR_CONSTANT: dump_constant(e); break; case EXPR_VARIABLE: dump_variable(e); break; case EXPR_FUNCTION: if (e->value.function.isym != NULL && e->value.function.isym->id == G95_ISYM_CONVERSION) dump_expr(e->value.function.actual->u.expr); else { dumpf("fcall(%L,", &e->where); dump_name(e->symbol, e->value.function.isym); dumpf(",%S,%d,", g95_typename(&e->ts), e->rank); dump_actual(e->value.function.actual); dump_char(')'); } break; case EXPR_PROCEDURE: dumpf("procedure(%L,", &e->where); dump_name(e->symbol, NULL); dump_char(')'); break; case EXPR_STRUCTURE: dump_cons("scons", e); break; case EXPR_ARRAY: dump_cons("acons", e); break; case EXPR_SUBSTRING: dumpf("substring_exp(%L,", &e->where); dump_constant(e); dump_char(','); dump_expr(e->ref->u.ss.start); dump_char(','); dump_expr(e->ref->u.ss.end); dump_char(')'); break; default: g95_internal_error("dump_expr(): Bad expression"); } }