[PATCH] WineD3D: Update the blit ortho on size changes=0A=

Stefan Doesinger stefan at codeweavers.com
Tue Jun 17 01:41:49 CDT 2008


=0A=
SetupForBlit sets up the GL viewport and projection matrix for=0A=
screen-cordinate access to the framebuffer. These settings were not=0A=
updated if the other gl states were already set up for blitting. Guild=0A=
Wars reads back an offscreen rendered texture from the framebuffer,=0A=
which currently sets up CTXUSAGE_BLIT, then changes the render target,=0A=
and draws to the texture, which has to be reloaded from system memory=0A=
before it can be rendered to(since GW loaded some data into it). If the=0A=
two render targets had different size this failed.=0A=
=0A=
The CTXUSAGE_BLIT in the framebuffer->texture readback is incorrect as=0A=
well, but this bug here still needs fixing=0A=
---=0A=
 dlls/wined3d/context.c         |   33 +++++++++++++++++++++++----------=0A=
 dlls/wined3d/wined3d_private.h |    1 +=0A=
 2 files changed, 24 insertions(+), 10 deletions(-)=0A=
=0A=
diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c=0A=
index 382f96d..fb7bb3f 100644=0A=
--- a/dlls/wined3d/context.c=0A=
+++ b/dlls/wined3d/context.c=0A=
@@ -610,6 +610,17 @@ void DestroyContext(IWineD3DDeviceImpl *This, =
WineD3DContext *context) {=0A=
     RemoveContextFromArray(This, context);=0A=
 }=0A=
 =0A=
+static inline void set_blit_dimension(UINT width, UINT height) {=0A=
+    glMatrixMode(GL_PROJECTION);=0A=
+    checkGLcall("glMatrixMode(GL_PROJECTION)");=0A=
+    glLoadIdentity();=0A=
+    checkGLcall("glLoadIdentity()");=0A=
+    glOrtho(0, width, height, 0, 0.0, -1.0);=0A=
+    checkGLcall("glOrtho");=0A=
+    glViewport(0, 0, width, height);=0A=
+    checkGLcall("glViewport");=0A=
+}=0A=
+=0A=
 =
/************************************************************************=
*****=0A=
  * SetupForBlit=0A=
  *=0A=
@@ -634,6 +645,14 @@ static inline void SetupForBlit(IWineD3DDeviceImpl =
*This, WineD3DContext *contex=0A=
 =0A=
     TRACE("Setting up context %p for blitting\n", context);=0A=
     if(context->last_was_blit) {=0A=
+        if(context->blit_w !=3D width || context->blit_h !=3D height) {=0A=
+            set_blit_dimension(width, height);=0A=
+            context->blit_w =3D width; context->blit_h =3D height;=0A=
+            /* No need to dirtify here, the states are still dirtified =
because they weren't=0A=
+             * applied since the last SetupForBlit call. Otherwise =
last_was_blit would not=0A=
+             * be set=0A=
+             */=0A=
+        }=0A=
         TRACE("Context is already set up for blitting, nothing to =
do\n");=0A=
         return;=0A=
     }=0A=
@@ -756,14 +775,6 @@ static inline void SetupForBlit(IWineD3DDeviceImpl =
*This, WineD3DContext *contex=0A=
     checkGLcall("glLoadIdentity()");=0A=
     Context_MarkStateDirty(context, =
STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), StateTable);=0A=
 =0A=
-    glMatrixMode(GL_PROJECTION);=0A=
-    checkGLcall("glMatrixMode(GL_PROJECTION)");=0A=
-    glLoadIdentity();=0A=
-    checkGLcall("glLoadIdentity()");=0A=
-    glOrtho(0, width, height, 0, 0.0, -1.0);=0A=
-    checkGLcall("glOrtho");=0A=
-    Context_MarkStateDirty(context, =
STATE_TRANSFORM(WINED3DTS_PROJECTION), StateTable);=0A=
-=0A=
     context->last_was_rhw =3D TRUE;=0A=
     Context_MarkStateDirty(context, STATE_VDECL, StateTable); /* =
because of last_was_rhw =3D TRUE */=0A=
 =0A=
@@ -775,9 +786,11 @@ static inline void SetupForBlit(IWineD3DDeviceImpl =
*This, WineD3DContext *contex=0A=
     glDisable(GL_CLIP_PLANE5); checkGLcall("glDisable(clip plane 5)");=0A=
     Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_CLIPPING), =
StateTable);=0A=
 =0A=
-    glViewport(0, 0, width, height);=0A=
-    checkGLcall("glViewport");=0A=
+    set_blit_dimension(width, height);=0A=
+    context->blit_w =3D width; context->blit_h =3D height;=0A=
     Context_MarkStateDirty(context, STATE_VIEWPORT, StateTable);=0A=
+    Context_MarkStateDirty(context, =
STATE_TRANSFORM(WINED3DTS_PROJECTION), StateTable);=0A=
+=0A=
 =0A=
     This->shader_backend->shader_fragment_enable((IWineD3DDevice *) =
This, FALSE);=0A=
 }=0A=
diff --git a/dlls/wined3d/wined3d_private.h =
b/dlls/wined3d/wined3d_private.h=0A=
index 880f93d..ae36ad1 100644=0A=
--- a/dlls/wined3d/wined3d_private.h=0A=
+++ b/dlls/wined3d/wined3d_private.h=0A=
@@ -616,6 +616,7 @@ struct WineD3DContext {=0A=
     unsigned char           num_untracked_materials;=0A=
     GLenum                  untracked_materials[2];=0A=
     BOOL                    last_was_blit, last_was_ckey;=0A=
+    UINT                    blit_w, blit_h;=0A=
     char                    texShaderBumpMap;=0A=
     BOOL                    fog_coord;=0A=
 =0A=
-- =0A=
1.5.4.5=0A=
=0A=

------=_NextPart_000_000C_01C8DB84.93B9EA20--




More information about the wine-patches mailing list