broadcom/vc5: Move the body of CLIF dumping to a per-version file.
authorEric Anholt <eric@anholt.net>
Tue, 9 Jan 2018 23:13:27 +0000 (15:13 -0800)
committerEric Anholt <eric@anholt.net>
Sat, 13 Jan 2018 05:55:38 +0000 (21:55 -0800)
I want the library's entrypoints to still be unversioned, but the actual
packet dumping needs to be per-version.

src/broadcom/Makefile.sources
src/broadcom/Makefile.vc5.am
src/broadcom/clif/clif_dump.c
src/broadcom/clif/clif_private.h [new file with mode: 0644]
src/broadcom/clif/v3dx_dump.c [new file with mode: 0644]
src/broadcom/meson.build

index d8803b8d87772bfc227f2f0dc5c3ebbe1a0536e0..2a6351b9a11bcd83f3325d6828442caf0a017b44 100644 (file)
@@ -39,6 +39,10 @@ BROADCOM_FILES = \
        qpu/qpu_pack.c \
        $()
 
+BROADCOM_PER_VERSION_SOURCES = \
+       clif/v3dx_dump.c \
+       $()
+
 BROADCOM_DECODER_FILES = \
        cle/v3d_decoder.c \
        cle/v3d_decoder.h \
index 3e8e28bc9478285ca8dff403095392e268511ebc..067da49f9e271506886ec2552e1f76345030cf74 100644 (file)
@@ -1,10 +1,14 @@
 noinst_LTLIBRARIES += libbroadcom.la
+noinst_LTLIBRARIES += libbroadcom_v33.la
 
 if USE_VC5_SIMULATOR
 AM_CFLAGS += $(VC5_SIMULATOR_CFLAGS)
 libbroadcom_la_LDFLAGS = $(VC5_SIMULATOR_LIBS)
 endif
 
+libbroadcom_v33_la_SOURCES = $(BROADCOM_PER_VERSION_SOURCES)
+libbroadcom_v33_la_CFLAGS = -DV3D_VERSION=33
+
 libbroadcom_la_SOURCES = $(BROADCOM_FILES)
 
 check_PROGRAMS += \
index ca5d5592779a4fa7fe0d1d7d46a45de56d9370cb..18c20d880f765ac1701e939e1476a0dd32f6fd5f 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 #include "clif_dump.h"
+#include "clif_private.h"
 #include "util/list.h"
 #include "util/ralloc.h"
 
 #include "broadcom/cle/v3d_decoder.h"
 
-#define __gen_user_data void
-#define __gen_address_type uint32_t
-#define __gen_address_offset(reloc) (*reloc)
-#define __gen_emit_reloc(cl, reloc)
-#define __gen_unpack_address(cl, s, e) (__gen_unpack_uint(cl, s, e) << (31 - (e - s)))
-
-enum reloc_worklist_type {
-        reloc_gl_shader_state,
-        reloc_generic_tile_list,
-};
-
-struct reloc_worklist_entry {
-        struct list_head link;
-
-        enum reloc_worklist_type type;
-        uint32_t addr;
-
-        union {
-                struct {
-                        uint32_t num_attrs;
-                } shader_state;
-                struct {
-                        uint32_t end;
-                } generic_tile_list;
-        };
-};
-
-struct clif_dump {
-        const struct v3d_device_info *devinfo;
-        bool (*lookup_vaddr)(void *data, uint32_t addr, void **vaddr);
-        FILE *out;
-        /* Opaque data from the caller that is passed to the callbacks. */
-        void *data;
-
-        struct v3d_spec *spec;
-
-        /* List of struct reloc_worklist_entry */
-        struct list_head worklist;
-};
-
-static void
-out(struct clif_dump *clif, const char *fmt, ...)
-{
-        va_list args;
-
-        va_start(args, fmt);
-        vfprintf(clif->out, fmt, args);
-        va_end(args);
-}
-
-#include "broadcom/cle/v3d_packet_v33_pack.h"
-
-static struct reloc_worklist_entry *
+struct reloc_worklist_entry *
 clif_dump_add_address_to_worklist(struct clif_dump *clif,
                                   enum reloc_worklist_type type,
                                   uint32_t addr)
@@ -132,106 +81,7 @@ static bool
 clif_dump_packet(struct clif_dump *clif, uint32_t offset, const uint8_t *cl,
                  uint32_t *size)
 {
-        struct v3d_group *inst = v3d_spec_find_instruction(clif->spec, cl);
-        if (!inst) {
-                out(clif, "0x%08x: Unknown packet %d!\n", offset, *cl);
-                return false;
-        }
-
-        *size = v3d_group_get_length(inst);
-
-        out(clif, "%s\n", v3d_group_get_name(inst));
-        v3d_print_group(clif->out, inst, 0, cl, "");
-
-        switch (*cl) {
-        case V3D33_GL_SHADER_STATE_opcode: {
-                struct V3D33_GL_SHADER_STATE values;
-                V3D33_GL_SHADER_STATE_unpack(cl, &values);
-
-                struct reloc_worklist_entry *reloc =
-                        clif_dump_add_address_to_worklist(clif,
-                                                          reloc_gl_shader_state,
-                                                          values.address);
-                if (reloc) {
-                        reloc->shader_state.num_attrs =
-                                values.number_of_attribute_arrays;
-                }
-                return true;
-        }
-
-        case V3D33_STORE_MULTI_SAMPLE_RESOLVED_TILE_COLOR_BUFFER_EXTENDED_opcode: {
-                struct V3D33_STORE_MULTI_SAMPLE_RESOLVED_TILE_COLOR_BUFFER_EXTENDED values;
-                V3D33_STORE_MULTI_SAMPLE_RESOLVED_TILE_COLOR_BUFFER_EXTENDED_unpack(cl, &values);
-
-                if (values.last_tile_of_frame)
-                        return false;
-                break;
-        }
-
-        case V3D33_TRANSFORM_FEEDBACK_ENABLE_opcode: {
-                struct V3D33_TRANSFORM_FEEDBACK_ENABLE values;
-                V3D33_TRANSFORM_FEEDBACK_ENABLE_unpack(cl, &values);
-                struct v3d_group *spec = v3d_spec_find_struct(clif->spec,
-                                                              "Transform Feedback Output Data Spec");
-                struct v3d_group *addr = v3d_spec_find_struct(clif->spec,
-                                                              "Transform Feedback Output Address");
-                assert(spec);
-                assert(addr);
-
-                cl += *size;
-
-                for (int i = 0; i < values.number_of_16_bit_output_data_specs_following; i++) {
-                        v3d_print_group(clif->out, spec, 0, cl, "");
-                        cl += v3d_group_get_length(spec);
-                        *size += v3d_group_get_length(spec);
-                }
-
-                for (int i = 0; i < values.number_of_32_bit_output_buffer_address_following; i++) {
-                        v3d_print_group(clif->out, addr, 0, cl, "");
-                        cl += v3d_group_get_length(addr);
-                        *size += v3d_group_get_length(addr);
-                }
-                break;
-        }
-
-        case V3D33_START_ADDRESS_OF_GENERIC_TILE_LIST_opcode: {
-                struct V3D33_START_ADDRESS_OF_GENERIC_TILE_LIST values;
-                V3D33_START_ADDRESS_OF_GENERIC_TILE_LIST_unpack(cl, &values);
-                struct reloc_worklist_entry *reloc =
-                        clif_dump_add_address_to_worklist(clif,
-                                                          reloc_generic_tile_list,
-                                                          values.start);
-                reloc->generic_tile_list.end = values.end;
-                break;
-        }
-
-        case V3D33_HALT_opcode:
-                return false;
-        }
-
-        return true;
-}
-
-static void
-clif_dump_gl_shader_state_record(struct clif_dump *clif,
-                                 struct reloc_worklist_entry *reloc, void *vaddr)
-{
-        struct v3d_group *state = v3d_spec_find_struct(clif->spec,
-                                                       "GL Shader State Record");
-        struct v3d_group *attr = v3d_spec_find_struct(clif->spec,
-                                                      "GL Shader State Attribute Record");
-        assert(state);
-        assert(attr);
-
-        out(clif, "GL Shader State Record at 0x%08x\n", reloc->addr);
-        v3d_print_group(clif->out, state, 0, vaddr, "");
-        vaddr += v3d_group_get_length(state);
-
-        for (int i = 0; i < reloc->shader_state.num_attrs; i++) {
-                out(clif, "  Attribute %d\n", i);
-                v3d_print_group(clif->out, attr, 0, vaddr, "");
-                vaddr += v3d_group_get_length(attr);
-        }
+        return v3d33_clif_dump_packet(clif, offset, cl, size);
 }
 
 static void
@@ -283,7 +133,8 @@ clif_process_worklist(struct clif_dump *clif)
 
                 switch (reloc->type) {
                 case reloc_gl_shader_state:
-                        clif_dump_gl_shader_state_record(clif, reloc, vaddr);
+                        v3d33_clif_dump_gl_shader_state_record(clif, reloc,
+                                                               vaddr);
                         break;
                 case reloc_generic_tile_list:
                         clif_dump_cl(clif, reloc->addr,
diff --git a/src/broadcom/clif/clif_private.h b/src/broadcom/clif/clif_private.h
new file mode 100644 (file)
index 0000000..d8453d5
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+ * Copyright © 2016-2018 Broadcom
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef CLIF_PRIVATE_H
+#define CLIF_PRIVATE_H
+
+#include <stdint.h>
+#include <stdarg.h>
+#include "util/list.h"
+
+struct clif_dump {
+        const struct v3d_device_info *devinfo;
+        bool (*lookup_vaddr)(void *data, uint32_t addr, void **vaddr);
+        FILE *out;
+        /* Opaque data from the caller that is passed to the callbacks. */
+        void *data;
+
+        struct v3d_spec *spec;
+
+        /* List of struct reloc_worklist_entry */
+        struct list_head worklist;
+};
+
+enum reloc_worklist_type {
+        reloc_gl_shader_state,
+        reloc_generic_tile_list,
+};
+
+struct reloc_worklist_entry {
+        struct list_head link;
+
+        enum reloc_worklist_type type;
+        uint32_t addr;
+
+        union {
+                struct {
+                        uint32_t num_attrs;
+                } shader_state;
+                struct {
+                        uint32_t end;
+                } generic_tile_list;
+        };
+};
+
+struct reloc_worklist_entry *
+clif_dump_add_address_to_worklist(struct clif_dump *clif,
+                                  enum reloc_worklist_type type,
+                                  uint32_t addr);
+
+bool v3d33_clif_dump_packet(struct clif_dump *clif, uint32_t offset,
+                            const uint8_t *cl, uint32_t *size);
+void v3d33_clif_dump_gl_shader_state_record(struct clif_dump *clif,
+                                            struct reloc_worklist_entry *reloc,
+                                            void *vaddr);
+
+static inline void
+out(struct clif_dump *clif, const char *fmt, ...)
+{
+        va_list args;
+
+        va_start(args, fmt);
+        vfprintf(clif->out, fmt, args);
+        va_end(args);
+}
+
+#endif /* CLIF_PRIVATE_H */
diff --git a/src/broadcom/clif/v3dx_dump.c b/src/broadcom/clif/v3dx_dump.c
new file mode 100644 (file)
index 0000000..506d3bb
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ * Copyright © 2016-2018 Broadcom
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#include <string.h>
+#include "broadcom/cle/v3d_decoder.h"
+#include "clif_dump.h"
+#include "clif_private.h"
+
+#define __gen_user_data void
+#define __gen_address_type uint32_t
+#define __gen_address_offset(reloc) (*reloc)
+#define __gen_emit_reloc(cl, reloc)
+#define __gen_unpack_address(cl, s, e) (__gen_unpack_uint(cl, s, e) << (31 - (e - s)))
+#include "broadcom/cle/v3dx_pack.h"
+#include "broadcom/common/v3d_macros.h"
+
+bool
+v3dX(clif_dump_packet)(struct clif_dump *clif, uint32_t offset,
+                       const uint8_t *cl, uint32_t *size)
+{
+        struct v3d_group *inst = v3d_spec_find_instruction(clif->spec, cl);
+        if (!inst) {
+                out(clif, "0x%08x: Unknown packet %d!\n", offset, *cl);
+                return false;
+        }
+
+        *size = v3d_group_get_length(inst);
+
+        out(clif, "%s\n", v3d_group_get_name(inst));
+        v3d_print_group(clif->out, inst, 0, cl, "");
+
+        switch (*cl) {
+        case V3D33_GL_SHADER_STATE_opcode: {
+                struct V3D33_GL_SHADER_STATE values;
+                V3D33_GL_SHADER_STATE_unpack(cl, &values);
+
+                struct reloc_worklist_entry *reloc =
+                        clif_dump_add_address_to_worklist(clif,
+                                                          reloc_gl_shader_state,
+                                                          values.address);
+                if (reloc) {
+                        reloc->shader_state.num_attrs =
+                                values.number_of_attribute_arrays;
+                }
+                return true;
+        }
+
+        case V3D33_STORE_MULTI_SAMPLE_RESOLVED_TILE_COLOR_BUFFER_EXTENDED_opcode: {
+                struct V3D33_STORE_MULTI_SAMPLE_RESOLVED_TILE_COLOR_BUFFER_EXTENDED values;
+                V3D33_STORE_MULTI_SAMPLE_RESOLVED_TILE_COLOR_BUFFER_EXTENDED_unpack(cl, &values);
+
+                if (values.last_tile_of_frame)
+                        return false;
+                break;
+        }
+
+        case V3D33_TRANSFORM_FEEDBACK_ENABLE_opcode: {
+                struct V3D33_TRANSFORM_FEEDBACK_ENABLE values;
+                V3D33_TRANSFORM_FEEDBACK_ENABLE_unpack(cl, &values);
+                struct v3d_group *spec = v3d_spec_find_struct(clif->spec,
+                                                              "Transform Feedback Output Data Spec");
+                struct v3d_group *addr = v3d_spec_find_struct(clif->spec,
+                                                              "Transform Feedback Output Address");
+                assert(spec);
+                assert(addr);
+
+                cl += *size;
+
+                for (int i = 0; i < values.number_of_16_bit_output_data_specs_following; i++) {
+                        v3d_print_group(clif->out, spec, 0, cl, "");
+                        cl += v3d_group_get_length(spec);
+                        *size += v3d_group_get_length(spec);
+                }
+
+                for (int i = 0; i < values.number_of_32_bit_output_buffer_address_following; i++) {
+                        v3d_print_group(clif->out, addr, 0, cl, "");
+                        cl += v3d_group_get_length(addr);
+                        *size += v3d_group_get_length(addr);
+                }
+                break;
+        }
+
+        case V3D33_START_ADDRESS_OF_GENERIC_TILE_LIST_opcode: {
+                struct V3D33_START_ADDRESS_OF_GENERIC_TILE_LIST values;
+                V3D33_START_ADDRESS_OF_GENERIC_TILE_LIST_unpack(cl, &values);
+                struct reloc_worklist_entry *reloc =
+                        clif_dump_add_address_to_worklist(clif,
+                                                          reloc_generic_tile_list,
+                                                          values.start);
+                reloc->generic_tile_list.end = values.end;
+                break;
+        }
+
+        case V3D33_HALT_opcode:
+                return false;
+        }
+
+        return true;
+}
+
+void
+v3dX(clif_dump_gl_shader_state_record)(struct clif_dump *clif,
+                                       struct reloc_worklist_entry *reloc,
+                                       void *vaddr)
+{
+        struct v3d_group *state = v3d_spec_find_struct(clif->spec,
+                                                       "GL Shader State Record");
+        struct v3d_group *attr = v3d_spec_find_struct(clif->spec,
+                                                      "GL Shader State Attribute Record");
+        assert(state);
+        assert(attr);
+
+        out(clif, "GL Shader State Record at 0x%08x\n", reloc->addr);
+        v3d_print_group(clif->out, state, 0, vaddr, "");
+        vaddr += v3d_group_get_length(state);
+
+        for (int i = 0; i < reloc->shader_state.num_attrs; i++) {
+                out(clif, "  Attribute %d\n", i);
+                v3d_print_group(clif->out, attr, 0, vaddr, "");
+                vaddr += v3d_group_get_length(attr);
+        }
+}
index f2a5e53c0a5edb96c313eaa30e2de42784eabe6c..839fa4a192ea750564870de5052b729a0f23cfcc 100644 (file)
@@ -22,10 +22,23 @@ inc_broadcom = include_directories('.', 'cle')
 
 subdir('cle')
 
+vc5_versions = ['33']
+
 if with_gallium_vc5
   subdir('compiler')
   subdir('qpu')
 
+  per_version_libs = []
+  foreach ver : vc5_versions
+    per_version_libs += static_library(
+      'libbroadcom-v' + ver,
+      files('clif/v3dx_dump.c'),
+      include_directories : [inc_common, inc_broadcom, inc_src],
+      c_args : [c_vis_args, no_override_init_args, '-DV3D_VERSION=' + ver],
+      dependencies: [dep_valgrind, dep_thread],
+    )
+  endforeach
+
   libbroadcom_vc5 = static_library(
     'libbroadcom_vc5',
     [
@@ -34,7 +47,7 @@ if with_gallium_vc5
     ],
     include_directories : [inc_common, inc_broadcom, inc_src],
     c_args : [c_vis_args, no_override_init_args],
-    link_whole : [libbroadcom_compiler, libbroadcom_qpu],
+    link_whole : [libbroadcom_compiler, libbroadcom_qpu] + per_version_libs,
     build_by_default : false,
     dependencies: [dep_valgrind, dep_thread],
   )