xref: /aosp_15_r20/external/mesa3d/src/intel/vulkan_hasvk/anv_nir.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2015 Intel 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 #ifndef ANV_NIR_H
25 #define ANV_NIR_H
26 
27 #include "nir/nir.h"
28 #include "anv_private.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 bool anv_nir_lower_multiview(nir_shader *shader, uint32_t view_mask);
35 
36 bool anv_nir_lower_ycbcr_textures(nir_shader *shader,
37                                   const struct anv_pipeline_layout *layout);
38 
39 static inline nir_address_format
anv_nir_ssbo_addr_format(const struct anv_physical_device * pdevice,enum elk_robustness_flags robust_flags)40 anv_nir_ssbo_addr_format(const struct anv_physical_device *pdevice,
41                          enum elk_robustness_flags robust_flags)
42 {
43    if (pdevice->has_a64_buffer_access) {
44       if (robust_flags & ELK_ROBUSTNESS_SSBO)
45          return nir_address_format_64bit_bounded_global;
46       else
47          return nir_address_format_64bit_global_32bit_offset;
48    } else {
49       return nir_address_format_32bit_index_offset;
50    }
51 }
52 
53 static inline nir_address_format
anv_nir_ubo_addr_format(const struct anv_physical_device * pdevice,enum elk_robustness_flags robust_flags)54 anv_nir_ubo_addr_format(const struct anv_physical_device *pdevice,
55                         enum elk_robustness_flags robust_flags)
56 {
57    if (pdevice->has_a64_buffer_access) {
58       if (robust_flags & ELK_ROBUSTNESS_UBO)
59          return nir_address_format_64bit_bounded_global;
60       else
61          return nir_address_format_64bit_global_32bit_offset;
62    } else {
63       return nir_address_format_32bit_index_offset;
64    }
65 }
66 
67 bool anv_nir_lower_ubo_loads(nir_shader *shader);
68 
69 void anv_nir_apply_pipeline_layout(nir_shader *shader,
70                                    const struct anv_physical_device *pdevice,
71                                    enum elk_robustness_flags robust_flags,
72                                    const struct anv_pipeline_layout *layout,
73                                    struct anv_pipeline_bind_map *map);
74 
75 void anv_nir_compute_push_layout(nir_shader *nir,
76                                  const struct anv_physical_device *pdevice,
77                                  enum elk_robustness_flags robust_flags,
78                                  struct elk_stage_prog_data *prog_data,
79                                  struct anv_pipeline_bind_map *map,
80                                  void *mem_ctx);
81 
82 void anv_nir_validate_push_layout(struct elk_stage_prog_data *prog_data,
83                                   struct anv_pipeline_bind_map *map);
84 
85 bool anv_nir_add_base_work_group_id(nir_shader *shader);
86 
87 #ifdef __cplusplus
88 }
89 #endif
90 
91 #endif /* ANV_NIR_H */
92