freedreno: drop shader_t
authorRob Clark <robdclark@chromium.org>
Sat, 25 Jul 2020 19:16:36 +0000 (12:16 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 28 Jul 2020 09:45:08 +0000 (09:45 +0000)
When this code was outside of the mesa tree, we needed our own enum.
Now we can use a common one, to simplify deduplicating the disasm
code.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6070>

src/freedreno/decode/cffdec.c
src/freedreno/decode/disasm-a2xx.c
src/freedreno/decode/disasm.h
src/freedreno/decode/meson.build
src/freedreno/decode/pgmdump.c

index d0b269578adff26fe95b6a506f755db417e4f5e8..cafb4a30a89ca8feb1ffeb92822fe0a2f4cb0734 100644 (file)
@@ -1114,18 +1114,18 @@ cp_im_loadi(uint32_t *dwords, uint32_t sizedwords, int level)
        uint32_t start = dwords[1] >> 16;
        uint32_t size  = dwords[1] & 0xffff;
        const char *type = NULL, *ext = NULL;
-       enum shader_t disasm_type;
+       gl_shader_stage disasm_type;
 
        switch (dwords[0]) {
        case 0:
                type = "vertex";
                ext = "vo";
-               disasm_type = SHADER_VERTEX;
+               disasm_type = MESA_SHADER_VERTEX;
                break;
        case 1:
                type = "fragment";
                ext = "fo";
-               disasm_type = SHADER_FRAGMENT;
+               disasm_type = MESA_SHADER_FRAGMENT;
                break;
        default:
                type = "<unknown>";
@@ -1189,23 +1189,23 @@ enum adreno_state_block {
  */
 
 static void
-a3xx_get_state_type(uint32_t *dwords, enum shader_t *stage, enum state_t *state,
+a3xx_get_state_type(uint32_t *dwords, gl_shader_stage *stage, enum state_t *state,
                    enum state_src_t *src)
 {
        unsigned state_block_id = (dwords[0] >> 19) & 0x7;
        unsigned state_type = dwords[1] & 0x3;
        static const struct {
-               enum shader_t stage;
+               gl_shader_stage stage;
                enum state_t state;
        } lookup[0xf][0x3] = {
-               [SB_VERT_TEX][0]    = { SHADER_VERTEX,    TEX_SAMP },
-               [SB_VERT_TEX][1]    = { SHADER_VERTEX,    TEX_CONST },
-               [SB_FRAG_TEX][0]    = { SHADER_FRAGMENT,  TEX_SAMP },
-               [SB_FRAG_TEX][1]    = { SHADER_FRAGMENT,  TEX_CONST },
-               [SB_VERT_SHADER][0] = { SHADER_VERTEX,    SHADER_PROG },
-               [SB_VERT_SHADER][1] = { SHADER_VERTEX,    SHADER_CONST },
-               [SB_FRAG_SHADER][0] = { SHADER_FRAGMENT,  SHADER_PROG },
-               [SB_FRAG_SHADER][1] = { SHADER_FRAGMENT,  SHADER_CONST },
+               [SB_VERT_TEX][0]    = { MESA_SHADER_VERTEX,    TEX_SAMP },
+               [SB_VERT_TEX][1]    = { MESA_SHADER_VERTEX,    TEX_CONST },
+               [SB_FRAG_TEX][0]    = { MESA_SHADER_FRAGMENT,  TEX_SAMP },
+               [SB_FRAG_TEX][1]    = { MESA_SHADER_FRAGMENT,  TEX_CONST },
+               [SB_VERT_SHADER][0] = { MESA_SHADER_VERTEX,    SHADER_PROG },
+               [SB_VERT_SHADER][1] = { MESA_SHADER_VERTEX,    SHADER_CONST },
+               [SB_FRAG_SHADER][0] = { MESA_SHADER_FRAGMENT,  SHADER_PROG },
+               [SB_FRAG_SHADER][1] = { MESA_SHADER_FRAGMENT,  SHADER_CONST },
        };
 
        *stage = lookup[state_block_id][state_type].stage;
@@ -1234,69 +1234,69 @@ _get_state_src(unsigned dword0)
 
 static void
 _get_state_type(unsigned state_block_id, unsigned state_type,
-               enum shader_t *stage, enum state_t *state)
+               gl_shader_stage *stage, enum state_t *state)
 {
        static const struct {
-               enum shader_t stage;
+               gl_shader_stage stage;
                enum state_t  state;
        } lookup[0x10][0x4] = {
                // SB4_VS_TEX:
-               [0x0][0] = { SHADER_VERTEX,    TEX_SAMP },
-               [0x0][1] = { SHADER_VERTEX,    TEX_CONST },
-               [0x0][2] = { SHADER_VERTEX,    UBO },
+               [0x0][0] = { MESA_SHADER_VERTEX,    TEX_SAMP },
+               [0x0][1] = { MESA_SHADER_VERTEX,    TEX_CONST },
+               [0x0][2] = { MESA_SHADER_VERTEX,    UBO },
                // SB4_HS_TEX:
-               [0x1][0] = { SHADER_TCS,       TEX_SAMP },
-               [0x1][1] = { SHADER_TCS,       TEX_CONST },
-               [0x1][2] = { SHADER_TCS,       UBO },
+               [0x1][0] = { MESA_SHADER_TESS_CTRL, TEX_SAMP },
+               [0x1][1] = { MESA_SHADER_TESS_CTRL, TEX_CONST },
+               [0x1][2] = { MESA_SHADER_TESS_CTRL, UBO },
                // SB4_DS_TEX:
-               [0x2][0] = { SHADER_TES,       TEX_SAMP },
-               [0x2][1] = { SHADER_TES,       TEX_CONST },
-               [0x2][2] = { SHADER_TES,       UBO },
+               [0x2][0] = { MESA_SHADER_TESS_EVAL, TEX_SAMP },
+               [0x2][1] = { MESA_SHADER_TESS_EVAL, TEX_CONST },
+               [0x2][2] = { MESA_SHADER_TESS_EVAL, UBO },
                // SB4_GS_TEX:
-               [0x3][0] = { SHADER_GEOM,      TEX_SAMP },
-               [0x3][1] = { SHADER_GEOM,      TEX_CONST },
-               [0x3][2] = { SHADER_GEOM,      UBO },
+               [0x3][0] = { MESA_SHADER_GEOMETRY,  TEX_SAMP },
+               [0x3][1] = { MESA_SHADER_GEOMETRY,  TEX_CONST },
+               [0x3][2] = { MESA_SHADER_GEOMETRY,  UBO },
                // SB4_FS_TEX:
-               [0x4][0] = { SHADER_FRAGMENT,  TEX_SAMP },
-               [0x4][1] = { SHADER_FRAGMENT,  TEX_CONST },
-               [0x4][2] = { SHADER_FRAGMENT,  UBO },
+               [0x4][0] = { MESA_SHADER_FRAGMENT,  TEX_SAMP },
+               [0x4][1] = { MESA_SHADER_FRAGMENT,  TEX_CONST },
+               [0x4][2] = { MESA_SHADER_FRAGMENT,  UBO },
                // SB4_CS_TEX:
-               [0x5][0] = { SHADER_COMPUTE,   TEX_SAMP },
-               [0x5][1] = { SHADER_COMPUTE,   TEX_CONST },
-               [0x5][2] = { SHADER_COMPUTE,   UBO },
+               [0x5][0] = { MESA_SHADER_COMPUTE,   TEX_SAMP },
+               [0x5][1] = { MESA_SHADER_COMPUTE,   TEX_CONST },
+               [0x5][2] = { MESA_SHADER_COMPUTE,   UBO },
                // SB4_VS_SHADER:
-               [0x8][0] = { SHADER_VERTEX,    SHADER_PROG },
-               [0x8][1] = { SHADER_VERTEX,    SHADER_CONST },
-               [0x8][2] = { SHADER_VERTEX,    UBO },
+               [0x8][0] = { MESA_SHADER_VERTEX,    SHADER_PROG },
+               [0x8][1] = { MESA_SHADER_VERTEX,    SHADER_CONST },
+               [0x8][2] = { MESA_SHADER_VERTEX,    UBO },
                // SB4_HS_SHADER
-               [0x9][0] = { SHADER_TCS,       SHADER_PROG },
-               [0x9][1] = { SHADER_TCS,       SHADER_CONST },
-               [0x9][2] = { SHADER_TCS,       UBO },
+               [0x9][0] = { MESA_SHADER_TESS_CTRL, SHADER_PROG },
+               [0x9][1] = { MESA_SHADER_TESS_CTRL, SHADER_CONST },
+               [0x9][2] = { MESA_SHADER_TESS_CTRL, UBO },
                // SB4_DS_SHADER
-               [0xa][0] = { SHADER_TES,       SHADER_PROG },
-               [0xa][1] = { SHADER_TES,       SHADER_CONST },
-               [0xa][2] = { SHADER_TES,       UBO },
+               [0xa][0] = { MESA_SHADER_TESS_EVAL, SHADER_PROG },
+               [0xa][1] = { MESA_SHADER_TESS_EVAL, SHADER_CONST },
+               [0xa][2] = { MESA_SHADER_TESS_EVAL, UBO },
                // SB4_GS_SHADER
-               [0xb][0] = { SHADER_GEOM,      SHADER_PROG },
-               [0xb][1] = { SHADER_GEOM,      SHADER_CONST },
-               [0xb][2] = { SHADER_GEOM,      UBO },
+               [0xb][0] = { MESA_SHADER_GEOMETRY,  SHADER_PROG },
+               [0xb][1] = { MESA_SHADER_GEOMETRY,  SHADER_CONST },
+               [0xb][2] = { MESA_SHADER_GEOMETRY,  UBO },
                // SB4_FS_SHADER:
-               [0xc][0] = { SHADER_FRAGMENT,  SHADER_PROG },
-               [0xc][1] = { SHADER_FRAGMENT,  SHADER_CONST },
-               [0xc][2] = { SHADER_FRAGMENT,  UBO },
+               [0xc][0] = { MESA_SHADER_FRAGMENT,  SHADER_PROG },
+               [0xc][1] = { MESA_SHADER_FRAGMENT,  SHADER_CONST },
+               [0xc][2] = { MESA_SHADER_FRAGMENT,  UBO },
                // SB4_CS_SHADER:
-               [0xd][0] = { SHADER_COMPUTE,   SHADER_PROG },
-               [0xd][1] = { SHADER_COMPUTE,   SHADER_CONST },
-               [0xd][2] = { SHADER_COMPUTE,   UBO },
-               [0xd][3] = { SHADER_COMPUTE,   SSBO_0 },      /* a6xx location */
+               [0xd][0] = { MESA_SHADER_COMPUTE,   SHADER_PROG },
+               [0xd][1] = { MESA_SHADER_COMPUTE,   SHADER_CONST },
+               [0xd][2] = { MESA_SHADER_COMPUTE,   UBO },
+               [0xd][3] = { MESA_SHADER_COMPUTE,   SSBO_0 },      /* a6xx location */
                // SB4_SSBO (shared across all stages)
                [0xe][0] = { 0, SSBO_0 },                     /* a5xx (and a4xx?) location */
                [0xe][1] = { 0, SSBO_1 },
                [0xe][2] = { 0, SSBO_2 },
                // SB4_CS_SSBO
-               [0xf][0] = { SHADER_COMPUTE, SSBO_0 },
-               [0xf][1] = { SHADER_COMPUTE, SSBO_1 },
-               [0xf][2] = { SHADER_COMPUTE, SSBO_2 },
+               [0xf][0] = { MESA_SHADER_COMPUTE, SSBO_0 },
+               [0xf][1] = { MESA_SHADER_COMPUTE, SSBO_1 },
+               [0xf][2] = { MESA_SHADER_COMPUTE, SSBO_2 },
                // unknown things
                /* This looks like combined UBO state for 3d stages (a5xx and
                 * before??  I think a6xx has UBO state per shader stage:
@@ -1310,7 +1310,7 @@ _get_state_type(unsigned state_block_id, unsigned state_type,
 }
 
 static void
-a4xx_get_state_type(uint32_t *dwords, enum shader_t *stage, enum state_t *state,
+a4xx_get_state_type(uint32_t *dwords, gl_shader_stage *stage, enum state_t *state,
                    enum state_src_t *src)
 {
        unsigned state_block_id = (dwords[0] >> 18) & 0xf;
@@ -1320,7 +1320,7 @@ a4xx_get_state_type(uint32_t *dwords, enum shader_t *stage, enum state_t *state,
 }
 
 static void
-a6xx_get_state_type(uint32_t *dwords, enum shader_t *stage, enum state_t *state,
+a6xx_get_state_type(uint32_t *dwords, gl_shader_stage *stage, enum state_t *state,
                    enum state_src_t *src)
 {
        unsigned state_block_id = (dwords[0] >> 18) & 0xf;
@@ -1406,7 +1406,7 @@ dump_tex_const(uint32_t *texconst, int num_unit, int level)
 static void
 cp_load_state(uint32_t *dwords, uint32_t sizedwords, int level)
 {
-       enum shader_t stage;
+       gl_shader_stage stage;
        enum state_t state;
        enum state_src_t src;
        uint32_t num_unit = (dwords[0] >> 22) & 0x1ff;
@@ -1437,7 +1437,9 @@ cp_load_state(uint32_t *dwords, uint32_t sizedwords, int level)
                break;
        case STATE_SRC_BINDLESS: {
                const unsigned base_reg =
-                       stage == SHADER_COMPUTE ? regbase("HLSQ_CS_BINDLESS_BASE[0]") : regbase("HLSQ_BINDLESS_BASE[0]");
+                       stage == MESA_SHADER_COMPUTE ?
+                               regbase("HLSQ_CS_BINDLESS_BASE[0]") :
+                               regbase("HLSQ_BINDLESS_BASE[0]");
 
                if (is_64b()) {
                        const unsigned reg = base_reg + (dwords[1] >> 28) * 2;
@@ -1478,13 +1480,13 @@ cp_load_state(uint32_t *dwords, uint32_t sizedwords, int level)
                 * note: num_unit seems to be # of instruction groups, where
                 * an instruction group has 4 64bit instructions.
                 */
-               if (stage == SHADER_VERTEX) {
+               if (stage == MESA_SHADER_VERTEX) {
                        ext = "vo3";
-               } else if (stage == SHADER_GEOM) {
+               } else if (stage == MESA_SHADER_GEOMETRY) {
                        ext = "go3";
-               } else if (stage == SHADER_COMPUTE) {
+               } else if (stage == MESA_SHADER_COMPUTE) {
                        ext = "co3";
-               } else if (stage == SHADER_FRAGMENT){
+               } else if (stage == MESA_SHADER_FRAGMENT){
                        ext = "fo3";
                }
 
index 622d00479a8e1cc71e791431192464d8da841d83..80b8a00d3486c9a28b830b6e1d6defcc814e8e28 100644 (file)
@@ -96,17 +96,17 @@ static void print_dstreg(uint32_t num, uint32_t mask, uint32_t dst_exp)
        }
 }
 
-static void print_export_comment(uint32_t num, enum shader_t type)
+static void print_export_comment(uint32_t num, gl_shader_stage type)
 {
        const char *name = NULL;
        switch (type) {
-       case SHADER_VERTEX:
+       case MESA_SHADER_VERTEX:
                switch (num) {
                case 62: name = "gl_Position";  break;
                case 63: name = "gl_PointSize"; break;
                }
                break;
-       case SHADER_FRAGMENT:
+       case MESA_SHADER_FRAGMENT:
                switch (num) {
                case 0:  name = "gl_FragColor"; break;
                }
@@ -212,7 +212,7 @@ struct {
 };
 
 static int disasm_alu(uint32_t *dwords, uint32_t alu_off,
-               int level, int sync, enum shader_t type)
+               int level, int sync, gl_shader_stage type)
 {
        instr_alu_t *alu = (instr_alu_t *)dwords;
 
@@ -577,7 +577,7 @@ static void print_cf(instr_cf_t *cf, int level)
  *   2) ALU and FETCH instructions
  */
 
-int disasm_a2xx(uint32_t *dwords, int sizedwords, int level, enum shader_t type)
+int disasm_a2xx(uint32_t *dwords, int sizedwords, int level, gl_shader_stage type)
 {
        instr_cf_t *cfs = (instr_cf_t *)dwords;
        int idx, max_idx;
index 21ae5a11cd2c4154be916106f6a381d08d3388c1..de89ab49e907f24ce265dafd2222fde802e9a89f 100644 (file)
 
 #include <stdio.h>
 
-enum shader_t {
-       SHADER_VERTEX,
-       SHADER_TCS,
-       SHADER_TES,
-       SHADER_GEOM,
-       SHADER_FRAGMENT,
-       SHADER_COMPUTE,
-};
+#include "compiler/shader_enums.h"
 
 /* bitmask of debug flags */
 enum debug_t {
@@ -50,7 +43,7 @@ struct shader_stats {
        int constlen;
 };
 
-int disasm_a2xx(uint32_t *dwords, int sizedwords, int level, enum shader_t type);
+int disasm_a2xx(uint32_t *dwords, int sizedwords, int level, gl_shader_stage type);
 int disasm_a3xx(uint32_t *dwords, int sizedwords, int level, FILE *out, unsigned gpu_id);
 int disasm_a3xx_stat(uint32_t *dwords, int sizedwords, int level, FILE *out,
                unsigned gpu_id, struct shader_stats *stats);
index 0ec9995aa744024cf81c27ed7cf3a569575e524d..74b3fd690d6e2c0b1532ad2af6aed25ba36b2ea3 100644 (file)
@@ -49,6 +49,8 @@ libfreedreno_cffdec = static_library(
   ],
   include_directories: [
     inc_freedreno_rnn,
+    inc_include,
+    inc_src,
   ],
   c_args : [ no_override_init_args ],
   gnu_symbol_visibility: 'hidden',
@@ -84,6 +86,8 @@ if dep_lua.found() and dep_libarchive.found()
     ],
     include_directories: [
       inc_freedreno_rnn,
+      inc_include,
+      inc_src,
     ],
     c_args : [no_override_init_args],
     gnu_symbol_visibility: 'hidden',
@@ -104,6 +108,8 @@ crashdec = executable(
   'crashdec.c',
   include_directories: [
     inc_freedreno_rnn,
+    inc_include,
+    inc_src,
   ],
   gnu_symbol_visibility: 'hidden',
   dependencies: [],
@@ -118,7 +124,10 @@ if dep_libarchive.found()
   pgmdump = executable(
     'pgmdump',
     'pgmdump.c',
-    include_directories: [],
+    include_directories: [
+      inc_include,
+      inc_src,
+    ],
     gnu_symbol_visibility: 'hidden',
     dependencies: [],
     link_with: [
@@ -131,7 +140,10 @@ if dep_libarchive.found()
   pgmdump2 = executable(
     'pgmdump2',
     'pgmdump2.c',
-    include_directories: [],
+    include_directories: [
+      inc_include,
+      inc_src,
+    ],
     gnu_symbol_visibility: 'hidden',
     dependencies: [],
     link_with: [
index b8d7cd3837a685910944012fddb0c176c867192e..ab5deae7335d15651d9eee2dfcd8ce33ee1acdcf 100644 (file)
@@ -444,7 +444,7 @@ static void dump_shaders_a2xx(struct state *state)
                } else {
                        dump_short_summary(state, vs_hdr->unknown1 - 1, constants);
                }
-               disasm_a2xx((uint32_t *)(ptr + 32), (sect_size - 32) / 4, level+1, SHADER_VERTEX);
+               disasm_a2xx((uint32_t *)(ptr + 32), (sect_size - 32) / 4, level+1, MESA_SHADER_VERTEX);
                dump_raw_shader((uint32_t *)(ptr + 32), (sect_size - 32) / 4, i, "vo");
                free(ptr);
 
@@ -495,7 +495,7 @@ static void dump_shaders_a2xx(struct state *state)
                } else {
                        dump_short_summary(state, fs_hdr->unknown1 - 1, constants);
                }
-               disasm_a2xx((uint32_t *)(ptr + 32), (sect_size - 32) / 4, level+1, SHADER_FRAGMENT);
+               disasm_a2xx((uint32_t *)(ptr + 32), (sect_size - 32) / 4, level+1, MESA_SHADER_FRAGMENT);
                dump_raw_shader((uint32_t *)(ptr + 32), (sect_size - 32) / 4, i, "fo");
                free(ptr);
 
@@ -585,7 +585,7 @@ printf("hdr_size=%d\n", hdr_size);
                        instrs_size -= 32;
                }
 
-               disasm_a3xx((uint32_t *)instrs, instrs_size / 4, level+1, SHADER_VERTEX, gpu_id);
+               disasm_a3xx((uint32_t *)instrs, instrs_size / 4, level+1, stdout, gpu_id);
                dump_raw_shader((uint32_t *)instrs, instrs_size / 4, i, "vo3");
                free(vs_hdr);
        }
@@ -980,12 +980,12 @@ int main(int argc, char **argv)
 
        /* figure out what sort of input we are dealing with: */
        if (!(check_extension(infile, ".rd") || check_extension(infile, ".rd.gz"))) {
-               enum shader_t shader = ~0;
+               gl_shader_stage shader = ~0;
                int ret;
                if (check_extension(infile, ".vo")) {
-                       shader = SHADER_VERTEX;
+                       shader = MESA_SHADER_VERTEX;
                } else if (check_extension(infile, ".fo")) {
-                       shader = SHADER_FRAGMENT;
+                       shader = MESA_SHADER_FRAGMENT;
                } else if (check_extension(infile, ".vo3")) {
                } else if (check_extension(infile, ".fo3")) {
                } else if (check_extension(infile, ".co3")) {