1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright 2012 Advanced Micro Devices, Inc. 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21bf215546Sopenharmony_ci * IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#ifndef AC_SHADER_UTIL_H 25bf215546Sopenharmony_ci#define AC_SHADER_UTIL_H 26bf215546Sopenharmony_ci 27bf215546Sopenharmony_ci#include "ac_binary.h" 28bf215546Sopenharmony_ci#include "amd_family.h" 29bf215546Sopenharmony_ci#include "compiler/nir/nir.h" 30bf215546Sopenharmony_ci#include "compiler/shader_enums.h" 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci#include <stdbool.h> 33bf215546Sopenharmony_ci#include <stdint.h> 34bf215546Sopenharmony_ci 35bf215546Sopenharmony_ci#ifdef __cplusplus 36bf215546Sopenharmony_ciextern "C" { 37bf215546Sopenharmony_ci#endif 38bf215546Sopenharmony_ci 39bf215546Sopenharmony_cienum ac_image_dim 40bf215546Sopenharmony_ci{ 41bf215546Sopenharmony_ci ac_image_1d, 42bf215546Sopenharmony_ci ac_image_2d, 43bf215546Sopenharmony_ci ac_image_3d, 44bf215546Sopenharmony_ci ac_image_cube, // includes cube arrays 45bf215546Sopenharmony_ci ac_image_1darray, 46bf215546Sopenharmony_ci ac_image_2darray, 47bf215546Sopenharmony_ci ac_image_2dmsaa, 48bf215546Sopenharmony_ci ac_image_2darraymsaa, 49bf215546Sopenharmony_ci}; 50bf215546Sopenharmony_ci 51bf215546Sopenharmony_cistruct ac_data_format_info { 52bf215546Sopenharmony_ci uint8_t element_size; 53bf215546Sopenharmony_ci uint8_t num_channels; 54bf215546Sopenharmony_ci uint8_t chan_byte_size; 55bf215546Sopenharmony_ci uint8_t chan_format; 56bf215546Sopenharmony_ci}; 57bf215546Sopenharmony_ci 58bf215546Sopenharmony_cistruct ac_spi_color_formats { 59bf215546Sopenharmony_ci unsigned normal : 8; 60bf215546Sopenharmony_ci unsigned alpha : 8; 61bf215546Sopenharmony_ci unsigned blend : 8; 62bf215546Sopenharmony_ci unsigned blend_alpha : 8; 63bf215546Sopenharmony_ci}; 64bf215546Sopenharmony_ci 65bf215546Sopenharmony_ci/* For ac_build_fetch_format. 66bf215546Sopenharmony_ci * 67bf215546Sopenharmony_ci * Note: FLOAT must be 0 (used for convenience of encoding in radeonsi). 68bf215546Sopenharmony_ci */ 69bf215546Sopenharmony_cienum ac_fetch_format 70bf215546Sopenharmony_ci{ 71bf215546Sopenharmony_ci AC_FETCH_FORMAT_FLOAT = 0, 72bf215546Sopenharmony_ci AC_FETCH_FORMAT_FIXED, 73bf215546Sopenharmony_ci AC_FETCH_FORMAT_UNORM, 74bf215546Sopenharmony_ci AC_FETCH_FORMAT_SNORM, 75bf215546Sopenharmony_ci AC_FETCH_FORMAT_USCALED, 76bf215546Sopenharmony_ci AC_FETCH_FORMAT_SSCALED, 77bf215546Sopenharmony_ci AC_FETCH_FORMAT_UINT, 78bf215546Sopenharmony_ci AC_FETCH_FORMAT_SINT, 79bf215546Sopenharmony_ci AC_FETCH_FORMAT_NONE, 80bf215546Sopenharmony_ci}; 81bf215546Sopenharmony_ci 82bf215546Sopenharmony_cienum ac_descriptor_type 83bf215546Sopenharmony_ci{ 84bf215546Sopenharmony_ci AC_DESC_IMAGE, 85bf215546Sopenharmony_ci AC_DESC_FMASK, 86bf215546Sopenharmony_ci AC_DESC_SAMPLER, 87bf215546Sopenharmony_ci AC_DESC_BUFFER, 88bf215546Sopenharmony_ci AC_DESC_PLANE_0, 89bf215546Sopenharmony_ci AC_DESC_PLANE_1, 90bf215546Sopenharmony_ci AC_DESC_PLANE_2, 91bf215546Sopenharmony_ci}; 92bf215546Sopenharmony_ci 93bf215546Sopenharmony_ciunsigned ac_get_spi_shader_z_format(bool writes_z, bool writes_stencil, bool writes_samplemask, 94bf215546Sopenharmony_ci bool writes_mrt0_alpha); 95bf215546Sopenharmony_ci 96bf215546Sopenharmony_ciunsigned ac_get_cb_shader_mask(unsigned spi_shader_col_format); 97bf215546Sopenharmony_ci 98bf215546Sopenharmony_ciuint32_t ac_vgt_gs_mode(unsigned gs_max_vert_out, enum amd_gfx_level gfx_level); 99bf215546Sopenharmony_ci 100bf215546Sopenharmony_ciunsigned ac_get_tbuffer_format(enum amd_gfx_level gfx_level, unsigned dfmt, unsigned nfmt); 101bf215546Sopenharmony_ci 102bf215546Sopenharmony_ciconst struct ac_data_format_info *ac_get_data_format_info(unsigned dfmt); 103bf215546Sopenharmony_ci 104bf215546Sopenharmony_cienum ac_image_dim ac_get_sampler_dim(enum amd_gfx_level gfx_level, enum glsl_sampler_dim dim, 105bf215546Sopenharmony_ci bool is_array); 106bf215546Sopenharmony_ci 107bf215546Sopenharmony_cienum ac_image_dim ac_get_image_dim(enum amd_gfx_level gfx_level, enum glsl_sampler_dim sdim, 108bf215546Sopenharmony_ci bool is_array); 109bf215546Sopenharmony_ci 110bf215546Sopenharmony_ciunsigned ac_get_fs_input_vgpr_cnt(const struct ac_shader_config *config, 111bf215546Sopenharmony_ci signed char *face_vgpr_index, signed char *ancillary_vgpr_index, 112bf215546Sopenharmony_ci signed char *sample_coverage_vgpr_index_ptr); 113bf215546Sopenharmony_ci 114bf215546Sopenharmony_civoid ac_choose_spi_color_formats(unsigned format, unsigned swap, unsigned ntype, 115bf215546Sopenharmony_ci bool is_depth, bool use_rbplus, 116bf215546Sopenharmony_ci struct ac_spi_color_formats *formats); 117bf215546Sopenharmony_ci 118bf215546Sopenharmony_civoid ac_compute_late_alloc(const struct radeon_info *info, bool ngg, bool ngg_culling, 119bf215546Sopenharmony_ci bool uses_scratch, unsigned *late_alloc_wave64, unsigned *cu_mask); 120bf215546Sopenharmony_ci 121bf215546Sopenharmony_ciunsigned ac_compute_cs_workgroup_size(uint16_t sizes[3], bool variable, unsigned max); 122bf215546Sopenharmony_ci 123bf215546Sopenharmony_ciunsigned ac_compute_lshs_workgroup_size(enum amd_gfx_level gfx_level, gl_shader_stage stage, 124bf215546Sopenharmony_ci unsigned tess_num_patches, 125bf215546Sopenharmony_ci unsigned tess_patch_in_vtx, 126bf215546Sopenharmony_ci unsigned tess_patch_out_vtx); 127bf215546Sopenharmony_ci 128bf215546Sopenharmony_ciunsigned ac_compute_esgs_workgroup_size(enum amd_gfx_level gfx_level, unsigned wave_size, 129bf215546Sopenharmony_ci unsigned es_verts, unsigned gs_inst_prims); 130bf215546Sopenharmony_ci 131bf215546Sopenharmony_ciunsigned ac_compute_ngg_workgroup_size(unsigned es_verts, unsigned gs_inst_prims, 132bf215546Sopenharmony_ci unsigned max_vtx_out, unsigned prim_amp_factor); 133bf215546Sopenharmony_ci 134bf215546Sopenharmony_civoid ac_set_reg_cu_en(void *cs, unsigned reg_offset, uint32_t value, uint32_t clear_mask, 135bf215546Sopenharmony_ci unsigned value_shift, const struct radeon_info *info, 136bf215546Sopenharmony_ci void set_sh_reg(void*, unsigned, uint32_t)); 137bf215546Sopenharmony_ci 138bf215546Sopenharmony_civoid ac_get_scratch_tmpring_size(const struct radeon_info *info, 139bf215546Sopenharmony_ci unsigned bytes_per_wave, unsigned *max_seen_bytes_per_wave, 140bf215546Sopenharmony_ci uint32_t *tmpring_size); 141bf215546Sopenharmony_ci 142bf215546Sopenharmony_ci#ifdef __cplusplus 143bf215546Sopenharmony_ci} 144bf215546Sopenharmony_ci#endif 145bf215546Sopenharmony_ci 146bf215546Sopenharmony_ci#endif 147