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@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.
@@ -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 is not correct. This removes every flag except SFLAG_NONPOW2. If you want to remove the SFLAG_NONPOW2 flag you have to invert the flag:
This->Flags &= ~SFLAG_NONPOW2
Actually I needed to set that flag, otherwise other code further on fails, using the incorrect height. And now that I look at it, all my bitwise operator knowledge is coming back from university, that should have been a bitwise or!
so: This->Flags |= SFLAG_NONPOW2;
I'll fix it and resend an updated patch.
On 3/31/07, Stefan Dösinger stefandoesinger@gmx.at wrote:
@@ -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 is not correct. This removes every flag except SFLAG_NONPOW2. If you want to remove the SFLAG_NONPOW2 flag you have to invert the flag:
This->Flags &= ~SFLAG_NONPOW2
Stefan Dösinger wrote:
@@ -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 is not correct. This removes every flag except SFLAG_NONPOW2. If you want to remove the SFLAG_NONPOW2 flag you have to invert the flag:
This->Flags &= ~SFLAG_NONPOW2
If you want to set the SFLAG_NONPOW2 flag...
This->Flags |= SFLAG_NONPOW2