From: Pekka Paalanen <ppaalanen@gmail.com>
To: Paul Gofman <pgofman@codeweavers.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH libdrm] xf86drm.c: Use integer logarithm.
Date: Wed, 28 Oct 2020 10:18:42 +0200 [thread overview]
Message-ID: <20201028101842.041e8a02@eldfell> (raw)
In-Reply-To: <20201026131120.1068959-1-pgofman@codeweavers.com>
[-- Attachment #1.1: Type: text/plain, Size: 2121 bytes --]
On Mon, 26 Oct 2020 16:11:20 +0300
Paul Gofman <pgofman@codeweavers.com> wrote:
> log() is affected by FP control word and can provide inaccurate result.
>
> Fixes Killer Instinct under Wine not being able to find AMD vulkan
> device.
>
> Signed-off-by: Paul Gofman <pgofman@codeweavers.com>
> ---
> With the rounding mode the application sets (unsigned int)log2(4) is 1.
> The log2_int() implemetation is copied from radeon/radeon_surface.c.
>
> xf86drm.c | 18 +++++++++++++++++-
> 1 file changed, 17 insertions(+), 1 deletion(-)
>
> diff --git a/xf86drm.c b/xf86drm.c
> index 50a6f092..dbb7c14b 100644
> --- a/xf86drm.c
> +++ b/xf86drm.c
> @@ -124,6 +124,22 @@ static drmServerInfoPtr drm_server_info;
> static bool drmNodeIsDRM(int maj, int min);
> static char *drmGetMinorNameForFD(int fd, int type);
>
> +static unsigned log2_int(unsigned x)
> +{
> + unsigned l;
> +
> + if (x < 2) {
> + return 0;
> + }
> + for (l = 2; ; l++) {
> + if ((unsigned)(1 << l) > x) {
Hi,
wouldn't this loop fail to end when x >= 0x80000000?
Sure, such value probably cannot occur where this is currently used,
but it seems like a landmine for the next developer to step on.
Thanks,
pq
> + return l - 1;
> + }
> + }
> + return 0;
> +}
> +
> +
> drm_public void drmSetServerInfo(drmServerInfoPtr info)
> {
> drm_server_info = info;
> @@ -4001,7 +4017,7 @@ static void drmFoldDuplicatedDevices(drmDevicePtr local_devices[], int count)
> for (j = i + 1; j < count; j++) {
> if (drmDevicesEqual(local_devices[i], local_devices[j])) {
> local_devices[i]->available_nodes |= local_devices[j]->available_nodes;
> - node_type = log2(local_devices[j]->available_nodes);
> + node_type = log2_int(local_devices[j]->available_nodes);
> memcpy(local_devices[i]->nodes[node_type],
> local_devices[j]->nodes[node_type], drmGetMaxNodeName());
> drmFreeDevice(&local_devices[j]);
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
[-- Attachment #2: Type: text/plain, Size: 160 bytes --]
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2020-10-28 8:18 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-26 13:11 [PATCH libdrm] xf86drm.c: Use integer logarithm Paul Gofman
2020-10-27 23:24 ` Dave Airlie
2020-10-28 8:18 ` Pekka Paalanen [this message]
2020-10-28 10:09 ` Paul Gofman
2020-10-28 10:30 ` Michel Dänzer
2020-10-28 10:36 ` Paul Gofman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201028101842.041e8a02@eldfell \
--to=ppaalanen@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=pgofman@codeweavers.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.