[PATCH 5/5] wined3d: Get rid of device->view_ident (try 2)
Stefan Dösinger
stefan at codeweavers.com
Wed Apr 24 04:29:57 CDT 2013
Ver 2: Rebased, but otherwise unmodified.
A quick test of pre-shader games shows that very few games hit the
optimized codepath, and the ones that do do not get a measurable
improvement from it. Warhammer 40k: Dawn of War sets an identity view
matrix, removing the optimization reduced the framerate in the main menu
from 498 to 497.6. The other game I found was Temple of Elemental Evil.
Games tested that either do not set a identity view matrix or don't
profit from the optimization because the state handler runs only once
anyway:
Battlefield 1942
3DMark2000, 3DMark2001
Call of Duty 2 (dx7 codepath)
Command and Conquer 3
Warcraft 3
GTA 3
---
dlls/wined3d/device.c | 15 ---------------
dlls/wined3d/state.c | 33 ++++++++-------------------------
dlls/wined3d/stateblock.c | 7 +++++++
dlls/wined3d/wined3d_private.h | 6 +-----
4 files changed, 16 insertions(+), 45 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 4e18be8..7b6a253 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -53,17 +53,6 @@ const struct wined3d_light WINED3D_default_light =
0.0f /* Phi */
};
-/**********************************************************
- * Global variable / Constants follow
- **********************************************************/
-const struct wined3d_matrix identity =
-{{{
- 1.0f, 0.0f, 0.0f, 0.0f,
- 0.0f, 1.0f, 0.0f, 0.0f,
- 0.0f, 0.0f, 1.0f, 0.0f,
- 0.0f, 0.0f, 0.0f, 1.0f,
-}}}; /* When needed for comparisons */
-
/* Note that except for WINED3DPT_POINTLIST and WINED3DPT_LINELIST these
* actually have the same values in GL and D3D. */
GLenum gl_primitive_type_from_d3d(enum wined3d_primitive_type primitive_type)
@@ -1208,8 +1197,6 @@ HRESULT CDECL wined3d_device_init_3d(struct wined3d_device *device,
create_dummy_textures(device, context);
- /* Initialize the current view state */
- device->view_ident = 1;
device->contexts[0]->last_was_rhw = 0;
switch (wined3d_settings.offscreen_rendering_mode)
@@ -1684,8 +1671,6 @@ void CDECL wined3d_device_set_transform(struct wined3d_device *device,
}
device->stateBlock->state.transforms[d3dts] = *matrix;
- if (d3dts == WINED3D_TS_VIEW)
- device->view_ident = !memcmp(matrix, &identity, sizeof(identity));
if (d3dts < WINED3D_TS_WORLD_MATRIX(device->adapter->gl_info.limits.blends))
device_invalidate_state(device, STATE_TRANSFORM(d3dts));
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 4eb466e..38b4153 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -3801,19 +3801,10 @@ static void transform_world(struct wined3d_context *context, const struct wined3
}
else
{
- /* In the general case, the view matrix is the identity matrix */
- if (context->swapchain->device->view_ident)
- {
- gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_WORLD_MATRIX(0)].u.m[0][0]);
- checkGLcall("glLoadMatrixf");
- }
- else
- {
- gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_VIEW].u.m[0][0]);
- checkGLcall("glLoadMatrixf");
- gl_info->gl_ops.gl.p_glMultMatrixf(&state->transforms[WINED3D_TS_WORLD_MATRIX(0)].u.m[0][0]);
- checkGLcall("glMultMatrixf");
- }
+ gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_VIEW].u.m[0][0]);
+ checkGLcall("glLoadMatrixf");
+ gl_info->gl_ops.gl.p_glMultMatrixf(&state->transforms[WINED3D_TS_WORLD_MATRIX(0)].u.m[0][0]);
+ checkGLcall("glMultMatrixf");
}
}
@@ -3883,18 +3874,10 @@ 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. */
- if (context->swapchain->device->view_ident)
- {
- gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_WORLD_MATRIX(matrix)].u.m[0][0]);
- checkGLcall("glLoadMatrixf");
- }
- else
- {
- gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_VIEW].u.m[0][0]);
- checkGLcall("glLoadMatrixf");
- gl_info->gl_ops.gl.p_glMultMatrixf(&state->transforms[WINED3D_TS_WORLD_MATRIX(matrix)].u.m[0][0]);
- checkGLcall("glMultMatrixf");
- }
+ gl_info->gl_ops.gl.p_glLoadMatrixf(&state->transforms[WINED3D_TS_VIEW].u.m[0][0]);
+ checkGLcall("glLoadMatrixf");
+ gl_info->gl_ops.gl.p_glMultMatrixf(&state->transforms[WINED3D_TS_WORLD_MATRIX(matrix)].u.m[0][0]);
+ checkGLcall("glMultMatrixf");
}
static void state_vertexblend_w(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c
index 8e17d23..aaf425c 100644
--- a/dlls/wined3d/stateblock.c
+++ b/dlls/wined3d/stateblock.c
@@ -1161,6 +1161,13 @@ void stateblock_init_default_state(struct wined3d_stateblock *stateblock)
unsigned int i;
struct wined3d_swapchain *swapchain;
struct wined3d_surface *backbuffer;
+ static const struct wined3d_matrix identity =
+ {{{
+ 1.0f, 0.0f, 0.0f, 0.0f,
+ 0.0f, 1.0f, 0.0f, 0.0f,
+ 0.0f, 0.0f, 1.0f, 0.0f,
+ 0.0f, 0.0f, 0.0f, 1.0f,
+ }}};
TRACE("stateblock %p.\n", stateblock);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 438f4d1..73862cc 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -863,9 +863,6 @@ do { \
#define checkGLcall(A) do {} while(0)
#endif
-/* Global variables */
-extern const struct wined3d_matrix identity DECLSPEC_HIDDEN;
-
enum wined3d_ffp_idx
{
WINED3D_FFP_POSITION = 0,
@@ -1704,7 +1701,6 @@ struct wined3d_device
DWORD vs_clipping;
UINT instance_count;
- WORD view_ident : 1; /* true iff view matrix is identity */
WORD vertexBlendUsed : 1; /* To avoid needless setting of the blend matrices */
WORD isRecordingState : 1;
WORD isInDraw : 1;
@@ -1714,7 +1710,7 @@ struct wined3d_device
WORD softwareVertexProcessing : 1; /* process vertex shaders using software or hardware */
WORD useDrawStridedSlow : 1;
WORD filter_messages : 1;
- WORD padding : 6;
+ WORD padding : 7;
BYTE fixed_function_usage_map; /* MAX_TEXTURES, 8 */
--
1.8.1.5
More information about the wine-patches
mailing list