Commit ba396e42 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Simplify the wined3d_matrix structure.

parent c5f03c39
......@@ -1362,10 +1362,10 @@ void CDECL wined3d_device_set_transform(struct wined3d_device *device,
{
TRACE("device %p, state %s, matrix %p.\n",
device, debug_d3dtstype(d3dts), matrix);
TRACE("%.8e %.8e %.8e %.8e\n", matrix->u.s._11, matrix->u.s._12, matrix->u.s._13, matrix->u.s._14);
TRACE("%.8e %.8e %.8e %.8e\n", matrix->u.s._21, matrix->u.s._22, matrix->u.s._23, matrix->u.s._24);
TRACE("%.8e %.8e %.8e %.8e\n", matrix->u.s._31, matrix->u.s._32, matrix->u.s._33, matrix->u.s._34);
TRACE("%.8e %.8e %.8e %.8e\n", matrix->u.s._41, matrix->u.s._42, matrix->u.s._43, matrix->u.s._44);
TRACE("%.8e %.8e %.8e %.8e\n", matrix->_11, matrix->_12, matrix->_13, matrix->_14);
TRACE("%.8e %.8e %.8e %.8e\n", matrix->_21, matrix->_22, matrix->_23, matrix->_24);
TRACE("%.8e %.8e %.8e %.8e\n", matrix->_31, matrix->_32, matrix->_33, matrix->_34);
TRACE("%.8e %.8e %.8e %.8e\n", matrix->_41, matrix->_42, matrix->_43, matrix->_44);
/* Handle recording of state blocks. */
if (device->recording)
......@@ -1382,7 +1382,7 @@ void CDECL wined3d_device_set_transform(struct wined3d_device *device,
* tend towards setting the same matrix repeatedly for some reason.
*
* From here on we assume that the new matrix is different, wherever it matters. */
if (!memcmp(&device->state.transforms[d3dts].u.m[0][0], matrix, sizeof(*matrix)))
if (!memcmp(&device->state.transforms[d3dts], matrix, sizeof(*matrix)))
{
TRACE("The application is setting the same matrix over again.\n");
return;
......@@ -2779,22 +2779,22 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
wined3d_device_get_transform(device, WINED3D_TS_WORLD_MATRIX(0), &world_mat);
TRACE("View mat:\n");
TRACE("%f %f %f %f\n", view_mat.u.s._11, view_mat.u.s._12, view_mat.u.s._13, view_mat.u.s._14);
TRACE("%f %f %f %f\n", view_mat.u.s._21, view_mat.u.s._22, view_mat.u.s._23, view_mat.u.s._24);
TRACE("%f %f %f %f\n", view_mat.u.s._31, view_mat.u.s._32, view_mat.u.s._33, view_mat.u.s._34);
TRACE("%f %f %f %f\n", view_mat.u.s._41, view_mat.u.s._42, view_mat.u.s._43, view_mat.u.s._44);
TRACE("%.8e %.8e %.8e %.8e\n", view_mat._11, view_mat._12, view_mat._13, view_mat._14);
TRACE("%.8e %.8e %.8e %.8e\n", view_mat._21, view_mat._22, view_mat._23, view_mat._24);
TRACE("%.8e %.8e %.8e %.8e\n", view_mat._31, view_mat._32, view_mat._33, view_mat._34);
TRACE("%.8e %.8e %.8e %.8e\n", view_mat._41, view_mat._42, view_mat._43, view_mat._44);
TRACE("Proj mat:\n");
TRACE("%f %f %f %f\n", proj_mat.u.s._11, proj_mat.u.s._12, proj_mat.u.s._13, proj_mat.u.s._14);
TRACE("%f %f %f %f\n", proj_mat.u.s._21, proj_mat.u.s._22, proj_mat.u.s._23, proj_mat.u.s._24);
TRACE("%f %f %f %f\n", proj_mat.u.s._31, proj_mat.u.s._32, proj_mat.u.s._33, proj_mat.u.s._34);
TRACE("%f %f %f %f\n", proj_mat.u.s._41, proj_mat.u.s._42, proj_mat.u.s._43, proj_mat.u.s._44);
TRACE("%.8e %.8e %.8e %.8e\n", proj_mat._11, proj_mat._12, proj_mat._13, proj_mat._14);
TRACE("%.8e %.8e %.8e %.8e\n", proj_mat._21, proj_mat._22, proj_mat._23, proj_mat._24);
TRACE("%.8e %.8e %.8e %.8e\n", proj_mat._31, proj_mat._32, proj_mat._33, proj_mat._34);
TRACE("%.8e %.8e %.8e %.8e\n", proj_mat._41, proj_mat._42, proj_mat._43, proj_mat._44);
TRACE("World mat:\n");
TRACE("%f %f %f %f\n", world_mat.u.s._11, world_mat.u.s._12, world_mat.u.s._13, world_mat.u.s._14);
TRACE("%f %f %f %f\n", world_mat.u.s._21, world_mat.u.s._22, world_mat.u.s._23, world_mat.u.s._24);
TRACE("%f %f %f %f\n", world_mat.u.s._31, world_mat.u.s._32, world_mat.u.s._33, world_mat.u.s._34);
TRACE("%f %f %f %f\n", world_mat.u.s._41, world_mat.u.s._42, world_mat.u.s._43, world_mat.u.s._44);
TRACE("%.8e %.8e %.8e %.8e\n", world_mat._11, world_mat._12, world_mat._13, world_mat._14);
TRACE("%.8e %.8e %.8e %.8e\n", world_mat._21, world_mat._22, world_mat._23, world_mat._24);
TRACE("%.8e %.8e %.8e %.8e\n", world_mat._31, world_mat._32, world_mat._33, world_mat._34);
TRACE("%.8e %.8e %.8e %.8e\n", world_mat._41, world_mat._42, world_mat._43, world_mat._44);
/* Get the viewport */
wined3d_device_get_viewport(device, &vp);
......@@ -2817,11 +2817,11 @@ static HRESULT process_vertices_strided(const struct wined3d_device *device, DWO
float x, y, z, rhw;
TRACE("In: ( %06.2f %06.2f %06.2f )\n", p[0], p[1], p[2]);
/* Multiplication with world, view and projection matrix */
x = (p[0] * mat.u.s._11) + (p[1] * mat.u.s._21) + (p[2] * mat.u.s._31) + (1.0f * mat.u.s._41);
y = (p[0] * mat.u.s._12) + (p[1] * mat.u.s._22) + (p[2] * mat.u.s._32) + (1.0f * mat.u.s._42);
z = (p[0] * mat.u.s._13) + (p[1] * mat.u.s._23) + (p[2] * mat.u.s._33) + (1.0f * mat.u.s._43);
rhw = (p[0] * mat.u.s._14) + (p[1] * mat.u.s._24) + (p[2] * mat.u.s._34) + (1.0f * mat.u.s._44);
/* Multiplication with world, view and projection matrix. */
x = (p[0] * mat._11) + (p[1] * mat._21) + (p[2] * mat._31) + mat._41;
y = (p[0] * mat._12) + (p[1] * mat._22) + (p[2] * mat._32) + mat._42;
z = (p[0] * mat._13) + (p[1] * mat._23) + (p[2] * mat._33) + mat._43;
rhw = (p[0] * mat._14) + (p[1] * mat._24) + (p[2] * mat._34) + mat._44;
TRACE("x=%f y=%f z=%f rhw=%f\n", x, y, z, rhw);
......
......@@ -782,7 +782,7 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
struct wined3d_matrix mat;
get_modelview_matrix(context, state, &mat);
GL_EXTCALL(glUniformMatrix4fv(prog->vs.modelview_matrix_location, 1, FALSE, (GLfloat *)&mat));
GL_EXTCALL(glUniformMatrix4fv(prog->vs.modelview_matrix_location, 1, FALSE, &mat._11));
checkGLcall("glUniformMatrix4fv");
}
......
......@@ -3299,7 +3299,7 @@ void transform_texture(struct wined3d_context *context, const struct wined3d_sta
generated = (state->texture_states[texUnit][WINED3D_TSS_TEXCOORD_INDEX] & 0xffff0000) != WINED3DTSS_TCI_PASSTHRU;
coordIdx = min(state->texture_states[texUnit][WINED3D_TSS_TEXCOORD_INDEX & 0x0000ffff], MAX_TEXTURES - 1);
set_texture_matrix(gl_info, &state->transforms[WINED3D_TS_TEXTURE0 + texUnit].u.m[0][0],
set_texture_matrix(gl_info, &state->transforms[WINED3D_TS_TEXTURE0 + texUnit],
state->texture_states[texUnit][WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS],
generated, context->last_was_rhw,
context->stream_info.use_map & (1 << (WINED3D_FFP_TEXCOORD0 + coordIdx))
......@@ -3876,7 +3876,7 @@ void clipplane(struct wined3d_context *context, const struct wined3d_state *stat
/* Clip Plane settings are affected by the model view in OpenGL, the View transform in direct3d */
if (!use_vs(state))
gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_VIEW].u.m[0][0]);
gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_VIEW]._11);
else
/* With vertex shaders, clip planes are not transformed in Direct3D,
* while in OpenGL they are still transformed by the model view matix. */
......@@ -3928,9 +3928,9 @@ static void transform_worldex(struct wined3d_context *context, const struct wine
/* World matrix 0 is multiplied with the view matrix because d3d uses 3
* matrices while gl uses only 2. To avoid weighting the view matrix
* incorrectly it has to be multiplied into every GL modelview matrix. */
gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_VIEW].u.m[0][0]);
gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_VIEW]._11);
checkGLcall("glLoadMatrixf");
gl_info->gl_ops.gl.p_glMultMatrixf(&state->transforms[WINED3D_TS_WORLD_MATRIX(matrix)].u.m[0][0]);
gl_info->gl_ops.gl.p_glMultMatrixf(&state->transforms[WINED3D_TS_WORLD_MATRIX(matrix)]._11);
checkGLcall("glMultMatrixf");
}
......@@ -4004,7 +4004,7 @@ static void transform_view(struct wined3d_context *context, const struct wined3d
gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW);
checkGLcall("glMatrixMode(GL_MODELVIEW)");
gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_VIEW].u.m[0][0]);
gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_VIEW]._11);
checkGLcall("glLoadMatrixf(...)");
/* Reset lights. TODO: Call light apply func */
......@@ -4117,7 +4117,7 @@ void transform_projection(struct wined3d_context *context, const struct wined3d_
gl_info->gl_ops.gl.p_glLoadMatrixd(projection);
checkGLcall("glLoadMatrixd");
gl_info->gl_ops.gl.p_glMultMatrixf(&state->transforms[WINED3D_TS_PROJECTION].u.m[0][0]);
gl_info->gl_ops.gl.p_glMultMatrixf(&state->transforms[WINED3D_TS_PROJECTION]._11);
checkGLcall("glLoadMatrixf");
}
}
......@@ -4820,7 +4820,7 @@ void light(struct wined3d_context *context, const struct wined3d_state *state, D
/* Light settings are affected by the model view in OpenGL, the View transform in direct3d*/
gl_info->gl_ops.gl.p_glMatrixMode(GL_MODELVIEW);
gl_info->gl_ops.gl.p_glPushMatrix();
gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_VIEW].u.m[0][0]);
gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_VIEW]._11);
/* Diffuse: */
colRGBA[0] = lightInfo->OriginalParms.diffuse.r;
......
......@@ -2782,8 +2782,8 @@ BOOL is_invalid_op(const struct wined3d_state *state, int stage,
void set_tex_op_nvrc(const struct wined3d_gl_info *gl_info, const struct wined3d_state *state,
BOOL is_alpha, int stage, enum wined3d_texture_op op, DWORD arg1, DWORD arg2, DWORD arg3,
INT texture_idx, DWORD dst) DECLSPEC_HIDDEN;
void set_texture_matrix(const struct wined3d_gl_info *gl_info, const float *smat, DWORD flags,
BOOL calculatedCoords, BOOL transformed, enum wined3d_format_id coordtype,
void set_texture_matrix(const struct wined3d_gl_info *gl_info, const struct wined3d_matrix *matrix,
DWORD flags, BOOL calculated_coords, BOOL transformed, enum wined3d_format_id format_id,
BOOL ffp_can_disable_proj) DECLSPEC_HIDDEN;
void texture_activate_dimensions(const struct wined3d_texture *texture,
const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
......
......@@ -1530,17 +1530,10 @@ struct wined3d_vec4
struct wined3d_matrix
{
union
{
struct
{
float _11, _12, _13, _14;
float _21, _22, _23, _24;
float _31, _32, _33, _34;
float _41, _42, _43, _44;
} DUMMYSTRUCTNAME;
float m[4][4];
} DUMMYUNIONNAME;
float _11, _12, _13, _14;
float _21, _22, _23, _24;
float _31, _32, _33, _34;
float _41, _42, _43, _44;
};
struct wined3d_light
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment