ac_shader_args.h revision 7ec681f3
11.37Sjmcneill/* 21.2Sgarbled * Copyright 2019 Valve Corporation 31.2Sgarbled * 41.2Sgarbled * Permission is hereby granted, free of charge, to any person obtaining a 51.2Sgarbled * copy of this software and associated documentation files (the "Software"), 61.2Sgarbled * to deal in the Software without restriction, including without limitation 71.2Sgarbled * on the rights to use, copy, modify, merge, publish, distribute, sub 81.2Sgarbled * license, and/or sell copies of the Software, and to permit persons to whom 91.2Sgarbled * the Software is furnished to do so, subject to the following conditions: 101.2Sgarbled * 111.2Sgarbled * The above copyright notice and this permission notice (including the next 121.2Sgarbled * paragraph) shall be included in all copies or substantial portions of the 131.2Sgarbled * Software. 141.2Sgarbled * 151.2Sgarbled * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 161.2Sgarbled * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 171.2Sgarbled * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL 181.2Sgarbled * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, 191.2Sgarbled * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 201.2Sgarbled * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE 211.2Sgarbled * USE OR OTHER DEALINGS IN THE SOFTWARE. 221.2Sgarbled */ 231.2Sgarbled 241.2Sgarbled#ifndef AC_SHADER_ARGS_H 251.2Sgarbled#define AC_SHADER_ARGS_H 261.2Sgarbled 271.2Sgarbled#include <stdbool.h> 281.2Sgarbled#include <stdint.h> 291.28Srin 301.28Srin#define AC_MAX_INLINE_PUSH_CONSTS 8 311.2Sgarbled 321.37Sjmcneillenum ac_arg_regfile 331.2Sgarbled{ 341.28Srin AC_ARG_SGPR, 351.16Smatt AC_ARG_VGPR, 361.2Sgarbled}; 371.16Smatt 381.29Srinenum ac_arg_type 391.28Srin{ 401.12Smacallan AC_ARG_FLOAT, 411.2Sgarbled AC_ARG_INT, 421.16Smatt AC_ARG_CONST_PTR, /* Pointer to i8 array */ 431.16Smatt AC_ARG_CONST_FLOAT_PTR, /* Pointer to f32 array */ 441.20Smatt AC_ARG_CONST_PTR_PTR, /* Pointer to pointer to i8 array */ 451.25Snonaka AC_ARG_CONST_DESC_PTR, /* Pointer to v4i32 array */ 461.2Sgarbled AC_ARG_CONST_IMAGE_PTR, /* Pointer to v8i32 array */ 471.16Smatt}; 481.16Smatt 491.16Smattstruct ac_arg { 501.2Sgarbled uint16_t arg_index; 511.2Sgarbled bool used; 521.2Sgarbled}; 531.2Sgarbled 541.2Sgarbled#define AC_MAX_ARGS 384 /* including all VS->TCS IO */ 551.16Smatt 561.2Sgarbledstruct ac_shader_args { 571.2Sgarbled /* Info on how to declare arguments */ 581.12Smacallan struct { 591.12Smacallan enum ac_arg_type type; 601.12Smacallan enum ac_arg_regfile file; 611.12Smacallan uint8_t offset; 621.2Sgarbled uint8_t size; 631.2Sgarbled bool skip; 641.15Smatt } args[AC_MAX_ARGS]; 651.2Sgarbled 661.27Srin uint16_t arg_count; 671.27Srin uint16_t num_sgprs_used; 681.34Sriastrad uint16_t num_vgprs_used; 691.27Srin 701.34Sriastrad uint16_t return_count; 711.27Srin uint16_t num_sgprs_returned; 721.27Srin uint16_t num_vgprs_returned; 731.2Sgarbled 741.2Sgarbled /* VS */ 751.2Sgarbled struct ac_arg base_vertex; 761.15Smatt struct ac_arg start_instance; 771.15Smatt struct ac_arg draw_id; 781.30Srin struct ac_arg vertex_buffers; 791.2Sgarbled struct ac_arg vertex_id; 801.2Sgarbled struct ac_arg vs_rel_patch_id; 811.2Sgarbled struct ac_arg vs_prim_id; 821.15Smatt struct ac_arg instance_id; 831.2Sgarbled 841.15Smatt /* Merged shaders */ 851.2Sgarbled struct ac_arg tess_offchip_offset; 861.2Sgarbled struct ac_arg merged_wave_info; 871.2Sgarbled /* On gfx10: 881.2Sgarbled * - bits 0..11: ordered_wave_id 891.2Sgarbled * - bits 12..20: number of vertices in group 901.2Sgarbled * - bits 22..30: number of primitives in group 911.15Smatt */ 921.2Sgarbled struct ac_arg gs_tg_info; 931.2Sgarbled struct ac_arg scratch_offset; 941.2Sgarbled 951.2Sgarbled /* TCS */ 961.2Sgarbled struct ac_arg tcs_factor_offset; 971.2Sgarbled struct ac_arg tcs_patch_id; 981.2Sgarbled struct ac_arg tcs_rel_ids; 991.2Sgarbled 1001.2Sgarbled /* TES */ 1011.2Sgarbled struct ac_arg tes_u; 1021.2Sgarbled struct ac_arg tes_v; 1031.2Sgarbled struct ac_arg tes_rel_patch_id; 1041.2Sgarbled struct ac_arg tes_patch_id; 1051.7Skiyohara 1061.2Sgarbled /* GS */ 1071.2Sgarbled struct ac_arg es2gs_offset; /* separate legacy ES */ 1081.2Sgarbled struct ac_arg gs2vs_offset; /* legacy GS */ 1091.2Sgarbled struct ac_arg gs_wave_id; /* legacy GS */ 1101.2Sgarbled struct ac_arg gs_vtx_offset[6]; /* GFX6-8: [0-5], GFX9+: [0-2] packed */ 1111.2Sgarbled struct ac_arg gs_prim_id; 1121.15Smatt struct ac_arg gs_invocation_id; 1131.15Smatt 1141.2Sgarbled /* Streamout */ 1151.2Sgarbled struct ac_arg streamout_config; 1161.2Sgarbled struct ac_arg streamout_write_index; 1171.2Sgarbled struct ac_arg streamout_offset[4]; 1181.2Sgarbled 1191.2Sgarbled /* PS */ 1201.15Smatt struct ac_arg frag_pos[4]; 1211.2Sgarbled struct ac_arg front_face; 1221.14Smatt struct ac_arg ancillary; 1231.14Smatt struct ac_arg sample_coverage; 1241.15Smatt struct ac_arg prim_mask; 1251.15Smatt struct ac_arg persp_sample; 1261.14Smatt struct ac_arg persp_center; 1271.2Sgarbled struct ac_arg persp_centroid; 1281.2Sgarbled struct ac_arg pull_model; 1291.2Sgarbled struct ac_arg linear_sample; 1301.2Sgarbled struct ac_arg linear_center; 1311.2Sgarbled struct ac_arg linear_centroid; 1321.2Sgarbled 1331.2Sgarbled /* CS */ 1341.2Sgarbled struct ac_arg local_invocation_ids; 1351.2Sgarbled struct ac_arg num_work_groups; 1361.2Sgarbled struct ac_arg workgroup_ids[3]; 1371.2Sgarbled struct ac_arg tg_size; 1381.2Sgarbled 1391.2Sgarbled /* Vulkan only */ 1401.2Sgarbled struct ac_arg push_constants; 1411.2Sgarbled struct ac_arg inline_push_consts[AC_MAX_INLINE_PUSH_CONSTS]; 1421.2Sgarbled unsigned base_inline_push_consts; 1431.14Smatt struct ac_arg view_index; 1441.2Sgarbled struct ac_arg sbt_descriptors; 1451.2Sgarbled struct ac_arg ray_launch_size; 1461.25Snonaka}; 1471.25Snonaka 1481.25Snonakavoid ac_add_arg(struct ac_shader_args *info, enum ac_arg_regfile regfile, unsigned registers, 1491.25Snonaka enum ac_arg_type type, struct ac_arg *arg); 1501.25Snonakavoid ac_add_return(struct ac_shader_args *info, enum ac_arg_regfile regfile); 1511.25Snonaka 1521.25Snonaka#endif 1531.2Sgarbled