Path: blob/21.2-virgl/src/gallium/drivers/r600/r600_dump.c
4570 views
/* -*- mesa-c++ -*-1*2* Copyright (c) 2018 Collabora LTD3*4* Author: Gert Wollny <[email protected]>5*6* Permission is hereby granted, free of charge, to any person obtaining a7* copy of this software and associated documentation files (the "Software"),8* to deal in the Software without restriction, including without limitation9* on the rights to use, copy, modify, merge, publish, distribute, sub10* license, and/or sell copies of the Software, and to permit persons to whom11* the Software is furnished to do so, subject to the following conditions:12*13* The above copyright notice and this permission notice (including the next14* paragraph) shall be included in all copies or substantial portions of the15* Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR18* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,19* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL20* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,21* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR22* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE23* USE OR OTHER DEALINGS IN THE SOFTWARE.24*/2526#include "r600_dump.h"27#include "r600_shader.h"28#include "tgsi/tgsi_strings.h"2930void print_shader_info(FILE *f , int id, struct r600_shader *shader)31{3233#define PRINT_INT_MEMBER(NAME) \34if (shader-> NAME) fprintf(f, " shader->" #NAME "=%d;\n", shader-> NAME)35#define PRINT_UINT_MEMBER(NAME) \36if (shader-> NAME) fprintf(f, " shader->" #NAME "=%u;\n", (unsigned)shader-> NAME)3738#define PRINT_INT_ARRAY_ELM(NAME, ELM) \39if (shader->NAME[i].ELM) fprintf(f, " shader->" #NAME "[%d]." #ELM "=%d;\n", i, (int)shader->NAME[i].ELM)40#define PRINT_UINT_ARRAY_ELM(NAME, ELM) \41if (shader->NAME[i].ELM) fprintf(f, " shader->" #NAME "[%d]." #ELM" =%u;\n", i, (unsigned)shader->NAME[i].ELM)4243fprintf(f, "#include \"gallium/drivers/r600/r600_shader.h\"\n");44fprintf(f, "void shader_%d_fill_data(struct r600_shader *shader)\n{\n", id);45fprintf(f, " memset(shader, 0, sizeof(struct r600_shader));\n");4647PRINT_UINT_MEMBER(processor_type);48PRINT_UINT_MEMBER(ninput);49PRINT_UINT_MEMBER(noutput);50PRINT_UINT_MEMBER(nhwatomic);51PRINT_UINT_MEMBER(nlds);52PRINT_UINT_MEMBER(nsys_inputs);5354for (unsigned i = 0; i < shader->ninput; ++i) {55PRINT_UINT_ARRAY_ELM(input, name);56PRINT_UINT_ARRAY_ELM(input, gpr);57PRINT_UINT_ARRAY_ELM(input, done);58PRINT_INT_ARRAY_ELM(input, sid);59PRINT_INT_ARRAY_ELM(input, spi_sid);60PRINT_UINT_ARRAY_ELM(input, interpolate);61PRINT_UINT_ARRAY_ELM(input, ij_index);62PRINT_UINT_ARRAY_ELM(input, interpolate_location); // TGSI_INTERPOLATE_LOC_CENTER, CENTROID, SAMPLE63PRINT_UINT_ARRAY_ELM(input, lds_pos); /* for evergreen */64PRINT_UINT_ARRAY_ELM(input, back_color_input);65PRINT_UINT_ARRAY_ELM(input, write_mask);66PRINT_INT_ARRAY_ELM(input, ring_offset);67}6869for (unsigned i = 0; i < shader->noutput; ++i) {70PRINT_UINT_ARRAY_ELM(output, name);71PRINT_UINT_ARRAY_ELM(output, gpr);72PRINT_UINT_ARRAY_ELM(output, done);73PRINT_INT_ARRAY_ELM(output, sid);74PRINT_INT_ARRAY_ELM(output, spi_sid);75PRINT_UINT_ARRAY_ELM(output, interpolate);76PRINT_UINT_ARRAY_ELM(output, ij_index);77PRINT_UINT_ARRAY_ELM(output, interpolate_location); // TGSI_INTERPOLATE_LOC_CENTER, CENTROID, SAMPLE78PRINT_UINT_ARRAY_ELM(output, lds_pos); /* for evergreen */79PRINT_UINT_ARRAY_ELM(output, back_color_input);80PRINT_UINT_ARRAY_ELM(output, write_mask);81PRINT_INT_ARRAY_ELM(output, ring_offset);82}8384for (unsigned i = 0; i < shader->nhwatomic; ++i) {85PRINT_UINT_ARRAY_ELM(atomics, start);86PRINT_UINT_ARRAY_ELM(atomics, end);87PRINT_UINT_ARRAY_ELM(atomics, buffer_id);88PRINT_UINT_ARRAY_ELM(atomics, hw_idx);89PRINT_UINT_ARRAY_ELM(atomics, array_id);90}9192PRINT_UINT_MEMBER(nhwatomic_ranges);93PRINT_UINT_MEMBER(uses_kill);94PRINT_UINT_MEMBER(fs_write_all);95PRINT_UINT_MEMBER(two_side);96PRINT_UINT_MEMBER(needs_scratch_space);97/* Number of color outputs in the TGSI shader,98* sometimes it could be higher than nr_cbufs (bug?).99* Also with writes_all property on eg+ it will be set to max CB number */100PRINT_UINT_MEMBER(nr_ps_max_color_exports);101/* Real number of ps color exports compiled in the bytecode */102PRINT_UINT_MEMBER(nr_ps_color_exports);103PRINT_UINT_MEMBER(ps_color_export_mask);104PRINT_UINT_MEMBER(ps_export_highest);105/* bit n is set if the shader writes gl_ClipDistance[n] */106PRINT_UINT_MEMBER(cc_dist_mask);107PRINT_UINT_MEMBER(clip_dist_write);108PRINT_UINT_MEMBER(cull_dist_write);109PRINT_UINT_MEMBER(vs_position_window_space);110/* flag is set if the shader writes VS_OUT_MISC_VEC (e.g. for PSIZE) */111PRINT_UINT_MEMBER(vs_out_misc_write);112PRINT_UINT_MEMBER(vs_out_point_size);113PRINT_UINT_MEMBER(vs_out_layer);114PRINT_UINT_MEMBER(vs_out_viewport);115PRINT_UINT_MEMBER(vs_out_edgeflag);116PRINT_UINT_MEMBER(has_txq_cube_array_z_comp);117PRINT_UINT_MEMBER(uses_tex_buffers);118PRINT_UINT_MEMBER(gs_prim_id_input);119PRINT_UINT_MEMBER(gs_tri_strip_adj_fix);120PRINT_UINT_MEMBER(ps_conservative_z);121122/* Size in bytes of a data item in the ring(s) (single vertex data).123Stages with only one ring items 123 will be set to 0. */124125PRINT_UINT_MEMBER(ring_item_sizes[0]);126PRINT_UINT_MEMBER(ring_item_sizes[1]);127PRINT_UINT_MEMBER(ring_item_sizes[2]);128PRINT_UINT_MEMBER(ring_item_sizes[3]);129130PRINT_UINT_MEMBER(indirect_files);131PRINT_UINT_MEMBER(max_arrays);132PRINT_UINT_MEMBER(num_arrays);133PRINT_UINT_MEMBER(vs_as_es);134PRINT_UINT_MEMBER(vs_as_ls);135PRINT_UINT_MEMBER(vs_as_gs_a);136PRINT_UINT_MEMBER(tes_as_es);137PRINT_UINT_MEMBER(tcs_prim_mode);138PRINT_UINT_MEMBER(ps_prim_id_input);139140if (shader->num_arrays > 0) {141fprintf(stderr, " shader->arrays = new r600_shader_array[%d];\n", shader->num_arrays);142for (unsigned i = 0; i < shader->num_arrays; ++i) {143PRINT_UINT_ARRAY_ELM(arrays, gpr_start);144PRINT_UINT_ARRAY_ELM(arrays, gpr_count);145PRINT_UINT_ARRAY_ELM(arrays, comp_mask);146}147}148149PRINT_UINT_MEMBER(uses_doubles);150PRINT_UINT_MEMBER(uses_atomics);151PRINT_UINT_MEMBER(uses_images);152PRINT_UINT_MEMBER(uses_helper_invocation);153PRINT_UINT_MEMBER(atomic_base);154PRINT_UINT_MEMBER(rat_base);155PRINT_UINT_MEMBER(image_size_const_offset);156157fprintf(f, "}\n");158}159160void print_pipe_info(FILE *f, struct tgsi_shader_info *shader)161{162PRINT_UINT_MEMBER(shader_buffers_load);163PRINT_UINT_MEMBER(shader_buffers_store);164PRINT_UINT_MEMBER(shader_buffers_atomic);165PRINT_UINT_MEMBER(writes_memory);166PRINT_UINT_MEMBER(file_mask[TGSI_FILE_HW_ATOMIC]);167PRINT_UINT_MEMBER(file_count[TGSI_FILE_HW_ATOMIC]);168169for(unsigned int i = 0; i < TGSI_PROPERTY_COUNT; ++i) {170if (shader->properties[i] != 0)171fprintf(stderr, "PROP: %s = %d\n", tgsi_property_names[i], shader->properties[i]);172}173174#define PRINT_UINT_ARRAY_MEMBER(M, IDX) \175if (shader-> M [ IDX ]) fprintf(f, #M "[%d] = %d\n", IDX, (unsigned) shader-> M [ IDX ]);176177for (int i = 0; i < shader->num_inputs; ++i) {178PRINT_UINT_ARRAY_MEMBER(input_semantic_name, i); /**< TGSI_SEMANTIC_x */179PRINT_UINT_ARRAY_MEMBER(input_semantic_index, i);180PRINT_UINT_ARRAY_MEMBER(input_interpolate, i);181PRINT_UINT_ARRAY_MEMBER(input_interpolate_loc, i);182PRINT_UINT_ARRAY_MEMBER(input_usage_mask, i);183PRINT_UINT_ARRAY_MEMBER(input_cylindrical_wrap, i);184}185186for (int i = 0; i < shader->num_inputs; ++i) {187PRINT_UINT_ARRAY_MEMBER(output_semantic_name, i);188PRINT_UINT_ARRAY_MEMBER(output_semantic_index, i);189PRINT_UINT_ARRAY_MEMBER(output_usagemask, i);190PRINT_UINT_ARRAY_MEMBER(output_streams, i);191}192193for (int i = 0; i < shader->num_system_values; ++i)194PRINT_UINT_ARRAY_MEMBER(system_value_semantic_name, i);195196PRINT_UINT_MEMBER(reads_pervertex_outputs);197PRINT_UINT_MEMBER(reads_perpatch_outputs);198PRINT_UINT_MEMBER(reads_tessfactor_outputs);199}200201202