Hi,
This patch has not been commited yet. Is there any reason for that ?
Christian
Christian Costa wrote:
Hi,
This patch fixes 2D in some games (Dino Crisis and Lands of Lore 3)
Changelog: Disable depth test when there is no Z buffer attached. Initialise texture states at creation instead of when tex name is generated.
Christian Costa titan.costa@wanadoo.fr
Index: dlls/ddraw/opengl_private.h
RCS file: /home/wine/wine/dlls/ddraw/opengl_private.h,v retrieving revision 1.2 diff -u -r1.2 opengl_private.h --- dlls/ddraw/opengl_private.h 12 Jun 2005 10:43:11 -0000 1.2 +++ dlls/ddraw/opengl_private.h 5 Oct 2005 20:51:34 -0000 @@ -193,21 +193,21 @@ extern HRESULT d3ddevice_create(IDirect3DDeviceImpl **obj, IDirectDrawImpl *d3d, IDirectDrawSurfaceImpl *surface, int version);
/* Used for Direct3D to request the device to enumerate itself */ -extern HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD version) ; -extern HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context) ; +extern HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD version); +extern HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context); extern HRESULT d3ddevice_find(IDirectDrawImpl *d3d, LPD3DFINDDEVICESEARCH lpD3DDFS, LPD3DFINDDEVICERESULT lplpD3DDevice);
/* Used by the DLL init routine to set-up the GL context and stuff properly */ extern BOOL d3ddevice_init_at_startup(void *gl_handle);
/* Used to upload the texture */ -extern HRESULT gltex_upload_texture(IDirectDrawSurfaceImpl *This, IDirect3DDeviceImpl *d3ddev, DWORD stage) ; +extern HRESULT gltex_upload_texture(IDirectDrawSurfaceImpl *This, IDirect3DDeviceImpl *d3ddev, DWORD stage);
/* Used to get the texture name */ -extern GLuint gltex_get_tex_name(IDirectDrawSurfaceImpl *This) ; +extern GLuint gltex_get_tex_name(IDirectDrawSurfaceImpl *This);
/* Used to set-up our orthographic projection */ -extern void d3ddevice_set_ortho(IDirect3DDeviceImpl *This) ; +extern void d3ddevice_set_ortho(IDirect3DDeviceImpl *This);
/* Rendering state management functions */ extern void set_render_state(IDirect3DDeviceImpl* This, D3DRENDERSTATETYPE dwRenderStateType, STATEBLOCK *lpStateBlock); @@ -222,7 +222,7 @@ extern HRESULT upload_surface_to_tex_memory_release(void);
/* Some utilities functions needed to be shared.. */ -extern GLenum convert_D3D_compare_to_GL(D3DCMPFUNC dwRenderState) ; +extern GLenum convert_D3D_compare_to_GL(D3DCMPFUNC dwRenderState);
#endif /* HAVE_OPENGL */
Index: dlls/ddraw/device_opengl.c
RCS file: /home/wine/wine/dlls/ddraw/device_opengl.c,v retrieving revision 1.9 diff -u -r1.9 device_opengl.c --- dlls/ddraw/device_opengl.c 25 Sep 2005 15:18:18 -0000 1.9 +++ dlls/ddraw/device_opengl.c 5 Oct 2005 20:51:45 -0000 @@ -1325,6 +1325,7 @@ IDirect3DDeviceGLImpl* glThis = (IDirect3DDeviceGLImpl*) This; int num_active_stages = 0; int num_tex_index = GET_TEXCOUNT_FROM_FVF(d3dvtVertexType);
BOOL reenable_depth_test = FALSE;
/* I put the trace before the various locks... So as to better understand where locks occur :-) */ if (TRACE_ON(ddraw)) {
@@ -1349,9 +1350,12 @@
hr = IDirectDrawSurface7_GetAttachedSurface(ICOM_INTERFACE(This->surface, IDirectDrawSurface7), (DDSCAPS2 *) &zbuf_caps, &zbuf);
- if (!FAILED(hr)) {
- if (SUCCEEDED(hr)) { This->current_zbuffer = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, zbuf); IDirectDrawSurface7_Release(zbuf);
- } else if (glThis->depth_test) {
glDisable(GL_DEPTH_TEST);
} } if (This->current_zbuffer != NULL) {reenable_depth_test = TRUE;
@@ -1615,6 +1619,9 @@ /* Whatever the case, disable the color material stuff */ glDisable(GL_COLOR_MATERIAL);
- if (reenable_depth_test)
- glEnable(GL_DEPTH_TEST);
- LEAVE_GL(); TRACE("End\n");
Index: dlls/ddraw/texture.c
RCS file: /home/wine/wine/dlls/ddraw/texture.c,v retrieving revision 1.4 diff -u -r1.4 texture.c --- dlls/ddraw/texture.c 3 Aug 2005 21:25:11 -0000 1.4 +++ dlls/ddraw/texture.c 5 Oct 2005 20:51:49 -0000 @@ -381,7 +381,7 @@ { if (src != NULL) { IDirectDrawSurfaceImpl *src_ptr = ICOM_OBJECT(IDirectDrawSurfaceImpl, IDirectDrawSurface7, src);
- if ((src_ptr->surface_desc.ddsCaps.dwCaps & DDSCAPS_3DDEVICE) && ((trans & (DDBLTFAST_SRCCOLORKEY | DDBLTFAST_DESTCOLORKEY)) == 0)) { /* This is a blt without color keying... We can use the direct copy. */
@@ -390,7 +390,7 @@ GLint cur_tex; IDirect3DTextureGLImpl *gl_surf_ptr = surf_ptr->tex_private; int y;
WARN("rsrc is NULL\n"); rsrc = &rsrc2;if (rsrc == NULL) {
@@ -400,10 +400,10 @@ rsrc->right = src_ptr->surface_desc.dwWidth; rsrc->bottom = src_ptr->surface_desc.dwHeight; }
width = rsrc->right - rsrc->left; height = rsrc->bottom - rsrc->top;
((dsty + height) > surf_ptr->surface_desc.dwHeight)) { FIXME("Does not handle clipping yet in FB => Texture blits !\n");if (((dstx + width) > surf_ptr->surface_desc.dwWidth) ||
@@ -413,16 +413,16 @@ if ((width == 0) || (height == 0)) { return DD_OK; }
TRACE(" direct frame buffer => texture BltFast override.\n");
ENTER_GL();
glGetIntegerv(GL_TEXTURE_BINDING_2D, &cur_tex); /* This call is to create the actual texture name in GL (as we do 'late' ID creation) */ gltex_get_tex_name(surf_ptr); glBindTexture(GL_TEXTURE_2D, gl_surf_ptr->tex_name);
!((dstx == 0) && (dsty == 0) && (width == surf_ptr->surface_desc.dwWidth) && (height == surf_ptr->surface_desc.dwHeight))) {if ((gl_surf_ptr->dirty_flag == SURFACE_MEMORY_DIRTY) &&
@@ -456,7 +456,7 @@ return DDERR_INVALIDPARAMS; } }
glReadBuffer(GL_FRONT); else if ((src_ptr->surface_desc.ddsCaps.dwCaps & (DDSCAPS_BACKBUFFER)) == (DDSCAPS_BACKBUFFER))if ((src_ptr->surface_desc.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER|DDSCAPS_PRIMARYSURFACE)) != 0)
@@ -467,7 +467,7 @@ LEAVE_GL(); return DDERR_INVALIDPARAMS; }
y >= (src_ptr->surface_desc.dwHeight - (rsrc->top + height)); y--) {for (y = (src_ptr->surface_desc.dwHeight - rsrc->top - 1);
@@ -477,13 +477,13 @@ width, 1); dsty++; }
glBindTexture(GL_TEXTURE_2D, cur_tex); LEAVE_GL();
/* The SURFACE_GL case is not handled by the 'global' dirty flag */ gl_surf_ptr->dirty_flag = SURFACE_GL;
} }return DD_OK;
@@ -544,9 +544,9 @@
if (glThis->dirty_flag == SURFACE_GL) {
GLint cur_tex;
- TRACE(" flushing GL texture back to memory.\n");
- ENTER_GL(); glGetIntegerv(GL_TEXTURE_BINDING_2D, &cur_tex); glBindTexture(GL_TEXTURE_2D, glThis->tex_name);
@@ -554,14 +554,14 @@ glBindTexture(GL_TEXTURE_2D, cur_tex); LEAVE_GL(); }
- /* First call the previous set_palette function */ glThis->set_palette(This, pal);
- /* And set the dirty flag */ glThis->dirty_flag = SURFACE_MEMORY_DIRTY; *(glThis->global_dirty_flag) = SURFACE_MEMORY_DIRTY;
- /* TODO: check palette on mipmapped surfaces... TODO: do we need to re-upload in case of usage of the paletted texture extension ? */
} @@ -603,7 +603,7 @@ gltex_lock_update(IDirectDrawSurfaceImpl* This, LPCRECT pRect, DWORD dwFlags) { IDirect3DTextureGLImpl *glThis = (IDirect3DTextureGLImpl *) This->tex_private;
- glThis->lock_update(This, pRect, dwFlags);
}
@@ -613,7 +613,7 @@ IDirect3DTextureGLImpl *glThis = (IDirect3DTextureGLImpl *) This->tex_private;
glThis->unlock_update(This, pRect);
- /* Set the dirty flag according to the lock type */ if ((This->lastlocktype & DDLOCK_READONLY) == 0) { glThis->dirty_flag = SURFACE_MEMORY_DIRTY;
@@ -868,7 +868,7 @@ /* First, initialize the texture vtables... */ ICOM_INIT_INTERFACE(surf, IDirect3DTexture, VTABLE_IDirect3DTexture); ICOM_INIT_INTERFACE(surf, IDirect3DTexture2, VTABLE_IDirect3DTexture2);
- /* Only create all the private stuff if we actually have an OpenGL context.. */ if (d3d->current_device != NULL) { IDirect3DTextureGLImpl *private;
@@ -877,12 +877,12 @@ if (private == NULL) return DDERR_OUTOFMEMORY;
surf->tex_private = private;
- private->final_release = surf->final_release; private->lock_update = surf->lock_update; private->unlock_update = surf->unlock_update; private->set_palette = surf->set_palette;
- /* If at creation, we can optimize stuff and wait the first 'unlock' to upload a valid stuff to OpenGL. Otherwise, it will be uploaded here (and may be invalid). */ surf->final_release = gltex_final_release;
@@ -895,7 +895,7 @@ to save those... */ surf->aux_blt = gltex_blt; surf->aux_bltfast = gltex_bltfast;
TRACE(" GL texture created for surface %p (private data at %p)\n", surf, private);
/* Do not create the OpenGL texture id here as some game generate textures from a different thread which
@@ -903,12 +903,14 @@ private->tex_name = 0; if (surf->mipmap_level == 0) { private->main = NULL;
private->__global_dirty_flag = SURFACE_MEMORY_DIRTY; private->global_dirty_flag = &(private->__global_dirty_flag);
} else { private->main = main; private->global_dirty_flag = &(((IDirect3DTextureGLImpl *) (private->main->tex_private))->__global_dirty_flag); } private->initial_upload_done = FALSE;
private->dirty_flag = SURFACE_MEMORY_DIRTY; }
return D3D_OK;
@@ -925,15 +927,11 @@ glGenTextures(1, &(private->tex_name)); if (private->tex_name == 0) ERR("Error at creation of OpenGL texture ID !\n"); TRACE(" GL texture id is : %d.\n", private->tex_name);
} else { private->tex_name = gltex_get_tex_name(private->main); TRACE(" GL texture id reusing id %d from surface %p (private at %p)).\n", private->tex_name, private->main, private->main->tex_private); } LEAVE_GL();private->__global_dirty_flag = SURFACE_MEMORY_DIRTY;
- /* And set the dirty flag accordingly */
- private->dirty_flag = SURFACE_MEMORY_DIRTY; } return ((IDirect3DTextureGLImpl *) (surf->tex_private))->tex_name;
}
On 10/9/05, Christian Costa titan.costa@wanadoo.fr wrote:
Hi,
This patch has not been commited yet. Is there any reason for that ?
This might not be the exact reason, but most of the changes you made to dlls/ddraw/texture.c are whitespace changes. The patch would be a lot shorter without those changes.
-- James Hawkins