From 1c4f76672d31e500e392dcebf25ee6af23d4b1db Mon Sep 17 00:00:00 2001 From: =?utf8?q?Alejandro=20Pi=C3=B1eiro?= Date: Mon, 13 Dec 2021 15:25:47 +0100 Subject: [PATCH] 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 Part-of: --- 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 6b459e1..80dd7fd 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); -- 2.7.4