aubinator: don't leak fd of opened aubfile
[mesa.git] / src / intel / tools / aubinator.c
index 53b2a27fa90969e011e254507dd5fe2ad7341f30..48d4456cc1612267e698dcea1bea028186b9ac30 100644 (file)
@@ -95,23 +95,6 @@ valid_offset(uint32_t offset)
    return offset < gtt_end;
 }
 
-/**
- * Set group variable size for groups with count="0".
- *
- * By default the group size is fixed and not needed because the struct
- * describing a group knows the number of elements. However, for groups with
- * count="0" we have a variable number of elements, and the struct describing
- * the group only includes one of them. So we calculate the remaining size of
- * the group based on the size we get here, and the offset after the last
- * element added to the group.
- */
-static void
-group_set_size(struct gen_group *strct, uint32_t size)
-{
-   if (strct->variable && strct->elem_size)
-      strct->group_size = size - (strct->variable_offset / 32);
-}
-
 static void
 decode_group(struct gen_group *strct, const uint32_t *p, int starting_dword)
 {
@@ -540,6 +523,14 @@ handle_3dstate_sampler_state_pointers(struct gen_spec *spec, uint32_t *p)
    dump_samplers(spec, p[1]);
 }
 
+static void
+handle_3dstate_sampler_state_pointers_gen6(struct gen_spec *spec, uint32_t *p)
+{
+   dump_samplers(spec, p[1]);
+   dump_samplers(spec, p[2]);
+   dump_samplers(spec, p[3]);
+}
+
 static void
 handle_3dstate_viewport_state_pointers_cc(struct gen_spec *spec, uint32_t *p)
 {
@@ -651,6 +642,8 @@ handle_load_register_imm(struct gen_spec *spec, uint32_t *p)
 #define _3DSTATE_SAMPLER_STATE_POINTERS_GS  0x782e0000
 #define _3DSTATE_SAMPLER_STATE_POINTERS_PS  0x782f0000
 
+#define _3DSTATE_SAMPLER_STATE_POINTERS     0x78020000
+
 #define _3DSTATE_VIEWPORT_STATE_POINTERS_CC 0x78230000
 #define _3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP 0x78210000
 #define _3DSTATE_BLEND_STATE_POINTERS       0x78240000
@@ -687,6 +680,7 @@ struct custom_handler {
    { _3DSTATE_SAMPLER_STATE_POINTERS_VS, handle_3dstate_sampler_state_pointers },
    { _3DSTATE_SAMPLER_STATE_POINTERS_GS, handle_3dstate_sampler_state_pointers },
    { _3DSTATE_SAMPLER_STATE_POINTERS_PS, handle_3dstate_sampler_state_pointers },
+   { _3DSTATE_SAMPLER_STATE_POINTERS, handle_3dstate_sampler_state_pointers_gen6 },
 
    { _3DSTATE_VIEWPORT_STATE_POINTERS_CC, handle_3dstate_viewport_state_pointers_cc },
    { _3DSTATE_VIEWPORT_STATE_POINTERS_SF_CLIP, handle_3dstate_viewport_state_pointers_sf_clip },
@@ -740,7 +734,6 @@ parse_commands(struct gen_spec *spec, uint32_t *cmds, int size, int engine)
               gen_group_get_name(inst), reset_color);
 
       if (option_full_decode) {
-         group_set_size(inst, length);
          decode_group(inst, p, 0);
 
          for (i = 0; i < ARRAY_LENGTH(custom_handlers); i++) {
@@ -911,6 +904,8 @@ aub_file_open(const char *filename)
       exit(EXIT_FAILURE);
    }
 
+   close(fd);
+
    file->cursor = file->map;
    file->end = file->map + sb.st_size / 4;
 
@@ -970,7 +965,8 @@ struct {
    { "bdw", MAKE_GEN(8, 0) },
    { "skl", MAKE_GEN(9, 0) },
    { "chv", MAKE_GEN(8, 0) },
-   { "bxt", MAKE_GEN(9, 0) }
+   { "bxt", MAKE_GEN(9, 0) },
+   { "cnl", MAKE_GEN(10, 0) },
 };
 
 enum {
@@ -1138,7 +1134,7 @@ print_help(const char *progname, FILE *file)
            "Decode aub file contents from either FILE or the standard input.\n\n"
            "A valid --gen option must be provided.\n\n"
            "      --help          display this help and exit\n"
-           "      --gen=platform  decode for given platform (ivb, byt, hsw, bdw, chv, skl, kbl or bxt)\n"
+           "      --gen=platform  decode for given platform (ivb, byt, hsw, bdw, chv, skl, kbl, bxt or cnl)\n"
            "      --headers       decode only command headers\n"
            "      --color[=WHEN]  colorize the output; WHEN can be 'auto' (default\n"
            "                        if omitted), 'always', or 'never'\n"
@@ -1166,7 +1162,8 @@ int main(int argc, char *argv[])
       { "chv", 0x22B3 }, /* Intel(R) HD Graphics (Cherryview) */
       { "skl", 0x1912 }, /* Intel(R) HD Graphics 530 (Skylake GT2) */
       { "kbl", 0x591D }, /* Intel(R) Kabylake GT2 */
-      { "bxt", 0x0A84 }  /* Intel(R) HD Graphics (Broxton) */
+      { "bxt", 0x0A84 },  /* Intel(R) HD Graphics (Broxton) */
+      { "cnl", 0x5A52 },  /* Intel(R) HD Graphics (Cannonlake) */
    };
    const struct option aubinator_opts[] = {
       { "help",       no_argument,       (int *) &help,                 true },