2017-12-14 13:51:45 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Advanced Micro Devices, Inc.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef AC_SHADER_UTIL_H
|
|
|
|
#define AC_SHADER_UTIL_H
|
|
|
|
|
2019-09-25 16:40:07 +02:00
|
|
|
#include "ac_binary.h"
|
2020-09-07 09:58:36 +02:00
|
|
|
#include "amd_family.h"
|
2019-09-25 14:10:18 +02:00
|
|
|
#include "compiler/nir/nir.h"
|
2021-08-11 08:57:04 +02:00
|
|
|
#include "compiler/shader_enums.h"
|
2019-09-25 14:10:18 +02:00
|
|
|
|
2020-09-07 09:58:36 +02:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2019-09-27 09:26:14 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2020-09-07 09:58:36 +02:00
|
|
|
enum ac_image_dim
|
|
|
|
{
|
|
|
|
ac_image_1d,
|
|
|
|
ac_image_2d,
|
|
|
|
ac_image_3d,
|
|
|
|
ac_image_cube, // includes cube arrays
|
|
|
|
ac_image_1darray,
|
|
|
|
ac_image_2darray,
|
|
|
|
ac_image_2dmsaa,
|
|
|
|
ac_image_2darraymsaa,
|
2019-09-25 14:10:18 +02:00
|
|
|
};
|
2017-12-14 13:51:45 +01:00
|
|
|
|
2020-01-14 13:01:53 +00:00
|
|
|
struct ac_data_format_info {
|
2020-09-07 09:58:36 +02:00
|
|
|
uint8_t element_size;
|
|
|
|
uint8_t num_channels;
|
|
|
|
uint8_t chan_byte_size;
|
|
|
|
uint8_t chan_format;
|
2020-01-14 13:01:53 +00:00
|
|
|
};
|
|
|
|
|
2020-06-11 22:25:53 +02:00
|
|
|
struct ac_spi_color_formats {
|
2020-09-07 09:58:36 +02:00
|
|
|
unsigned normal : 8;
|
|
|
|
unsigned alpha : 8;
|
|
|
|
unsigned blend : 8;
|
|
|
|
unsigned blend_alpha : 8;
|
2020-06-11 22:25:53 +02:00
|
|
|
};
|
|
|
|
|
2020-10-08 16:49:44 +02:00
|
|
|
/* For ac_build_fetch_format.
|
|
|
|
*
|
|
|
|
* Note: FLOAT must be 0 (used for convenience of encoding in radeonsi).
|
|
|
|
*/
|
|
|
|
enum ac_fetch_format
|
|
|
|
{
|
|
|
|
AC_FETCH_FORMAT_FLOAT = 0,
|
|
|
|
AC_FETCH_FORMAT_FIXED,
|
|
|
|
AC_FETCH_FORMAT_UNORM,
|
|
|
|
AC_FETCH_FORMAT_SNORM,
|
|
|
|
AC_FETCH_FORMAT_USCALED,
|
|
|
|
AC_FETCH_FORMAT_SSCALED,
|
|
|
|
AC_FETCH_FORMAT_UINT,
|
|
|
|
AC_FETCH_FORMAT_SINT,
|
2020-10-08 16:52:36 +02:00
|
|
|
AC_FETCH_FORMAT_NONE,
|
2020-10-08 16:49:44 +02:00
|
|
|
};
|
|
|
|
|
radv,aco: lower texture descriptor loads in NIR
fossil-db (Sienna Cichlid):
Totals from 39445 (24.30% of 162293) affected shaders:
MaxWaves: 875988 -> 875972 (-0.00%)
Instrs: 35372561 -> 35234909 (-0.39%); split: -0.41%, +0.03%
CodeSize: 190237480 -> 189379240 (-0.45%); split: -0.47%, +0.02%
VGPRs: 1889856 -> 1889928 (+0.00%); split: -0.00%, +0.01%
SpillSGPRs: 10764 -> 10857 (+0.86%); split: -2.04%, +2.91%
SpillVGPRs: 1891 -> 1907 (+0.85%); split: -0.32%, +1.16%
Scratch: 260096 -> 261120 (+0.39%)
Latency: 477701150 -> 477578466 (-0.03%); split: -0.06%, +0.03%
InvThroughput: 87819847 -> 87830346 (+0.01%); split: -0.03%, +0.04%
VClause: 673353 -> 673829 (+0.07%); split: -0.04%, +0.11%
SClause: 1385396 -> 1366478 (-1.37%); split: -1.65%, +0.29%
Copies: 2327965 -> 2229134 (-4.25%); split: -4.58%, +0.34%
Branches: 906707 -> 906434 (-0.03%); split: -0.13%, +0.10%
PreSGPRs: 1874153 -> 1862698 (-0.61%); split: -1.34%, +0.73%
PreVGPRs: 1691382 -> 1691383 (+0.00%); split: -0.00%, +0.00%
Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12773>
2021-08-12 15:36:56 +01:00
|
|
|
enum ac_descriptor_type
|
|
|
|
{
|
|
|
|
AC_DESC_IMAGE,
|
|
|
|
AC_DESC_FMASK,
|
|
|
|
AC_DESC_SAMPLER,
|
|
|
|
AC_DESC_BUFFER,
|
|
|
|
AC_DESC_PLANE_0,
|
|
|
|
AC_DESC_PLANE_1,
|
|
|
|
AC_DESC_PLANE_2,
|
|
|
|
};
|
|
|
|
|
2022-05-13 22:34:17 -04:00
|
|
|
unsigned ac_get_spi_shader_z_format(bool writes_z, bool writes_stencil, bool writes_samplemask,
|
|
|
|
bool writes_mrt0_alpha);
|
2017-12-14 13:51:45 +01:00
|
|
|
|
2020-09-07 09:58:36 +02:00
|
|
|
unsigned ac_get_cb_shader_mask(unsigned spi_shader_col_format);
|
2017-12-15 15:37:18 +01:00
|
|
|
|
2022-05-12 02:50:17 -04:00
|
|
|
uint32_t ac_vgt_gs_mode(unsigned gs_max_vert_out, enum amd_gfx_level gfx_level);
|
2017-12-15 15:37:19 +01:00
|
|
|
|
2022-05-12 02:50:17 -04:00
|
|
|
unsigned ac_get_tbuffer_format(enum amd_gfx_level gfx_level, unsigned dfmt, unsigned nfmt);
|
2019-09-25 14:10:18 +02:00
|
|
|
|
2020-09-07 09:58:36 +02:00
|
|
|
const struct ac_data_format_info *ac_get_data_format_info(unsigned dfmt);
|
2020-01-14 13:01:53 +00:00
|
|
|
|
2022-05-12 02:50:17 -04:00
|
|
|
enum ac_image_dim ac_get_sampler_dim(enum amd_gfx_level gfx_level, enum glsl_sampler_dim dim,
|
2020-09-07 09:58:36 +02:00
|
|
|
bool is_array);
|
2019-09-25 14:10:18 +02:00
|
|
|
|
2022-05-12 02:50:17 -04:00
|
|
|
enum ac_image_dim ac_get_image_dim(enum amd_gfx_level gfx_level, enum glsl_sampler_dim sdim,
|
2020-09-07 09:58:36 +02:00
|
|
|
bool is_array);
|
2019-09-25 14:10:18 +02:00
|
|
|
|
2020-09-07 09:58:36 +02:00
|
|
|
unsigned ac_get_fs_input_vgpr_cnt(const struct ac_shader_config *config,
|
2021-12-13 22:37:41 -05:00
|
|
|
signed char *face_vgpr_index, signed char *ancillary_vgpr_index,
|
|
|
|
signed char *sample_coverage_vgpr_index_ptr);
|
2019-09-25 16:40:07 +02:00
|
|
|
|
ac,radv: use better export formats for 8-bit when RB+ isn't allowed
When RB+ is enabled, R8_UINT/R8_SINT/R8_UNORM should use FP16_ABGR
for 2x exporting performance. Otherwise, use 32_R to remove useless
instructions needed for 16-bit compressed exports.
fossils-db (Vega10):
Totals from 8858 (6.35% of 139517) affected shaders:
SGPRs: 801248 -> 801210 (-0.00%); split: -0.01%, +0.00%
VGPRs: 596224 -> 596120 (-0.02%); split: -0.02%, +0.01%
CodeSize: 71462452 -> 71356684 (-0.15%); split: -0.15%, +0.00%
MaxWaves: 37097 -> 37105 (+0.02%); split: +0.04%, -0.02%
Instrs: 13963177 -> 13950809 (-0.09%); split: -0.09%, +0.00%
Cycles: 1476539360 -> 1476489996 (-0.00%); split: -0.00%, +0.00%
VMEM: 2363008 -> 2361349 (-0.07%); split: +0.04%, -0.11%
SMEM: 550362 -> 549977 (-0.07%); split: +0.01%, -0.08%
VClause: 245704 -> 245727 (+0.01%); split: -0.01%, +0.02%
SClause: 485161 -> 485104 (-0.01%); split: -0.01%, +0.00%
Copies: 1420034 -> 1422310 (+0.16%); split: -0.01%, +0.17%
Branches: 518710 -> 518705 (-0.00%)
PreSGPRs: 706633 -> 706584 (-0.01%)
PreVGPRs: 547163 -> 547007 (-0.03%); split: -0.03%, +0.01%
Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7512>
2020-11-16 08:57:59 +01:00
|
|
|
void ac_choose_spi_color_formats(unsigned format, unsigned swap, unsigned ntype,
|
|
|
|
bool is_depth, bool use_rbplus,
|
2020-09-07 09:58:36 +02:00
|
|
|
struct ac_spi_color_formats *formats);
|
2020-06-11 22:25:53 +02:00
|
|
|
|
2021-07-07 16:37:30 -04:00
|
|
|
void ac_compute_late_alloc(const struct radeon_info *info, bool ngg, bool ngg_culling,
|
|
|
|
bool uses_scratch, unsigned *late_alloc_wave64, unsigned *cu_mask);
|
|
|
|
|
2021-08-11 08:57:04 +02:00
|
|
|
unsigned ac_compute_cs_workgroup_size(uint16_t sizes[3], bool variable, unsigned max);
|
|
|
|
|
2022-05-12 02:50:17 -04:00
|
|
|
unsigned ac_compute_lshs_workgroup_size(enum amd_gfx_level gfx_level, gl_shader_stage stage,
|
2021-08-11 08:57:04 +02:00
|
|
|
unsigned tess_num_patches,
|
|
|
|
unsigned tess_patch_in_vtx,
|
|
|
|
unsigned tess_patch_out_vtx);
|
|
|
|
|
2022-05-12 02:50:17 -04:00
|
|
|
unsigned ac_compute_esgs_workgroup_size(enum amd_gfx_level gfx_level, unsigned wave_size,
|
2021-08-11 08:57:04 +02:00
|
|
|
unsigned es_verts, unsigned gs_inst_prims);
|
|
|
|
|
|
|
|
unsigned ac_compute_ngg_workgroup_size(unsigned es_verts, unsigned gs_inst_prims,
|
|
|
|
unsigned max_vtx_out, unsigned prim_amp_factor);
|
|
|
|
|
2021-12-08 02:15:50 -05:00
|
|
|
void ac_set_reg_cu_en(void *cs, unsigned reg_offset, uint32_t value, uint32_t clear_mask,
|
|
|
|
unsigned value_shift, const struct radeon_info *info,
|
|
|
|
void set_sh_reg(void*, unsigned, uint32_t));
|
|
|
|
|
2022-04-02 00:45:24 -04:00
|
|
|
void ac_get_scratch_tmpring_size(const struct radeon_info *info, bool compute,
|
2022-01-26 19:38:26 -05:00
|
|
|
unsigned bytes_per_wave, unsigned *max_seen_bytes_per_wave,
|
|
|
|
uint32_t *tmpring_size);
|
|
|
|
|
2019-09-27 09:26:14 +02:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-12-14 13:51:45 +01:00
|
|
|
#endif
|