Path: blob/21.2-virgl/src/amd/common/ac_shader_args.h
7237 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#ifndef AC_SHADER_ARGS_H24#define AC_SHADER_ARGS_H2526#include <stdbool.h>27#include <stdint.h>2829#define AC_MAX_INLINE_PUSH_CONSTS 83031enum ac_arg_regfile32{33AC_ARG_SGPR,34AC_ARG_VGPR,35};3637enum ac_arg_type38{39AC_ARG_FLOAT,40AC_ARG_INT,41AC_ARG_CONST_PTR, /* Pointer to i8 array */42AC_ARG_CONST_FLOAT_PTR, /* Pointer to f32 array */43AC_ARG_CONST_PTR_PTR, /* Pointer to pointer to i8 array */44AC_ARG_CONST_DESC_PTR, /* Pointer to v4i32 array */45AC_ARG_CONST_IMAGE_PTR, /* Pointer to v8i32 array */46};4748struct ac_arg {49uint16_t arg_index;50bool used;51};5253#define AC_MAX_ARGS 384 /* including all VS->TCS IO */5455struct ac_shader_args {56/* Info on how to declare arguments */57struct {58enum ac_arg_type type;59enum ac_arg_regfile file;60uint8_t offset;61uint8_t size;62bool skip;63} args[AC_MAX_ARGS];6465uint16_t arg_count;66uint16_t num_sgprs_used;67uint16_t num_vgprs_used;6869uint16_t return_count;70uint16_t num_sgprs_returned;71uint16_t num_vgprs_returned;7273/* VS */74struct ac_arg base_vertex;75struct ac_arg start_instance;76struct ac_arg draw_id;77struct ac_arg vertex_buffers;78struct ac_arg vertex_id;79struct ac_arg vs_rel_patch_id;80struct ac_arg vs_prim_id;81struct ac_arg instance_id;8283/* Merged shaders */84struct ac_arg tess_offchip_offset;85struct ac_arg merged_wave_info;86/* On gfx10:87* - bits 0..11: ordered_wave_id88* - bits 12..20: number of vertices in group89* - bits 22..30: number of primitives in group90*/91struct ac_arg gs_tg_info;92struct ac_arg scratch_offset;9394/* TCS */95struct ac_arg tcs_factor_offset;96struct ac_arg tcs_patch_id;97struct ac_arg tcs_rel_ids;9899/* TES */100struct ac_arg tes_u;101struct ac_arg tes_v;102struct ac_arg tes_rel_patch_id;103struct ac_arg tes_patch_id;104105/* GS */106struct ac_arg es2gs_offset; /* separate legacy ES */107struct ac_arg gs2vs_offset; /* legacy GS */108struct ac_arg gs_wave_id; /* legacy GS */109struct ac_arg gs_vtx_offset[6]; /* separate legacy GS */110struct ac_arg gs_prim_id;111struct ac_arg gs_invocation_id;112113/* Streamout */114struct ac_arg streamout_config;115struct ac_arg streamout_write_index;116struct ac_arg streamout_offset[4];117118/* PS */119struct ac_arg frag_pos[4];120struct ac_arg front_face;121struct ac_arg ancillary;122struct ac_arg sample_coverage;123struct ac_arg prim_mask;124struct ac_arg persp_sample;125struct ac_arg persp_center;126struct ac_arg persp_centroid;127struct ac_arg pull_model;128struct ac_arg linear_sample;129struct ac_arg linear_center;130struct ac_arg linear_centroid;131132/* CS */133struct ac_arg local_invocation_ids;134struct ac_arg num_work_groups;135struct ac_arg workgroup_ids[3];136struct ac_arg tg_size;137138/* Vulkan only */139struct ac_arg push_constants;140struct ac_arg inline_push_consts[AC_MAX_INLINE_PUSH_CONSTS];141unsigned num_inline_push_consts;142unsigned base_inline_push_consts;143struct ac_arg view_index;144struct ac_arg sbt_descriptors;145};146147void ac_add_arg(struct ac_shader_args *info, enum ac_arg_regfile regfile, unsigned registers,148enum ac_arg_type type, struct ac_arg *arg);149void ac_add_return(struct ac_shader_args *info, enum ac_arg_regfile regfile);150151#endif152153154