mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 06:40:11 +01:00
intel/gen_decoder: Add gen_spec_load_filename() function.
Refactor the code from gen_spec_load_from_path() into a separate function, that can be used with a xml file that doesn't fit the genX.xml filename format. Will be used soon for implementing unit tests for gen_decoder. Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
This commit is contained in:
parent
1f2b22a6bd
commit
69506cbb74
2 changed files with 21 additions and 12 deletions
|
|
@ -649,23 +649,16 @@ gen_spec_load(const struct gen_device_info *devinfo)
|
|||
}
|
||||
|
||||
struct gen_spec *
|
||||
gen_spec_load_from_path(const struct gen_device_info *devinfo,
|
||||
const char *path)
|
||||
gen_spec_load_filename(const char *filename)
|
||||
{
|
||||
struct parser_context ctx;
|
||||
size_t len, filename_len = strlen(path) + 20;
|
||||
char *filename = malloc(filename_len);
|
||||
void *buf;
|
||||
FILE *input;
|
||||
|
||||
len = snprintf(filename, filename_len, "%s/gen%i.xml",
|
||||
path, devinfo_to_gen(devinfo, false));
|
||||
assert(len < filename_len);
|
||||
void *buf;
|
||||
size_t len;
|
||||
|
||||
input = fopen(filename, "r");
|
||||
if (input == NULL) {
|
||||
fprintf(stderr, "failed to open xml description\n");
|
||||
free(filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -675,7 +668,6 @@ gen_spec_load_from_path(const struct gen_device_info *devinfo,
|
|||
if (ctx.parser == NULL) {
|
||||
fprintf(stderr, "failed to create parser\n");
|
||||
fclose(input);
|
||||
free(filename);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -716,7 +708,6 @@ gen_spec_load_from_path(const struct gen_device_info *devinfo,
|
|||
XML_ParserFree(ctx.parser);
|
||||
|
||||
fclose(input);
|
||||
free(filename);
|
||||
|
||||
/* free ctx.spec if genxml is empty */
|
||||
if (ctx.spec &&
|
||||
|
|
@ -731,6 +722,23 @@ gen_spec_load_from_path(const struct gen_device_info *devinfo,
|
|||
return ctx.spec;
|
||||
}
|
||||
|
||||
struct gen_spec *
|
||||
gen_spec_load_from_path(const struct gen_device_info *devinfo,
|
||||
const char *path)
|
||||
{
|
||||
size_t len, filename_len = strlen(path) + 20;
|
||||
char *filename = malloc(filename_len);
|
||||
|
||||
len = snprintf(filename, filename_len, "%s/gen%i.xml",
|
||||
path, devinfo_to_gen(devinfo, false));
|
||||
assert(len < filename_len);
|
||||
|
||||
struct gen_spec *spec = gen_spec_load_filename(filename);
|
||||
free(filename);
|
||||
|
||||
return spec;
|
||||
}
|
||||
|
||||
void gen_spec_destroy(struct gen_spec *spec)
|
||||
{
|
||||
ralloc_free(spec);
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@ struct gen_group *gen_spec_find_struct(struct gen_spec *spec, const char *name);
|
|||
struct gen_spec *gen_spec_load(const struct gen_device_info *devinfo);
|
||||
struct gen_spec *gen_spec_load_from_path(const struct gen_device_info *devinfo,
|
||||
const char *path);
|
||||
struct gen_spec *gen_spec_load_filename(const char *filename);
|
||||
void gen_spec_destroy(struct gen_spec *spec);
|
||||
uint32_t gen_spec_get_gen(struct gen_spec *spec);
|
||||
struct gen_group *gen_spec_find_instruction(struct gen_spec *spec,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue