Mesa (master): st/nine: Add driconf option to limit texture memory

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sun Mar 7 13:27:40 UTC 2021


Module: Mesa
Branch: master
Commit: 0beb77751ebdf4db291aa791c12af843e193ef1c
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0beb77751ebdf4db291aa791c12af843e193ef1c

Author: Axel Davy <davyaxel0 at gmail.com>
Date:   Sat Feb  6 23:30:56 2021 +0100

st/nine: Add driconf option to limit texture memory

Signed-off-by: Axel Davy <davyaxel0 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9377>

---

 src/gallium/frontends/nine/adapter9.h | 1 +
 src/gallium/frontends/nine/device9.c  | 2 +-
 src/gallium/targets/d3dadapter9/drm.c | 2 ++
 src/util/driconf.h                    | 4 ++++
 4 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/gallium/frontends/nine/adapter9.h b/src/gallium/frontends/nine/adapter9.h
index 605444cbc8d..ef129687727 100644
--- a/src/gallium/frontends/nine/adapter9.h
+++ b/src/gallium/frontends/nine/adapter9.h
@@ -44,6 +44,7 @@ struct d3dadapter9_context
     int csmt_force;
     BOOL dynamic_texture_workaround;
     BOOL shader_inline_constants;
+    int memfd_virtualsizelimit;
 
     void (*destroy)( struct d3dadapter9_context *ctx );
 };
diff --git a/src/gallium/frontends/nine/device9.c b/src/gallium/frontends/nine/device9.c
index ccba38a6347..9b44b9827b7 100644
--- a/src/gallium/frontends/nine/device9.c
+++ b/src/gallium/frontends/nine/device9.c
@@ -236,7 +236,7 @@ NineDevice9_ctor( struct NineDevice9 *This,
     /* Create first, it messes up our state. */
     This->hud = hud_create(This->context.cso, NULL, NULL); /* NULL result is fine */
 
-    This->allocator = nine_allocator_create(This, 512);
+    This->allocator = nine_allocator_create(This, pCTX->memfd_virtualsizelimit);
 
     /* Available memory counter. Updated only for allocations with this device
      * instance. This is the Win 7 behavior.
diff --git a/src/gallium/targets/d3dadapter9/drm.c b/src/gallium/targets/d3dadapter9/drm.c
index a8a77129b0a..4967b06c0e8 100644
--- a/src/gallium/targets/d3dadapter9/drm.c
+++ b/src/gallium/targets/d3dadapter9/drm.c
@@ -60,6 +60,7 @@ const driOptionDescription __driConfigOptionsNine[] = {
         DRI_CONF_NINE_CSMT(-1)
         DRI_CONF_NINE_DYNAMICTEXTUREWORKAROUND(false)
         DRI_CONF_NINE_SHADERINLINECONSTANTS(false)
+        DRI_CONF_NINE_SHMEM_LIMIT()
     DRI_CONF_SECTION_END
 };
 
@@ -277,6 +278,7 @@ drm_create_adapter( int fd,
     ctx->base.csmt_force = driQueryOptioni(&userInitOptions, "csmt_force");
     ctx->base.dynamic_texture_workaround = driQueryOptionb(&userInitOptions, "dynamic_texture_workaround");
     ctx->base.shader_inline_constants = driQueryOptionb(&userInitOptions, "shader_inline_constants");
+    ctx->base.memfd_virtualsizelimit = driQueryOptioni(&userInitOptions, "texture_memory_limit");
 
     driDestroyOptionCache(&userInitOptions);
     driDestroyOptionInfo(&defaultInitOptions);
diff --git a/src/util/driconf.h b/src/util/driconf.h
index 422fec52df2..9c0c353b7b5 100644
--- a/src/util/driconf.h
+++ b/src/util/driconf.h
@@ -402,6 +402,10 @@
    DRI_CONF_OPT_B(shader_inline_constants, def, \
                   "If set to true, recompile shaders with integer or boolean constants when the values are known. Can cause stutter, but can increase slightly performance.")
 
+#define DRI_CONF_NINE_SHMEM_LIMIT() \
+   DRI_CONF_OPT_I(texture_memory_limit, 512, 0, 0, \
+                  "In MB the limit of virtual memory used for textures until shmem files are unmapped (default 512MB, 32bits only). If negative disables shmem. Set to a low amount to reduce virtual memory usage, but can inccur a small perf hit if too low.")
+
 /**
  * \brief radeonsi specific configuration options
  */



More information about the mesa-commit mailing list