17ec681f3Smrg/* 27ec681f3Smrg * Copyright (C) 2018-2019 Lima Project 37ec681f3Smrg * 47ec681f3Smrg * Permission is hereby granted, free of charge, to any person obtaining a 57ec681f3Smrg * copy of this software and associated documentation files (the "Software"), 67ec681f3Smrg * to deal in the Software without restriction, including without limitation 77ec681f3Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 87ec681f3Smrg * and/or sell copies of the Software, and to permit persons to whom the 97ec681f3Smrg * Software is furnished to do so, subject to the following conditions: 107ec681f3Smrg * 117ec681f3Smrg * The above copyright notice and this permission notice shall be included in 127ec681f3Smrg * all copies or substantial portions of the Software. 137ec681f3Smrg * 147ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 157ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 167ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 177ec681f3Smrg * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 187ec681f3Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 197ec681f3Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 207ec681f3Smrg * OTHER DEALINGS IN THE SOFTWARE. 217ec681f3Smrg * 227ec681f3Smrg */ 237ec681f3Smrg 247ec681f3Smrg#ifndef H_LIMA_PARSER 257ec681f3Smrg#define H_LIMA_PARSER 267ec681f3Smrg 277ec681f3Smrgstatic const char *PIPE_COMPARE_FUNC_STRING[] = { 287ec681f3Smrg "NEVER", /* 0 */ 297ec681f3Smrg "LESS", /* 1 */ 307ec681f3Smrg "EQUAL", /* 2 */ 317ec681f3Smrg "LEQUAL", /* 3 */ 327ec681f3Smrg "GREATER", /* 4 */ 337ec681f3Smrg "NOTEQUAL", /* 5 */ 347ec681f3Smrg "GEQUAL", /* 6 */ 357ec681f3Smrg "ALWAYS", /* 7 */ 367ec681f3Smrg}; 377ec681f3Smrg 387ec681f3Smrgstatic const char *PIPE_STENCIL_OP_STRING[] = { 397ec681f3Smrg "KEEP", /* 0 */ 407ec681f3Smrg "REPLACE", /* 1 */ 417ec681f3Smrg "ZERO", /* 2 */ 427ec681f3Smrg "INVERT", /* 3 */ 437ec681f3Smrg "INCR_WRAP", /* 4 */ 447ec681f3Smrg "DECR_WRAP", /* 5 */ 457ec681f3Smrg "INCR", /* 6 */ 467ec681f3Smrg "DECR", /* 7 */ 477ec681f3Smrg}; 487ec681f3Smrg 497ec681f3Smrgstatic const char *PIPE_BLEND_FUNC_STRING[] = { 507ec681f3Smrg "SUBTRACT", /* 0 */ 517ec681f3Smrg "REV_SUBTRACT", /* 1 */ 527ec681f3Smrg "ADD", /* 2 */ 537ec681f3Smrg "UNKNOWN_3", /* 3 */ 547ec681f3Smrg "BLEND_MIN", /* 4 */ 557ec681f3Smrg "BLEND_MAX", /* 5 */ 567ec681f3Smrg}; 577ec681f3Smrg 587ec681f3Smrgstatic const char *PIPE_BLENDFACTOR_STRING[] = { 597ec681f3Smrg "SRC_COLOR", /* 0 */ 607ec681f3Smrg "DST_COLOR", /* 1 */ 617ec681f3Smrg "CONST_COLOR", /* 2 */ 627ec681f3Smrg "ZERO", /* 3 */ 637ec681f3Smrg "UNKNOWN_4", /* 4 */ 647ec681f3Smrg "UNKNOWN_5", /* 5 */ 657ec681f3Smrg "UNKNOWN_6", /* 6 */ 667ec681f3Smrg "SRC_ALPHA_SAT", /* 7 */ 677ec681f3Smrg "INV_SRC_COLOR", /* 8 */ 687ec681f3Smrg "INV_DST_COLOR", /* 9 */ 697ec681f3Smrg "INV_CONST_COLOR", /* 10 */ 707ec681f3Smrg "ONE", /* 11 */ 717ec681f3Smrg "UNKNOWN_12", /* 12 */ 727ec681f3Smrg "UNKNOWN_13", /* 13 */ 737ec681f3Smrg "UNKNOWN_14", /* 14 */ 747ec681f3Smrg "UNKNOWN_15", /* 15 */ 757ec681f3Smrg "SRC_ALPHA", /* 16 */ 767ec681f3Smrg "DST_ALPHA", /* 17 */ 777ec681f3Smrg "CONST_ALPHA", /* 18 */ 787ec681f3Smrg "UNKNOWN_19", /* 19 */ 797ec681f3Smrg "UNKNOWN_20", /* 20 */ 807ec681f3Smrg "UNKNOWN_21", /* 21 */ 817ec681f3Smrg "UNKNOWN_22", /* 22 */ 827ec681f3Smrg "UNKNOWN_23", /* 23 */ 837ec681f3Smrg "INV_SRC_ALPHA", /* 24 */ 847ec681f3Smrg "INV_DST_ALPHA", /* 25 */ 857ec681f3Smrg "INV_CONST_ALPHA", /* 26 */ 867ec681f3Smrg 877ec681f3Smrg}; 887ec681f3Smrg 897ec681f3Smrgstatic inline const char 907ec681f3Smrg*lima_get_compare_func_string(int func) { 917ec681f3Smrg if ((func >= 0) && (func <= 7)) 927ec681f3Smrg return PIPE_COMPARE_FUNC_STRING[func]; 937ec681f3Smrg else 947ec681f3Smrg return "UNKNOWN"; 957ec681f3Smrg} 967ec681f3Smrg 977ec681f3Smrgstatic inline const char 987ec681f3Smrg*lima_get_stencil_op_string(int func) { 997ec681f3Smrg if ((func >= 0) && (func <= 7)) 1007ec681f3Smrg return PIPE_STENCIL_OP_STRING[func]; 1017ec681f3Smrg else 1027ec681f3Smrg return "UNKNOWN"; 1037ec681f3Smrg} 1047ec681f3Smrg 1057ec681f3Smrgstatic inline const char 1067ec681f3Smrg*lima_get_blend_func_string(int func) { 1077ec681f3Smrg if ((func >= 0) && (func <= 5)) 1087ec681f3Smrg return PIPE_BLEND_FUNC_STRING[func]; 1097ec681f3Smrg else 1107ec681f3Smrg return "UNKNOWN"; 1117ec681f3Smrg} 1127ec681f3Smrg 1137ec681f3Smrgstatic inline const char 1147ec681f3Smrg*lima_get_blendfactor_string(int func) { 1157ec681f3Smrg if ((func >= 0) && (func <= 26)) 1167ec681f3Smrg return PIPE_BLENDFACTOR_STRING[func]; 1177ec681f3Smrg else 1187ec681f3Smrg return "UNKNOWN"; 1197ec681f3Smrg} 1207ec681f3Smrg 1217ec681f3Smrgvoid lima_parse_shader(FILE *fp, uint32_t *data, int size, bool is_frag); 1227ec681f3Smrgvoid lima_parse_vs(FILE *fp, uint32_t *data, int size, uint32_t start); 1237ec681f3Smrgvoid lima_parse_plbu(FILE *fp, uint32_t *data, int size, uint32_t start); 1247ec681f3Smrgvoid lima_parse_render_state(FILE *fp, uint32_t *data, int size, uint32_t start); 1257ec681f3Smrgvoid lima_parse_texture_descriptor(FILE *fp, uint32_t *data, int size, uint32_t start, uint32_t offset); 1267ec681f3Smrg 1277ec681f3Smrg#endif 128