2 * Copyright © 2017 Red Hat
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:
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
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
24 #include "ac_shader_info.h"
25 #include "ac_nir_to_llvm.h"
27 gather_intrinsic_info(nir_intrinsic_instr
*instr
, struct ac_shader_info
*info
)
29 switch (instr
->intrinsic
) {
30 case nir_intrinsic_interp_var_at_sample
:
31 info
->ps
.needs_sample_positions
= true;
33 case nir_intrinsic_load_draw_id
:
34 info
->vs
.needs_draw_id
= true;
36 case nir_intrinsic_load_num_work_groups
:
37 info
->cs
.grid_components_used
= instr
->num_components
;
45 gather_info_block(nir_block
*block
, struct ac_shader_info
*info
)
47 nir_foreach_instr(instr
, block
) {
48 switch (instr
->type
) {
49 case nir_instr_type_intrinsic
:
50 gather_intrinsic_info(nir_instr_as_intrinsic(instr
), info
);
59 gather_info_input_decl(nir_shader
*nir
,
60 const struct ac_nir_compiler_options
*options
,
62 struct ac_shader_info
*info
)
65 case MESA_SHADER_VERTEX
:
66 info
->vs
.has_vertex_buffers
= true;
74 ac_nir_shader_info_pass(struct nir_shader
*nir
,
75 const struct ac_nir_compiler_options
*options
,
76 struct ac_shader_info
*info
)
78 struct nir_function
*func
= (struct nir_function
*)exec_list_get_head(&nir
->functions
);
80 info
->needs_push_constants
= true;
82 info
->needs_push_constants
= false;
83 else if (!options
->layout
->push_constant_size
&&
84 !options
->layout
->dynamic_offset_count
)
85 info
->needs_push_constants
= false;
87 nir_foreach_variable(variable
, &nir
->inputs
)
88 gather_info_input_decl(nir
, options
, variable
, info
);
90 nir_foreach_block(block
, func
->impl
) {
91 gather_info_block(block
, info
);