[PATCH 01/12] d3drm: Implement frame Transform

Henri Verbeet hverbeet at gmail.com
Fri Jun 14 19:38:01 CDT 2019


Hi Jeff,

On Fri, 14 Jun 2019 at 09:00, Jeff Smith <whydoubt at gmail.com> wrote:
>  static HRESULT WINAPI d3drm_frame3_Transform(IDirect3DRMFrame3 *iface, D3DVECTOR *d, D3DVECTOR *s)
>  {
> -    FIXME("iface %p, d %p, s %p stub!\n", iface, d, s);
> +    struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
>
> -    return E_NOTIMPL;
> +    TRACE("iface %p, d %p, s %p.\n", iface, d, s);
> +
> +    d->u1.x = s->u1.x * frame->transform[0][0] + s->u2.y * frame->transform[1][0]
> +            + s->u3.z * frame->transform[2][0] + frame->transform[3][0];
> +    d->u2.y = s->u1.x * frame->transform[0][1] + s->u2.y * frame->transform[1][1]
> +            + s->u3.z * frame->transform[2][1] + frame->transform[3][1];
> +    d->u3.z = s->u1.x * frame->transform[0][2] + s->u2.y * frame->transform[1][2]
> +            + s->u3.z * frame->transform[2][2] + frame->transform[3][2];
> +
> +    while ((frame = frame->parent))
> +    {
> +        D3DVALUE x = d->u1.x;
> +        D3DVALUE y = d->u2.y;
> +        D3DVALUE z = d->u3.z;
> +        d->u1.x = x * frame->transform[0][0] + y * frame->transform[1][0]
> +                + z * frame->transform[2][0] + frame->transform[3][0];
> +        d->u2.y = x * frame->transform[0][1] + y * frame->transform[1][1]
> +                + z * frame->transform[2][1] + frame->transform[3][1];
> +        d->u3.z = x * frame->transform[0][2] + y * frame->transform[1][2]
> +                + z * frame->transform[2][2] + frame->transform[3][2];
> +    }
> +
> +    return D3DRM_OK;
>  }
This would probably benefit from a helper function along the lines of
wined3d_vec4_transform() in wined3d.

> +#define SET_TRANSFORM(frame, m11,m12,m13, m21,m22,m23, m31,m32,m33, m41,m42,m43) \
> +    { \
> +        D3DRMMATRIX4D matrix; \
> +        matrix[0][0] = D3DVAL(m11); \
> +        matrix[0][1] = D3DVAL(m12); \
> +        matrix[0][2] = D3DVAL(m13); \
> +        matrix[0][3] = D3DVAL(0); \
> +        matrix[1][0] = D3DVAL(m21); \
> +        matrix[1][1] = D3DVAL(m22); \
> +        matrix[1][2] = D3DVAL(m23); \
> +        matrix[1][3] = D3DVAL(0); \
> +        matrix[2][0] = D3DVAL(m31); \
> +        matrix[2][1] = D3DVAL(m32); \
> +        matrix[2][2] = D3DVAL(m33); \
> +        matrix[2][3] = D3DVAL(0); \
> +        matrix[3][0] = D3DVAL(m41); \
> +        matrix[3][1] = D3DVAL(m42); \
> +        matrix[3][2] = D3DVAL(m43); \
> +        matrix[3][3] = D3DVAL(1); \
> +        IDirect3DRMFrame_AddTransform(frame, D3DRMCOMBINE_REPLACE, matrix); \
> +    }
> +#define SET_VECTOR(vector, vx,vy,vz) \
> +    { \
> +        (vector).x = D3DVAL(vx); \
> +        (vector).y = D3DVAL(vy); \
> +        (vector).z = D3DVAL(vz); \
> +    }
> +
> +#define MAXERROR_ABS 0.000001
> +#define MAXERROR_REL 0.000001
> +#define CHECK(a, b) \
> +    { \
> +        if (pass) \
> +        { \
> +            if ((a < 1 && a > -1) || (b < 1 && b > -1)) \
> +            { \
> +               if (fabs((a) - (b)) > MAXERROR_ABS) \
> +               { \
> +                   pass = 0; \
> +               } \
> +            } \
> +            else \
> +            { \
> +               if (fabs((a) - (b)) > fabs(MAXERROR_REL * (b))) \
> +               { \
> +                   pass = 0; \
> +               } \
> +            } \
> +        } \
> +    }
> +
> +#define EXPECT_VECTOR(test_description, vector, vx,vy,vz) \
> +    { \
> +        int pass = 1; \
> +        ok(hr == D3DRM_OK, test_description ": returned hr = %x\n", hr); \
> +        CHECK((vector).x, vx); \
> +        CHECK((vector).y, vy); \
> +        CHECK((vector).z, vz); \
> +        ok(pass, test_description ": vector result is not correct\n"); \
> +    }
I don't think any of these need to be macros. You may want to take a
look at e.g. the compare_point() helper in dlls/d2d1/tests/d2d1.c as
an example.

As an aside, I'd recommend sending smaller series of patches,
especially when you're new to a module. Although I don't mind, it's
not necessary to send patches to my codeweavers.com address, I see
them here.

Thanks for working on this,

Henri



More information about the wine-devel mailing list