[1/8] WineD3D: Break the viewport out of the vertex declaration
state
Stefan Dösinger
stefan at codeweavers.com
Wed Jan 3 17:05:05 CST 2007
From 5a89d1bcdff1be4741d291c82c0c9b18a56cef6f Mon Sep 17 00:00:00 2001
From: =?utf-8?q?Stefan_D=C3=B6singer?= <stefan at imac.local>
Date: Wed, 3 Jan 2007 00:53:54 +0100
Subject: [PATCH] WineD3D: Break the viewport out of the vdecl state
---
dlls/wined3d/device.c | 18 +-----------------
dlls/wined3d/state.c | 27 +++++++++++++++++++++++----
dlls/wined3d/wined3d_private.h | 1 -
3 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 676f875..db35a07 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3055,26 +3055,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl
TRACE("Recording... not performing anything\n");
return WINED3D_OK;
}
- This->viewport_changed = TRUE;
-
- ENTER_GL();
TRACE("(%p) : x=%d, y=%d, wid=%d, hei=%d, minz=%f, maxz=%f\n", This,
pViewport->X, pViewport->Y, pViewport->Width, pViewport->Height, pViewport->MinZ, pViewport->MaxZ);
-
- glDepthRange(pViewport->MinZ, pViewport->MaxZ);
- checkGLcall("glDepthRange");
- /* Note: GL requires lower left, DirectX supplies upper left */
- /* TODO: replace usage of renderTarget with context management */
- glViewport(pViewport->X,
- (((IWineD3DSurfaceImpl *)This->render_targets[0])->currentDesc.Height - (pViewport->Y + pViewport->Height)),
- pViewport->Width, pViewport->Height);
-
- checkGLcall("glViewport");
-
- LEAVE_GL();
-
- /* Todo: move the gl code too */
+
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VIEWPORT);
return WINED3D_OK;
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 935bd90..38d7883 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -2059,8 +2059,6 @@ static void vertexdeclaration(DWORD stat
*/
if (useVertexShaderFunction) {
device->posFixup[1] = device->render_offscreen ? -1.0 : 1.0;
- device->posFixup[2] = 0.9 / stateblock->viewport.Width;
- device->posFixup[3] = -0.9 / stateblock->viewport.Height;
}
}
@@ -2071,7 +2069,9 @@ static void vertexdeclaration(DWORD stat
/* TODO: Move this mainly to the viewport state and only apply when the vp has changed
* or transformed / untransformed was switched
*/
- if(!isStateDirty(stateblock->wineD3DDevice, STATE_TRANSFORM(WINED3DTS_PROJECTION))) {
+ if(wasrhw != device->last_was_rhw &&
+ !isStateDirty(stateblock->wineD3DDevice, STATE_TRANSFORM(WINED3DTS_PROJECTION)) &&
+ !isStateDirty(stateblock->wineD3DDevice, STATE_VIEWPORT)) {
transform_projection(STATE_TRANSFORM(WINED3DTS_PROJECTION), stateblock);
}
/* World matrix needs reapplication here only if we're switching between rhw and non-rhw
@@ -2097,6 +2097,25 @@ static void vertexdeclaration(DWORD stat
}
}
+static void viewport(DWORD state, IWineD3DStateBlockImpl *stateblock) {
+ glDepthRange(stateblock->viewport.MinZ, stateblock->viewport.MaxZ);
+ checkGLcall("glDepthRange");
+ /* Note: GL requires lower left, DirectX supplies upper left */
+ /* TODO: replace usage of renderTarget with context management */
+ glViewport(stateblock->viewport.X,
+ (((IWineD3DSurfaceImpl *)stateblock->wineD3DDevice->render_targets[0])->currentDesc.Height - (stateblock->viewport.Y + stateblock->viewport.Height)),
+ stateblock->viewport.Width, stateblock->viewport.Height);
+
+ checkGLcall("glViewport");
+
+ stateblock->wineD3DDevice->posFixup[2] = 0.9 / stateblock->viewport.Width;
+ stateblock->wineD3DDevice->posFixup[3] = -0.9 / stateblock->viewport.Height;
+ if(!isStateDirty(stateblock->wineD3DDevice, STATE_TRANSFORM(D3DTS_PROJECTION))) {
+ transform_projection(STATE_TRANSFORM(D3DTS_PROJECTION), stateblock);
+ }
+
+}
+
const struct StateEntry StateTable[] =
{
/* State name representative, apply function */
@@ -3114,6 +3133,6 @@ const struct StateEntry StateTable[] =
{ /* , STATE_STREAMSRC */ STATE_VDECL, vertexdeclaration },
{ /* , STATE_VDECL */ STATE_VDECL, vertexdeclaration },
{ /* , STATE_VSHADER */ STATE_VDECL, vertexdeclaration },
- { /* , STATE_VIEWPORT */ STATE_VDECL, vertexdeclaration },
+ { /* , STATE_VIEWPORT */ STATE_VIEWPORT, viewport },
};
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 0e5dc23..a63e577 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -565,7 +565,6 @@ typedef struct IWineD3DDeviceImpl
/* Optimization */
BOOL view_ident; /* true iff view matrix is identity */
BOOL last_was_rhw; /* true iff last draw_primitive was in xyzrhw mode */
- BOOL viewport_changed; /* Was the viewport changed since the last draw? */
GLenum tracking_parm; /* Which source is tracking current colour */
LONG tracking_color; /* used iff GL_COLOR_MATERIAL was enabled */
#define DISABLED_TRACKING 0 /* Disabled */
--
1.4.2.4
More information about the wine-patches
mailing list