2016-01-21 09:19:53 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright © 2015-2016 Intel Corporation
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "brw_compiler.h"
|
2017-03-09 16:01:30 -08:00
|
|
|
#include "brw_eu.h"
|
2023-11-06 12:52:50 +02:00
|
|
|
#include "brw_nir.h"
|
2024-02-28 13:59:35 -08:00
|
|
|
#include "brw_private.h"
|
2021-04-05 10:44:41 -07:00
|
|
|
#include "dev/intel_debug.h"
|
2016-01-21 09:19:53 -08:00
|
|
|
#include "compiler/nir/nir.h"
|
2022-09-13 12:49:56 +03:00
|
|
|
#include "util/u_debug.h"
|
2016-01-21 09:19:53 -08:00
|
|
|
|
2023-11-06 12:52:50 +02:00
|
|
|
const struct nir_shader_compiler_options brw_scalar_nir_options = {
|
2024-02-14 22:41:17 -08:00
|
|
|
.avoid_ternary_with_two_constants = true,
|
2024-04-05 11:15:36 -04:00
|
|
|
.compact_arrays = true,
|
nir: introduce discard_is_demote compiler option
This new option indicates that the driver emits the same
code for nir_intrinsic_discard and nir_intrinsic_demote.
Otherwise, it is assumed that discard is implemented as
terminate.
spirv_to_nir uses this option in order to directly emit
nir_demote in case of OpKill.
RADV GFX11:
Totals from 3965 (4.99% of 79439) affected shaders:
MaxWaves: 119418 -> 119424 (+0.01%); split: +0.03%, -0.03%
Instrs: 1608753 -> 1620830 (+0.75%); split: -0.18%, +0.93%
CodeSize: 8759152 -> 8785152 (+0.30%); split: -0.18%, +0.48%
VGPRs: 152292 -> 149232 (-2.01%); split: -2.37%, +0.36%
Latency: 9162314 -> 10033923 (+9.51%); split: -0.46%, +9.97%
InvThroughput: 1491656 -> 1493408 (+0.12%); split: -0.10%, +0.22%
VClause: 21424 -> 21452 (+0.13%); split: -0.31%, +0.44%
SClause: 53598 -> 55871 (+4.24%); split: -2.15%, +6.39%
Copies: 90553 -> 90462 (-0.10%); split: -2.91%, +2.81%
Branches: 16283 -> 16311 (+0.17%)
PreSGPRs: 113993 -> 113254 (-0.65%); split: -1.84%, +1.19%
PreVGPRs: 110951 -> 108914 (-1.84%); split: -2.08%, +0.24%
VALU: 963192 -> 963167 (-0.00%); split: -0.01%, +0.01%
SALU: 87926 -> 90795 (+3.26%); split: -2.92%, +6.18%
VMEM: 25937 -> 25936 (-0.00%)
SMEM: 110012 -> 109799 (-0.19%); split: -0.20%, +0.01%
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27617>
2024-02-14 12:38:40 +01:00
|
|
|
.discard_is_demote = true,
|
2024-02-14 22:41:17 -08:00
|
|
|
.divergence_analysis_options =
|
|
|
|
|
(nir_divergence_single_patch_per_tcs_subgroup |
|
|
|
|
|
nir_divergence_single_patch_per_tes_subgroup |
|
|
|
|
|
nir_divergence_shader_record_ptr_uniform),
|
|
|
|
|
.force_indirect_unrolling = nir_var_function_temp,
|
2024-02-17 07:49:03 -08:00
|
|
|
.has_bfe = true,
|
|
|
|
|
.has_bfi = true,
|
|
|
|
|
.has_bfm = true,
|
2024-02-14 22:41:17 -08:00
|
|
|
.has_pack_32_4x8 = true,
|
|
|
|
|
.has_uclz = true,
|
|
|
|
|
.lower_base_vertex = true,
|
|
|
|
|
.lower_bitfield_extract = true,
|
|
|
|
|
.lower_bitfield_insert = true,
|
|
|
|
|
.lower_device_index_to_zero = true,
|
|
|
|
|
.lower_fdiv = true,
|
|
|
|
|
.lower_fisnormal = true,
|
|
|
|
|
.lower_flrp16 = true,
|
|
|
|
|
.lower_flrp64 = true,
|
|
|
|
|
.lower_fmod = true,
|
|
|
|
|
.lower_hadd64 = true,
|
|
|
|
|
.lower_insert_byte = true,
|
|
|
|
|
.lower_insert_word = true,
|
|
|
|
|
.lower_isign = true,
|
|
|
|
|
.lower_ldexp = true,
|
|
|
|
|
.lower_pack_half_2x16 = true,
|
2016-01-25 11:07:28 -08:00
|
|
|
.lower_pack_snorm_2x16 = true,
|
2024-02-14 22:41:17 -08:00
|
|
|
.lower_pack_snorm_4x8 = true,
|
2016-01-25 11:07:28 -08:00
|
|
|
.lower_pack_unorm_2x16 = true,
|
2024-02-14 22:41:17 -08:00
|
|
|
.lower_pack_unorm_4x8 = true,
|
|
|
|
|
.lower_scmp = true,
|
|
|
|
|
.lower_to_scalar = true,
|
|
|
|
|
.lower_uadd_carry = true,
|
|
|
|
|
.lower_ufind_msb = true,
|
|
|
|
|
.lower_uniforms_to_ubo = true,
|
|
|
|
|
.lower_unpack_half_2x16 = true,
|
2016-01-25 11:07:28 -08:00
|
|
|
.lower_unpack_snorm_2x16 = true,
|
2024-02-14 22:41:17 -08:00
|
|
|
.lower_unpack_snorm_4x8 = true,
|
2016-01-25 11:07:28 -08:00
|
|
|
.lower_unpack_unorm_2x16 = true,
|
2024-02-14 22:41:17 -08:00
|
|
|
.lower_unpack_unorm_4x8 = true,
|
|
|
|
|
.lower_usub_borrow = true,
|
2016-12-13 11:36:51 +11:00
|
|
|
.max_unroll_iterations = 32,
|
2024-02-14 22:41:17 -08:00
|
|
|
.support_16bit_alu = true,
|
|
|
|
|
.use_interpolated_input_intrinsics = true,
|
|
|
|
|
.vectorize_io = true,
|
|
|
|
|
.vectorize_tess_levels = true,
|
|
|
|
|
.vertex_id_zero_based = true,
|
2024-07-24 13:33:23 -04:00
|
|
|
.has_ddx_intrinsics = true,
|
|
|
|
|
.scalarize_ddx = true,
|
2016-01-21 09:30:05 -08:00
|
|
|
};
|
|
|
|
|
|
2016-01-21 09:19:53 -08:00
|
|
|
struct brw_compiler *
|
2021-04-05 13:19:39 -07:00
|
|
|
brw_compiler_create(void *mem_ctx, const struct intel_device_info *devinfo)
|
2016-01-21 09:19:53 -08:00
|
|
|
{
|
|
|
|
|
struct brw_compiler *compiler = rzalloc(mem_ctx, struct brw_compiler);
|
2024-02-14 17:41:46 -08:00
|
|
|
assert(devinfo->ver >= 9);
|
2016-01-21 09:19:53 -08:00
|
|
|
|
|
|
|
|
compiler->devinfo = devinfo;
|
|
|
|
|
|
2022-06-29 14:13:31 -07:00
|
|
|
brw_init_isa_info(&compiler->isa, devinfo);
|
|
|
|
|
|
2016-01-21 09:19:53 -08:00
|
|
|
brw_fs_alloc_reg_sets(compiler);
|
|
|
|
|
|
2022-09-13 12:49:56 +03:00
|
|
|
compiler->precise_trig = debug_get_bool_option("INTEL_PRECISE_TRIG", false);
|
2016-06-11 13:17:27 -07:00
|
|
|
|
2022-08-16 11:02:20 -07:00
|
|
|
compiler->use_tcs_multi_patch = devinfo->ver >= 12;
|
intel/compiler: Implement TCS 8_PATCH mode and INTEL_DEBUG=tcs8
Our tessellation control shaders can be dispatched in several modes.
- SINGLE_PATCH (Gen7+) processes a single patch per thread, with each
channel corresponding to a different patch vertex. PATCHLIST_N will
launch (N / 8) threads. If N is less than 8, some channels will be
disabled, leaving some untapped hardware capabilities. Conditionals
based on gl_InvocationID are non-uniform, which means that they'll
often have to execute both paths. However, if there are fewer than
8 vertices, all invocations will happen within a single thread, so
barriers can become no-ops, which is nice. We also burn a maximum
of 4 registers for ICP handles, so we can compile without regard for
the value of N. It also works in all cases.
- DUAL_PATCH mode processes up to two patches at a time, where the first
four channels come from patch 1, and the second group of four come
from patch 2. This tries to provide better EU utilization for small
patches (N <= 4). It cannot be used in all cases.
- 8_PATCH mode processes 8 patches at a time, with a thread launched per
vertex in the patch. Each channel corresponds to the same vertex, but
in each of the 8 patches. This utilizes all channels even for small
patches. It also makes conditions on gl_InvocationID uniform, leading
to proper jumps. Barriers, unfortunately, become real. Worse, for
PATCHLIST_N, the thread payload burns N registers for ICP handles.
This can burn up to 32 registers, or 1/4 of our register file, for
URB handles. For Vulkan (and DX), we know the number of vertices at
compile time, so we can limit the amount of waste. In GL, the patch
dimension is dynamic state, so we either would have to waste all 32
(not reasonable) or guess (badly) and recompile. This is unfortunate.
Because we can only spawn 16 thread instances, we can only use this
mode for PATCHLIST_16 and smaller. The rest must use SINGLE_PATCH.
This patch implements the new 8_PATCH TCS mode, but leaves us using
SINGLE_PATCH by default. A new INTEL_DEBUG=tcs8 flag will switch to
using 8_PATCH mode for testing and benchmarking purposes. We may
want to consider using 8_PATCH mode in Vulkan in some cases.
The data I've seen shows that 8_PATCH mode can be more efficient in
some cases, but SINGLE_PATCH mode (the one we use today) is faster
in other cases. Ultimately, the TES matters much more than the TCS
for performance, so the decision may not matter much.
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2019-05-03 14:57:54 -07:00
|
|
|
|
2024-07-26 21:34:49 -07:00
|
|
|
compiler->indirect_ubos_use_sampler = devinfo->ver < 12;
|
2020-02-21 11:29:06 -06:00
|
|
|
|
2023-10-10 15:35:46 -07:00
|
|
|
compiler->lower_dpas = devinfo->verx10 < 125 ||
|
2024-01-10 13:13:06 -08:00
|
|
|
intel_device_info_is_mtl(devinfo) ||
|
2024-02-01 18:14:23 -08:00
|
|
|
(intel_device_info_is_arl(devinfo) &&
|
|
|
|
|
devinfo->platform != INTEL_PLATFORM_ARL_H) ||
|
2023-10-10 15:35:46 -07:00
|
|
|
debug_get_bool_option("INTEL_LOWER_DPAS", false);
|
|
|
|
|
|
2019-02-25 17:17:29 -08:00
|
|
|
nir_lower_int64_options int64_options =
|
|
|
|
|
nir_lower_imul64 |
|
|
|
|
|
nir_lower_isign64 |
|
|
|
|
|
nir_lower_divmod64 |
|
intel/compiler: Fix 64-bit ufind_msb, find_lsb, and bit_count
We only support 32-bit versions of ufind_msb, find_lsb, and bit_count,
so we need to lower them via nir_lower_int64.
Previously, we were failing to do so on platforms older than Icelake
and let those operations fall through to nir_lower_bit_size, which
used a callback to determine it should lower them for bit_size != 32.
However, that pass only emulates small bit-size operations by promoting
them to supported, larger bit-sizes (i.e. 16-bit using 32-bit). It
doesn't support emulating larger operations (i.e. 64-bit using 32-bit).
So nir_lower_bit_size would just u2u32 the 64-bit source, causing us to
flat ignore half of the bits.
Commit 78a195f252d (intel/compiler: Postpone most int64 lowering to
brw_postprocess_nir) provoked this bug on Icelake and later as well,
by moving the nir_lower_int64 handling for ufind_msb until late in
compilation, allowing it to reach nir_lower_bit_size which broke it.
To fix this, we always set int64 lowering for these opcodes, and also
correct the nir_lower_bit_size callback to ignore 64-bit operations.
Cc: mesa-stable
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23123>
2023-05-18 17:19:42 -07:00
|
|
|
nir_lower_imul_high64 |
|
|
|
|
|
nir_lower_find_lsb64 |
|
|
|
|
|
nir_lower_ufind_msb64 |
|
2023-08-14 12:58:51 -07:00
|
|
|
nir_lower_bit_count64 |
|
|
|
|
|
nir_lower_iadd3_64;
|
2019-02-25 17:17:29 -08:00
|
|
|
nir_lower_doubles_options fp64_options =
|
|
|
|
|
nir_lower_drcp |
|
|
|
|
|
nir_lower_dsqrt |
|
|
|
|
|
nir_lower_drsq |
|
2024-05-01 16:03:33 -07:00
|
|
|
nir_lower_dsign |
|
2019-02-25 17:17:29 -08:00
|
|
|
nir_lower_dtrunc |
|
|
|
|
|
nir_lower_dfloor |
|
|
|
|
|
nir_lower_dceil |
|
|
|
|
|
nir_lower_dfract |
|
|
|
|
|
nir_lower_dround_even |
|
2019-07-11 16:59:31 -05:00
|
|
|
nir_lower_dmod |
|
|
|
|
|
nir_lower_dsub |
|
|
|
|
|
nir_lower_ddiv;
|
2019-02-25 17:17:29 -08:00
|
|
|
|
2022-03-09 16:56:08 -08:00
|
|
|
if (!devinfo->has_64bit_float || INTEL_DEBUG(DEBUG_SOFT64))
|
2019-02-25 17:17:29 -08:00
|
|
|
fp64_options |= nir_lower_fp64_full_software;
|
2022-03-09 16:56:08 -08:00
|
|
|
if (!devinfo->has_64bit_int)
|
|
|
|
|
int64_options |= (nir_lower_int64_options)~0;
|
2019-02-25 17:17:29 -08:00
|
|
|
|
2022-06-22 18:31:08 +02:00
|
|
|
/* The Bspec's section titled "Instruction_multiply[DevBDW+]" claims that
|
2021-03-29 15:46:12 -07:00
|
|
|
* destination type can be Quadword and source type Doubleword for Gfx8 and
|
|
|
|
|
* Gfx9. So, lower 64 bit multiply instruction on rest of the platforms.
|
2019-02-14 23:08:39 -08:00
|
|
|
*/
|
2024-02-17 07:49:03 -08:00
|
|
|
if (devinfo->ver > 9)
|
2019-02-14 23:08:39 -08:00
|
|
|
int64_options |= nir_lower_imul_2x32_64;
|
|
|
|
|
|
2022-09-28 17:31:07 -07:00
|
|
|
if (devinfo->ver >= 20)
|
|
|
|
|
int64_options |= (nir_lower_icmp64 | nir_lower_minmax64 |
|
|
|
|
|
nir_lower_logic64 | nir_lower_ufind_msb64 |
|
|
|
|
|
nir_lower_bit_count64 |
|
|
|
|
|
nir_lower_bcsel64 | nir_lower_conv64 |
|
|
|
|
|
nir_lower_extract64 | nir_lower_scan_reduce_bitwise64 |
|
2023-01-04 12:52:07 -08:00
|
|
|
nir_lower_scan_reduce_iadd64 | nir_lower_subgroup_shuffle64 |
|
|
|
|
|
nir_lower_iadd_sat64 | nir_lower_uadd_sat64);
|
2022-09-28 17:31:07 -07:00
|
|
|
|
2016-01-21 09:19:53 -08:00
|
|
|
/* We want the GLSL compiler to emit code that uses condition codes */
|
2019-02-03 19:46:16 -06:00
|
|
|
for (int i = 0; i < MESA_ALL_SHADER_STAGES; i++) {
|
2019-02-25 17:17:29 -08:00
|
|
|
struct nir_shader_compiler_options *nir_options =
|
|
|
|
|
rzalloc(compiler, struct nir_shader_compiler_options);
|
2024-02-14 22:41:17 -08:00
|
|
|
*nir_options = brw_scalar_nir_options;
|
|
|
|
|
int64_options |= nir_lower_usub_sat64;
|
2019-04-18 17:48:15 -07:00
|
|
|
|
2024-02-17 07:49:03 -08:00
|
|
|
/* Gfx11 loses LRP. */
|
|
|
|
|
nir_options->lower_flrp32 = devinfo->ver >= 11;
|
2019-04-18 17:48:15 -07:00
|
|
|
|
2024-02-17 07:49:03 -08:00
|
|
|
nir_options->lower_fpow = devinfo->ver >= 12;
|
2022-12-13 09:43:39 -08:00
|
|
|
|
2024-01-16 12:55:10 +01:00
|
|
|
nir_options->has_rotate16 = devinfo->ver >= 11;
|
|
|
|
|
nir_options->has_rotate32 = devinfo->ver >= 11;
|
2021-06-28 17:49:01 -07:00
|
|
|
nir_options->has_iadd3 = devinfo->verx10 >= 125;
|
2019-05-30 14:14:52 -07:00
|
|
|
|
2021-11-26 19:27:03 +02:00
|
|
|
nir_options->has_sdot_4x8 = devinfo->ver >= 12;
|
|
|
|
|
nir_options->has_udot_4x8 = devinfo->ver >= 12;
|
2021-02-23 18:46:53 -08:00
|
|
|
nir_options->has_sudot_4x8 = devinfo->ver >= 12;
|
2023-12-05 19:58:20 -06:00
|
|
|
nir_options->has_sdot_4x8_sat = devinfo->ver >= 12;
|
|
|
|
|
nir_options->has_udot_4x8_sat = devinfo->ver >= 12;
|
|
|
|
|
nir_options->has_sudot_4x8_sat = devinfo->ver >= 12;
|
2021-02-23 18:46:53 -08:00
|
|
|
|
2019-02-25 17:17:29 -08:00
|
|
|
nir_options->lower_int64_options = int64_options;
|
|
|
|
|
nir_options->lower_doubles_options = fp64_options;
|
2019-06-17 17:12:25 -05:00
|
|
|
|
|
|
|
|
nir_options->unify_interfaces = i < MESA_SHADER_FRAGMENT;
|
|
|
|
|
|
2021-07-29 19:34:26 +10:00
|
|
|
nir_options->force_indirect_unrolling |=
|
|
|
|
|
brw_nir_no_indirect_mask(compiler, i);
|
|
|
|
|
|
2022-08-16 11:02:20 -07:00
|
|
|
if (compiler->use_tcs_multi_patch) {
|
|
|
|
|
/* TCS MULTI_PATCH mode has multiple patches per subgroup */
|
2020-10-16 16:05:52 -07:00
|
|
|
nir_options->divergence_analysis_options &=
|
|
|
|
|
~nir_divergence_single_patch_per_tcs_subgroup;
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-07 19:26:22 -08:00
|
|
|
if (devinfo->ver < 12)
|
|
|
|
|
nir_options->divergence_analysis_options |=
|
|
|
|
|
nir_divergence_single_prim_per_subgroup;
|
|
|
|
|
|
2021-12-07 15:53:49 +10:00
|
|
|
compiler->nir_options[i] = nir_options;
|
2016-01-21 09:19:53 -08:00
|
|
|
}
|
|
|
|
|
|
2023-07-21 11:50:51 +02:00
|
|
|
compiler->mesh.mue_header_packing =
|
|
|
|
|
(unsigned)debug_get_num_option("INTEL_MESH_HEADER_PACKING", 3);
|
|
|
|
|
compiler->mesh.mue_compaction =
|
|
|
|
|
debug_get_bool_option("INTEL_MESH_COMPACTION", true);
|
|
|
|
|
|
2016-01-21 09:19:53 -08:00
|
|
|
return compiler;
|
|
|
|
|
}
|
2017-10-21 01:30:13 -07:00
|
|
|
|
2018-07-25 14:31:05 -07:00
|
|
|
static void
|
|
|
|
|
insert_u64_bit(uint64_t *val, bool add)
|
|
|
|
|
{
|
|
|
|
|
*val = (*val << 1) | !!add;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint64_t
|
|
|
|
|
brw_get_compiler_config_value(const struct brw_compiler *compiler)
|
|
|
|
|
{
|
|
|
|
|
uint64_t config = 0;
|
2023-01-21 12:49:44 +01:00
|
|
|
unsigned bits = 0;
|
|
|
|
|
|
2018-07-25 14:31:05 -07:00
|
|
|
insert_u64_bit(&config, compiler->precise_trig);
|
2023-01-21 12:49:44 +01:00
|
|
|
bits++;
|
2024-01-17 10:25:29 -08:00
|
|
|
insert_u64_bit(&config, compiler->lower_dpas);
|
|
|
|
|
bits++;
|
2024-01-17 10:31:32 -08:00
|
|
|
insert_u64_bit(&config, compiler->mesh.mue_compaction);
|
|
|
|
|
bits++;
|
2021-10-08 12:09:04 -07:00
|
|
|
|
2018-07-25 14:31:05 -07:00
|
|
|
uint64_t mask = DEBUG_DISK_CACHE_MASK;
|
2023-01-21 12:49:44 +01:00
|
|
|
bits += util_bitcount64(mask);
|
2024-01-17 13:58:21 -08:00
|
|
|
|
|
|
|
|
u_foreach_bit64(bit, mask)
|
|
|
|
|
insert_u64_bit(&config, INTEL_DEBUG(1ULL << bit));
|
2023-01-21 12:49:44 +01:00
|
|
|
|
|
|
|
|
mask = SIMD_DISK_CACHE_MASK;
|
|
|
|
|
bits += util_bitcount64(mask);
|
2024-01-17 13:58:21 -08:00
|
|
|
|
|
|
|
|
u_foreach_bit64(bit, mask)
|
|
|
|
|
insert_u64_bit(&config, (intel_simd & (1ULL << bit)) != 0);
|
2023-01-21 12:49:44 +01:00
|
|
|
|
2024-01-17 10:31:32 -08:00
|
|
|
mask = 3;
|
|
|
|
|
bits += util_bitcount64(mask);
|
|
|
|
|
|
|
|
|
|
u_foreach_bit64(bit, mask)
|
|
|
|
|
insert_u64_bit(&config, (compiler->mesh.mue_header_packing & (1ULL << bit)) != 0);
|
|
|
|
|
|
2023-01-21 12:49:44 +01:00
|
|
|
assert(bits <= util_bitcount64(UINT64_MAX));
|
|
|
|
|
|
2018-07-25 14:31:05 -07:00
|
|
|
return config;
|
|
|
|
|
}
|
|
|
|
|
|
2024-02-09 15:30:57 -08:00
|
|
|
void
|
|
|
|
|
brw_device_sha1(char *hex,
|
|
|
|
|
const struct intel_device_info *devinfo) {
|
|
|
|
|
struct mesa_sha1 ctx;
|
|
|
|
|
_mesa_sha1_init(&ctx);
|
|
|
|
|
brw_device_sha1_update(&ctx, devinfo);
|
|
|
|
|
unsigned char result[20];
|
|
|
|
|
_mesa_sha1_final(&ctx, result);
|
|
|
|
|
_mesa_sha1_format(hex, result);
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-21 01:30:13 -07:00
|
|
|
unsigned
|
|
|
|
|
brw_prog_data_size(gl_shader_stage stage)
|
|
|
|
|
{
|
|
|
|
|
static const size_t stage_sizes[] = {
|
2020-10-21 14:46:50 -05:00
|
|
|
[MESA_SHADER_VERTEX] = sizeof(struct brw_vs_prog_data),
|
|
|
|
|
[MESA_SHADER_TESS_CTRL] = sizeof(struct brw_tcs_prog_data),
|
|
|
|
|
[MESA_SHADER_TESS_EVAL] = sizeof(struct brw_tes_prog_data),
|
|
|
|
|
[MESA_SHADER_GEOMETRY] = sizeof(struct brw_gs_prog_data),
|
|
|
|
|
[MESA_SHADER_FRAGMENT] = sizeof(struct brw_wm_prog_data),
|
|
|
|
|
[MESA_SHADER_COMPUTE] = sizeof(struct brw_cs_prog_data),
|
2021-10-29 12:27:45 -07:00
|
|
|
[MESA_SHADER_TASK] = sizeof(struct brw_task_prog_data),
|
|
|
|
|
[MESA_SHADER_MESH] = sizeof(struct brw_mesh_prog_data),
|
2020-10-21 14:46:50 -05:00
|
|
|
[MESA_SHADER_RAYGEN] = sizeof(struct brw_bs_prog_data),
|
|
|
|
|
[MESA_SHADER_ANY_HIT] = sizeof(struct brw_bs_prog_data),
|
|
|
|
|
[MESA_SHADER_CLOSEST_HIT] = sizeof(struct brw_bs_prog_data),
|
|
|
|
|
[MESA_SHADER_MISS] = sizeof(struct brw_bs_prog_data),
|
|
|
|
|
[MESA_SHADER_INTERSECTION] = sizeof(struct brw_bs_prog_data),
|
|
|
|
|
[MESA_SHADER_CALLABLE] = sizeof(struct brw_bs_prog_data),
|
|
|
|
|
[MESA_SHADER_KERNEL] = sizeof(struct brw_cs_prog_data),
|
2017-10-21 01:30:13 -07:00
|
|
|
};
|
|
|
|
|
assert((int)stage >= 0 && stage < ARRAY_SIZE(stage_sizes));
|
|
|
|
|
return stage_sizes[stage];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned
|
|
|
|
|
brw_prog_key_size(gl_shader_stage stage)
|
|
|
|
|
{
|
|
|
|
|
static const size_t stage_sizes[] = {
|
2020-10-21 14:46:50 -05:00
|
|
|
[MESA_SHADER_VERTEX] = sizeof(struct brw_vs_prog_key),
|
|
|
|
|
[MESA_SHADER_TESS_CTRL] = sizeof(struct brw_tcs_prog_key),
|
|
|
|
|
[MESA_SHADER_TESS_EVAL] = sizeof(struct brw_tes_prog_key),
|
|
|
|
|
[MESA_SHADER_GEOMETRY] = sizeof(struct brw_gs_prog_key),
|
|
|
|
|
[MESA_SHADER_FRAGMENT] = sizeof(struct brw_wm_prog_key),
|
|
|
|
|
[MESA_SHADER_COMPUTE] = sizeof(struct brw_cs_prog_key),
|
2021-10-29 12:27:45 -07:00
|
|
|
[MESA_SHADER_TASK] = sizeof(struct brw_task_prog_key),
|
|
|
|
|
[MESA_SHADER_MESH] = sizeof(struct brw_mesh_prog_key),
|
2020-10-21 14:46:50 -05:00
|
|
|
[MESA_SHADER_RAYGEN] = sizeof(struct brw_bs_prog_key),
|
|
|
|
|
[MESA_SHADER_ANY_HIT] = sizeof(struct brw_bs_prog_key),
|
|
|
|
|
[MESA_SHADER_CLOSEST_HIT] = sizeof(struct brw_bs_prog_key),
|
|
|
|
|
[MESA_SHADER_MISS] = sizeof(struct brw_bs_prog_key),
|
|
|
|
|
[MESA_SHADER_INTERSECTION] = sizeof(struct brw_bs_prog_key),
|
|
|
|
|
[MESA_SHADER_CALLABLE] = sizeof(struct brw_bs_prog_key),
|
|
|
|
|
[MESA_SHADER_KERNEL] = sizeof(struct brw_cs_prog_key),
|
2017-10-21 01:30:13 -07:00
|
|
|
};
|
|
|
|
|
assert((int)stage >= 0 && stage < ARRAY_SIZE(stage_sizes));
|
|
|
|
|
return stage_sizes[stage];
|
|
|
|
|
}
|
2020-08-08 12:55:29 -05:00
|
|
|
|
|
|
|
|
void
|
2022-06-29 14:13:31 -07:00
|
|
|
brw_write_shader_relocs(const struct brw_isa_info *isa,
|
2020-08-08 12:55:29 -05:00
|
|
|
void *program,
|
|
|
|
|
const struct brw_stage_prog_data *prog_data,
|
|
|
|
|
struct brw_shader_reloc_value *values,
|
|
|
|
|
unsigned num_values)
|
|
|
|
|
{
|
|
|
|
|
for (unsigned i = 0; i < prog_data->num_relocs; i++) {
|
|
|
|
|
assert(prog_data->relocs[i].offset % 8 == 0);
|
2020-09-04 12:09:11 -05:00
|
|
|
void *dst = program + prog_data->relocs[i].offset;
|
2020-08-08 12:55:29 -05:00
|
|
|
for (unsigned j = 0; j < num_values; j++) {
|
|
|
|
|
if (prog_data->relocs[i].id == values[j].id) {
|
2020-09-04 12:09:11 -05:00
|
|
|
uint32_t value = values[j].value + prog_data->relocs[i].delta;
|
|
|
|
|
switch (prog_data->relocs[i].type) {
|
2020-09-04 12:23:35 -05:00
|
|
|
case BRW_SHADER_RELOC_TYPE_U32:
|
|
|
|
|
*(uint32_t *)dst = value;
|
|
|
|
|
break;
|
2020-09-04 12:09:11 -05:00
|
|
|
case BRW_SHADER_RELOC_TYPE_MOV_IMM:
|
2022-06-29 14:13:31 -07:00
|
|
|
brw_update_reloc_imm(isa, dst, value);
|
2020-09-04 12:09:11 -05:00
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
unreachable("Invalid relocation type");
|
|
|
|
|
}
|
2020-08-08 12:55:29 -05:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-10-19 15:49:51 +03:00
|
|
|
|
|
|
|
|
void
|
|
|
|
|
brw_stage_prog_data_add_printf(struct brw_stage_prog_data *prog_data,
|
|
|
|
|
void *mem_ctx,
|
|
|
|
|
const u_printf_info *print)
|
|
|
|
|
{
|
|
|
|
|
prog_data->printf_info_count++;
|
|
|
|
|
prog_data->printf_info = reralloc(mem_ctx, prog_data->printf_info,
|
|
|
|
|
u_printf_info,
|
|
|
|
|
prog_data->printf_info_count);
|
|
|
|
|
|
|
|
|
|
prog_data->printf_info[prog_data->printf_info_count - 1] = *print;
|
|
|
|
|
if (print->string_size > 0) {
|
|
|
|
|
prog_data->printf_info[prog_data->printf_info_count - 1].strings =
|
|
|
|
|
ralloc_size(mem_ctx, print->string_size);
|
|
|
|
|
memcpy(prog_data->printf_info[prog_data->printf_info_count - 1].strings,
|
|
|
|
|
print->strings, print->string_size);
|
|
|
|
|
}
|
|
|
|
|
if (print->num_args > 0) {
|
|
|
|
|
prog_data->printf_info[prog_data->printf_info_count - 1].arg_sizes =
|
|
|
|
|
ralloc_array(mem_ctx, __typeof__(*print->arg_sizes), print->num_args);
|
|
|
|
|
memcpy(prog_data->printf_info[prog_data->printf_info_count - 1].arg_sizes,
|
|
|
|
|
print->arg_sizes, sizeof(print->arg_sizes[0]) *print->num_args);
|
|
|
|
|
}
|
|
|
|
|
}
|