Mesa (main): v3d,v3dv: add options to force 32-bit or 16-bit TMU precision

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Aug 11 06:12:10 UTC 2021


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

Author: Iago Toral Quiroga <itoral at igalia.com>
Date:   Tue Aug 10 11:32:50 2021 +0200

v3d,v3dv: add options to force 32-bit or 16-bit TMU precision

Reviewed-by: Alejandro Piñeiro <apinheiro at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12303>

---

 src/broadcom/common/v3d_debug.c       | 8 ++++++++
 src/broadcom/common/v3d_debug.h       | 2 ++
 src/broadcom/vulkan/v3dv_formats.c    | 6 ++++++
 src/broadcom/vulkan/v3dv_pipeline.c   | 8 +++++++-
 src/gallium/drivers/v3d/v3d_formats.c | 6 ++++++
 5 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/src/broadcom/common/v3d_debug.c b/src/broadcom/common/v3d_debug.c
index 120905d34bb..5352e3d2f98 100644
--- a/src/broadcom/common/v3d_debug.c
+++ b/src/broadcom/common/v3d_debug.c
@@ -76,6 +76,14 @@ static const struct debug_named_value debug_control[] = {
           "Dump register allocation failures" },
         { "dump_spirv",  V3D_DEBUG_DUMP_SPIRV,
           "Dump SPIR-V code" },
+        { "tmu32",  V3D_DEBUG_TMU_32BIT,
+          "Force 32-bit precision on all TMU operations" },
+        /* This can lead to incorrect behavior for applications that do
+         * require full 32-bit precision, but can improve performance
+         * for those that don't.
+         */
+        { "tmu16",  V3D_DEBUG_TMU_16BIT,
+          "Force 16-bit precision on all TMU operations" },
         { NULL }
 };
 
diff --git a/src/broadcom/common/v3d_debug.h b/src/broadcom/common/v3d_debug.h
index efa26975870..21ae4ce7829 100644
--- a/src/broadcom/common/v3d_debug.h
+++ b/src/broadcom/common/v3d_debug.h
@@ -59,6 +59,8 @@ extern uint32_t V3D_DEBUG;
 #define V3D_DEBUG_PRECOMPILE        (1 << 15)
 #define V3D_DEBUG_RA                (1 << 16)
 #define V3D_DEBUG_DUMP_SPIRV        (1 << 17)
+#define V3D_DEBUG_TMU_32BIT         (1 << 18)
+#define V3D_DEBUG_TMU_16BIT         (1 << 19)
 
 #define V3D_DEBUG_SHADERS           (V3D_DEBUG_TGSI | V3D_DEBUG_NIR | \
                                      V3D_DEBUG_VIR | V3D_DEBUG_QPU | \
diff --git a/src/broadcom/vulkan/v3dv_formats.c b/src/broadcom/vulkan/v3dv_formats.c
index 69e5468008d..6e32d341a25 100644
--- a/src/broadcom/vulkan/v3dv_formats.c
+++ b/src/broadcom/vulkan/v3dv_formats.c
@@ -45,6 +45,12 @@ uint8_t
 v3dv_get_tex_return_size(const struct v3dv_format *vf,
                          bool compare_enable)
 {
+   if (unlikely(V3D_DEBUG & V3D_DEBUG_TMU_16BIT))
+      return 16;
+
+   if (unlikely(V3D_DEBUG & V3D_DEBUG_TMU_32BIT))
+      return 32;
+
    if (compare_enable)
       return 16;
 
diff --git a/src/broadcom/vulkan/v3dv_pipeline.c b/src/broadcom/vulkan/v3dv_pipeline.c
index 4e692bbf389..aaf828ac426 100644
--- a/src/broadcom/vulkan/v3dv_pipeline.c
+++ b/src/broadcom/vulkan/v3dv_pipeline.c
@@ -711,7 +711,13 @@ lower_tex_src_to_offset(nir_builder *b, nir_tex_instr *instr, unsigned src_idx,
       deref->var->data.index + base_index :
       base_index;
 
-   uint8_t return_size = relaxed_precision || instr->is_shadow ? 16 : 32;
+   uint8_t return_size;
+   if (unlikely(V3D_DEBUG & V3D_DEBUG_TMU_16BIT))
+      return_size = 16;
+   else  if (unlikely(V3D_DEBUG & V3D_DEBUG_TMU_32BIT))
+      return_size = 32;
+   else
+      return_size = relaxed_precision || instr->is_shadow ? 16 : 32;
 
    struct v3dv_descriptor_map *map =
       pipeline_get_descriptor_map(pipeline, binding_layout->type,
diff --git a/src/gallium/drivers/v3d/v3d_formats.c b/src/gallium/drivers/v3d/v3d_formats.c
index 6e5c7c0538d..70218946e33 100644
--- a/src/gallium/drivers/v3d/v3d_formats.c
+++ b/src/gallium/drivers/v3d/v3d_formats.c
@@ -102,6 +102,12 @@ v3d_get_tex_return_size(const struct v3d_device_info *devinfo,
         if (!vf)
                 return 0;
 
+        if (unlikely(V3D_DEBUG & V3D_DEBUG_TMU_16BIT))
+                return 16;
+
+        if (unlikely(V3D_DEBUG & V3D_DEBUG_TMU_32BIT))
+                return 32;
+
         if (compare == PIPE_TEX_COMPARE_R_TO_TEXTURE)
                 return 16;
 



More information about the mesa-commit mailing list