Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/d3drm/frame.c | 27 +++++++++++++++++-- dlls/d3drm/tests/d3drm.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 91 insertions(+), 3 deletions(-)
diff --git a/dlls/d3drm/frame.c b/dlls/d3drm/frame.c index 8bed50b57e..46b5f37412 100644 --- a/dlls/d3drm/frame.c +++ b/dlls/d3drm/frame.c @@ -937,10 +937,31 @@ static HRESULT WINAPI d3drm_frame1_AddMoveCallback(IDirect3DRMFrame *iface, return E_NOTIMPL; }
+static void matrix_multiply_affine(D3DRMMATRIX4D d, D3DRMMATRIX4D s1, D3DRMMATRIX4D s2) +{ + d[0][0] = s1[0][0] * s2[0][0] + s1[0][1] * s2[1][0] + s1[0][2] * s2[2][0]; + d[0][1] = s1[0][0] * s2[0][1] + s1[0][1] * s2[1][1] + s1[0][2] * s2[2][1]; + d[0][2] = s1[0][0] * s2[0][2] + s1[0][1] * s2[1][2] + s1[0][2] * s2[2][2]; + d[0][3] = 0.0f; + d[1][0] = s1[1][0] * s2[0][0] + s1[1][1] * s2[1][0] + s1[1][2] * s2[2][0]; + d[1][1] = s1[1][0] * s2[0][1] + s1[1][1] * s2[1][1] + s1[1][2] * s2[2][1]; + d[1][2] = s1[1][0] * s2[0][2] + s1[1][1] * s2[1][2] + s1[1][2] * s2[2][2]; + d[1][3] = 0.0f; + d[2][0] = s1[2][0] * s2[0][0] + s1[2][1] * s2[1][0] + s1[2][2] * s2[2][0]; + d[2][1] = s1[2][0] * s2[0][1] + s1[2][1] * s2[1][1] + s1[2][2] * s2[2][1]; + d[2][2] = s1[2][0] * s2[0][2] + s1[2][1] * s2[1][2] + s1[2][2] * s2[2][2]; + d[2][3] = 0.0f; + d[3][0] = s1[3][0] * s2[0][0] + s1[3][1] * s2[1][0] + s1[3][2] * s2[2][0] + s2[3][0]; + d[3][1] = s1[3][0] * s2[0][1] + s1[3][1] * s2[1][1] + s1[3][2] * s2[2][1] + s2[3][1]; + d[3][2] = s1[3][0] * s2[0][2] + s1[3][1] * s2[1][2] + s1[3][2] * s2[2][2] + s2[3][2]; + d[3][3] = 1.0f; +} + static HRESULT WINAPI d3drm_frame3_AddTransform(IDirect3DRMFrame3 *iface, D3DRMCOMBINETYPE type, D3DRMMATRIX4D matrix) { struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface); + D3DRMMATRIX4D m;
TRACE("iface %p, type %#x, matrix %p.\n", iface, type, matrix);
@@ -951,11 +972,13 @@ static HRESULT WINAPI d3drm_frame3_AddTransform(IDirect3DRMFrame3 *iface, break;
case D3DRMCOMBINE_BEFORE: - FIXME("D3DRMCOMBINE_BEFORE not supported yet\n"); + memcpy(m, frame->transform, sizeof(D3DRMMATRIX4D)); + matrix_multiply_affine(frame->transform, matrix, m); break;
case D3DRMCOMBINE_AFTER: - FIXME("D3DRMCOMBINE_AFTER not supported yet\n"); + memcpy(m, frame->transform, sizeof(D3DRMMATRIX4D)); + matrix_multiply_affine(frame->transform, m, matrix); break;
default: diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index cc4f8fe16a..9cfdba484e 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -75,6 +75,30 @@ static void vector_eq_(unsigned int line, const D3DVECTOR *left, const D3DVECTOR check_vector_(line, left, U1(right)->x, U2(right)->y, U3(right)->z, 0); }
+#define check_matrix(a, b,c,d, e,f,g, h,i,j, k,l,m, n) check_matrix_(__LINE__, a, b,c,d, e,f,g, h,i,j, k,l,m, n) +static void check_matrix_(unsigned int line, const D3DRMMATRIX4D m, + D3DVALUE m11, D3DVALUE m12, D3DVALUE m13, + D3DVALUE m21, D3DVALUE m22, D3DVALUE m23, + D3DVALUE m31, D3DVALUE m32, D3DVALUE m33, + D3DVALUE m41, D3DVALUE m42, D3DVALUE m43, + unsigned int ulps) +{ + BOOL ret = compare_float(m[0][0], m11, ulps) + && compare_float(m[0][1], m12, ulps) + && compare_float(m[0][2], m13, ulps) + && compare_float(m[1][0], m21, ulps) + && compare_float(m[1][1], m22, ulps) + && compare_float(m[1][2], m23, ulps) + && compare_float(m[2][0], m31, ulps) + && compare_float(m[2][1], m32, ulps) + && compare_float(m[2][2], m33, ulps) + && compare_float(m[3][0], m41, ulps) + && compare_float(m[3][1], m42, ulps) + && compare_float(m[3][2], m43, ulps); + + ok_(__FILE__, line)(ret, "Got unexpected matrix.\n"); +} + static D3DRMMATRIX4D identity = { { 1.0f, 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f, 0.0f }, @@ -2709,12 +2733,28 @@ cleanup: DestroyWindow(window); }
+static void set_transform(IDirect3DRMFrame *frame, + D3DVALUE m11, D3DVALUE m12, D3DVALUE m13, + D3DVALUE m21, D3DVALUE m22, D3DVALUE m23, + D3DVALUE m31, D3DVALUE m32, D3DVALUE m33, + D3DVALUE m41, D3DVALUE m42, D3DVALUE m43) +{ + D3DRMMATRIX4D matrix = { + {m11, m12, m13, 0.0f}, + {m21, m22, m23, 0.0f}, + {m31, m32, m33, 0.0f}, + {m41, m42, m43, 1.0f} + }; + + IDirect3DRMFrame_AddTransform(frame, D3DRMCOMBINE_REPLACE, matrix); +} + static void test_frame_transform(void) { HRESULT hr; IDirect3DRM *d3drm; IDirect3DRMFrame *frame; - D3DRMMATRIX4D matrix; + D3DRMMATRIX4D matrix, add_matrix;
hr = Direct3DRMCreate(&d3drm); ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr); @@ -2726,6 +2766,31 @@ static void test_frame_transform(void) ok(hr == D3DRM_OK, "IDirect3DRMFrame_GetTransform returned hr = %x\n", hr); ok(!memcmp(matrix, identity, sizeof(D3DRMMATRIX4D)), "Returned matrix is not identity\n");
+ + memcpy(add_matrix, identity, sizeof(D3DRMMATRIX4D)); + add_matrix[3][0] = 3.0f; + add_matrix[3][1] = 3.0f; + add_matrix[3][2] = 3.0f; + + set_transform(frame, 2,0,0, 0,2,0, 0,0,2, 0,0,0); + hr = IDirect3DRMFrame_AddTransform(frame, D3DRMCOMBINE_REPLACE, add_matrix); + ok(hr == D3DRM_OK, "Cannot add transform (REPLACE) (hr = %x)", hr); + IDirect3DRMFrame_GetTransform(frame, matrix); + check_matrix(matrix, 1,0,0, 0,1,0, 0,0,1, 3,3,3, 32); + + set_transform(frame, 2,0,0, 0,2,0, 0,0,2, 0,0,0); + hr = IDirect3DRMFrame_AddTransform(frame, D3DRMCOMBINE_BEFORE, add_matrix); + ok(hr == D3DRM_OK, "Cannot add transform (BEFORE) (hr = %x)", hr); + IDirect3DRMFrame_GetTransform(frame, matrix); + check_matrix(matrix, 2,0,0, 0,2,0, 0,0,2, 6,6,6, 32); + + set_transform(frame, 2,0,0, 0,2,0, 0,0,2, 0,0,0); + hr = IDirect3DRMFrame_AddTransform(frame, D3DRMCOMBINE_AFTER, add_matrix); + ok(hr == D3DRM_OK, "Cannot add transform (AFTER) (hr = %x)", hr); + IDirect3DRMFrame_GetTransform(frame, matrix); + check_matrix(matrix, 2,0,0, 0,2,0, 0,0,2, 3,3,3, 32); + + IDirect3DRMFrame_Release(frame); IDirect3DRM_Release(d3drm); }
Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/d3drm/frame.c | 3 +++ dlls/d3drm/tests/d3drm.c | 4 ++++ 2 files changed, 7 insertions(+)
diff --git a/dlls/d3drm/frame.c b/dlls/d3drm/frame.c index 46b5f37412..ed1e6c719f 100644 --- a/dlls/d3drm/frame.c +++ b/dlls/d3drm/frame.c @@ -965,6 +965,9 @@ static HRESULT WINAPI d3drm_frame3_AddTransform(IDirect3DRMFrame3 *iface,
TRACE("iface %p, type %#x, matrix %p.\n", iface, type, matrix);
+ if (matrix[0][3] != 0.0f || matrix[1][3] != 0.0f || matrix[2][3] != 0.0f || matrix[3][3] != 1.0f) + return D3DRMERR_BADVALUE; + switch (type) { case D3DRMCOMBINE_REPLACE: diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index 9cfdba484e..e91b1ddee6 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -2790,6 +2790,10 @@ static void test_frame_transform(void) IDirect3DRMFrame_GetTransform(frame, matrix); check_matrix(matrix, 2,0,0, 0,2,0, 0,0,2, 3,3,3, 32);
+ add_matrix[3][3] = 2.0f; + hr = IDirect3DRMFrame_AddTransform(frame, D3DRMCOMBINE_REPLACE, add_matrix); + ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr); +
IDirect3DRMFrame_Release(frame); IDirect3DRM_Release(d3drm);
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=53814
Your paranoid android.
=== debian9 (build log) ===
Task: WineTest did not produce the wow32 report
Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/d3drm/frame.c | 50 ++++++++++++++++++++++++++++++++++++++++++------ dlls/d3drm/tests/d3drm.c | 19 ++++++++++++++++++ 2 files changed, 63 insertions(+), 6 deletions(-)
diff --git a/dlls/d3drm/frame.c b/dlls/d3drm/frame.c index ed1e6c719f..7bb848b4c6 100644 --- a/dlls/d3drm/frame.c +++ b/dlls/d3drm/frame.c @@ -1015,25 +1015,63 @@ static HRESULT WINAPI d3drm_frame1_AddTransform(IDirect3DRMFrame *iface, static HRESULT WINAPI d3drm_frame3_AddTranslation(IDirect3DRMFrame3 *iface, D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z) { - FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e stub!\n", iface, type, x, y, z); + struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
- return E_NOTIMPL; + TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e.\n", iface, type, x, y, z); + + switch (type) + { + case D3DRMCOMBINE_REPLACE: + memcpy(frame->transform, identity, sizeof(D3DRMMATRIX4D)); + frame->transform[3][0] = x; + frame->transform[3][1] = y; + frame->transform[3][2] = z; + break; + + case D3DRMCOMBINE_BEFORE: + frame->transform[3][0] += frame->transform[0][0] * x + + frame->transform[1][0] * y + + frame->transform[2][0] * z; + frame->transform[3][1] += frame->transform[0][1] * x + + frame->transform[1][1] * y + + frame->transform[2][1] * z; + frame->transform[3][2] += frame->transform[0][2] * x + + frame->transform[1][2] * y + + frame->transform[2][2] * z; + break; + + case D3DRMCOMBINE_AFTER: + frame->transform[3][0] += x; + frame->transform[3][1] += y; + frame->transform[3][2] += z; + break; + + default: + WARN("Unknown Combine Type %u\n", type); + return D3DRMERR_BADVALUE; + } + + return D3DRM_OK; }
static HRESULT WINAPI d3drm_frame2_AddTranslation(IDirect3DRMFrame2 *iface, D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z) { - FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e stub!\n", iface, type, x, y, z); + struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
- return E_NOTIMPL; + TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e.\n", iface, type, x, y, z); + + return d3drm_frame3_AddTranslation(&frame->IDirect3DRMFrame3_iface, type, x, y, z); }
static HRESULT WINAPI d3drm_frame1_AddTranslation(IDirect3DRMFrame *iface, D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z) { - FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e stub!\n", iface, type, x, y, z); + struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
- return E_NOTIMPL; + TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e.\n", iface, type, x, y, z); + + return d3drm_frame3_AddTranslation(&frame->IDirect3DRMFrame3_iface, type, x, y, z); }
static HRESULT WINAPI d3drm_frame3_AddScale(IDirect3DRMFrame3 *iface, diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index e91b1ddee6..22869e57c5 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -2795,6 +2795,25 @@ static void test_frame_transform(void) ok(hr == D3DRMERR_BADVALUE, "Expected hr == D3DRMERR_BADVALUE, got %x.\n", hr);
+ set_transform(frame, 2,0,0, 0,2,0, 0,0,2, 0,0,0); + hr = IDirect3DRMFrame_AddTranslation(frame, D3DRMCOMBINE_REPLACE, 3.0f, 3.0f, 3.0f); + ok(hr == D3DRM_OK, "Cannot add translation (REPLACE) (hr = %x)", hr); + IDirect3DRMFrame_GetTransform(frame, matrix); + check_matrix(matrix, 1,0,0, 0,1,0, 0,0,1, 3,3,3, 32); + + set_transform(frame, 2,0,0, 0,2,0, 0,0,2, 0,0,0); + hr = IDirect3DRMFrame_AddTranslation(frame, D3DRMCOMBINE_BEFORE, 3.0f, 3.0f, 3.0f); + ok(hr == D3DRM_OK, "Cannot add translation (BEFORE) (hr = %x)", hr); + IDirect3DRMFrame_GetTransform(frame, matrix); + check_matrix(matrix, 2,0,0, 0,2,0, 0,0,2, 6,6,6, 32); + + set_transform(frame, 2,0,0, 0,2,0, 0,0,2, 0,0,0); + hr = IDirect3DRMFrame_AddTranslation(frame, D3DRMCOMBINE_AFTER, 3.0f, 3.0f, 3.0f); + ok(hr == D3DRM_OK, "Cannot add translation (AFTER) (hr = %x)", hr); + IDirect3DRMFrame_GetTransform(frame, matrix); + check_matrix(matrix, 2,0,0, 0,2,0, 0,0,2, 3,3,3, 32); + + IDirect3DRMFrame_Release(frame); IDirect3DRM_Release(d3drm); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=53815
Your paranoid android.
=== debian9 (build log) ===
Task: WineTest did not produce the wow32 report
Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/d3drm/frame.c | 59 +++++++++++++++++++++++++++++++++++++++++++----- dlls/d3drm/tests/d3drm.c | 19 ++++++++++++++++ 2 files changed, 72 insertions(+), 6 deletions(-)
diff --git a/dlls/d3drm/frame.c b/dlls/d3drm/frame.c index 7bb848b4c6..26f01d85dc 100644 --- a/dlls/d3drm/frame.c +++ b/dlls/d3drm/frame.c @@ -1077,25 +1077,72 @@ static HRESULT WINAPI d3drm_frame1_AddTranslation(IDirect3DRMFrame *iface, static HRESULT WINAPI d3drm_frame3_AddScale(IDirect3DRMFrame3 *iface, D3DRMCOMBINETYPE type, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) { - FIXME("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e stub!\n", iface, type, sx, sy, sz); + struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface);
- return E_NOTIMPL; + TRACE("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e.\n", iface, type, sx, sy, sz); + + switch (type) + { + case D3DRMCOMBINE_REPLACE: + memcpy(frame->transform, identity, sizeof(D3DRMMATRIX4D)); + frame->transform[0][0] = sx; + frame->transform[1][1] = sy; + frame->transform[2][2] = sz; + break; + + case D3DRMCOMBINE_BEFORE: + frame->transform[0][0] *= sx; + frame->transform[0][1] *= sx; + frame->transform[0][2] *= sx; + frame->transform[1][0] *= sy; + frame->transform[1][1] *= sy; + frame->transform[1][2] *= sy; + frame->transform[2][0] *= sz; + frame->transform[2][1] *= sz; + frame->transform[2][2] *= sz; + break; + + case D3DRMCOMBINE_AFTER: + frame->transform[0][0] *= sx; + frame->transform[0][1] *= sy; + frame->transform[0][2] *= sz; + frame->transform[1][0] *= sx; + frame->transform[1][1] *= sy; + frame->transform[1][2] *= sz; + frame->transform[2][0] *= sx; + frame->transform[2][1] *= sy; + frame->transform[2][2] *= sz; + frame->transform[3][0] *= sx; + frame->transform[3][1] *= sy; + frame->transform[3][2] *= sz; + break; + + default: + WARN("Unknown Combine Type %u\n", type); + return D3DRMERR_BADVALUE; + } + + return D3DRM_OK; }
static HRESULT WINAPI d3drm_frame2_AddScale(IDirect3DRMFrame2 *iface, D3DRMCOMBINETYPE type, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) { - FIXME("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e stub!\n", iface, type, sx, sy, sz); + struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
- return E_NOTIMPL; + TRACE("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e.\n", iface, type, sx, sy, sz); + + return d3drm_frame3_AddScale(&frame->IDirect3DRMFrame3_iface, type, sx, sy, sz); }
static HRESULT WINAPI d3drm_frame1_AddScale(IDirect3DRMFrame *iface, D3DRMCOMBINETYPE type, D3DVALUE sx, D3DVALUE sy, D3DVALUE sz) { - FIXME("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e stub!\n", iface, type, sx, sy, sz); + struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
- return E_NOTIMPL; + TRACE("iface %p, type %#x, sx %.8e, sy %.8e, sz %.8e.\n", iface, type, sx, sy, sz); + + return d3drm_frame3_AddScale(&frame->IDirect3DRMFrame3_iface, type, sx, sy, sz); }
static HRESULT WINAPI d3drm_frame3_AddRotation(IDirect3DRMFrame3 *iface, diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index 22869e57c5..ecf23103a7 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -2814,6 +2814,25 @@ static void test_frame_transform(void) check_matrix(matrix, 2,0,0, 0,2,0, 0,0,2, 3,3,3, 32);
+ set_transform(frame, 1,0,0, 0,1,0, 0,0,1, 3,3,3); + hr = IDirect3DRMFrame_AddScale(frame, D3DRMCOMBINE_REPLACE, 2.0f, 2.0f, 2.0f); + ok(hr == D3DRM_OK, "Cannot add scale (REPLACE) (hr = %x)", hr); + IDirect3DRMFrame_GetTransform(frame, matrix); + check_matrix(matrix, 2,0,0, 0,2,0, 0,0,2, 0,0,0, 32); + + set_transform(frame, 1,0,0, 0,1,0, 0,0,1, 3,3,3); + hr = IDirect3DRMFrame_AddScale(frame, D3DRMCOMBINE_BEFORE, 2.0f, 2.0f, 2.0f); + ok(hr == D3DRM_OK, "Cannot add scale (BEFORE) (hr = %x)", hr); + IDirect3DRMFrame_GetTransform(frame, matrix); + check_matrix(matrix, 2,0,0, 0,2,0, 0,0,2, 3,3,3, 32); + + set_transform(frame, 1,0,0, 0,1,0, 0,0,1, 3,3,3); + hr = IDirect3DRMFrame_AddScale(frame, D3DRMCOMBINE_AFTER, 2.0f, 2.0f, 2.0f); + ok(hr == D3DRM_OK, "Cannot add scale (AFTER) (hr = %x)", hr); + IDirect3DRMFrame_GetTransform(frame, matrix); + check_matrix(matrix, 2,0,0, 0,2,0, 0,0,2, 6,6,6, 32); + + IDirect3DRMFrame_Release(frame); IDirect3DRM_Release(d3drm); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=53816
Your paranoid android.
=== debian9 (build log) ===
Task: WineTest did not produce the wow32 report
Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/d3drm/frame.c | 75 +++++++++++++++++++++++++++++++++++++++++++----- dlls/d3drm/tests/d3drm.c | 48 +++++++++++++++++++++++++++++++ 2 files changed, 116 insertions(+), 7 deletions(-)
diff --git a/dlls/d3drm/frame.c b/dlls/d3drm/frame.c index 26f01d85dc..10aebb704e 100644 --- a/dlls/d3drm/frame.c +++ b/dlls/d3drm/frame.c @@ -1145,29 +1145,90 @@ static HRESULT WINAPI d3drm_frame1_AddScale(IDirect3DRMFrame *iface, return d3drm_frame3_AddScale(&frame->IDirect3DRMFrame3_iface, type, sx, sy, sz); }
+static void rotate_axis(D3DRMMATRIX4D matrix, D3DVECTOR *axis, D3DVALUE theta) +{ + D3DVALUE stheta, ctheta, coff; + + D3DRMVectorNormalize(axis); + stheta = sinf(theta); + ctheta = cosf(theta); + coff = 1.0f - ctheta; + + matrix[0][0] = coff * axis->u1.x * axis->u1.x + ctheta; + matrix[1][0] = coff * axis->u1.x * axis->u2.y - stheta * axis->u3.z; + matrix[2][0] = coff * axis->u1.x * axis->u3.z + stheta * axis->u2.y; + matrix[3][0] = 0.0f; + matrix[0][1] = coff * axis->u2.y * axis->u1.x + stheta * axis->u3.z; + matrix[1][1] = coff * axis->u2.y * axis->u2.y + ctheta; + matrix[2][1] = coff * axis->u2.y * axis->u3.z - stheta * axis->u1.x; + matrix[3][1] = 0.0f; + matrix[0][2] = coff * axis->u3.z * axis->u1.x - stheta * axis->u2.y; + matrix[1][2] = coff * axis->u3.z * axis->u2.y + stheta * axis->u1.x; + matrix[2][2] = coff * axis->u3.z * axis->u3.z + ctheta; + matrix[3][2] = 0.0f; + matrix[0][3] = 0.0f; + matrix[1][3] = 0.0f; + matrix[2][3] = 0.0f; + matrix[3][3] = 1.0f; +} + static HRESULT WINAPI d3drm_frame3_AddRotation(IDirect3DRMFrame3 *iface, D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) { - FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e stub!\n", - iface, type, x, y, z, theta); + struct d3drm_frame *frame = impl_from_IDirect3DRMFrame3(iface); + D3DVECTOR axis; + D3DRMMATRIX4D m, m2;
- return E_NOTIMPL; + TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e.\n", iface, type, x, y, z, theta); + + axis.u1.x = x; + axis.u2.y = y; + axis.u3.z = z; + + switch (type) + { + case D3DRMCOMBINE_REPLACE: + rotate_axis(frame->transform, &axis, theta); + break; + + case D3DRMCOMBINE_BEFORE: + rotate_axis(m, &axis, theta); + memcpy(m2, frame->transform, sizeof(D3DRMMATRIX4D)); + matrix_multiply_affine(frame->transform, m, m2); + break; + + case D3DRMCOMBINE_AFTER: + memcpy(m, frame->transform, sizeof(D3DRMMATRIX4D)); + rotate_axis(m2, &axis, theta); + matrix_multiply_affine(frame->transform, m, m2); + break; + + default: + WARN("Unknown Combine Type %u\n", type); + return D3DRMERR_BADVALUE; + } + + return D3DRM_OK; }
static HRESULT WINAPI d3drm_frame2_AddRotation(IDirect3DRMFrame2 *iface, D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) { - FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e stub!\n", iface, type, x, y, z, theta); + struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
- return E_NOTIMPL; + TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e.\n", iface, type, x, y, z, theta); + + return d3drm_frame3_AddRotation(&frame->IDirect3DRMFrame3_iface, type, x, y, z, theta); }
static HRESULT WINAPI d3drm_frame1_AddRotation(IDirect3DRMFrame *iface, D3DRMCOMBINETYPE type, D3DVALUE x, D3DVALUE y, D3DVALUE z, D3DVALUE theta) { - FIXME("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e stub!\n", iface, type, x, y, z, theta); + struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
- return E_NOTIMPL; + TRACE("iface %p, type %#x, x %.8e, y %.8e, z %.8e, theta %.8e.\n", iface, type, x, y, z, theta); + + return d3drm_frame3_AddRotation(&frame->IDirect3DRMFrame3_iface, type, x, y, z, theta); }
static HRESULT WINAPI d3drm_frame3_AddVisual(IDirect3DRMFrame3 *iface, IUnknown *visual) diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index ecf23103a7..71dbe7793c 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -2749,6 +2749,20 @@ static void set_transform(IDirect3DRMFrame *frame, IDirect3DRMFrame_AddTransform(frame, D3DRMCOMBINE_REPLACE, matrix); }
+static void sanitize_matrix(D3DRMMATRIX4D m) +{ + int i, j; + + for (i = 0; i < 4; i++) + { + for (j = 0; j < 4; j++) + { + if (m[i][j] > -1e-7 && m[i][j] < 1e-7) + m[i][j] = 0.0; + } + } +} + static void test_frame_transform(void) { HRESULT hr; @@ -2833,6 +2847,40 @@ static void test_frame_transform(void) check_matrix(matrix, 2,0,0, 0,2,0, 0,0,2, 6,6,6, 32);
+ set_transform(frame, 1,0,0, 0,1,0, 0,0,1, 3,3,3); + hr = IDirect3DRMFrame_AddRotation(frame, D3DRMCOMBINE_REPLACE, 1.0f, 0.0f, 0.0f, 1.57079633f); + ok(hr == D3DRM_OK, "Cannot add rotation (REPLACE) (hr = %x)", hr); + IDirect3DRMFrame_GetTransform(frame, matrix); + sanitize_matrix(matrix); + check_matrix(matrix, 1,0,0, 0,0,1, 0,-1,0, 0,0,0, 32); + + set_transform(frame, 1,0,0, 0,1,0, 0,0,1, 3,3,3); + hr = IDirect3DRMFrame_AddRotation(frame, D3DRMCOMBINE_BEFORE, 1.0f, 0.0f, 0.0f, 1.57079633f); + ok(hr == D3DRM_OK, "Cannot add rotation (BEFORE) (hr = %x)", hr); + IDirect3DRMFrame_GetTransform(frame, matrix); + sanitize_matrix(matrix); + check_matrix(matrix, 1,0,0, 0,0,1, 0,-1,0, 3,3,3, 32); + + set_transform(frame, 1,0,0, 0,1,0, 0,0,1, 3,3,3); + hr = IDirect3DRMFrame_AddRotation(frame, D3DRMCOMBINE_AFTER, 1.0f, 0.0f, 0.0f, 1.57079633f); + ok(hr == D3DRM_OK, "Cannot add rotation (AFTER) (hr = %x)", hr); + IDirect3DRMFrame_GetTransform(frame, matrix); + sanitize_matrix(matrix); + check_matrix(matrix, 1,0,0, 0,0,1, 0,-1,0, 3,-3,3, 32); + + hr = IDirect3DRMFrame_AddRotation(frame, D3DRMCOMBINE_REPLACE, 0.0f, 0.0f, 1.0f, 1.57079633f); + ok(hr == D3DRM_OK, "Cannot add rotation around Z axis (AFTER) (hr = %x)", hr); + IDirect3DRMFrame_GetTransform(frame, matrix); + sanitize_matrix(matrix); + check_matrix(matrix, 0,1,0, -1,0,0, 0,0,1, 0,0,0, 32); + + hr = IDirect3DRMFrame_AddRotation(frame, D3DRMCOMBINE_REPLACE, 0.0f, 0.0f, 0.0f, 1.57079633f); + ok(hr == D3DRM_OK, "Cannot add rotation around null axis (hr = %x)", hr); + IDirect3DRMFrame_GetTransform(frame, matrix); + sanitize_matrix(matrix); + check_matrix(matrix, 1,0,0, 0,0,1, 0,-1,0, 0,0,0, 32); + + IDirect3DRMFrame_Release(frame); IDirect3DRM_Release(d3drm); }
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=53817
Your paranoid android.
=== debian9 (build log) ===
Task: WineTest did not produce the wow32 report
Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/d3drm/frame.c | 33 +++++++++++++++++++++++++++------ dlls/d3drm/tests/d3drm.c | 25 ++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 7 deletions(-)
diff --git a/dlls/d3drm/frame.c b/dlls/d3drm/frame.c index 10aebb704e..a97143cd37 100644 --- a/dlls/d3drm/frame.c +++ b/dlls/d3drm/frame.c @@ -1717,6 +1717,13 @@ static HRESULT WINAPI d3drm_frame1_GetTextureTopology(IDirect3DRMFrame *iface, B return E_NOTIMPL; }
+static void transform_affine(D3DVECTOR *d, D3DVALUE *s, D3DRMMATRIX4D m) +{ + d->u1.x = s->u1.x * m[0][0] + s->u2.y * m[1][0] + s->u3.z * m[2][0] + m[3][0]; + d->u2.y = s->u1.x * m[0][1] + s->u2.y * m[1][1] + s->u3.z * m[2][1] + m[3][1]; + d->u3.z = s->u1.x * m[0][2] + s->u2.y * m[1][2] + s->u3.z * m[2][2] + m[3][2]; +} + static HRESULT WINAPI d3drm_frame3_InverseTransform(IDirect3DRMFrame3 *iface, D3DVECTOR *d, D3DVECTOR *s) { FIXME("iface %p, d %p, s %p stub!\n", iface, d, s); @@ -2588,23 +2595,37 @@ static HRESULT WINAPI d3drm_frame1_SetZbufferMode(IDirect3DRMFrame *iface, D3DRM
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); + + transform_affine(d, s, frame->transform); + while ((frame = frame->parent)) + { + D3DVECTOR temp; + memcpy(&temp, d, sizeof(D3DVECTOR)); + transform_affine(d, &temp, frame->transform); + } + + return D3DRM_OK; }
static HRESULT WINAPI d3drm_frame2_Transform(IDirect3DRMFrame2 *iface, D3DVECTOR *d, D3DVECTOR *s) { - FIXME("iface %p, d %p, s %p stub!\n", iface, d, s); + struct d3drm_frame *frame = impl_from_IDirect3DRMFrame2(iface);
- return E_NOTIMPL; + TRACE("iface %p, d %p, s %p.\n", iface, d, s); + + return d3drm_frame3_Transform(&frame->IDirect3DRMFrame3_iface, d, s); }
static HRESULT WINAPI d3drm_frame1_Transform(IDirect3DRMFrame *iface, D3DVECTOR *d, D3DVECTOR *s) { - FIXME("iface %p, d %p, s %p stub!\n", iface, d, s); + struct d3drm_frame *frame = impl_from_IDirect3DRMFrame(iface);
- return E_NOTIMPL; + TRACE("iface %p, d %p, s %p.\n", iface, d, s); + + return d3drm_frame3_Transform(&frame->IDirect3DRMFrame3_iface, d, s); }
static HRESULT WINAPI d3drm_frame2_AddMoveCallback2(IDirect3DRMFrame2 *iface, diff --git a/dlls/d3drm/tests/d3drm.c b/dlls/d3drm/tests/d3drm.c index 71dbe7793c..a52d102a9a 100644 --- a/dlls/d3drm/tests/d3drm.c +++ b/dlls/d3drm/tests/d3drm.c @@ -2749,6 +2749,13 @@ static void set_transform(IDirect3DRMFrame *frame, IDirect3DRMFrame_AddTransform(frame, D3DRMCOMBINE_REPLACE, matrix); }
+static void set_vector(D3DVECTOR *vector, D3DVALUE vx, D3DVALUE vy, D3DVALUE vz) +{ + vector->x = vx; + vector->y = vy; + vector->z = vz; +} + static void sanitize_matrix(D3DRMMATRIX4D m) { int i, j; @@ -2767,8 +2774,9 @@ static void test_frame_transform(void) { HRESULT hr; IDirect3DRM *d3drm; - IDirect3DRMFrame *frame; + IDirect3DRMFrame *frame, *subframe; D3DRMMATRIX4D matrix, add_matrix; + D3DVECTOR v1, v2;
hr = Direct3DRMCreate(&d3drm); ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr); @@ -2881,6 +2889,21 @@ static void test_frame_transform(void) check_matrix(matrix, 1,0,0, 0,0,1, 0,-1,0, 0,0,0, 32);
+ set_transform(frame, 2,0,0, 0,4,0, 0,0,8, 64,64,64); + IDirect3DRM_CreateFrame(d3drm, frame, &subframe); + set_transform(subframe, 1,0,0, 0,1,0, 0,0,1, 11,11,11); + set_vector(&v1, 3,5,7); + + hr = IDirect3DRMFrame_Transform(frame, &v2, &v1); + ok(hr == D3DRM_OK, "Cannot transform (hr = %x)", hr); + check_vector(&v2, 70,84,120, 32); + + hr = IDirect3DRMFrame_Transform(subframe, &v2, &v1); + ok(hr == D3DRM_OK, "Cannot transform subframe (hr = %x)", hr); + check_vector(&v2, 92,128,208, 32); + + + IDirect3DRMFrame_Release(subframe); IDirect3DRMFrame_Release(frame); IDirect3DRM_Release(d3drm); }
On Mon, Jun 17, 2019 at 8:21 PM Jeff Smith whydoubt@gmail.com wrote:
+static void transform_affine(D3DVECTOR *d, D3DVALUE *s, D3DRMMATRIX4D m) +{
- d->u1.x = s->u1.x * m[0][0] + s->u2.y * m[1][0] + s->u3.z * m[2][0] + m[3][0];
- d->u2.y = s->u1.x * m[0][1] + s->u2.y * m[1][1] + s->u3.z * m[2][1] + m[3][1];
- d->u3.z = s->u1.x * m[0][2] + s->u2.y * m[1][2] + s->u3.z * m[2][2] + m[3][2];
+}
I already have that second arg corrected to "D3DVECTOR *s" but I sent the wrong version of the patch. I will get the right one in on the next round.
-- Jeff
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=53818
Your paranoid android.
=== debian9 (build log) ===
../../../wine/dlls/d3drm/frame.c:1722:16: error: request for member ‘u1’ in something not a structure or union ../../../wine/dlls/d3drm/frame.c:1722:36: error: request for member ‘u2’ in something not a structure or union ../../../wine/dlls/d3drm/frame.c:1722:56: error: request for member ‘u3’ in something not a structure or union ../../../wine/dlls/d3drm/frame.c:1723:16: error: request for member ‘u1’ in something not a structure or union ../../../wine/dlls/d3drm/frame.c:1723:36: error: request for member ‘u2’ in something not a structure or union ../../../wine/dlls/d3drm/frame.c:1723:56: error: request for member ‘u3’ in something not a structure or union ../../../wine/dlls/d3drm/frame.c:1724:16: error: request for member ‘u1’ in something not a structure or union ../../../wine/dlls/d3drm/frame.c:1724:36: error: request for member ‘u2’ in something not a structure or union ../../../wine/dlls/d3drm/frame.c:1724:56: error: request for member ‘u3’ in something not a structure or union Makefile:361: recipe for target 'frame.cross.o' failed Makefile:8513: recipe for target 'dlls/d3drm' failed Task: The win32 build failed
=== debian9 (build log) ===
../../../wine/dlls/d3drm/frame.c:1722:16: error: request for member ‘u1’ in something not a structure or union ../../../wine/dlls/d3drm/frame.c:1722:36: error: request for member ‘u2’ in something not a structure or union ../../../wine/dlls/d3drm/frame.c:1722:56: error: request for member ‘u3’ in something not a structure or union ../../../wine/dlls/d3drm/frame.c:1723:16: error: request for member ‘u1’ in something not a structure or union ../../../wine/dlls/d3drm/frame.c:1723:36: error: request for member ‘u2’ in something not a structure or union ../../../wine/dlls/d3drm/frame.c:1723:56: error: request for member ‘u3’ in something not a structure or union ../../../wine/dlls/d3drm/frame.c:1724:16: error: request for member ‘u1’ in something not a structure or union ../../../wine/dlls/d3drm/frame.c:1724:36: error: request for member ‘u2’ in something not a structure or union ../../../wine/dlls/d3drm/frame.c:1724:56: error: request for member ‘u3’ in something not a structure or union Makefile:359: recipe for target 'frame.cross.o' failed Makefile:8272: recipe for target 'dlls/d3drm' failed Task: The wow64 build failed
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=53813
Your paranoid android.
=== debian9 (build log) ===
Task: WineTest did not produce the wow32 report