• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <stdbool.h>
28 #include <stdint.h>
29 
30 #define AC_MAX_INLINE_PUSH_CONSTS 8
31 
32 enum ac_arg_regfile
33 {
34    AC_ARG_SGPR,
35    AC_ARG_VGPR,
36 };
37 
38 enum ac_arg_type
39 {
40    AC_ARG_FLOAT,
41    AC_ARG_INT,
42    AC_ARG_CONST_PTR,       /* Pointer to i8 array */
43    AC_ARG_CONST_FLOAT_PTR, /* Pointer to f32 array */
44    AC_ARG_CONST_PTR_PTR,   /* Pointer to pointer to i8 array */
45    AC_ARG_CONST_DESC_PTR,  /* Pointer to v4i32 array */
46    AC_ARG_CONST_IMAGE_PTR, /* Pointer to v8i32 array */
47 };
48 
49 struct ac_arg {
50    uint8_t arg_index;
51    bool used;
52 };
53 
54 #define AC_MAX_ARGS 128
55 
56 struct ac_shader_args {
57    /* Info on how to declare arguments */
58    struct {
59       enum ac_arg_type type;
60       enum ac_arg_regfile file;
61       uint8_t offset;
62       uint8_t size;
63       bool skip;
64    } args[AC_MAX_ARGS];
65 
66    uint8_t arg_count;
67    uint8_t sgpr_count;
68    uint8_t num_sgprs_used;
69    uint8_t num_vgprs_used;
70 
71    struct ac_arg base_vertex;
72    struct ac_arg start_instance;
73    struct ac_arg draw_id;
74    struct ac_arg vertex_id;
75    struct ac_arg instance_id;
76    struct ac_arg tcs_patch_id;
77    struct ac_arg tcs_rel_ids;
78    struct ac_arg tes_patch_id;
79    struct ac_arg gs_prim_id;
80    struct ac_arg gs_invocation_id;
81 
82    /* PS */
83    struct ac_arg frag_pos[4];
84    struct ac_arg front_face;
85    struct ac_arg ancillary;
86    struct ac_arg sample_coverage;
87    struct ac_arg prim_mask;
88    struct ac_arg persp_sample;
89    struct ac_arg persp_center;
90    struct ac_arg persp_centroid;
91    struct ac_arg pull_model;
92    struct ac_arg linear_sample;
93    struct ac_arg linear_center;
94    struct ac_arg linear_centroid;
95 
96    /* CS */
97    struct ac_arg local_invocation_ids;
98    struct ac_arg num_work_groups;
99    struct ac_arg workgroup_ids[3];
100    struct ac_arg tg_size;
101 
102    /* Vulkan only */
103    struct ac_arg push_constants;
104    struct ac_arg inline_push_consts[AC_MAX_INLINE_PUSH_CONSTS];
105    unsigned num_inline_push_consts;
106    unsigned base_inline_push_consts;
107    struct ac_arg view_index;
108 };
109 
110 void ac_add_arg(struct ac_shader_args *info, enum ac_arg_regfile regfile, unsigned registers,
111                 enum ac_arg_type type, struct ac_arg *arg);
112 
113 #endif
114