Path: blob/21.2-virgl/src/amd/compiler/aco_instruction_selection.h
4550 views
/*1* Copyright © 2018 Valve Corporation2*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* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* 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 NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*22*/2324#ifndef ACO_INSTRUCTION_SELECTION_H25#define ACO_INSTRUCTION_SELECTION_H2627#include "aco_ir.h"2829#include "vulkan/radv_shader_args.h"3031#include <array>32#include <unordered_map>33#include <vector>3435namespace aco {3637struct shader_io_state {38uint8_t mask[VARYING_SLOT_MAX];39Temp temps[VARYING_SLOT_MAX * 4u];4041shader_io_state()42{43memset(mask, 0, sizeof(mask));44std::fill_n(temps, VARYING_SLOT_MAX * 4u, Temp(0, RegClass::v1));45}46};4748struct isel_context {49const struct radv_nir_compiler_options* options;50struct radv_shader_args* args;51Program* program;52nir_shader* shader;53uint32_t constant_data_offset;54Block* block;55uint32_t first_temp_id;56std::unordered_map<unsigned, std::array<Temp, NIR_MAX_VEC_COMPONENTS>> allocated_vec;57Stage stage;58struct {59bool has_branch;60struct {61unsigned header_idx;62Block* exit;63bool has_divergent_continue = false;64bool has_divergent_branch = false;65} parent_loop;66struct {67bool is_divergent = false;68} parent_if;69bool exec_potentially_empty_discard =70false; /* set to false when loop_nest_depth==0 && parent_if.is_divergent==false */71uint16_t exec_potentially_empty_break_depth = UINT16_MAX;72/* Set to false when loop_nest_depth==exec_potentially_empty_break_depth73* and parent_if.is_divergent==false. Called _break but it's also used for74* loop continues. */75bool exec_potentially_empty_break = false;76std::unique_ptr<unsigned[]> nir_to_aco; /* NIR block index to ACO block index */77} cf_info;7879/* NIR range analysis. */80struct hash_table* range_ht;81nir_unsigned_upper_bound_config ub_config;8283Temp arg_temps[AC_MAX_ARGS];8485/* FS inputs */86Temp persp_centroid, linear_centroid;8788/* GS inputs */89Temp gs_wave_id;9091/* VS output information */92bool export_clip_dists;93unsigned num_clip_distances;94unsigned num_cull_distances;9596/* tessellation information */97uint64_t tcs_temp_only_inputs;98uint32_t tcs_num_patches;99bool tcs_in_out_eq = false;100101/* I/O information */102shader_io_state inputs;103shader_io_state outputs;104};105106inline Temp107get_arg(isel_context* ctx, struct ac_arg arg)108{109assert(arg.used);110return ctx->arg_temps[arg.arg_index];111}112113void init_context(isel_context* ctx, nir_shader* shader);114void cleanup_context(isel_context* ctx);115116isel_context setup_isel_context(Program* program, unsigned shader_count,117struct nir_shader* const* shaders, ac_shader_config* config,118struct radv_shader_args* args, bool is_gs_copy_shader);119120} // namespace aco121122#endif /* ACO_INSTRUCTION_SELECTION_H */123124125