broadcom/compiler: avoid unneeded sint/unorm clamping when lowering stores

They are being used on integer to integer stores. From Vulkan sec,
final paragraph of 16.4.4 "Texel Output Format Conversion":
    "Each component is converted based on its type and size (as
     defined in the Format Definition section for each
     VkFormat). ... Integer outputs are converted such that their value
     is preserved. The converted value of any integer that cannot be
     represented in the target format is undefined."

I didn't find a equivalent quote for OpenGL as all conversion entries
are forcused on float to integer, fixed-point to integer, etc, and not
on integer to integer. Didn't find any test failure with this change.

We didn't get any shader-db stats change with shaderdb (even
overriding to OpenGL 4.4 to get more shaders built), so as a reference
Vulkan shader-db stats with the pattern
dEQP-VK.image.*.with_format.*.*
   total instructions in shared programs: 37534 -> 36522 (-2.70%)
   instructions in affected programs: 12080 -> 11068 (-8.38%)
   helped: 241
   HURT: 0
   Instructions are helped.

   total uniforms in shared programs: 9100 -> 8550 (-6.04%)
   uniforms in affected programs: 3004 -> 2454 (-18.31%)
   helped: 229
   HURT: 0

   total max-temps in shared programs: 6110 -> 6014 (-1.57%)
   max-temps in affected programs: 402 -> 306 (-23.88%)
   helped: 43
   HURT: 0
   Max-temps are helped.

   total nops in shared programs: 1523 -> 1526 (0.20%)
   nops in affected programs: 21 -> 24 (14.29%)
   helped: 3
   HURT: 6
   Inconclusive result (value mean confidence interval includes 0).

Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14194>
This commit is contained in:
Alejandro Piñeiro 2021-12-13 15:25:47 +01:00 committed by Marge Bot
parent cca8803e6b
commit 1c4f76672d
1 changed files with 4 additions and 2 deletions

View File

@ -133,11 +133,13 @@ v3d_nir_lower_image_store(nir_builder *b, nir_intrinsic_instr *instr)
bool pack_mask = false;
if (r_chan->pure_integer &&
r_chan->type == UTIL_FORMAT_TYPE_SIGNED) {
formatted = nir_format_clamp_sint(b, color, bits);
/* We don't need to do any conversion or clamping in this case */
formatted = color;
pack_mask = true;
} else if (r_chan->pure_integer &&
r_chan->type == UTIL_FORMAT_TYPE_UNSIGNED) {
formatted = nir_format_clamp_uint(b, color, bits);
/* We don't need to do any conversion or clamping in this case */
formatted = color;
} else if (r_chan->normalized &&
r_chan->type == UTIL_FORMAT_TYPE_SIGNED) {
formatted = nir_format_float_to_snorm(b, color, bits);