101e04c3fSmrg/*
201e04c3fSmrg * Copyright © 2015 Intel Corporation
301e04c3fSmrg *
401e04c3fSmrg * Permission is hereby granted, free of charge, to any person obtaining a
501e04c3fSmrg * copy of this software and associated documentation files (the "Software"),
601e04c3fSmrg * to deal in the Software without restriction, including without limitation
701e04c3fSmrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
801e04c3fSmrg * and/or sell copies of the Software, and to permit persons to whom the
901e04c3fSmrg * Software is furnished to do so, subject to the following conditions:
1001e04c3fSmrg *
1101e04c3fSmrg * The above copyright notice and this permission notice (including the next
1201e04c3fSmrg * paragraph) shall be included in all copies or substantial portions of the
1301e04c3fSmrg * Software.
1401e04c3fSmrg *
1501e04c3fSmrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1601e04c3fSmrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1701e04c3fSmrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
1801e04c3fSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1901e04c3fSmrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
2001e04c3fSmrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
2101e04c3fSmrg * IN THE SOFTWARE.
2201e04c3fSmrg */
2301e04c3fSmrg
2401e04c3fSmrg#ifndef ANV_NIR_H
2501e04c3fSmrg#define ANV_NIR_H
2601e04c3fSmrg
2701e04c3fSmrg#include "nir/nir.h"
2801e04c3fSmrg#include "anv_private.h"
2901e04c3fSmrg
3001e04c3fSmrg#ifdef __cplusplus
3101e04c3fSmrgextern "C" {
3201e04c3fSmrg#endif
3301e04c3fSmrg
347ec681f3Smrgbool anv_check_for_primitive_replication(nir_shader **shaders,
357ec681f3Smrg                                         struct anv_graphics_pipeline *pipeline);
3601e04c3fSmrg
377ec681f3Smrgbool anv_nir_lower_multiview(nir_shader *shader,
387ec681f3Smrg                             struct anv_graphics_pipeline *pipeline);
3901e04c3fSmrg
4001e04c3fSmrgbool anv_nir_lower_ycbcr_textures(nir_shader *shader,
417ec681f3Smrg                                  const struct anv_pipeline_layout *layout);
4201e04c3fSmrg
439f464c52Smayastatic inline nir_address_format
449f464c52Smayaanv_nir_ssbo_addr_format(const struct anv_physical_device *pdevice,
459f464c52Smaya                         bool robust_buffer_access)
469f464c52Smaya{
479f464c52Smaya   if (pdevice->has_a64_buffer_access) {
489f464c52Smaya      if (robust_buffer_access)
499f464c52Smaya         return nir_address_format_64bit_bounded_global;
509f464c52Smaya      else
517ec681f3Smrg         return nir_address_format_64bit_global_32bit_offset;
529f464c52Smaya   } else {
539f464c52Smaya      return nir_address_format_32bit_index_offset;
549f464c52Smaya   }
559f464c52Smaya}
569f464c52Smaya
577ec681f3Smrgstatic inline nir_address_format
587ec681f3Smrganv_nir_ubo_addr_format(const struct anv_physical_device *pdevice,
597ec681f3Smrg                        bool robust_buffer_access)
607ec681f3Smrg{
617ec681f3Smrg   if (pdevice->has_a64_buffer_access) {
627ec681f3Smrg      if (robust_buffer_access)
637ec681f3Smrg         return nir_address_format_64bit_bounded_global;
647ec681f3Smrg      else
657ec681f3Smrg         return nir_address_format_64bit_global_32bit_offset;
667ec681f3Smrg   } else {
677ec681f3Smrg      return nir_address_format_32bit_index_offset;
687ec681f3Smrg   }
697ec681f3Smrg}
707ec681f3Smrg
717ec681f3Smrgbool anv_nir_lower_ubo_loads(nir_shader *shader);
727ec681f3Smrg
7301e04c3fSmrgvoid anv_nir_apply_pipeline_layout(const struct anv_physical_device *pdevice,
7401e04c3fSmrg                                   bool robust_buffer_access,
757ec681f3Smrg                                   const struct anv_pipeline_layout *layout,
7601e04c3fSmrg                                   nir_shader *shader,
7701e04c3fSmrg                                   struct anv_pipeline_bind_map *map);
7801e04c3fSmrg
797ec681f3Smrgvoid anv_nir_compute_push_layout(const struct anv_physical_device *pdevice,
807ec681f3Smrg                                 bool robust_buffer_access,
817ec681f3Smrg                                 nir_shader *nir,
827ec681f3Smrg                                 struct brw_stage_prog_data *prog_data,
837ec681f3Smrg                                 struct anv_pipeline_bind_map *map,
847ec681f3Smrg                                 void *mem_ctx);
857ec681f3Smrg
867ec681f3Smrgvoid anv_nir_validate_push_layout(struct brw_stage_prog_data *prog_data,
877ec681f3Smrg                                  struct anv_pipeline_bind_map *map);
887ec681f3Smrg
897ec681f3Smrgbool anv_nir_add_base_work_group_id(nir_shader *shader);
9001e04c3fSmrg
9101e04c3fSmrg#ifdef __cplusplus
9201e04c3fSmrg}
9301e04c3fSmrg#endif
9401e04c3fSmrg
9501e04c3fSmrg#endif /* ANV_NIR_H */
96