[PATCH vkd3d 2/2] vkd3d: Optimise the GPU VA allocator.

Sveinar Søpler cybermax at dexter.no
Wed Nov 20 11:06:36 CST 2019


I am getting a compile warning when compiling 32-bit with this patch.

--

In file included from ./include/private/vkd3d_memory.h:26,
                  from libs/vkd3d/vkd3d_private.h:27,
                  from libs/vkd3d/device.c:19:
libs/vkd3d/device.c: In function ‘vkd3d_gpu_va_allocator_dereference_slab’:
libs/vkd3d/device.c:1963:13: warning: format ‘%zu’ expects argument of 
type ‘size_t’, but argument 7 has type ‘SIZE_T’ {aka ‘const long 
unsigned int’} [-Wformat=]
  1963 |         ERR("Address %#"PRIx64" is %#"PRIx64" bytes into slab 
%u of size %zu.\n",
       |             ^~~~~~~~~~~~
  1964 |                 address, base_offset, slab_idx, slab->size);
       |                                                 ~~~~~~~~~~
       |                                                     |
       |                                                     SIZE_T {aka 
const long unsigned int}
./include/private/vkd3d_debug.h:71:57: note: in definition of macro 
‘VKD3D_DBG_PRINTF’
    71 |         vkd3d_dbg_printf(vkd3d_dbg_level, __FUNCTION__, 
__VA_ARGS__); } while (0)
       | ^~~~~~~~~~~
./include/private/vkd3d_debug.h:85:15: note: in expansion of macro 
‘VKD3D_DBG_LOG’
    85 | #define ERR   VKD3D_DBG_LOG(ERR)
       |               ^~~~~~~~~~~~~
libs/vkd3d/device.c:1963:9: note: in expansion of macro ‘ERR’
  1963 |         ERR("Address %#"PRIx64" is %#"PRIx64" bytes into slab 
%u of size %zu.\n",
       |         ^~~
libs/vkd3d/device.c:1963:76: note: format string is defined here
  1963 |         ERR("Address %#"PRIx64" is %#"PRIx64" bytes into slab 
%u of size %zu.\n",
| ~~^
| |
| unsigned int
| %lu

--

%zu expects this to be unsigned int and not long for my 32-bit compiler. 
I dunno if this is different for MSVC or some other compiler for 32-bit? 
Should it just be changed for %lu to get rid of the warning, or is there 
some weirdness with Ubuntu gcc-9 behavior? (Or my setup for that matter).

Compile log from OBS in case there is something i have done wrong: 
https://build.opensuse.org/build/home:SveSop/xUbuntu_18.04/i586/vkd3d/_log

Sveinar

On 24.10.2019 16:33, hverbeet at codeweavers.com (Henri Verbeet) wrote:
> From: Hans-Kristian Arntzen <post at arntzen-software.no>
>
> The GPU VA allocator was allocating memory in a way where dereferencing
> GPU VA required a lock + bsearch() to find the right VA range.
>
> Rather than going this route, we turn the common case into O(1) and
> lock-free by creating a slab allocator which allows us to lookup a
> pointer directly from a GPU VA with (VA - Base) / PageSize.
>
> The number of allocations in the fast path must be limited since we
> cannot trivially grow the allocator while remaining lock-free for
> dereferences.
>
> Signed-off-by: Hans-Kristian Arntzen <post at arntzen-software.no>
> Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
> ---
> This supersedes patch 171219.
>
>   libs/vkd3d/device.c        | 226 +++++++++++++++++++++++++++++++++++++--------
>   libs/vkd3d/vkd3d_private.h |  28 ++++--
>   2 files changed, 204 insertions(+), 50 deletions(-)
>



More information about the wine-devel mailing list