Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

demmt: determine object decoder only once per class

  • Loading branch information...
commit 117c1a3a8c4ecb7e7a5a0b86e643f220ec819663 1 parent 13e04c9
@mslusarz mslusarz authored
View
1  rnn/demmt.c
@@ -1220,7 +1220,6 @@ int main(int argc, char *argv[])
usage();
ib_supported = chipset >= 0x80 || chipset == 0x50;
- demmt_object_init_chipset(chipset);
if (!colors)
colors = &envy_null_colors;
View
294 rnn/demmt_objects.c
@@ -296,306 +296,30 @@ static void decode_nvc0_m2mf(int mthd, uint32_t data)
}
}
-#define END_OF_OBJS { 0, NULL }
-struct gpu_object
+static const struct gpu_object
{
uint32_t class_;
void (*fun)(int, uint32_t);
-};
-
-static const struct gpu_object no_objs[] = { END_OF_OBJS };
-
-static const struct gpu_object *nv04_objs = no_objs;
-static const struct gpu_object *nv05_objs = no_objs;
-static const struct gpu_object *nv10_objs = no_objs;
-static const struct gpu_object *nv15_objs = no_objs;
-static const struct gpu_object *nv1a_objs = no_objs;
-static const struct gpu_object *nv11_objs = no_objs;
-static const struct gpu_object *nv17_objs = no_objs;
-static const struct gpu_object *nv1f_objs = no_objs;
-static const struct gpu_object *nv18_objs = no_objs;
-static const struct gpu_object *nv20_objs = no_objs;
-static const struct gpu_object *nv2a_objs = no_objs;
-static const struct gpu_object *nv25_objs = no_objs;
-static const struct gpu_object *nv28_objs = no_objs;
-static const struct gpu_object *nv30_objs = no_objs;
-static const struct gpu_object *nv35_objs = no_objs;
-static const struct gpu_object *nv31_objs = no_objs;
-static const struct gpu_object *nv36_objs = no_objs;
-static const struct gpu_object *nv34_objs = no_objs;
-static const struct gpu_object *nv40_objs = no_objs;
-static const struct gpu_object *nv45_objs = no_objs;
-static const struct gpu_object *nv41_objs = no_objs;
-static const struct gpu_object *nv42_objs = no_objs;
-static const struct gpu_object *nv43_objs = no_objs;
-static const struct gpu_object *nv44_objs = no_objs;
-static const struct gpu_object *nv4a_objs = no_objs;
-static const struct gpu_object *nv47_objs = no_objs;
-static const struct gpu_object *nv49_objs = no_objs;
-static const struct gpu_object *nv4b_objs = no_objs;
-static const struct gpu_object *nv46_objs = no_objs;
-static const struct gpu_object *nv4e_objs = no_objs;
-static const struct gpu_object *nv4c_objs = no_objs;
-static const struct gpu_object *nv67_objs = no_objs;
-static const struct gpu_object *nv68_objs = no_objs;
-static const struct gpu_object *nv63_objs = no_objs;
-
-static const struct gpu_object nv50_objs[] =
+}
+objs[] =
{
{ 0x502d, decode_nv50_2d },
{ 0x5097, decode_nv50_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nv84_objs[] =
-{
- { 0x502d, decode_nv50_2d },
- { 0x8297, decode_nv50_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nv86_objs[] =
-{
- { 0x502d, decode_nv50_2d },
- { 0x8297, decode_nv50_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nv92_objs[] =
-{
- { 0x502d, decode_nv50_2d },
- { 0x8297, decode_nv50_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nv94_objs[] =
-{
- { 0x502d, decode_nv50_2d },
{ 0x8297, decode_nv50_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nv96_objs[] =
-{
- { 0x502d, decode_nv50_2d },
- { 0x8297, decode_nv50_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nv98_objs[] =
-{
- { 0x502d, decode_nv50_2d },
- { 0x8297, decode_nv50_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nva0_objs[] =
-{
- { 0x502d, decode_nv50_2d },
{ 0x8397, decode_nv50_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nvaa_objs[] =
-{
- { 0x502d, decode_nv50_2d },
- { 0x8397, decode_nv50_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nvac_objs[] =
-{
- { 0x502d, decode_nv50_2d },
- { 0x8397, decode_nv50_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nva3_objs[] =
-{
- { 0x502d, decode_nv50_2d },
- { 0x8597, decode_nv50_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nva5_objs[] =
-{
- { 0x502d, decode_nv50_2d },
- { 0x8597, decode_nv50_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nva8_objs[] =
-{
- { 0x502d, decode_nv50_2d },
{ 0x8597, decode_nv50_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nvaf_objs[] =
-{
- { 0x502d, decode_nv50_2d },
{ 0x8697, decode_nv50_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nvc0_objs[] =
-{
- { 0x9039, decode_nvc0_m2mf },
- { 0x9097, decode_nvc0_nvc1_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nvc4_objs[] =
-{
- { 0x9039, decode_nvc0_m2mf },
- { 0x9097, decode_nvc0_nvc1_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nvc3_objs[] =
-{
- { 0x9039, decode_nvc0_m2mf },
- { 0x9097, decode_nvc0_nvc1_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nvce_objs[] =
-{
{ 0x9039, decode_nvc0_m2mf },
{ 0x9097, decode_nvc0_nvc1_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nvcf_objs[] =
-{
- { 0x9039, decode_nvc0_m2mf },
- { 0x9097, decode_nvc0_nvc1_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nvc1_objs[] =
-{
- { 0x9039, decode_nvc0_m2mf },
{ 0x9197, decode_nvc0_nvc1_3d },
- { 0x9097, decode_nvc0_nvc1_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nvc8_objs[] =
-{
- { 0x9039, decode_nvc0_m2mf },
- { 0x9097, decode_nvc0_nvc1_3d },
- END_OF_OBJS
+ { 0, NULL}
};
-static const struct gpu_object nvd9_objs[] =
+void *demmt_get_decoder(uint32_t class_)
{
- { 0x9039, decode_nvc0_m2mf },
- { 0x9097, decode_nvc0_nvc1_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object nvd7_objs[] =
-{
- { 0x9039, decode_nvc0_m2mf },
- { 0x9097, decode_nvc0_nvc1_3d },
- END_OF_OBJS
-};
-
-static const struct gpu_object *nve4_objs = no_objs;
-static const struct gpu_object *nve7_objs = no_objs;
-static const struct gpu_object *nve6_objs = no_objs;
-static const struct gpu_object *nvea_objs = no_objs;
-static const struct gpu_object *nvf0_objs = no_objs;
-static const struct gpu_object *nvf1_objs = no_objs;
-static const struct gpu_object *nv108_objs = no_objs;
-static const struct gpu_object *nv117_objs = no_objs;
-
-static const struct gpu_object *objects;
-
-void demmt_object_init_chipset(int chipset)
-{
- if (chipset == 0x04) objects = nv04_objs;
- else if (chipset == 0x05) objects = nv05_objs;
- else if (chipset == 0x10) objects = nv10_objs;
- else if (chipset == 0x15) objects = nv15_objs;
- else if (chipset == 0x1a) objects = nv1a_objs;
- else if (chipset == 0x11) objects = nv11_objs;
- else if (chipset == 0x17) objects = nv17_objs;
- else if (chipset == 0x1f) objects = nv1f_objs;
- else if (chipset == 0x18) objects = nv18_objs;
- else if (chipset == 0x20) objects = nv20_objs;
- else if (chipset == 0x2a) objects = nv2a_objs;
- else if (chipset == 0x25) objects = nv25_objs;
- else if (chipset == 0x28) objects = nv28_objs;
- else if (chipset == 0x30) objects = nv30_objs;
- else if (chipset == 0x35) objects = nv35_objs;
- else if (chipset == 0x31) objects = nv31_objs;
- else if (chipset == 0x36) objects = nv36_objs;
- else if (chipset == 0x34) objects = nv34_objs;
- else if (chipset == 0x40) objects = nv40_objs;
- else if (chipset == 0x45) objects = nv45_objs;
- else if (chipset == 0x41) objects = nv41_objs;
- else if (chipset == 0x42) objects = nv42_objs;
- else if (chipset == 0x43) objects = nv43_objs;
- else if (chipset == 0x44) objects = nv44_objs;
- else if (chipset == 0x4a) objects = nv4a_objs;
- else if (chipset == 0x47) objects = nv47_objs;
- else if (chipset == 0x49) objects = nv49_objs;
- else if (chipset == 0x4b) objects = nv4b_objs;
- else if (chipset == 0x46) objects = nv46_objs;
- else if (chipset == 0x4e) objects = nv4e_objs;
- else if (chipset == 0x4c) objects = nv4c_objs;
- else if (chipset == 0x67) objects = nv67_objs;
- else if (chipset == 0x68) objects = nv68_objs;
- else if (chipset == 0x63) objects = nv63_objs;
- else if (chipset == 0x50) objects = nv50_objs;
- else if (chipset == 0x84) objects = nv84_objs;
- else if (chipset == 0x86) objects = nv86_objs;
- else if (chipset == 0x92) objects = nv92_objs;
- else if (chipset == 0x94) objects = nv94_objs;
- else if (chipset == 0x96) objects = nv96_objs;
- else if (chipset == 0x98) objects = nv98_objs;
- else if (chipset == 0xa0) objects = nva0_objs;
- else if (chipset == 0xaa) objects = nvaa_objs;
- else if (chipset == 0xac) objects = nvac_objs;
- else if (chipset == 0xa3) objects = nva3_objs;
- else if (chipset == 0xa5) objects = nva5_objs;
- else if (chipset == 0xa8) objects = nva8_objs;
- else if (chipset == 0xaf) objects = nvaf_objs;
- else if (chipset == 0xc0) objects = nvc0_objs;
- else if (chipset == 0xc4) objects = nvc4_objs;
- else if (chipset == 0xc3) objects = nvc3_objs;
- else if (chipset == 0xce) objects = nvce_objs;
- else if (chipset == 0xcf) objects = nvcf_objs;
- else if (chipset == 0xc1) objects = nvc1_objs;
- else if (chipset == 0xc8) objects = nvc8_objs;
- else if (chipset == 0xd9) objects = nvd9_objs;
- else if (chipset == 0xd7) objects = nvd7_objs;
- else if (chipset == 0xe4) objects = nve4_objs;
- else if (chipset == 0xe7) objects = nve7_objs;
- else if (chipset == 0xe6) objects = nve6_objs;
- else if (chipset == 0xea) objects = nvea_objs;
- else if (chipset == 0xf0) objects = nvf0_objs;
- else if (chipset == 0xf1) objects = nvf1_objs;
- else if (chipset == 0x108) objects = nv108_objs;
- else if (chipset == 0x117) objects = nv117_objs;
- else
- mmt_log("object code does not know anything about chipset nv%x\n", chipset);
-}
-
-void demmt_parse_command(uint32_t class_, int mthd, uint32_t data)
-{
- if (!disassemble_shaders)
- return;
-
- const struct gpu_object *o = objects;
- for (o = objects; o->class_ != 0; o++)
- {
+ const struct gpu_object *o;
+ for (o = objs; o->class_ != 0; o++)
if (o->class_ == class_)
- {
- o->fun(mthd, data);
- return;
- }
- }
+ return o->fun;
+ return NULL;
}
View
3  rnn/demmt_objects.h
@@ -3,7 +3,6 @@
#include <stdint.h>
-void demmt_parse_command(uint32_t class_, int curaddr, uint32_t cmd);
-void demmt_object_init_chipset(int chipset);
+void *demmt_get_decoder(uint32_t class_);
#endif
View
11 rnn/demmt_pushbuf.c
@@ -44,6 +44,7 @@ struct obj
uint32_t class;
char *name;
struct rnndeccontext *ctx;
+ void (*decoder)(int, uint32_t);
};
static struct obj *subchans[8] = { NULL };
@@ -73,6 +74,7 @@ void pushbuf_add_object(uint32_t handle, uint32_t class)
obj->class = class;
obj->ctx = rnndec_newcontext(rnndb);
obj->ctx->colors = colors;
+ obj->decoder = demmt_get_decoder(class);
v = NULL;
FINDARRAY(chs->vals, v, v->value == chipset);
@@ -406,9 +408,12 @@ static uint64_t pushbuf_print(struct pushbuf_decode_state *pstate, struct buffer
}
fprintf(stdout, "PB: 0x%08x %s\n", cmd, cmdoutput);
- struct obj *obj = subchans[pstate->subchan];
- if (obj)
- demmt_parse_command(obj->class, mthd, cmd);
+ if (disassemble_shaders)
+ {
+ struct obj *obj = subchans[pstate->subchan];
+ if (obj && obj->decoder)
+ obj->decoder(mthd, cmd);
+ }
cur += 4;
}
Please sign in to comment.
Something went wrong with that request. Please try again.