From 996cfb841ef5618f78400d42a862d2015ff37536 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Wed, 10 Nov 2021 11:36:08 +0100 Subject: [PATCH] ddraw: Use wined3d_bit_scan() in compute_sphere_visibility(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit RĂ©mi Bernon reports an unspecified issue with gcc 11 related to compute_sphere_visibility() expecting 12 input planes, but d3d_device3_ComputeSphereVisibility() only providing 6. The actual number of planes required depends on the "enabled_planes" mask. This patch should make the code better reflect that, but I do not have a gcc 11 setup to verify it resolves the issue there. Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- dlls/ddraw/device.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c index 8afbab0e58d..6e8f109173b 100644 --- a/dlls/ddraw/device.c +++ b/dlls/ddraw/device.c @@ -4638,17 +4638,20 @@ static void prepare_clip_space_planes(struct d3d_device *device, struct wined3d_ plane[5].w = m._44 - m._43; } -static void compute_sphere_visibility(struct wined3d_vec4 plane[12], DWORD enabled_planes, BOOL equality, - D3DVECTOR *centers, D3DVALUE *radii, DWORD sphere_count, DWORD *return_values) +static void compute_sphere_visibility(const struct wined3d_vec4 *planes, DWORD enabled_planes, BOOL equality, + const D3DVECTOR *centres, const D3DVALUE *radii, unsigned int sphere_count, DWORD *return_values) { - UINT i, j; + unsigned int mask, i, j; + memset(return_values, 0, sphere_count * sizeof(*return_values)); for (i = 0; i < sphere_count; ++i) { - return_values[i] = 0; - for (j = 0; j < 12; ++j) - if (enabled_planes & 1u << j) - return_values[i] |= in_plane(j, plane[j], centers[i], radii[i], equality); + mask = enabled_planes; + while (mask) + { + j = wined3d_bit_scan(&mask); + return_values[i] |= in_plane(j, planes[j], centres[i], radii[i], equality); + } } }