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  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * 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 NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #include "compiler/shader_enums.h"
25 #include "util/list.h"
26 #include "util/macros.h"
27 #include "ac_shader_args.h"
28 #include "amd_family.h"
29 #include "radv_constants.h"
30 #include "radv_shader.h"
31 
32 struct radv_shader_args {
33    struct ac_shader_args ac;
34 
35    struct ac_arg descriptor_sets[MAX_SETS];
36    struct ac_arg ring_offsets;
37 
38    /* Streamout */
39    struct ac_arg streamout_buffers;
40 
41    /* NGG GS */
42    struct ac_arg ngg_gs_state;
43    struct ac_arg ngg_culling_settings;
44    struct ac_arg ngg_viewport_scale[2];
45    struct ac_arg ngg_viewport_translate[2];
46 
47    struct ac_arg prolog_inputs;
48    struct ac_arg vs_inputs[MAX_VERTEX_ATTRIBS];
49 
50    struct radv_userdata_locations user_sgprs_locs;
51    unsigned num_user_sgprs;
52 
53    bool explicit_scratch_args;
54    bool remap_spi_ps_input;
55    bool load_grid_size_from_user_sgpr;
56    bool is_gs_copy_shader;
57    bool is_trap_handler_shader;
58 };
59 
60 static inline struct radv_shader_args *
radv_shader_args_from_ac(struct ac_shader_args * args)61 radv_shader_args_from_ac(struct ac_shader_args *args)
62 {
63    return container_of(args, struct radv_shader_args, ac);
64 }
65 
66 struct radv_pipeline_key;
67 struct radv_shader_info;
68 
69 void radv_declare_shader_args(enum chip_class chip_class, const struct radv_pipeline_key *key,
70                               const struct radv_shader_info *info, gl_shader_stage stage,
71                               bool has_previous_stage, gl_shader_stage previous_stage,
72                               struct radv_shader_args *args);
73