1/* 2 * Copyright (C) 2018-2019 Lima Project 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice shall be included in 12 * all copies or substantial portions of the Software. 13 * 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 * OTHER DEALINGS IN THE SOFTWARE. 21 * 22 */ 23 24#ifndef H_LIMA_PARSER 25#define H_LIMA_PARSER 26 27static const char *PIPE_COMPARE_FUNC_STRING[] = { 28 "NEVER", /* 0 */ 29 "LESS", /* 1 */ 30 "EQUAL", /* 2 */ 31 "LEQUAL", /* 3 */ 32 "GREATER", /* 4 */ 33 "NOTEQUAL", /* 5 */ 34 "GEQUAL", /* 6 */ 35 "ALWAYS", /* 7 */ 36}; 37 38static const char *PIPE_STENCIL_OP_STRING[] = { 39 "KEEP", /* 0 */ 40 "REPLACE", /* 1 */ 41 "ZERO", /* 2 */ 42 "INVERT", /* 3 */ 43 "INCR_WRAP", /* 4 */ 44 "DECR_WRAP", /* 5 */ 45 "INCR", /* 6 */ 46 "DECR", /* 7 */ 47}; 48 49static const char *PIPE_BLEND_FUNC_STRING[] = { 50 "SUBTRACT", /* 0 */ 51 "REV_SUBTRACT", /* 1 */ 52 "ADD", /* 2 */ 53 "UNKNOWN_3", /* 3 */ 54 "BLEND_MIN", /* 4 */ 55 "BLEND_MAX", /* 5 */ 56}; 57 58static const char *PIPE_BLENDFACTOR_STRING[] = { 59 "SRC_COLOR", /* 0 */ 60 "DST_COLOR", /* 1 */ 61 "CONST_COLOR", /* 2 */ 62 "ZERO", /* 3 */ 63 "UNKNOWN_4", /* 4 */ 64 "UNKNOWN_5", /* 5 */ 65 "UNKNOWN_6", /* 6 */ 66 "SRC_ALPHA_SAT", /* 7 */ 67 "INV_SRC_COLOR", /* 8 */ 68 "INV_DST_COLOR", /* 9 */ 69 "INV_CONST_COLOR", /* 10 */ 70 "ONE", /* 11 */ 71 "UNKNOWN_12", /* 12 */ 72 "UNKNOWN_13", /* 13 */ 73 "UNKNOWN_14", /* 14 */ 74 "UNKNOWN_15", /* 15 */ 75 "SRC_ALPHA", /* 16 */ 76 "DST_ALPHA", /* 17 */ 77 "CONST_ALPHA", /* 18 */ 78 "UNKNOWN_19", /* 19 */ 79 "UNKNOWN_20", /* 20 */ 80 "UNKNOWN_21", /* 21 */ 81 "UNKNOWN_22", /* 22 */ 82 "UNKNOWN_23", /* 23 */ 83 "INV_SRC_ALPHA", /* 24 */ 84 "INV_DST_ALPHA", /* 25 */ 85 "INV_CONST_ALPHA", /* 26 */ 86 87}; 88 89static inline const char 90*lima_get_compare_func_string(int func) { 91 if ((func >= 0) && (func <= 7)) 92 return PIPE_COMPARE_FUNC_STRING[func]; 93 else 94 return "UNKNOWN"; 95} 96 97static inline const char 98*lima_get_stencil_op_string(int func) { 99 if ((func >= 0) && (func <= 7)) 100 return PIPE_STENCIL_OP_STRING[func]; 101 else 102 return "UNKNOWN"; 103} 104 105static inline const char 106*lima_get_blend_func_string(int func) { 107 if ((func >= 0) && (func <= 5)) 108 return PIPE_BLEND_FUNC_STRING[func]; 109 else 110 return "UNKNOWN"; 111} 112 113static inline const char 114*lima_get_blendfactor_string(int func) { 115 if ((func >= 0) && (func <= 26)) 116 return PIPE_BLENDFACTOR_STRING[func]; 117 else 118 return "UNKNOWN"; 119} 120 121void lima_parse_shader(FILE *fp, uint32_t *data, int size, bool is_frag); 122void lima_parse_vs(FILE *fp, uint32_t *data, int size, uint32_t start); 123void lima_parse_plbu(FILE *fp, uint32_t *data, int size, uint32_t start); 124void lima_parse_render_state(FILE *fp, uint32_t *data, int size, uint32_t start); 125void lima_parse_texture_descriptor(FILE *fp, uint32_t *data, int size, uint32_t start, uint32_t offset); 126 127#endif 128