Path: blob/21.2-virgl/src/gallium/drivers/r600/r600_shader.h
4570 views
/*1* Copyright 2010 Jerome Glisse <[email protected]>2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* on the rights to use, copy, modify, merge, publish, distribute, sub7* license, and/or sell copies of the Software, and to permit persons to whom8* the Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL17* THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,18* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR19* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE20* USE OR OTHER DEALINGS IN THE SOFTWARE.21*/22#ifndef R600_SHADER_H23#define R600_SHADER_H2425#include "r600_asm.h"262728#ifdef __cplusplus29extern "C" {30#endif3132/* Valid shader configurations:33*34* API shaders VS | TCS | TES | GS |pass| PS35* are compiled as: | | | |thru|36* | | | | |37* Only VS & PS: VS | -- | -- | -- | -- | PS38* With GS: ES | -- | -- | GS | VS | PS39* With Tessel.: LS | HS | VS | -- | -- | PS40* With both: LS | HS | ES | GS | VS | PS41*/4243struct r600_shader_io {44unsigned name;45unsigned gpr;46unsigned done;47unsigned sid;48int spi_sid;49unsigned interpolate;50unsigned ij_index;51unsigned interpolate_location; // TGSI_INTERPOLATE_LOC_CENTER, CENTROID, SAMPLE52unsigned lds_pos; /* for evergreen */53unsigned back_color_input;54unsigned write_mask;55int ring_offset;56unsigned uses_interpolate_at_centroid;57};5859struct r600_shader_atomic {60unsigned start, end;61unsigned buffer_id;62unsigned hw_idx;63unsigned array_id;64};6566struct r600_shader {67unsigned processor_type;68struct r600_bytecode bc;69unsigned ninput;70unsigned noutput;71unsigned nhwatomic;72unsigned nlds;73unsigned nsys_inputs;74struct r600_shader_io input[PIPE_MAX_SHADER_INPUTS];75struct r600_shader_io output[PIPE_MAX_SHADER_OUTPUTS];76struct r600_shader_atomic atomics[8];77unsigned nhwatomic_ranges;78boolean uses_kill;79boolean fs_write_all;80boolean two_side;81boolean needs_scratch_space;82/* Number of color outputs in the TGSI shader,83* sometimes it could be higher than nr_cbufs (bug?).84* Also with writes_all property on eg+ it will be set to max CB number */85unsigned nr_ps_max_color_exports;86/* Real number of ps color exports compiled in the bytecode */87unsigned nr_ps_color_exports;88unsigned ps_color_export_mask;89unsigned ps_export_highest;90/* bit n is set if the shader writes gl_ClipDistance[n] */91unsigned cc_dist_mask;92unsigned clip_dist_write;93unsigned cull_dist_write;94boolean vs_position_window_space;95/* flag is set if the shader writes VS_OUT_MISC_VEC (e.g. for PSIZE) */96boolean vs_out_misc_write;97boolean vs_out_point_size;98boolean vs_out_layer;99boolean vs_out_viewport;100boolean vs_out_edgeflag;101boolean has_txq_cube_array_z_comp;102boolean uses_tex_buffers;103boolean gs_prim_id_input;104boolean gs_tri_strip_adj_fix;105uint8_t ps_conservative_z;106107/* Size in bytes of a data item in the ring(s) (single vertex data).108Stages with only one ring items 123 will be set to 0. */109unsigned ring_item_sizes[4];110111unsigned indirect_files;112unsigned max_arrays;113unsigned num_arrays;114unsigned vs_as_es;115unsigned vs_as_ls;116unsigned vs_as_gs_a;117unsigned tes_as_es;118unsigned tcs_prim_mode;119unsigned ps_prim_id_input;120struct r600_shader_array * arrays;121122boolean uses_doubles;123boolean uses_atomics;124boolean uses_images;125boolean uses_helper_invocation;126uint8_t atomic_base;127uint8_t rat_base;128uint8_t image_size_const_offset;129};130131union r600_shader_key {132struct {133unsigned nr_cbufs:4;134unsigned first_atomic_counter:4;135unsigned image_size_const_offset:5;136unsigned color_two_side:1;137unsigned alpha_to_one:1;138unsigned apply_sample_id_mask:1;139unsigned dual_source_blend:1;140} ps;141struct {142unsigned prim_id_out:8;143unsigned first_atomic_counter:4;144unsigned as_es:1; /* export shader */145unsigned as_ls:1; /* local shader */146unsigned as_gs_a:1;147} vs;148struct {149unsigned first_atomic_counter:4;150unsigned as_es:1;151} tes;152struct {153unsigned first_atomic_counter:4;154unsigned prim_mode:3;155} tcs;156struct {157unsigned first_atomic_counter:4;158unsigned tri_strip_adj_fix:1;159} gs;160};161162struct r600_shader_array {163unsigned gpr_start;164unsigned gpr_count;165unsigned comp_mask;166};167168struct r600_pipe_shader {169struct r600_pipe_shader_selector *selector;170struct r600_pipe_shader *next_variant;171/* for GS - corresponding copy shader (installed as VS) */172struct r600_pipe_shader *gs_copy_shader;173struct r600_shader shader;174struct r600_command_buffer command_buffer; /* register writes */175struct r600_resource *bo;176unsigned sprite_coord_enable;177unsigned flatshade;178unsigned pa_cl_vs_out_cntl;179unsigned nr_ps_color_outputs;180unsigned ps_color_export_mask;181182union r600_shader_key key;183unsigned db_shader_control;184unsigned ps_depth_export;185unsigned enabled_stream_buffers_mask;186unsigned scratch_space_needed; /* size of scratch space (if > 0) counted in vec4 */187};188189/* return the table index 0-5 for TGSI_INTERPOLATE_LINEAR/PERSPECTIVE and190TGSI_INTERPOLATE_LOC_CENTER/SAMPLE/COUNT. Other input values return -1. */191int eg_get_interpolator_index(unsigned interpolate, unsigned location);192193int r600_get_lds_unique_index(unsigned semantic_name, unsigned index);194195int generate_gs_copy_shader(struct r600_context *rctx,196struct r600_pipe_shader *gs,197struct pipe_stream_output_info *so);198199#ifdef __cplusplus200} // extern "C"201#endif202203204#endif205206207