Mesa (main): broadcom/compiler: avoid unneeded sint/unorm clamping when lowering stores

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Dec 15 12:12:55 UTC 2021


Module: Mesa
Branch: main
Commit: 1c4f76672d31e500e392dcebf25ee6af23d4b1db
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1c4f76672d31e500e392dcebf25ee6af23d4b1db

Author: Alejandro Piñeiro <apinheiro at igalia.com>
Date:   Mon Dec 13 15:25:47 2021 +0100

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 at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14194>

---

 src/broadcom/compiler/v3d_nir_lower_image_load_store.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/broadcom/compiler/v3d_nir_lower_image_load_store.c b/src/broadcom/compiler/v3d_nir_lower_image_load_store.c
index 6b459e1afa9..80dd7fd0836 100644
--- a/src/broadcom/compiler/v3d_nir_lower_image_load_store.c
+++ b/src/broadcom/compiler/v3d_nir_lower_image_load_store.c
@@ -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);



More information about the mesa-commit mailing list