mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 13:58:04 +02:00
pan/bi: Improve interoperability of the command-line disassembler
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8358>
This commit is contained in:
parent
7c6aa5f49d
commit
58cf95a637
1 changed files with 19 additions and 2 deletions
|
|
@ -79,6 +79,10 @@ compile_shader(char **argv, bool vertex_only)
|
|||
return compiled;
|
||||
}
|
||||
|
||||
#define BI_FOURCC(ch0, ch1, ch2, ch3) ( \
|
||||
(uint32_t)(ch0) | (uint32_t)(ch1) << 8 | \
|
||||
(uint32_t)(ch2) << 16 | (uint32_t)(ch3) << 24)
|
||||
|
||||
static void
|
||||
disassemble(const char *filename, bool verbose)
|
||||
{
|
||||
|
|
@ -89,14 +93,27 @@ disassemble(const char *filename, bool verbose)
|
|||
unsigned filesize = ftell(fp);
|
||||
rewind(fp);
|
||||
|
||||
unsigned char *code = malloc(filesize);
|
||||
uint32_t *code = malloc(filesize);
|
||||
unsigned res = fread(code, 1, filesize, fp);
|
||||
if (res != filesize) {
|
||||
printf("Couldn't read full file\n");
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
disassemble_bifrost(stdout, code, filesize, verbose);
|
||||
if (filesize && code[0] == BI_FOURCC('M', 'B', 'S', '2')) {
|
||||
for (int i = 0; i < filesize / 4; ++i) {
|
||||
if (code[i] != BI_FOURCC('O', 'B', 'J', 'C'))
|
||||
continue;
|
||||
|
||||
unsigned size = code[i + 1];
|
||||
unsigned offset = i + 2;
|
||||
|
||||
disassemble_bifrost(stdout, (uint8_t*)(code + offset), size, verbose);
|
||||
}
|
||||
} else {
|
||||
disassemble_bifrost(stdout, (uint8_t*)code, filesize, verbose);
|
||||
}
|
||||
|
||||
free(code);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue