Module: Mesa Branch: master Commit: 3dd6b79215cba88c43301e80601149bf8188662d URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=3dd6b79215cba88c43301e80601149bf8188662d
Author: Axel Davy <[email protected]> Date: Sun Jan 17 18:20:03 2021 +0100 st/nine: Clamp GetAvailableTextureMem Previously we used to clamp "available_texture_limit", which was incorrect. "available_texture_mem" should have been clamped instead. The resulting code was noop. The idea behind that code was that 32 bits executable would see maximum 4GB video memory. However it seems according to users that 32 bits apps should be able to allocate more than 4GB, thus the clamping is inappropriate. Instead clamp the return of GetAvailableTextureMem, to correctly report a high value when there is more than 4GB available. I do not know what should exactly be the clamp value, for now have a 64MB margin below UINT_MAX. Signed-off-by: Axel Davy <[email protected]> Acked-by: Timur Kristóf <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9177> --- src/gallium/frontends/nine/device9.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/gallium/frontends/nine/device9.c b/src/gallium/frontends/nine/device9.c index c8685588f11..e9b2a5e75ee 100644 --- a/src/gallium/frontends/nine/device9.c +++ b/src/gallium/frontends/nine/device9.c @@ -240,10 +240,7 @@ NineDevice9_ctor( struct NineDevice9 *This, * Win XP shares this counter across multiple devices. */ This->available_texture_mem = This->screen->get_param(This->screen, PIPE_CAP_VIDEO_MEMORY); 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. */ @@ -671,7 +668,8 @@ NineDevice9_TestCooperativeLevel( struct NineDevice9 *This ) UINT NINE_WINAPI NineDevice9_GetAvailableTextureMem( struct NineDevice9 *This ) { - return This->available_texture_mem; + /* To prevent overflows - Not sure how this should be handled */ + return (UINT)MIN2(This->available_texture_mem, (long long)(UINT_MAX - (64 << 20))); /* 64 MB margin */ } void _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
