Path: blob/21.2-virgl/src/amd/common/ac_shader_args.c
7206 views
/*1* Copyright 2019 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* 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*/2223#include "ac_shader_args.h"2425#include "nir/nir_builder.h"2627void ac_add_arg(struct ac_shader_args *info, enum ac_arg_regfile regfile, unsigned size,28enum ac_arg_type type, struct ac_arg *arg)29{30assert(info->arg_count < AC_MAX_ARGS);3132unsigned offset;33if (regfile == AC_ARG_SGPR) {34offset = info->num_sgprs_used;35info->num_sgprs_used += size;36} else {37assert(regfile == AC_ARG_VGPR);38offset = info->num_vgprs_used;39info->num_vgprs_used += size;40}4142info->args[info->arg_count].file = regfile;43info->args[info->arg_count].offset = offset;44info->args[info->arg_count].size = size;45info->args[info->arg_count].type = type;4647if (arg) {48arg->arg_index = info->arg_count;49arg->used = true;50}5152info->arg_count++;53}5455void ac_add_return(struct ac_shader_args *info, enum ac_arg_regfile regfile)56{57assert(info->return_count < AC_MAX_ARGS);5859if (regfile == AC_ARG_SGPR) {60/* SGPRs must be inserted before VGPRs. */61assert(info->num_vgprs_returned == 0);62info->num_sgprs_returned++;;63} else {64assert(regfile == AC_ARG_VGPR);65info->num_vgprs_returned++;66}6768info->return_count++;69}707172