Module: Mesa
Branch: staging/20.1
Commit: e24c6c04a4626e2f59730cb8eb68a568fd43b096
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e24c6c04a4626e2f59730cb8eb68a568fd43b096

Author: Pierre-Eric Pelloux-Prayer <[email protected]>
Date:   Thu Aug 13 11:15:36 2020 +0200

radeonsi,driconf: add clamp_div_by_zero option

Cc: mesa-stable
Reviewed-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6259>
(cherry picked from commit b8445520cba818dbc53db95ce99e2beb00d8884e)

---

 .pick_status.json                               | 2 +-
 src/gallium/drivers/radeonsi/si_debug_options.h | 1 +
 src/gallium/drivers/radeonsi/si_pipe.c          | 5 ++++-
 src/gallium/drivers/radeonsi/si_pipe.h          | 1 +
 src/gallium/drivers/radeonsi/si_shader_llvm.c   | 1 +
 5 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/.pick_status.json b/.pick_status.json
index b0791baf0c1..4b2667df6d4 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -22,7 +22,7 @@
         "description": "radeonsi,driconf: add clamp_div_by_zero option",
         "nominated": true,
         "nomination_type": 0,
-        "resolution": 0,
+        "resolution": 1,
         "master_sha": null,
         "because_sha": null
     },
diff --git a/src/gallium/drivers/radeonsi/si_debug_options.h 
b/src/gallium/drivers/radeonsi/si_debug_options.h
index 83c7425e094..febb3135793 100644
--- a/src/gallium/drivers/radeonsi/si_debug_options.h
+++ b/src/gallium/drivers/radeonsi/si_debug_options.h
@@ -7,5 +7,6 @@ OPT_BOOL(halt_shaders, false, "Halt shaders at the start (will 
hang)")
 OPT_BOOL(vs_fetch_always_opencode, false,
          "Always open code vertex fetches (less efficient, purely for 
testing)")
 OPT_BOOL(prim_restart_tri_strips_only, false, "Only enable primitive restart 
for triangle strips")
+OPT_BOOL(clamp_div_by_zero, false, "Clamp div by zero (x / 0 becomes FLT_MAX 
instead of NaN)")
 
 #undef OPT_BOOL
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c 
b/src/gallium/drivers/radeonsi/si_pipe.c
index e0420934c27..81614cbfb01 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -885,7 +885,7 @@ static void si_disk_cache_create(struct si_screen *sscreen)
    disk_cache_format_hex_id(cache_id, sha1, 20 * 2);
 
 /* These flags affect shader compilation. */
-#define ALL_FLAGS (DBG(GISEL))
+#define ALL_FLAGS (DBG(GISEL) | DBG(CLAMP_DIV_BY_ZERO))
    uint64_t shader_debug_flags = sscreen->debug_flags & ALL_FLAGS;
 
    /* Add the high bits of 32-bit addresses, which affects
@@ -1002,6 +1002,9 @@ static struct pipe_screen 
*radeonsi_screen_create_impl(struct radeon_winsys *ws,
 #include "si_debug_options.h"
    }
 
+   if (sscreen->options.clamp_div_by_zero)
+      sscreen->debug_flags |= DBG(CLAMP_DIV_BY_ZERO);
+
    si_disk_cache_create(sscreen);
 
    /* Determine the number of shader compiler threads. */
diff --git a/src/gallium/drivers/radeonsi/si_pipe.h 
b/src/gallium/drivers/radeonsi/si_pipe.h
index de4f0e342c5..2b576a8fe31 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.h
+++ b/src/gallium/drivers/radeonsi/si_pipe.h
@@ -159,6 +159,7 @@ enum
    DBG_W64_GE,
    DBG_W64_PS,
    DBG_W64_CS,
+   DBG_CLAMP_DIV_BY_ZERO,
 
    /* Shader compiler options (with no effect on the shader cache): */
    DBG_CHECK_IR,
diff --git a/src/gallium/drivers/radeonsi/si_shader_llvm.c 
b/src/gallium/drivers/radeonsi/si_shader_llvm.c
index 63c9c033ab4..e200114ef12 100644
--- a/src/gallium/drivers/radeonsi/si_shader_llvm.c
+++ b/src/gallium/drivers/radeonsi/si_shader_llvm.c
@@ -452,6 +452,7 @@ bool si_nir_build_llvm(struct si_shader_context *ctx, 
struct nir_shader *nir)
    ctx->abi.inputs = &ctx->inputs[0];
    ctx->abi.clamp_shadow_reference = true;
    ctx->abi.robust_buffer_access = true;
+   ctx->abi.clamp_div_by_zero = ctx->screen->options.clamp_div_by_zero;
 
    if (ctx->shader->selector->info.properties[TGSI_PROPERTY_CS_LOCAL_SIZE]) {
       assert(gl_shader_stage_is_compute(nir->info.stage));

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to