summaryrefslogtreecommitdiff
path: root/lib/mesa/src/gallium/drivers/lima/lima_parser.h
blob: eed7926fb5ec51b93ca282f7c572b99737f7f094 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
 * Copyright (C) 2018-2019 Lima Project
 *
 * 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 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 COPYRIGHT HOLDER(S) OR AUTHOR(S) 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 H_LIMA_PARSER
#define H_LIMA_PARSER

static const char *PIPE_COMPARE_FUNC_STRING[] = {
   "NEVER",    /* 0 */
   "LESS",     /* 1 */
   "EQUAL",    /* 2 */
   "LEQUAL",   /* 3 */
   "GREATER",  /* 4 */
   "NOTEQUAL", /* 5 */
   "GEQUAL",   /* 6 */
   "ALWAYS",   /* 7 */
};

static const char *PIPE_STENCIL_OP_STRING[] = {
   "KEEP",      /* 0 */
   "REPLACE",   /* 1 */
   "ZERO",      /* 2 */
   "INVERT",    /* 3 */
   "INCR_WRAP", /* 4 */
   "DECR_WRAP", /* 5 */
   "INCR",      /* 6 */
   "DECR",      /* 7 */
};

static const char *PIPE_BLEND_FUNC_STRING[] = {
   "SUBTRACT",     /* 0 */
   "REV_SUBTRACT", /* 1 */
   "ADD",          /* 2 */
   "UNKNOWN_3",    /* 3 */
   "BLEND_MIN",    /* 4 */
   "BLEND_MAX",    /* 5 */
};

static const char *PIPE_BLENDFACTOR_STRING[] = {
   "SRC_COLOR",        /* 0 */
   "DST_COLOR",        /* 1 */
   "CONST_COLOR",      /* 2 */
   "ZERO",             /* 3 */
   "UNKNOWN_4",        /* 4 */
   "SRC2_COLOR",       /* 5 */
   "UNKNOWN_6",        /* 6 */
   "SRC_ALPHA_SAT",    /* 7 */
   "INV_SRC_COLOR",    /* 8 */
   "INV_DST_COLOR",    /* 9 */
   "INV_CONST_COLOR",  /* 10 */
   "ONE",              /* 11 */
   "UNKNOWN_12",       /* 12 */
   "INV_SRC2_COLOR",   /* 13 */
   "UNKNOWN_14",       /* 14 */
   "UNKNOWN_15",       /* 15 */
   "SRC_ALPHA",        /* 16 */
   "DST_ALPHA",        /* 17 */
   "CONST_ALPHA",      /* 18 */
   "UNKNOWN_19",       /* 19 */
   "UNKNOWN_20",       /* 20 */
   "SRC2_ALPHA",       /* 21 */
   "UNKNOWN_22",       /* 22 */
   "UNKNOWN_23",       /* 23 */
   "INV_SRC_ALPHA",    /* 24 */
   "INV_DST_ALPHA",    /* 25 */
   "INV_CONST_ALPHA",  /* 26 */
   "UNKNOWN_27",       /* 27 */
   "UNKNOWN_28",       /* 28 */
   "INV_SRC2_ALPHA",   /* 29 */
};

static const char *LIMA_WRAP_MODE_STRING[] = {
   "TEX_WRAP_REPEAT",                  /* 0 */
   "TEX_WRAP_CLAMP_TO_EDGE",           /* 1 */
   "TEX_WRAP_CLAMP",                   /* 2 */
   "TEX_WRAP_CLAMP_TO_BORDER",         /* 3 */
   "TEX_WRAP_MIRROR_REPEAT",           /* 4 */
   "TEX_WRAP_MIRROR_CLAMP_TO_EDGE",    /* 5 */
   "TEX_WRAP_MIRROR_CLAMP",            /* 6 */
   "TEX_WRAP_MIRROR_CLAMP_TO_BORDER",  /* 7 */
};

static inline const char
*lima_get_compare_func_string(int func) {
   if ((func >= 0) && (func <= 7))
      return PIPE_COMPARE_FUNC_STRING[func];
   else
      return "UNKNOWN";
}

static inline const char
*lima_get_stencil_op_string(int func) {
   if ((func >= 0) && (func <= 7))
      return PIPE_STENCIL_OP_STRING[func];
   else
      return "UNKNOWN";
}

static inline const char
*lima_get_blend_func_string(int func) {
   if ((func >= 0) && (func <= 5))
      return PIPE_BLEND_FUNC_STRING[func];
   else
      return "UNKNOWN";
}

static inline const char
*lima_get_blendfactor_string(int func) {
   if ((func >= 0) && (func <= 26))
      return PIPE_BLENDFACTOR_STRING[func];
   else
      return "UNKNOWN";
}

static inline const char
*lima_get_wrap_mode_string(int mode) {
   if ((mode >= 0) && (mode <= 7))
      return LIMA_WRAP_MODE_STRING[mode];
   else
      return "UNKNOWN";
}

void lima_parse_shader(FILE *fp, uint32_t *data, int size, bool is_frag);
void lima_parse_vs(FILE *fp, uint32_t *data, int size, uint32_t start);
void lima_parse_plbu(FILE *fp, uint32_t *data, int size, uint32_t start);
void lima_parse_render_state(FILE *fp, uint32_t *data, int size, uint32_t start);
void lima_parse_texture_descriptor(FILE *fp, uint32_t *data, int size, uint32_t start, uint32_t offset);

#endif