st/nine: Increase available GPU memory
authorAxel Davy <davyaxel0@gmail.com>
Fri, 8 May 2020 20:26:07 +0000 (22:26 +0200)
committerMarge Bot <eric+marge@anholt.net>
Fri, 15 May 2020 15:43:57 +0000 (15:43 +0000)
This patch caps to 4GB the limit of GPU memory accessible
only for 32bits build.
This would deserve some tests on windows, so we might change that
behaviour in the future. For example, it's possible that
GetAvailableTextureMem is capped to 4GB on 64bits build.

We cap to a bit less than 4GB, which might help
https://github.com/iXit/Mesa-3D/issues/323

In addition, increase from 80% to 95% the allocation limit above
which we fail allocating.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5015>

src/gallium/frontends/nine/device9.c

index 97223cd8fa544d794290b8d8e05b7e374231ce7f..2634b88a61461c891e1bbea9f3ab48119d47bc82 100644 (file)
@@ -217,14 +217,15 @@ NineDevice9_ctor( struct NineDevice9 *This,
      * instance. This is the Win 7 behavior.
      * Win XP shares this counter across multiple devices. */
     This->available_texture_mem = This->screen->get_param(This->screen, PIPE_CAP_VIDEO_MEMORY);
-    if (This->available_texture_mem < 4096)
-        This->available_texture_mem <<= 20;
-    else
-        This->available_texture_mem = UINT_MAX;
-    /* We cap texture memory usage to 80% of what is reported free initially
+    This->available_texture_mem <<= 20;
+#ifdef PIPE_ARCH_X86
+    /* To prevent overflows for 32bits apps - Not sure about this one */
+    This->available_texture_limit = MAX2(This->available_texture_limit, UINT_MAX - (64 << 20));
+#endif
+    /* We cap texture memory usage to 95% of what is reported free initially
      * This helps get closer Win behaviour. For example VertexBuffer allocation
      * still succeeds when texture allocation fails. */
-    This->available_texture_limit = This->available_texture_mem * 20LL / 100LL;
+    This->available_texture_limit = This->available_texture_mem * 5LL / 100LL;
 
     /* create implicit swapchains */
     This->nswapchains = ID3DPresentGroup_GetMultiheadCount(This->present);