mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-09-13 09:16:14 -07:00
vkd3d-dxbc: Allow the section to extract to be specified by tag.
This commit is contained in:
parent
6c3b87bed0
commit
73996c9941
Notes:
Alexandre Julliard
2024-04-04 22:42:25 +02:00
Approved-by: Henri Verbeet (@hverbeet) Approved-by: Alexandre Julliard (@julliard) Merge-Request: https://gitlab.winehq.org/wine/vkd3d/-/merge_requests/755
@ -279,7 +279,13 @@ static void print_usage(const char *program_name)
|
|||||||
" --colour Enable colour, even when not supported by the output.\n"
|
" --colour Enable colour, even when not supported by the output.\n"
|
||||||
" -e, --emit Emit the content of the DXBC blob.\n"
|
" -e, --emit Emit the content of the DXBC blob.\n"
|
||||||
" -x, --extract=<section> Extract the data contained in <section>.\n"
|
" -x, --extract=<section> Extract the data contained in <section>.\n"
|
||||||
" <section> must be of the form 'i:<index>'.\n"
|
" <section> may either be of the form 'i:<index>' in\n"
|
||||||
|
" order to specify a section by its index or of the\n"
|
||||||
|
" form 't:<tag>' in order to specify a section by its\n"
|
||||||
|
" tag. <tag> may be either a four-character string or a\n"
|
||||||
|
" 32-bit hexadecimal integer. For example: 'i:2',\n"
|
||||||
|
" 't:SHDR', 't:52444853'. If multiple sections match\n"
|
||||||
|
" the same tag, the first matching section is used.\n"
|
||||||
" -h, --help Display this information and exit.\n"
|
" -h, --help Display this information and exit.\n"
|
||||||
" --ignore-checksum Do not validate the checksum when parsing the DXBC\n"
|
" --ignore-checksum Do not validate the checksum when parsing the DXBC\n"
|
||||||
" blob.\n"
|
" blob.\n"
|
||||||
@ -428,6 +434,26 @@ static const char *dump_tag(char *out, uint32_t tag)
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool parse_tag(uint32_t *t, const char *s)
|
||||||
|
{
|
||||||
|
char *end;
|
||||||
|
|
||||||
|
if (strlen(s) == 4)
|
||||||
|
{
|
||||||
|
*t = VKD3D_MAKE_TAG(s[0], s[1], s[2], s[3]);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strlen(s) == 8)
|
||||||
|
{
|
||||||
|
*t = strtoul(s, &end, 16);
|
||||||
|
if (!*end)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
static void dump_line(const struct colours *colours, const char *prefix,
|
static void dump_line(const struct colours *colours, const char *prefix,
|
||||||
const uint8_t *data, size_t offset, size_t count)
|
const uint8_t *data, size_t offset, size_t count)
|
||||||
{
|
{
|
||||||
@ -561,6 +587,7 @@ static bool emit_dxbc(const struct vkd3d_shader_dxbc_desc *dxbc_desc, const stru
|
|||||||
static struct vkd3d_shader_dxbc_section_desc *get_section(size_t section_count,
|
static struct vkd3d_shader_dxbc_section_desc *get_section(size_t section_count,
|
||||||
struct vkd3d_shader_dxbc_section_desc *sections, const char *s)
|
struct vkd3d_shader_dxbc_section_desc *sections, const char *s)
|
||||||
{
|
{
|
||||||
|
uint32_t tag;
|
||||||
size_t idx;
|
size_t idx;
|
||||||
char *end;
|
char *end;
|
||||||
|
|
||||||
@ -576,6 +603,23 @@ static struct vkd3d_shader_dxbc_section_desc *get_section(size_t section_count,
|
|||||||
return §ions[idx];
|
return §ions[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!strncmp("t:", s, 2))
|
||||||
|
{
|
||||||
|
s += 2;
|
||||||
|
if (!parse_tag(&tag, s))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Invalid section tag '%s' specified.\n", s);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
for (idx = 0; idx < section_count; ++idx)
|
||||||
|
{
|
||||||
|
if (sections[idx].tag == tag)
|
||||||
|
return §ions[idx];
|
||||||
|
}
|
||||||
|
fprintf(stderr, "Section '%s' not found.\n", s);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(stderr, "Invalid section specifier '%s' specified.\n", s);
|
fprintf(stderr, "Invalid section specifier '%s' specified.\n", s);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user