[PATCH 01/12] d3drm: Implement frame Transform
Jeff Smith
whydoubt at gmail.com
Thu Jun 13 23:27:26 CDT 2019
Signed-off-by: Jeff Smith <whydoubt at gmail.com>
---
dlls/d3drm/frame.c | 38 +++++++++++++++++++----
dlls/d3drm/tests/d3drm.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 110 insertions(+), 7 deletions(-)
diff --git a/dlls/d3drm/frame.c b/dlls/d3drm/frame.c
index 8bed50b57e..14a524ea7d 100644
--- a/dlls/d3drm/frame.c
+++ b/dlls/d3drm/frame.c
@@ -2416,23 +2416,49 @@ 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);
+
+ 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;
}
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 cc4f8fe16a..76e0ec19fb 100644
--- a/dlls/d3drm/tests/d3drm.c
+++ b/dlls/d3drm/tests/d3drm.c
@@ -20,6 +20,7 @@
*/
#include <limits.h>
+#include <math.h>
#define COBJMACROS
#include <d3d.h>
@@ -2709,12 +2710,75 @@ cleanup:
DestroyWindow(window);
}
+#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"); \
+ }
+
static void test_frame_transform(void)
{
HRESULT hr;
IDirect3DRM *d3drm;
- IDirect3DRMFrame *frame;
+ IDirect3DRMFrame *frame, *subframe;
D3DRMMATRIX4D matrix;
+ D3DVECTOR v1, v2;
hr = Direct3DRMCreate(&d3drm);
ok(hr == D3DRM_OK, "Cannot get IDirect3DRM interface (hr = %x)\n", hr);
@@ -2726,6 +2790,19 @@ 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");
+
+ IDirect3DRM_CreateFrame(d3drm, frame, &subframe);
+
+ SET_TRANSFORM(frame, 2,0,0, 0,4,0, 0,0,8, 64,64,64);
+ 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);
+ EXPECT_VECTOR("Transform", v2, 70,84,120);
+ hr = IDirect3DRMFrame_Transform(subframe, &v2, &v1);
+ EXPECT_VECTOR("Transform (subframe)", v2, 92,128,208);
+
+
+ IDirect3DRMFrame_Release(subframe);
IDirect3DRMFrame_Release(frame);
IDirect3DRM_Release(d3drm);
}
--
2.14.3
More information about the wine-devel
mailing list