Skip to content

bx::normalize return bad result when simd is enable on macOS(M1)/iOS platform #298

Closed
@junjie020

Description

@junjie020

I have this code:

// simd is enable
bx::Vec3 nv = bx::normalize(bx::Vec3(0.f, 1.f, 0.f));

On window platform, it will return: nv = (0.f, 1.f, 0.f), as we expected.

On macOS/iOS(ARM architecture), it will return: nv = (0.f, 1.00000572f, 0.f), the y coordinate is slightly larger than 1.

I dig into the code, I found that, simd_sqrt with value 1, will return a value less than 1.

It will bring some bad result, like:

const bx::Vec3 dir = texelUvToDir(side, uu, vv);

float srcU, srcV;
bx::toLatLong(&srcU, &srcV, dir);

here, dir should return value (0.f, 1.f, 0.f), but we get (0.f, 1.00000572f, 0.f), it cause bx::toLatLong return NaN in srcV

this code is from:
https://github.com/bkaradzic/bimg/blob/master/src/image_cubemap_filter.cpp#L242

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions