aco: Use common argument handling
[mesa.git] / src / amd / common / ac_shader_args.h
1 /*
2 * Copyright 2019 Valve Corporation
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * on the rights to use, copy, modify, merge, publish, distribute, sub
8 * license, and/or sell copies of the Software, and to permit persons to whom
9 * the Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHOR(S) AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
21 * USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23
24 #ifndef AC_SHADER_ARGS_H
25 #define AC_SHADER_ARGS_H
26
27 #include <stdint.h>
28 #include <stdbool.h>
29
30 #define AC_MAX_INLINE_PUSH_CONSTS 8
31
32 enum ac_arg_regfile {
33 AC_ARG_SGPR,
34 AC_ARG_VGPR,
35 };
36
37 enum ac_arg_type {
38 AC_ARG_FLOAT,
39 AC_ARG_INT,
40 AC_ARG_CONST_PTR, /* Pointer to i8 array */
41 AC_ARG_CONST_FLOAT_PTR, /* Pointer to f32 array */
42 AC_ARG_CONST_PTR_PTR, /* Pointer to pointer to i8 array */
43 AC_ARG_CONST_DESC_PTR, /* Pointer to v4i32 array */
44 AC_ARG_CONST_IMAGE_PTR, /* Pointer to v8i32 array */
45 };
46
47 struct ac_arg {
48 uint8_t arg_index;
49 bool used;
50 };
51
52
53 #define AC_MAX_ARGS 64
54 struct ac_shader_args {
55 /* Info on how to declare arguments */
56 struct {
57 enum ac_arg_type type;
58 enum ac_arg_regfile file;
59 uint8_t offset;
60 uint8_t size;
61 bool skip;
62 } args[AC_MAX_ARGS];
63
64 uint8_t arg_count;
65 uint8_t sgpr_count;
66 uint8_t num_sgprs_used;
67 uint8_t num_vgprs_used;
68
69 struct ac_arg base_vertex;
70 struct ac_arg start_instance;
71 struct ac_arg draw_id;
72 struct ac_arg vertex_id;
73 struct ac_arg instance_id;
74 struct ac_arg tcs_patch_id;
75 struct ac_arg tcs_rel_ids;
76 struct ac_arg tes_patch_id;
77 struct ac_arg gs_prim_id;
78 struct ac_arg gs_invocation_id;
79
80 /* PS */
81 struct ac_arg frag_pos[4];
82 struct ac_arg front_face;
83 struct ac_arg ancillary;
84 struct ac_arg sample_coverage;
85 struct ac_arg prim_mask;
86 struct ac_arg persp_sample;
87 struct ac_arg persp_center;
88 struct ac_arg persp_centroid;
89 struct ac_arg linear_sample;
90 struct ac_arg linear_center;
91 struct ac_arg linear_centroid;
92
93 /* CS */
94 struct ac_arg local_invocation_ids;
95 struct ac_arg num_work_groups;
96 struct ac_arg workgroup_ids[3];
97 struct ac_arg tg_size;
98
99 /* Vulkan only */
100 struct ac_arg push_constants;
101 struct ac_arg inline_push_consts[AC_MAX_INLINE_PUSH_CONSTS];
102 unsigned num_inline_push_consts;
103 unsigned base_inline_push_consts;
104 struct ac_arg view_index;
105 };
106
107 void ac_add_arg(struct ac_shader_args *info, enum ac_arg_regfile regfile,
108 unsigned registers, enum ac_arg_type type,
109 struct ac_arg *arg);
110
111 #endif
112