DirectDrawRenderer - opengl non power of 2 windows

Nathan Williams nathan.andrew.williams at gmail.com
Fri Mar 30 19:16:52 CDT 2007


My first patch!

Sorry this took so long for such a simple patch, I have just been run
off my feet until now.

Before I submit this to wine-patches, is anyone able to do some
further testing for me, to make sure it doesn't break any currently
working games?

This patch fixes a bug that causes a crash for direct draw games when
using opengl as the DirectDrawRenderer.

I wanted to make sure this works and is safe, before I venture into
making it optimized as Stefan suggested.

On 3/25/07, Stefan Dösinger <stefandoesinger at gmx.at> wrote:
>
> case WINED3DFMT_P8:
> {
>     int height = This->glRect.bottom - This->glRect.top; <--!!!
>     type = GL_UNSIGNED_BYTE;
>     fmt = GL_RGBA;
>
>     mem = HeapAlloc(GetProcessHeap(), 0, This->resource.size * sizeof(DWORD));
>     if(!mem) {
>         ERR("Out of memory\n");
>         return;
>     }
>     memory_allocated = TRUE;
>     d3dfmt_convert_surface(This->resource.allocatedMemory,
>     ...
>
>
> I think the int height = This->glRect.bottom - This->glRect.top is the
> problem. It should use This->currentDesc.Height instead. The opengl rectangle
> is a helper for surfaces which are bigger than the max size supported by
> opengl If they are used for 2D blits. For example swat3 creates a 3000x32
> surface to blit text in 32x32 rectangles. In this case only the needed area
> is uploaded to gl and used for blits.
>
> Here the gl rectangle does not apply. For the sake of optimization you may
> change the code to only convert the dirty rectangle instead of the whole
> surface.
>
>



-- 
Nathan
-------------- next part --------------
From 0842a21fd3a43643af3c7ff543804ad2823a91d4 Mon Sep 17 00:00:00 2001
From: Nathan Williams <nathan.andrew.williams at gmail.com>
Date: Sat, 31 Mar 2007 10:05:39 +1000
Subject: Fixing power of 2 assumptions in the OpenGL ddraw renderer

---
 dlls/wined3d/surface.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 8ac924b..6b6c70d 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -955,7 +955,6 @@ static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This) {
 
         case WINED3DFMT_P8:
         {
-            int height = This->glRect.bottom - This->glRect.top;
             type = GL_UNSIGNED_BYTE;
             fmt = GL_RGBA;
 
@@ -969,7 +968,7 @@ static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This) {
                                    mem,
                                    pitch,
                                    pitch,
-                                   height,
+                                   This->currentDesc.Height,
                                    pitch * 4,
                                    CONVERT_PALETTED,
                                    This);
@@ -3194,6 +3193,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) {
     } else {
         /* No oversize, gl rect is the full texture size */
         This->Flags &= ~SFLAG_OVERSIZE;
+        This->Flags &= SFLAG_NONPOW2;
         This->glRect.left = 0;
         This->glRect.top = 0;
         This->glRect.right = This->pow2Width;
-- 
1.4.4.4



More information about the wine-devel mailing list