17ec681f3Smrg/* 27ec681f3Smrg * Copyright (c) 2019 Andreas Baierl <ichgeh@imkreisrum.de> 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, sub license, 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 (including the 127ec681f3Smrg * next paragraph) shall be included in all copies or substantial portions 137ec681f3Smrg * of the Software. 147ec681f3Smrg * 157ec681f3Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 167ec681f3Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 177ec681f3Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 187ec681f3Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 197ec681f3Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 207ec681f3Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 217ec681f3Smrg * DEALINGS IN THE SOFTWARE. 227ec681f3Smrg * 237ec681f3Smrg */ 247ec681f3Smrg 257ec681f3Smrg#include "util/u_math.h" 267ec681f3Smrg 277ec681f3Smrg#include <stdio.h> 287ec681f3Smrg#include <stdint.h> 297ec681f3Smrg#include <string.h> 307ec681f3Smrg 317ec681f3Smrg#include "lima_context.h" 327ec681f3Smrg#include "lima_parser.h" 337ec681f3Smrg#include "lima_texture.h" 347ec681f3Smrg 357ec681f3Smrg#include "lima/ir/gp/codegen.h" 367ec681f3Smrg#include "lima/ir/pp/codegen.h" 377ec681f3Smrg 387ec681f3Smrgtypedef struct { 397ec681f3Smrg char *info; 407ec681f3Smrg} render_state_info; 417ec681f3Smrg 427ec681f3Smrgstatic render_state_info render_state_infos[] = { 437ec681f3Smrg { .info = "BLEND_COLOR_BG", }, 447ec681f3Smrg { .info = "BLEND_COLOR_RA", }, 457ec681f3Smrg { .info = "ALPHA_BLEND", }, 467ec681f3Smrg { .info = "DEPTH_TEST", }, 477ec681f3Smrg { .info = "DEPTH_RANGE", }, 487ec681f3Smrg { .info = "STENCIL_FRONT", }, 497ec681f3Smrg { .info = "STENCIL_BACK", }, 507ec681f3Smrg { .info = "STENCIL_TEST", }, 517ec681f3Smrg { .info = "MULTI_SAMPLE", }, 527ec681f3Smrg { .info = "SHADER_ADDRESS (FS)", }, 537ec681f3Smrg { .info = "VARYING_TYPES", }, 547ec681f3Smrg { .info = "UNIFORMS_ADDRESS (PP)", }, 557ec681f3Smrg { .info = "TEXTURES_ADDRESS", }, 567ec681f3Smrg { .info = "AUX0", }, 577ec681f3Smrg { .info = "AUX1", }, 587ec681f3Smrg { .info = "VARYINGS_ADDRESS", }, 597ec681f3Smrg}; 607ec681f3Smrg 617ec681f3Smrg/* VS CMD stream parser functions */ 627ec681f3Smrg 637ec681f3Smrgstatic void 647ec681f3Smrgparse_vs_draw(FILE *fp, uint32_t *value1, uint32_t *value2) 657ec681f3Smrg{ 667ec681f3Smrg if ((*value1 == 0x00000000) && (*value2 == 0x00000000)) 677ec681f3Smrg fprintf(fp, "\t/* ---EMPTY CMD */\n"); 687ec681f3Smrg else 697ec681f3Smrg fprintf(fp, "\t/* DRAW: num: %d, index_draw: %s */\n", 707ec681f3Smrg (*value1 & 0xff000000) >> 24 | (*value2 & 0x000000ff) << 8, 717ec681f3Smrg (*value1 & 0x00000001) ? "true" : "false"); 727ec681f3Smrg} 737ec681f3Smrg 747ec681f3Smrgstatic void 757ec681f3Smrgparse_vs_shader_info(FILE *fp, uint32_t *value1, uint32_t *value2) 767ec681f3Smrg{ 777ec681f3Smrg fprintf(fp, "\t/* SHADER_INFO: prefetch: %d, size: %d */\n", 787ec681f3Smrg (*value1 & 0xfff00000) >> 20, 797ec681f3Smrg (((*value1 & 0x000fffff) >> 10) + 1) << 4); 807ec681f3Smrg} 817ec681f3Smrg 827ec681f3Smrgstatic void 837ec681f3Smrgparse_vs_unknown1(FILE *fp, uint32_t *value1, uint32_t *value2) 847ec681f3Smrg{ 857ec681f3Smrg fprintf(fp, "\t/* UNKNOWN_1 */\n"); 867ec681f3Smrg} 877ec681f3Smrg 887ec681f3Smrgstatic void 897ec681f3Smrgparse_vs_varying_attribute_count(FILE *fp, uint32_t *value1, uint32_t *value2) 907ec681f3Smrg{ 917ec681f3Smrg fprintf(fp, "\t/* VARYING_ATTRIBUTE_COUNT: nr_vary: %d, nr_attr: %d */\n", 927ec681f3Smrg ((*value1 & 0x00ffffff) >> 8) + 1, (*value1 >> 24) + 1); 937ec681f3Smrg} 947ec681f3Smrg 957ec681f3Smrgstatic void 967ec681f3Smrgparse_vs_attributes_address(FILE *fp, uint32_t *value1, uint32_t *value2) 977ec681f3Smrg{ 987ec681f3Smrg fprintf(fp, "\t/* ATTRIBUTES_ADDRESS: address: 0x%08x, size: %d */\n", 997ec681f3Smrg *value1, (*value2 & 0x0fffffff) >> 17); 1007ec681f3Smrg} 1017ec681f3Smrg 1027ec681f3Smrgstatic void 1037ec681f3Smrgparse_vs_varyings_address(FILE *fp, uint32_t *value1, uint32_t *value2) 1047ec681f3Smrg{ 1057ec681f3Smrg fprintf(fp, "\t/* VARYINGS_ADDRESS: varying info @ 0x%08x, size: %d */\n", 1067ec681f3Smrg *value1, (*value2 & 0x0fffffff) >> 17); 1077ec681f3Smrg} 1087ec681f3Smrg 1097ec681f3Smrgstatic void 1107ec681f3Smrgparse_vs_uniforms_address(FILE *fp, uint32_t *value1, uint32_t *value2) 1117ec681f3Smrg{ 1127ec681f3Smrg fprintf(fp, "\t/* UNIFORMS_ADDRESS (GP): address: 0x%08x, size: %d */\n", 1137ec681f3Smrg *value1, (*value2 & 0x0fffffff) >> 12); 1147ec681f3Smrg} 1157ec681f3Smrg 1167ec681f3Smrgstatic void 1177ec681f3Smrgparse_vs_shader_address(FILE *fp, uint32_t *value1, uint32_t *value2) 1187ec681f3Smrg{ 1197ec681f3Smrg fprintf(fp, "\t/* SHADER_ADDRESS (VS): address: 0x%08x, size: %d */\n", 1207ec681f3Smrg *value1, (*value2 & 0x0fffffff) >> 12); 1217ec681f3Smrg} 1227ec681f3Smrg 1237ec681f3Smrgstatic void 1247ec681f3Smrgparse_vs_semaphore(FILE *fp, uint32_t *value1, uint32_t *value2) 1257ec681f3Smrg{ 1267ec681f3Smrg if (*value1 == 0x00028000) 1277ec681f3Smrg fprintf(fp, "\t/* SEMAPHORE_BEGIN_1 */\n"); 1287ec681f3Smrg else if (*value1 == 0x00000001) 1297ec681f3Smrg fprintf(fp, "\t/* SEMAPHORE_BEGIN_2 */\n"); 1307ec681f3Smrg else if (*value1 == 0x00000000) 1317ec681f3Smrg fprintf(fp, "\t/* SEMAPHORE_END: index_draw disabled */\n"); 1327ec681f3Smrg else if (*value1 == 0x00018000) 1337ec681f3Smrg fprintf(fp, "\t/* SEMAPHORE_END: index_draw enabled */\n"); 1347ec681f3Smrg else 1357ec681f3Smrg fprintf(fp, "\t/* SEMAPHORE - cmd unknown! */\n"); 1367ec681f3Smrg} 1377ec681f3Smrg 1387ec681f3Smrgstatic void 1397ec681f3Smrgparse_vs_unknown2(FILE *fp, uint32_t *value1, uint32_t *value2) 1407ec681f3Smrg{ 1417ec681f3Smrg fprintf(fp, "\t/* UNKNOWN_2 */\n"); 1427ec681f3Smrg} 1437ec681f3Smrg 1447ec681f3Smrgstatic void 1457ec681f3Smrgparse_vs_continue(FILE *fp, uint32_t *value1, uint32_t *value2) 1467ec681f3Smrg{ 1477ec681f3Smrg fprintf(fp, "\t/* CONTINUE: at 0x%08x */\n", *value1); 1487ec681f3Smrg} 1497ec681f3Smrg 1507ec681f3Smrgvoid 1517ec681f3Smrglima_parse_vs(FILE *fp, uint32_t *data, int size, uint32_t start) 1527ec681f3Smrg{ 1537ec681f3Smrg uint32_t *value1; 1547ec681f3Smrg uint32_t *value2; 1557ec681f3Smrg 1567ec681f3Smrg fprintf(fp, "\n"); 1577ec681f3Smrg fprintf(fp, "/* ============ VS CMD STREAM BEGIN ============= */\n"); 1587ec681f3Smrg for (int i = 0; i * 4 < size; i += 2) { 1597ec681f3Smrg value1 = &data[i]; 1607ec681f3Smrg value2 = &data[i + 1]; 1617ec681f3Smrg fprintf(fp, "/* 0x%08x (0x%08x) */\t0x%08x 0x%08x", 1627ec681f3Smrg start + i * 4, i * 4, *value1, *value2); 1637ec681f3Smrg 1647ec681f3Smrg if ((*value2 & 0xffff0000) == 0x00000000) 1657ec681f3Smrg parse_vs_draw(fp, value1, value2); 1667ec681f3Smrg else if ((*value2 & 0xff0000ff) == 0x10000040) 1677ec681f3Smrg parse_vs_shader_info(fp, value1, value2); 1687ec681f3Smrg else if ((*value2 & 0xff0000ff) == 0x10000041) 1697ec681f3Smrg parse_vs_unknown1(fp, value1, value2); 1707ec681f3Smrg else if ((*value2 & 0xff0000ff) == 0x10000042) 1717ec681f3Smrg parse_vs_varying_attribute_count(fp, value1, value2); 1727ec681f3Smrg else if ((*value2 & 0xff0000ff) == 0x20000000) 1737ec681f3Smrg parse_vs_attributes_address(fp, value1, value2); 1747ec681f3Smrg else if ((*value2 & 0xff0000ff) == 0x20000008) 1757ec681f3Smrg parse_vs_varyings_address(fp, value1, value2); 1767ec681f3Smrg else if ((*value2 & 0xff000000) == 0x30000000) 1777ec681f3Smrg parse_vs_uniforms_address(fp, value1, value2); 1787ec681f3Smrg else if ((*value2 & 0xff000000) == 0x40000000) 1797ec681f3Smrg parse_vs_shader_address(fp, value1, value2); 1807ec681f3Smrg else if ((*value2 & 0xff000000)== 0x50000000) 1817ec681f3Smrg parse_vs_semaphore(fp, value1, value2); 1827ec681f3Smrg else if ((*value2 & 0xff000000) == 0x60000000) 1837ec681f3Smrg parse_vs_unknown2(fp, value1, value2); 1847ec681f3Smrg else if ((*value2 & 0xff000000) == 0xf0000000) 1857ec681f3Smrg parse_vs_continue(fp, value1, value2); 1867ec681f3Smrg else 1877ec681f3Smrg fprintf(fp, "\t/* --- unknown cmd --- */\n"); 1887ec681f3Smrg } 1897ec681f3Smrg fprintf(fp, "/* ============ VS CMD STREAM END =============== */\n"); 1907ec681f3Smrg fprintf(fp, "\n"); 1917ec681f3Smrg} 1927ec681f3Smrg 1937ec681f3Smrg/* PLBU CMD stream parser functions */ 1947ec681f3Smrg 1957ec681f3Smrgstatic void 1967ec681f3Smrgparse_plbu_block_step(FILE *fp, uint32_t *value1, uint32_t *value2) 1977ec681f3Smrg{ 1987ec681f3Smrg fprintf(fp, "\t/* BLOCK_STEP: shift_min: %d, shift_h: %d, shift_w: %d */\n", 1997ec681f3Smrg (*value1 & 0xf0000000) >> 28, 2007ec681f3Smrg (*value1 & 0x0fff0000) >> 16, 2017ec681f3Smrg *value1 & 0x0000ffff); 2027ec681f3Smrg} 2037ec681f3Smrg 2047ec681f3Smrgstatic void 2057ec681f3Smrgparse_plbu_tiled_dimensions(FILE *fp, uint32_t *value1, uint32_t *value2) 2067ec681f3Smrg{ 2077ec681f3Smrg fprintf(fp, "\t/* TILED_DIMENSIONS: tiled_w: %d, tiled_h: %d */\n", 2087ec681f3Smrg ((*value1 & 0xff000000) >> 24) + 1, 2097ec681f3Smrg ((*value1 & 0x00ffff00) >> 8) + 1); 2107ec681f3Smrg} 2117ec681f3Smrg 2127ec681f3Smrgstatic void 2137ec681f3Smrgparse_plbu_block_stride(FILE *fp, uint32_t *value1, uint32_t *value2) 2147ec681f3Smrg{ 2157ec681f3Smrg fprintf(fp, "\t/* BLOCK_STRIDE: block_w: %d */\n", *value1 & 0x000000ff); 2167ec681f3Smrg} 2177ec681f3Smrg 2187ec681f3Smrgstatic void 2197ec681f3Smrgparse_plbu_array_address(FILE *fp, uint32_t *value1, uint32_t *value2) 2207ec681f3Smrg{ 2217ec681f3Smrg fprintf(fp, "\t/* ARRAY_ADDRESS: gp_stream: 0x%08x, block_num (block_w * block_h): %d */\n", 2227ec681f3Smrg *value1, (*value2 & 0x00ffffff) + 1); 2237ec681f3Smrg} 2247ec681f3Smrg 2257ec681f3Smrgstatic void 2267ec681f3Smrgparse_plbu_viewport_left(FILE *fp, float *value1, uint32_t *value2) 2277ec681f3Smrg{ 2287ec681f3Smrg fprintf(fp, "\t/* VIEWPORT_LEFT: viewport_left: %f */\n", *value1); 2297ec681f3Smrg} 2307ec681f3Smrg 2317ec681f3Smrgstatic void 2327ec681f3Smrgparse_plbu_viewport_right(FILE *fp, float *value1, uint32_t *value2) 2337ec681f3Smrg{ 2347ec681f3Smrg fprintf(fp, "\t/* VIEWPORT_RIGHT: viewport_right: %f */\n", *value1); 2357ec681f3Smrg} 2367ec681f3Smrg 2377ec681f3Smrgstatic void 2387ec681f3Smrgparse_plbu_viewport_bottom(FILE *fp, float *value1, uint32_t *value2) 2397ec681f3Smrg{ 2407ec681f3Smrg fprintf(fp, "\t/* VIEWPORT_BOTTOM: viewport_bottom: %f */\n", *value1); 2417ec681f3Smrg} 2427ec681f3Smrg 2437ec681f3Smrgstatic void 2447ec681f3Smrgparse_plbu_viewport_top(FILE *fp, float *value1, uint32_t *value2) 2457ec681f3Smrg{ 2467ec681f3Smrg fprintf(fp, "\t/* VIEWPORT_TOP: viewport_top: %f */\n", *value1); 2477ec681f3Smrg} 2487ec681f3Smrg 2497ec681f3Smrgstatic void 2507ec681f3Smrgparse_plbu_semaphore(FILE *fp, uint32_t *value1, uint32_t *value2) 2517ec681f3Smrg{ 2527ec681f3Smrg if (*value1 == 0x00010002) 2537ec681f3Smrg fprintf(fp, "\t/* ARRAYS_SEMAPHORE_BEGIN */\n"); 2547ec681f3Smrg else if (*value1 == 0x00010001) 2557ec681f3Smrg fprintf(fp, "\t/* ARRAYS_SEMAPHORE_END */\n"); 2567ec681f3Smrg else 2577ec681f3Smrg fprintf(fp, "\t/* SEMAPHORE - cmd unknown! */\n"); 2587ec681f3Smrg} 2597ec681f3Smrg 2607ec681f3Smrgstatic void 2617ec681f3Smrgparse_plbu_primitive_setup(FILE *fp, uint32_t *value1, uint32_t *value2) 2627ec681f3Smrg{ 2637ec681f3Smrg if (*value1 == 0x00000200) 2647ec681f3Smrg fprintf(fp, "\t/* UNKNOWN_2 (PRIMITIVE_SETUP INIT?) */\n"); 2657ec681f3Smrg else 2667ec681f3Smrg fprintf(fp, "\t/* PRIMITIVE_SETUP: %scull: %d (0x%x), index_size: %d */\n", 2677ec681f3Smrg (*value1 & 0x1000) ? "force point size, " : "", 2687ec681f3Smrg (*value1 & 0x000f0000) >> 16, (*value1 & 0x000f0000) >> 16, 2697ec681f3Smrg (*value1 & 0x00000e00) >> 9); 2707ec681f3Smrg} 2717ec681f3Smrg 2727ec681f3Smrgstatic void 2737ec681f3Smrgparse_plbu_rsw_vertex_array(FILE *fp, uint32_t *value1, uint32_t *value2) 2747ec681f3Smrg{ 2757ec681f3Smrg fprintf(fp, "\t/* RSW_VERTEX_ARRAY: rsw: 0x%08x, gl_pos: 0x%08x */\n", 2767ec681f3Smrg *value1, 2777ec681f3Smrg (*value2 & 0x0fffffff) << 4); 2787ec681f3Smrg} 2797ec681f3Smrg 2807ec681f3Smrgstatic void 2817ec681f3Smrgparse_plbu_scissors(FILE *fp, uint32_t *value1, uint32_t *value2) 2827ec681f3Smrg{ 2837ec681f3Smrg float minx = (*value1 & 0xc0000000) >> 30 | (*value2 & 0x00001fff) << 2; 2847ec681f3Smrg float maxx = ((*value2 & 0x0fffe000) >> 13) + 1; 2857ec681f3Smrg float miny = *value1 & 0x00003fff; 2867ec681f3Smrg float maxy = ((*value1 & 0x3fff8000) >> 15) + 1; 2877ec681f3Smrg 2887ec681f3Smrg fprintf(fp, "\t/* SCISSORS: minx: %f, maxx: %f, miny: %f, maxy: %f */\n", 2897ec681f3Smrg minx, maxx, miny, maxy); 2907ec681f3Smrg} 2917ec681f3Smrg 2927ec681f3Smrgstatic void 2937ec681f3Smrgparse_plbu_unknown_1(FILE *fp, uint32_t *value1, uint32_t *value2) 2947ec681f3Smrg{ 2957ec681f3Smrg fprintf(fp, "\t/* UNKNOWN_1 */\n"); 2967ec681f3Smrg} 2977ec681f3Smrg 2987ec681f3Smrgstatic void 2997ec681f3Smrgparse_plbu_low_prim_size(FILE *fp, float *value1, uint32_t *value2) 3007ec681f3Smrg{ 3017ec681f3Smrg fprintf(fp, "\t/* LOW_PRIM_SIZE: size: %f */\n", *value1); 3027ec681f3Smrg} 3037ec681f3Smrg 3047ec681f3Smrgstatic void 3057ec681f3Smrgparse_plbu_depth_range_near(FILE *fp, float *value1, uint32_t *value2) 3067ec681f3Smrg{ 3077ec681f3Smrg fprintf(fp, "\t/* DEPTH_RANG_NEAR: depth_range: %f */\n", *value1); 3087ec681f3Smrg} 3097ec681f3Smrg 3107ec681f3Smrgstatic void 3117ec681f3Smrgparse_plbu_depth_range_far(FILE *fp, float *value1, uint32_t *value2) 3127ec681f3Smrg{ 3137ec681f3Smrg fprintf(fp, "\t/* DEPTH_RANGE_FAR: depth_range: %f */\n", *value1); 3147ec681f3Smrg} 3157ec681f3Smrg 3167ec681f3Smrgstatic void 3177ec681f3Smrgparse_plbu_indexed_dest(FILE *fp, uint32_t *value1, uint32_t *value2) 3187ec681f3Smrg{ 3197ec681f3Smrg fprintf(fp, "\t/* INDEXED_DEST: gl_pos: 0x%08x */\n", *value1); 3207ec681f3Smrg} 3217ec681f3Smrg 3227ec681f3Smrgstatic void 3237ec681f3Smrgparse_plbu_indexed_pt_size(FILE *fp, uint32_t *value1, uint32_t *value2) 3247ec681f3Smrg{ 3257ec681f3Smrg fprintf(fp, "\t/* INDEXED_PT_SIZE: pt_size: 0x%08x */\n", *value1); 3267ec681f3Smrg} 3277ec681f3Smrg 3287ec681f3Smrgstatic void 3297ec681f3Smrgparse_plbu_indices(FILE *fp, uint32_t *value1, uint32_t *value2) 3307ec681f3Smrg{ 3317ec681f3Smrg fprintf(fp, "\t/* INDICES: indices: 0x%08x */\n", *value1); 3327ec681f3Smrg} 3337ec681f3Smrg 3347ec681f3Smrgstatic void 3357ec681f3Smrgparse_plbu_draw_arrays(FILE *fp, uint32_t *value1, uint32_t *value2) 3367ec681f3Smrg{ 3377ec681f3Smrg if ((*value1 == 0x00000000) && (*value2 == 0x00000000)) { 3387ec681f3Smrg fprintf(fp, "\t/* ---EMPTY CMD */\n"); 3397ec681f3Smrg return; 3407ec681f3Smrg } 3417ec681f3Smrg 3427ec681f3Smrg uint32_t count = (*value1 & 0xff000000) >> 24 | (*value2 & 0x000000ff) << 8; 3437ec681f3Smrg uint32_t start = *value1 & 0x00ffffff; 3447ec681f3Smrg uint32_t mode = (*value2 & 0x001f0000) >> 16; 3457ec681f3Smrg 3467ec681f3Smrg fprintf(fp, "\t/* DRAW_ARRAYS: count: %d, start: %d, mode: %d (0x%x) */\n", 3477ec681f3Smrg count, start, mode, mode); 3487ec681f3Smrg} 3497ec681f3Smrg 3507ec681f3Smrgstatic void 3517ec681f3Smrgparse_plbu_draw_elements(FILE *fp, uint32_t *value1, uint32_t *value2) 3527ec681f3Smrg{ 3537ec681f3Smrg uint32_t count = (*value1 & 0xff000000) >> 24 | (*value2 & 0x000000ff) << 8; 3547ec681f3Smrg uint32_t start = *value1 & 0x00ffffff; 3557ec681f3Smrg uint32_t mode = (*value2 & 0x001f0000) >> 16; 3567ec681f3Smrg 3577ec681f3Smrg fprintf(fp, "\t/* DRAW_ELEMENTS: count: %d, start: %d, mode: %d (0x%x) */\n", 3587ec681f3Smrg count, start, mode, mode); 3597ec681f3Smrg} 3607ec681f3Smrg 3617ec681f3Smrgstatic void 3627ec681f3Smrgparse_plbu_continue(FILE *fp, uint32_t *value1, uint32_t *value2) 3637ec681f3Smrg{ 3647ec681f3Smrg fprintf(fp, "\t/* CONTINUE: continue at 0x%08x */\n", *value1); 3657ec681f3Smrg} 3667ec681f3Smrg 3677ec681f3Smrgstatic void 3687ec681f3Smrgparse_plbu_end(FILE *fp, uint32_t *value1, uint32_t *value2) 3697ec681f3Smrg{ 3707ec681f3Smrg fprintf(fp, "\t/* END (FINISH/FLUSH) */\n"); 3717ec681f3Smrg} 3727ec681f3Smrg 3737ec681f3Smrgvoid 3747ec681f3Smrglima_parse_plbu(FILE *fp, uint32_t *data, int size, uint32_t start) 3757ec681f3Smrg{ 3767ec681f3Smrg uint32_t *value1; 3777ec681f3Smrg uint32_t *value2; 3787ec681f3Smrg 3797ec681f3Smrg fprintf(fp, "/* ============ PLBU CMD STREAM BEGIN ============= */\n"); 3807ec681f3Smrg for (int i = 0; i * 4 < size; i += 2) { 3817ec681f3Smrg value1 = &data[i]; 3827ec681f3Smrg value2 = &data[i + 1]; 3837ec681f3Smrg fprintf(fp, "/* 0x%08x (0x%08x) */\t0x%08x 0x%08x", 3847ec681f3Smrg start + i * 4, i * 4, *value1, *value2); 3857ec681f3Smrg 3867ec681f3Smrg if ((*value2 & 0xffe00000) == 0x00000000) 3877ec681f3Smrg parse_plbu_draw_arrays(fp, value1, value2); 3887ec681f3Smrg else if ((*value2 & 0xffe00000) == 0x00200000) 3897ec681f3Smrg parse_plbu_draw_elements(fp, value1, value2); 3907ec681f3Smrg else if ((*value2 & 0xff000fff) == 0x10000100) 3917ec681f3Smrg parse_plbu_indexed_dest(fp, value1, value2); 3927ec681f3Smrg else if ((*value2 & 0xff000fff) == 0x10000101) 3937ec681f3Smrg parse_plbu_indices(fp, value1, value2); 3947ec681f3Smrg else if ((*value2 & 0xff000fff) == 0x10000102) 3957ec681f3Smrg parse_plbu_indexed_pt_size(fp, value1, value2); 3967ec681f3Smrg else if ((*value2 & 0xff000fff) == 0x10000105) 3977ec681f3Smrg parse_plbu_viewport_bottom(fp, (float *)value1, value2); 3987ec681f3Smrg else if ((*value2 & 0xff000fff) == 0x10000106) 3997ec681f3Smrg parse_plbu_viewport_top(fp, (float *)value1, value2); 4007ec681f3Smrg else if ((*value2 & 0xff000fff) == 0x10000107) 4017ec681f3Smrg parse_plbu_viewport_left(fp, (float *)value1, value2); 4027ec681f3Smrg else if ((*value2 & 0xff000fff) == 0x10000108) 4037ec681f3Smrg parse_plbu_viewport_right(fp, (float *)value1, value2); 4047ec681f3Smrg else if ((*value2 & 0xff000fff) == 0x10000109) 4057ec681f3Smrg parse_plbu_tiled_dimensions(fp, value1, value2); 4067ec681f3Smrg else if ((*value2 & 0xff000fff) == 0x1000010a) 4077ec681f3Smrg parse_plbu_unknown_1(fp, value1, value2); 4087ec681f3Smrg else if ((*value2 & 0xff000fff) == 0x1000010b) /* also unknown_2 */ 4097ec681f3Smrg parse_plbu_primitive_setup(fp, value1, value2); 4107ec681f3Smrg else if ((*value2 & 0xff000fff) == 0x1000010c) 4117ec681f3Smrg parse_plbu_block_step(fp, value1, value2); 4127ec681f3Smrg else if ((*value2 & 0xff000fff) == 0x1000010d) 4137ec681f3Smrg parse_plbu_low_prim_size(fp, (float *)value1, value2); 4147ec681f3Smrg else if ((*value2 & 0xff000fff) == 0x1000010e) 4157ec681f3Smrg parse_plbu_depth_range_near(fp, (float *)value1, value2); 4167ec681f3Smrg else if ((*value2 & 0xff000fff) == 0x1000010f) 4177ec681f3Smrg parse_plbu_depth_range_far(fp, (float *)value1, value2); 4187ec681f3Smrg else if ((*value2 & 0xff000000) == 0x28000000) 4197ec681f3Smrg parse_plbu_array_address(fp, value1, value2); 4207ec681f3Smrg else if ((*value2 & 0xf0000000) == 0x30000000) 4217ec681f3Smrg parse_plbu_block_stride(fp, value1, value2); 4227ec681f3Smrg else if (*value2 == 0x50000000) 4237ec681f3Smrg parse_plbu_end(fp, value1, value2); 4247ec681f3Smrg else if ((*value2 & 0xf0000000)== 0x60000000) 4257ec681f3Smrg parse_plbu_semaphore(fp, value1, value2); 4267ec681f3Smrg else if ((*value2 & 0xf0000000)== 0x70000000) 4277ec681f3Smrg parse_plbu_scissors(fp, value1, value2); 4287ec681f3Smrg else if ((*value2 & 0xf0000000)== 0x80000000) 4297ec681f3Smrg parse_plbu_rsw_vertex_array(fp, value1, value2); 4307ec681f3Smrg else if ((*value2 & 0xf0000000)== 0xf0000000) 4317ec681f3Smrg parse_plbu_continue(fp, value1, value2); 4327ec681f3Smrg else 4337ec681f3Smrg fprintf(fp, "\t/* --- unknown cmd --- */\n"); 4347ec681f3Smrg } 4357ec681f3Smrg fprintf(fp, "/* ============ PLBU CMD STREAM END =============== */\n"); 4367ec681f3Smrg fprintf(fp, "\n"); 4377ec681f3Smrg} 4387ec681f3Smrg 4397ec681f3Smrgvoid 4407ec681f3Smrglima_parse_shader(FILE *fp, uint32_t *data, int size, bool is_frag) 4417ec681f3Smrg{ 4427ec681f3Smrg uint32_t *value = &data[0]; 4437ec681f3Smrg 4447ec681f3Smrg if (is_frag) { 4457ec681f3Smrg uint32_t *bin = value; 4467ec681f3Smrg uint32_t offt = 0; 4477ec681f3Smrg uint32_t next_instr_length = 0; 4487ec681f3Smrg 4497ec681f3Smrg fprintf(fp, "/* ============ FS DISASSEMBLY BEGIN ============== */\n"); 4507ec681f3Smrg 4517ec681f3Smrg do { 4527ec681f3Smrg ppir_codegen_ctrl *ctrl = (ppir_codegen_ctrl *)bin; 4537ec681f3Smrg fprintf(fp, "@%6d: ", offt); 4547ec681f3Smrg ppir_disassemble_instr(bin, offt, fp); 4557ec681f3Smrg bin += ctrl->count; 4567ec681f3Smrg offt += ctrl->count; 4577ec681f3Smrg next_instr_length = ctrl->next_count; 4587ec681f3Smrg } while (next_instr_length); 4597ec681f3Smrg 4607ec681f3Smrg fprintf(fp, "/* ============ FS DISASSEMBLY END ================= */\n"); 4617ec681f3Smrg } else { 4627ec681f3Smrg fprintf(fp, "/* ============ VS DISASSEMBLY BEGIN ============== */\n"); 4637ec681f3Smrg gpir_disassemble_program((gpir_codegen_instr *)value, size / sizeof(gpir_codegen_instr), fp); 4647ec681f3Smrg fprintf(fp, "/* ============ VS DISASSEMBLY END ================= */\n"); 4657ec681f3Smrg } 4667ec681f3Smrg} 4677ec681f3Smrg 4687ec681f3Smrgstatic void 4697ec681f3Smrgparse_rsw(FILE *fp, uint32_t *value, int i, uint32_t *helper) 4707ec681f3Smrg{ 4717ec681f3Smrg fprintf(fp, "\t/* %s", render_state_infos[i].info); 4727ec681f3Smrg 4737ec681f3Smrg switch (i) { 4747ec681f3Smrg case 0: /* BLEND COLOR BG */ 4757ec681f3Smrg fprintf(fp, ": blend_color.color[1] = %f, blend_color.color[2] = %f */\n", 4767ec681f3Smrg (float)(ubyte_to_float((*value & 0xffff0000) >> 16)), 4777ec681f3Smrg (float)(ubyte_to_float(*value & 0x0000ffff))); 4787ec681f3Smrg break; 4797ec681f3Smrg case 1: /* BLEND COLOR RA */ 4807ec681f3Smrg fprintf(fp, ": blend_color.color[3] = %f, blend_color.color[0] = %f */\n", 4817ec681f3Smrg (float)(ubyte_to_float((*value & 0xffff0000) >> 16)), 4827ec681f3Smrg (float)(ubyte_to_float(*value & 0x0000ffff))); 4837ec681f3Smrg break; 4847ec681f3Smrg case 2: /* ALPHA BLEND */ 4857ec681f3Smrg fprintf(fp, "(1): colormask 0x%02x, rgb_func %d (%s), alpha_func %d (%s) */\n", 4867ec681f3Smrg (*value & 0xf0000000) >> 28, /* colormask */ 4877ec681f3Smrg (*value & 0x00000007), 4887ec681f3Smrg lima_get_blend_func_string((*value & 0x00000007)), /* rgb_func */ 4897ec681f3Smrg (*value & 0x00000038) >> 3, 4907ec681f3Smrg lima_get_blend_func_string((*value & 0x00000038) >> 3)); /* alpha_func */ 4917ec681f3Smrg /* add a few tabs for alignment */ 4927ec681f3Smrg fprintf(fp, "\t\t\t\t\t\t/* %s(2)", render_state_infos[i].info); 4937ec681f3Smrg fprintf(fp, ": rgb_src_factor %d (%s), rbg_dst_factor %d (%s) */\n", 4947ec681f3Smrg (*value & 0x000007c0) >> 6, 4957ec681f3Smrg lima_get_blendfactor_string((*value & 0x000007c0) >> 6), /* rgb_src_factor */ 4967ec681f3Smrg (*value & 0x0000f800) >> 11, 4977ec681f3Smrg lima_get_blendfactor_string((*value & 0x0000f800) >> 11)); /* rgb_dst_factor */ 4987ec681f3Smrg fprintf(fp, "\t\t\t\t\t\t/* %s(3)", render_state_infos[i].info); 4997ec681f3Smrg fprintf(fp, ": alpha_src_factor %d (%s), alpha_dst_factor %d (%s), bits 24-27 0x%02x */\n", 5007ec681f3Smrg (*value & 0x000f0000) >> 16, 5017ec681f3Smrg lima_get_blendfactor_string((*value & 0x000f0000) >> 16), /* alpha_src_factor */ 5027ec681f3Smrg (*value & 0x00f00000) >> 20, 5037ec681f3Smrg lima_get_blendfactor_string((*value & 0x00f00000) >> 20), /* alpha_dst_factor */ 5047ec681f3Smrg (*value & 0x0f000000) >> 24); /* bits 24-27 */ 5057ec681f3Smrg break; 5067ec681f3Smrg case 3: /* DEPTH TEST */ 5077ec681f3Smrg if ((*value & 0x00000001) == 0x00000001) 5087ec681f3Smrg fprintf(fp, "(1): depth test enabled && writes allowed"); 5097ec681f3Smrg else 5107ec681f3Smrg fprintf(fp, "(1): depth test disabled || writes not allowed"); 5117ec681f3Smrg 5127ec681f3Smrg fprintf(fp, "\n\t\t\t\t\t\t/* %s(2)", render_state_infos[i].info); 5137ec681f3Smrg fprintf(fp, ": depth_func %d (%s)", ((*value & 0x0000000e) >> 1), 5147ec681f3Smrg lima_get_compare_func_string((*value & 0x0000000e) >> 1)); 5157ec681f3Smrg fprintf(fp, ", offset_scale: %d", (*value & 0x00ff0000) >> 16); 5167ec681f3Smrg fprintf(fp, ", offset_units: %d", (*value & 0xff000000) >> 24); 5177ec681f3Smrg if (*value & 0x400) 5187ec681f3Smrg fprintf(fp, ", shader writes depth or stencil"); 5197ec681f3Smrg if (*value & 0x800) 5207ec681f3Smrg fprintf(fp, ", shader writes depth"); 5217ec681f3Smrg if (*value & 0x1000) 5227ec681f3Smrg fprintf(fp, ", shader writes stencil"); 5237ec681f3Smrg fprintf(fp, " */\n\t\t\t\t\t\t/* %s(3)", render_state_infos[i].info); 5247ec681f3Smrg if ((*value & 0x00000010) == 0x00000010) 5257ec681f3Smrg fprintf(fp, ": ignore depth clip near"); 5267ec681f3Smrg if ((*value & 0x00000020) == 0x00000020) 5277ec681f3Smrg fprintf(fp, ", ignore depth clip far"); 5287ec681f3Smrg fprintf(fp, ", unknown bits 6-9: 0x%08x", *value & 0x000003c0); 5297ec681f3Smrg fprintf(fp, ", unknown bits 13-15: 0x%08x */\n", *value & 0x00000e000); 5307ec681f3Smrg break; 5317ec681f3Smrg case 4: /* DEPTH RANGE */ 5327ec681f3Smrg fprintf(fp, ": viewport.far = %f, viewport.near = %f */\n", 5337ec681f3Smrg (float)(ushort_to_float((*value & 0xffff0000) >> 16)), 5347ec681f3Smrg (float)(ushort_to_float(*value & 0x0000ffff))); 5357ec681f3Smrg break; 5367ec681f3Smrg case 5: /* STENCIL FRONT */ 5377ec681f3Smrg fprintf(fp, "(1): valuemask 0x%02x, ref value %d (0x%02x), stencil_func %d (%s)*/\n", 5387ec681f3Smrg (*value & 0xff000000) >> 24, /* valuemask */ 5397ec681f3Smrg (*value & 0x00ff0000) >> 16, (*value & 0x00ff0000) >> 16, /* ref value */ 5407ec681f3Smrg (*value & 0x00000007), 5417ec681f3Smrg lima_get_compare_func_string((*value & 0x00000007))); /* stencil_func */ 5427ec681f3Smrg /* add a few tabs for alignment */ 5437ec681f3Smrg fprintf(fp, "\t\t\t\t\t\t/* %s(2)", render_state_infos[i].info); 5447ec681f3Smrg fprintf(fp, ": fail_op %d (%s), zfail_op %d (%s), zpass_op %d (%s), unknown (12-15) 0x%02x */\n", 5457ec681f3Smrg (*value & 0x00000038) >> 3, 5467ec681f3Smrg lima_get_stencil_op_string((*value & 0x00000038) >> 3), /* fail_op */ 5477ec681f3Smrg (*value & 0x000001c0) >> 6, 5487ec681f3Smrg lima_get_stencil_op_string((*value & 0x000001c0) >> 6), /* zfail_op */ 5497ec681f3Smrg (*value & 0x00000e00) >> 9, 5507ec681f3Smrg lima_get_stencil_op_string((*value & 0x00000e00) >> 9), /* zpass_op */ 5517ec681f3Smrg (*value & 0x0000f000) >> 12); /* unknown */ 5527ec681f3Smrg break; 5537ec681f3Smrg case 6: /* STENCIL BACK */ 5547ec681f3Smrg fprintf(fp, "(1): valuemask 0x%02x, ref value %d (0x%02x), stencil_func %d (%s)*/\n", 5557ec681f3Smrg (*value & 0xff000000) >> 24, /* valuemask */ 5567ec681f3Smrg (*value & 0x00ff0000) >> 16, (*value & 0x00ff0000) >> 16, /* ref value */ 5577ec681f3Smrg (*value & 0x00000007), 5587ec681f3Smrg lima_get_compare_func_string((*value & 0x00000007))); /* stencil_func */ 5597ec681f3Smrg /* add a few tabs for alignment */ 5607ec681f3Smrg fprintf(fp, "\t\t\t\t\t\t/* %s(2)", render_state_infos[i].info); 5617ec681f3Smrg fprintf(fp, ": fail_op %d (%s), zfail_op %d (%s), zpass_op %d (%s), unknown (12-15) 0x%02x */\n", 5627ec681f3Smrg (*value & 0x00000038) >> 3, 5637ec681f3Smrg lima_get_stencil_op_string((*value & 0x00000038) >> 3), /* fail_op */ 5647ec681f3Smrg (*value & 0x000001c0) >> 6, 5657ec681f3Smrg lima_get_stencil_op_string((*value & 0x000001c0) >> 6), /* zfail_op */ 5667ec681f3Smrg (*value & 0x00000e00) >> 9, 5677ec681f3Smrg lima_get_stencil_op_string((*value & 0x00000e00) >> 9), /* zpass_op */ 5687ec681f3Smrg (*value & 0x0000f000) >> 12); /* unknown */ 5697ec681f3Smrg break; 5707ec681f3Smrg case 7: /* STENCIL TEST */ 5717ec681f3Smrg fprintf(fp, "(1): stencil_front writemask 0x%02x, stencil_back writemask 0x%02x */\n", 5727ec681f3Smrg (*value & 0x000000ff), /* front writemask */ 5737ec681f3Smrg (*value & 0x0000ff00) >> 8); /* back writemask */ 5747ec681f3Smrg /* add a few tabs for alignment */ 5757ec681f3Smrg fprintf(fp, "\t\t\t\t\t\t/* %s(2)", render_state_infos[i].info); 5767ec681f3Smrg fprintf(fp, ": alpha_ref_value: 0x%02x */\n", (*value & 0x00ff0000) >> 16); 5777ec681f3Smrg fprintf(fp, "\t\t\t\t\t\t/* %s(3)", render_state_infos[i].info); 5787ec681f3Smrg fprintf(fp, ": unknown (bits 24-31) 0x%02x */\n", 5797ec681f3Smrg (*value & 0xff000000) >> 24); /* unknown */ 5807ec681f3Smrg break; 5817ec681f3Smrg case 8: /* MULTI SAMPLE */ 5827ec681f3Smrg if ((*value & 0x00000f00) == 0x00000000) 5837ec681f3Smrg fprintf(fp, ": points"); 5847ec681f3Smrg else if ((*value & 0x00000f00) == 0x00000400) 5857ec681f3Smrg fprintf(fp, ": lines"); 5867ec681f3Smrg else if ((*value & 0x00000f00) == 0x00000800) 5877ec681f3Smrg fprintf(fp, ": triangles"); 5887ec681f3Smrg else 5897ec681f3Smrg fprintf(fp, ": unknown"); 5907ec681f3Smrg 5917ec681f3Smrg if ((*value & 0x00000078) == 0x00000068) 5927ec681f3Smrg fprintf(fp, ", fb_samples */\n"); 5937ec681f3Smrg else if ((*value & 0x00000078) == 0x00000000) 5947ec681f3Smrg fprintf(fp, " */\n"); 5957ec681f3Smrg else 5967ec681f3Smrg fprintf(fp, ", UNKNOWN\n"); 5977ec681f3Smrg fprintf(fp, "\t\t\t\t\t\t/* %s(2)", render_state_infos[i].info); 5987ec681f3Smrg fprintf(fp, ": alpha_test_func: %d (%s) */\n", 5997ec681f3Smrg (*value & 0x00000007), 6007ec681f3Smrg lima_get_compare_func_string((*value & 0x00000007))); /* alpha_test_func */ 6017ec681f3Smrg break; 6027ec681f3Smrg case 9: /* SHADER ADDRESS */ 6037ec681f3Smrg fprintf(fp, ": fs shader @ 0x%08x, first instr length %d */\n", 6047ec681f3Smrg *value & 0xffffffe0, *value & 0x0000001f); 6057ec681f3Smrg break; 6067ec681f3Smrg case 10: /* VARYING TYPES */ 6077ec681f3Smrg fprintf(fp, "(1): "); 6087ec681f3Smrg int val, j; 6097ec681f3Smrg /* 0 - 5 */ 6107ec681f3Smrg for (j = 0; j < 6; j++) { 6117ec681f3Smrg val = (*value >> (j * 3)) & 0x07; 6127ec681f3Smrg fprintf(fp, "val %d-%d, ", j, val); 6137ec681f3Smrg } 6147ec681f3Smrg /* 6 - 9 */ 6157ec681f3Smrg /* add a few tabs for alignment */ 6167ec681f3Smrg fprintf(fp, "\n\t\t\t\t\t\t/* %s(2): ", render_state_infos[i].info); 6177ec681f3Smrg for (j = 6; j < 10; j++) { 6187ec681f3Smrg val = (*value >> (j * 3)) & 0x07; 6197ec681f3Smrg fprintf(fp, "val %d-%d, ", j, val); 6207ec681f3Smrg } 6217ec681f3Smrg /* 10 */ 6227ec681f3Smrg val = ((*value & 0xc0000000) >> 30) | ((*helper & 0x00000001) << 2); 6237ec681f3Smrg fprintf(fp, "val %d-%d, ", j, val); 6247ec681f3Smrg j++; 6257ec681f3Smrg /* 11 */ 6267ec681f3Smrg val = (*helper & 0x0000000e) >> 1; 6277ec681f3Smrg fprintf(fp, "val %d-%d */\n", j, val); 6287ec681f3Smrg break; 6297ec681f3Smrg case 11: /* UNIFORMS ADDRESS */ 6307ec681f3Smrg fprintf(fp, ": pp uniform info @ 0x%08x, bits: 0x%01x */\n", 6317ec681f3Smrg *value & 0xfffffff0, *value & 0x0000000f); 6327ec681f3Smrg break; 6337ec681f3Smrg case 12: /* TEXTURES ADDRESS */ 6347ec681f3Smrg fprintf(fp, ": address: 0x%08x */\n", *value); 6357ec681f3Smrg break; 6367ec681f3Smrg case 13: /* AUX0 */ 6377ec681f3Smrg fprintf(fp, "(1): varying_stride: %d", /* bits 0 - 4 varying stride, 8 aligned */ 6387ec681f3Smrg (*value & 0x0000001f) << 3); 6397ec681f3Smrg if ((*value & 0x00000020) == 0x00000020) /* bit 5 has num_samplers */ 6407ec681f3Smrg fprintf(fp, ", num_samplers %d", 6417ec681f3Smrg (*value & 0xffffc000) >> 14); /* bits 14 - 31 num_samplers */ 6427ec681f3Smrg 6437ec681f3Smrg if ((*value & 0x00000080) == 0x00000080) /* bit 7 has_fs_uniforms */ 6447ec681f3Smrg fprintf(fp, ", has_fs_uniforms */"); 6457ec681f3Smrg else 6467ec681f3Smrg fprintf(fp, " */"); 6477ec681f3Smrg 6487ec681f3Smrg fprintf(fp, "\n\t\t\t\t\t\t/* %s(2):", render_state_infos[i].info); 6497ec681f3Smrg if ((*value & 0x00000200) == 0x00000200) /* bit 9 early-z */ 6507ec681f3Smrg fprintf(fp, " early-z enabled"); 6517ec681f3Smrg else 6527ec681f3Smrg fprintf(fp, " early-z disabled"); 6537ec681f3Smrg 6547ec681f3Smrg if ((*value & 0x00001000) == 0x00001000) /* bit 12 pixel-kill */ 6557ec681f3Smrg fprintf(fp, ", pixel kill enabled"); 6567ec681f3Smrg else 6577ec681f3Smrg fprintf(fp, ", pixel kill disabled"); 6587ec681f3Smrg 6597ec681f3Smrg if ((*value & 0x00000040) == 0x00000040) /* bit 6 unknown */ 6607ec681f3Smrg fprintf(fp, ", bit 6 set"); 6617ec681f3Smrg 6627ec681f3Smrg if ((*value & 0x00000100) == 0x00000100) /* bit 8 unknown */ 6637ec681f3Smrg fprintf(fp, ", bit 8 set"); 6647ec681f3Smrg 6657ec681f3Smrg if (((*value & 0x00000c00) >> 10) > 0) /* bit 10 - 11 unknown */ 6667ec681f3Smrg fprintf(fp, ", bit 10 - 11: %d", ((*value & 0x00000c00) >> 10)); 6677ec681f3Smrg 6687ec681f3Smrg if ((*value & 0x00002000) == 0x00002000) /* bit 13 unknown */ 6697ec681f3Smrg fprintf(fp, ", bit 13 set"); 6707ec681f3Smrg fprintf(fp, " */\n"); 6717ec681f3Smrg break; 6727ec681f3Smrg case 14: /* AUX1 */ 6737ec681f3Smrg fprintf(fp, ": "); 6747ec681f3Smrg if ((*value & 0x00002000) == 0x00002000) 6757ec681f3Smrg fprintf(fp, "blend->base.dither true, "); 6767ec681f3Smrg 6777ec681f3Smrg if ((*value & 0x00001000) == 0x00001000) 6787ec681f3Smrg fprintf(fp, "glFrontFace(GL_CCW), "); 6797ec681f3Smrg else 6807ec681f3Smrg fprintf(fp, "glFrontFace(GL_CW), "); 6817ec681f3Smrg 6827ec681f3Smrg if ((*value & 0x00010000) == 0x00010000) 6837ec681f3Smrg fprintf(fp, "ctx->const_buffer[PIPE_SHADER_FRAGMENT].buffer true "); 6847ec681f3Smrg fprintf(fp, "*/\n"); 6857ec681f3Smrg break; 6867ec681f3Smrg case 15: /* VARYINGS ADDRESS */ 6877ec681f3Smrg fprintf(fp, ": varyings @ 0x%08x */\n", *value & 0xfffffff0); 6887ec681f3Smrg break; 6897ec681f3Smrg default: /* should never be executed! */ 6907ec681f3Smrg fprintf(fp, ": something went wrong!!! */\n"); 6917ec681f3Smrg break; 6927ec681f3Smrg } 6937ec681f3Smrg} 6947ec681f3Smrg 6957ec681f3Smrgvoid 6967ec681f3Smrglima_parse_render_state(FILE *fp, uint32_t *data, int size, uint32_t start) 6977ec681f3Smrg{ 6987ec681f3Smrg uint32_t *value; 6997ec681f3Smrg 7007ec681f3Smrg fprintf(fp, "/* ============ RSW BEGIN ========================= */\n"); 7017ec681f3Smrg for (int i = 0; i * 4 < size; i++) { 7027ec681f3Smrg value = &data[i]; 7037ec681f3Smrg fprintf(fp, "/* 0x%08x (0x%08x) */\t0x%08x", 7047ec681f3Smrg start + i * 4, i * 4, *value); 7057ec681f3Smrg if (i == 10) 7067ec681f3Smrg parse_rsw(fp, value, i, &data[15]); 7077ec681f3Smrg else 7087ec681f3Smrg parse_rsw(fp, value, i, NULL); 7097ec681f3Smrg } 7107ec681f3Smrg fprintf(fp, "/* ============ RSW END =========================== */\n"); 7117ec681f3Smrg} 7127ec681f3Smrg 7137ec681f3Smrgstatic void 7147ec681f3Smrgparse_texture(FILE *fp, uint32_t *data, uint32_t start, uint32_t offset) 7157ec681f3Smrg{ 7167ec681f3Smrg uint32_t i = 0; 7177ec681f3Smrg offset /= 4; 7187ec681f3Smrg lima_tex_desc *desc = (lima_tex_desc *)&data[offset]; 7197ec681f3Smrg 7207ec681f3Smrg /* Word 0 */ 7217ec681f3Smrg fprintf(fp, "/* 0x%08x (0x%08x) */\t0x%08x\n", 7227ec681f3Smrg start + i * 4, i * 4, *(&data[i + offset])); 7237ec681f3Smrg i++; 7247ec681f3Smrg fprintf(fp, "\t format: 0x%x (%d)\n", desc->format, desc->format); 7257ec681f3Smrg fprintf(fp, "\t flag1: 0x%x (%d)\n", desc->flag1, desc->flag1); 7267ec681f3Smrg fprintf(fp, "\t swap_r_b: 0x%x (%d)\n", desc->swap_r_b, desc->swap_r_b); 7277ec681f3Smrg fprintf(fp, "\t unknown_0_1: 0x%x (%d)\n", desc->unknown_0_1, desc->unknown_0_1); 7287ec681f3Smrg fprintf(fp, "\t stride: 0x%x (%d)\n", desc->stride, desc->stride); 7297ec681f3Smrg fprintf(fp, "\t unknown_0_2: 0x%x (%d)\n", desc->unknown_0_2, desc->unknown_0_2); 7307ec681f3Smrg 7317ec681f3Smrg /* Word 1 - 3 */ 7327ec681f3Smrg fprintf(fp, "/* 0x%08x (0x%08x) */\t0x%08x 0x%08x 0x%08x\n", 7337ec681f3Smrg start + i * 4, i * 4, *(&data[i + offset]), *(&data[i + 1 + offset]), *(&data[i + 2 + offset])); 7347ec681f3Smrg i += 3; 7357ec681f3Smrg fprintf(fp, "\t unknown_1_1: 0x%x (%d)\n", desc->unknown_1_1, desc->unknown_1_1); 7367ec681f3Smrg fprintf(fp, "\t unnorm_coords: 0x%x (%d)\n", desc->unnorm_coords, desc->unnorm_coords); 7377ec681f3Smrg fprintf(fp, "\t unknown_1_2: 0x%x (%d)\n", desc->unknown_1_2, desc->unknown_1_2); 7387ec681f3Smrg fprintf(fp, "\t texture_type: 0x%x (%d)\n", desc->texture_type, desc->texture_type); 7397ec681f3Smrg fprintf(fp, "\t min_lod: 0x%x (%d) (%f)\n", desc->min_lod, desc->min_lod, lima_fixed8_to_float(desc->min_lod)); 7407ec681f3Smrg fprintf(fp, "\t max_lod: 0x%x (%d) (%f)\n", desc->max_lod, desc->max_lod, lima_fixed8_to_float(desc->max_lod)); 7417ec681f3Smrg fprintf(fp, "\t lod_bias: 0x%x (%d) (%f)\n", desc->lod_bias, desc->lod_bias, lima_fixed8_to_float(desc->lod_bias)); 7427ec681f3Smrg fprintf(fp, "\t unknown_2_1: 0x%x (%d)\n", desc->unknown_2_1, desc->unknown_2_1); 7437ec681f3Smrg fprintf(fp, "\t has_stride: 0x%x (%d)\n", desc->has_stride, desc->has_stride); 7447ec681f3Smrg fprintf(fp, "\t min_mipfilter_2: 0x%x (%d)\n", desc->min_mipfilter_2, desc->min_mipfilter_2); 7457ec681f3Smrg fprintf(fp, "\t min_img_filter_nearest: 0x%x (%d)\n", desc->min_img_filter_nearest, desc->min_img_filter_nearest); 7467ec681f3Smrg fprintf(fp, "\t mag_img_filter_nearest: 0x%x (%d)\n", desc->mag_img_filter_nearest, desc->mag_img_filter_nearest); 7477ec681f3Smrg fprintf(fp, "\t wrap_s_clamp_to_edge: 0x%x (%d)\n", desc->wrap_s_clamp_to_edge, desc->wrap_s_clamp_to_edge); 7487ec681f3Smrg fprintf(fp, "\t wrap_s_clamp: 0x%x (%d)\n", desc->wrap_s_clamp, desc->wrap_s_clamp); 7497ec681f3Smrg fprintf(fp, "\t wrap_s_mirror_repeat: 0x%x (%d)\n", desc->wrap_s_mirror_repeat, desc->wrap_s_mirror_repeat); 7507ec681f3Smrg fprintf(fp, "\t wrap_t_clamp_to_edge: 0x%x (%d)\n", desc->wrap_t_clamp_to_edge, desc->wrap_t_clamp_to_edge); 7517ec681f3Smrg fprintf(fp, "\t wrap_t_clamp: 0x%x (%d)\n", desc->wrap_t_clamp, desc->wrap_t_clamp); 7527ec681f3Smrg fprintf(fp, "\t wrap_t_mirror_repeat: 0x%x (%d)\n", desc->wrap_t_mirror_repeat, desc->wrap_t_mirror_repeat); 7537ec681f3Smrg fprintf(fp, "\t unknown_2_2: 0x%x (%d)\n", desc->unknown_2_2, desc->unknown_2_2); 7547ec681f3Smrg fprintf(fp, "\t width: 0x%x (%d)\n", desc->width, desc->width); 7557ec681f3Smrg fprintf(fp, "\t height: 0x%x (%d)\n", desc->height, desc->height); 7567ec681f3Smrg fprintf(fp, "\t unknown_3_1: 0x%x (%d)\n", desc->unknown_3_1, desc->unknown_3_1); 7577ec681f3Smrg fprintf(fp, "\t unknown_3_2: 0x%x (%d)\n", desc->unknown_3_2, desc->unknown_3_2); 7587ec681f3Smrg 7597ec681f3Smrg /* Word 4 */ 7607ec681f3Smrg fprintf(fp, "/* 0x%08x (0x%08x) */\t0x%08x\n", 7617ec681f3Smrg start + i * 4, i * 4, *(&data[i + offset])); 7627ec681f3Smrg i++; 7637ec681f3Smrg fprintf(fp, "\t unknown_4: 0x%x (%d)\n", desc->unknown_4, desc->unknown_4); 7647ec681f3Smrg 7657ec681f3Smrg /* Word 5 */ 7667ec681f3Smrg fprintf(fp, "/* 0x%08x (0x%08x) */\t0x%08x\n", 7677ec681f3Smrg start + i * 4, i * 4, *(&data[i + offset])); 7687ec681f3Smrg i++; 7697ec681f3Smrg fprintf(fp, "\t unknown_5: 0x%x (%d)\n", desc->unknown_5, desc->unknown_5); 7707ec681f3Smrg 7717ec681f3Smrg /* Word 6 - */ 7727ec681f3Smrg fprintf(fp, "/* 0x%08x (0x%08x) */", 7737ec681f3Smrg start + i * 4, i * 4); 7747ec681f3Smrg fprintf(fp, "\t"); 7757ec681f3Smrg 7767ec681f3Smrg int miplevels = (int)lima_fixed8_to_float(desc->max_lod); 7777ec681f3Smrg for (int k = 0; k < ((((miplevels + 1) * 26) + 64) / 32); k++) 7787ec681f3Smrg fprintf(fp, "0x%08x ", *(&data[i + offset + k])); 7797ec681f3Smrg fprintf(fp, "\n"); 7807ec681f3Smrg 7817ec681f3Smrg i++; 7827ec681f3Smrg fprintf(fp, "\t unknown_6_1: 0x%x (%d)\n", desc->va_s.unknown_6_1, desc->va_s.unknown_6_1); 7837ec681f3Smrg fprintf(fp, "\t layout: 0x%x (%d)\n", desc->va_s.layout, desc->va_s.layout); 7847ec681f3Smrg fprintf(fp, "\t unknown_6_2: 0x%x (%d)\n", desc->va_s.unknown_6_2, desc->va_s.unknown_6_2); 7857ec681f3Smrg fprintf(fp, "\t unknown_6_3: 0x%x (%d)\n", desc->va_s.unknown_6_3, desc->va_s.unknown_6_3); 7867ec681f3Smrg 7877ec681f3Smrg /* first level */ 7887ec681f3Smrg fprintf(fp, "\t va_0: 0x%x \n", desc->va_s.va_0 << 6); 7897ec681f3Smrg 7907ec681f3Smrg /* second level up to desc->miplevels */ 7917ec681f3Smrg int j; 7927ec681f3Smrg unsigned va_bit_idx; 7937ec681f3Smrg unsigned va_idx; 7947ec681f3Smrg uint32_t va; 7957ec681f3Smrg uint32_t va_1; 7967ec681f3Smrg uint32_t va_2; 7977ec681f3Smrg for (j = 1; j <= miplevels; j++) { 7987ec681f3Smrg va = 0; 7997ec681f3Smrg va_1 = 0; 8007ec681f3Smrg va_2 = 0; 8017ec681f3Smrg 8027ec681f3Smrg va_bit_idx = VA_BIT_OFFSET + (VA_BIT_SIZE * j); 8037ec681f3Smrg va_idx = va_bit_idx / 32; 8047ec681f3Smrg va_bit_idx %= 32; 8057ec681f3Smrg 8067ec681f3Smrg /* the first (32 - va_bit_idx) bits */ 8077ec681f3Smrg va_1 |= (*(&data[i + offset + va_idx - 1]) >> va_bit_idx); 8087ec681f3Smrg 8097ec681f3Smrg /* do we need some bits from the following word? */ 8107ec681f3Smrg if (va_bit_idx > 6) { 8117ec681f3Smrg /* shift left and right again to erase the unneeded bits, keep space for va1 */ 8127ec681f3Smrg va_2 |= (*(&data[i + offset + va_idx]) << (2 * 32 - VA_BIT_SIZE - va_bit_idx)); 8137ec681f3Smrg va_2 >>= ((2 * 32 - VA_BIT_SIZE - va_bit_idx) - (32 - va_bit_idx)); 8147ec681f3Smrg va |= va_2; 8157ec681f3Smrg } 8167ec681f3Smrg va |= va_1; 8177ec681f3Smrg va <<= 6; 8187ec681f3Smrg fprintf(fp, "\t va_%d: 0x%x \n", j, va); 8197ec681f3Smrg } 8207ec681f3Smrg} 8217ec681f3Smrg 8227ec681f3Smrgvoid 8237ec681f3Smrglima_parse_texture_descriptor(FILE *fp, uint32_t *data, int size, uint32_t start, uint32_t offset) 8247ec681f3Smrg{ 8257ec681f3Smrg fprintf(fp, "/* ============ TEXTURE BEGIN ===================== */\n"); 8267ec681f3Smrg parse_texture(fp, data, start, offset); 8277ec681f3Smrg fprintf(fp, "/* ============ TEXTURE END ======================= */\n"); 8287ec681f3Smrg} 829