Stefan Dösinger : wined3d: Update the blit ortho on size changes.

Alexandre Julliard julliard at winehq.org
Wed Jul 2 06:03:42 CDT 2008


Module: wine
Branch: master
Commit: 74c5684f903cdf84607bb67bf8c739bffc8df5d0
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=74c5684f903cdf84607bb67bf8c739bffc8df5d0

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Tue Jun 17 01:41:49 2008 +0200

wined3d: Update the blit ortho on size changes.

SetupForBlit sets up the GL viewport and projection matrix for
screen-cordinate access to the framebuffer. These settings were not
updated if the other gl states were already set up for blitting. Guild
Wars reads back an offscreen rendered texture from the framebuffer,
which currently sets up CTXUSAGE_BLIT, then changes the render target,
and draws to the texture, which has to be reloaded from system memory
before it can be rendered to(since GW loaded some data into it). If the
two render targets had different size this failed.

---

 dlls/wined3d/context.c         |   33 +++++++++++++++++++++++----------
 dlls/wined3d/wined3d_private.h |    1 +
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c
index 382f96d..fb7bb3f 100644
--- a/dlls/wined3d/context.c
+++ b/dlls/wined3d/context.c
@@ -610,6 +610,17 @@ void DestroyContext(IWineD3DDeviceImpl *This, WineD3DContext *context) {
     RemoveContextFromArray(This, context);
 }
 
+static inline void set_blit_dimension(UINT width, UINT height) {
+    glMatrixMode(GL_PROJECTION);
+    checkGLcall("glMatrixMode(GL_PROJECTION)");
+    glLoadIdentity();
+    checkGLcall("glLoadIdentity()");
+    glOrtho(0, width, height, 0, 0.0, -1.0);
+    checkGLcall("glOrtho");
+    glViewport(0, 0, width, height);
+    checkGLcall("glViewport");
+}
+
 /*****************************************************************************
  * SetupForBlit
  *
@@ -634,6 +645,14 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex
 
     TRACE("Setting up context %p for blitting\n", context);
     if(context->last_was_blit) {
+        if(context->blit_w != width || context->blit_h != height) {
+            set_blit_dimension(width, height);
+            context->blit_w = width; context->blit_h = height;
+            /* No need to dirtify here, the states are still dirtified because they weren't
+             * applied since the last SetupForBlit call. Otherwise last_was_blit would not
+             * be set
+             */
+        }
         TRACE("Context is already set up for blitting, nothing to do\n");
         return;
     }
@@ -756,14 +775,6 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex
     checkGLcall("glLoadIdentity()");
     Context_MarkStateDirty(context, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(0)), StateTable);
 
-    glMatrixMode(GL_PROJECTION);
-    checkGLcall("glMatrixMode(GL_PROJECTION)");
-    glLoadIdentity();
-    checkGLcall("glLoadIdentity()");
-    glOrtho(0, width, height, 0, 0.0, -1.0);
-    checkGLcall("glOrtho");
-    Context_MarkStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION), StateTable);
-
     context->last_was_rhw = TRUE;
     Context_MarkStateDirty(context, STATE_VDECL, StateTable); /* because of last_was_rhw = TRUE */
 
@@ -775,9 +786,11 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, WineD3DContext *contex
     glDisable(GL_CLIP_PLANE5); checkGLcall("glDisable(clip plane 5)");
     Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_CLIPPING), StateTable);
 
-    glViewport(0, 0, width, height);
-    checkGLcall("glViewport");
+    set_blit_dimension(width, height);
+    context->blit_w = width; context->blit_h = height;
     Context_MarkStateDirty(context, STATE_VIEWPORT, StateTable);
+    Context_MarkStateDirty(context, STATE_TRANSFORM(WINED3DTS_PROJECTION), StateTable);
+
 
     This->shader_backend->shader_fragment_enable((IWineD3DDevice *) This, FALSE);
 }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 880f93d..ae36ad1 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -616,6 +616,7 @@ struct WineD3DContext {
     unsigned char           num_untracked_materials;
     GLenum                  untracked_materials[2];
     BOOL                    last_was_blit, last_was_ckey;
+    UINT                    blit_w, blit_h;
     char                    texShaderBumpMap;
     BOOL                    fog_coord;
 




More information about the wine-cvs mailing list