Commit 97f216c9 authored by Lionel Ulmer's avatar Lionel Ulmer Committed by Alexandre Julliard

- some tracing fixes

- flush the right buffer to the screen
parent c577c27e
......@@ -253,7 +253,7 @@ struct IDirect3DDeviceImpl
void (*matrices_updated)(IDirect3DDeviceImpl *This, DWORD matrices);
void (*set_matrices)(IDirect3DDeviceImpl *This, DWORD matrices,
D3DMATRIX *world_mat, D3DMATRIX *view_mat, D3DMATRIX *proj_mat);
void (*flush_to_framebuffer)(IDirect3DDeviceImpl *This, LPCRECT pRect);
void (*flush_to_framebuffer)(IDirect3DDeviceImpl *This, LPCRECT pRect, IDirectDrawSurfaceImpl *surf);
STATEBLOCK state_block;
......
......@@ -113,7 +113,7 @@ static BOOL opengl_flip( LPVOID dev, LPVOID drawable)
TRACE("(%p, %ld)\n", gl_d3d_dev->display,(Drawable)drawable);
ENTER_GL();
if (gl_d3d_dev->state == SURFACE_MEMORY_DIRTY) {
d3d_dev->flush_to_framebuffer(d3d_dev, NULL);
d3d_dev->flush_to_framebuffer(d3d_dev, NULL, gl_d3d_dev->lock_surf);
}
gl_d3d_dev->state = SURFACE_GL;
gl_d3d_dev->front_state = SURFACE_GL;
......@@ -1128,7 +1128,7 @@ static void draw_primitive_strided(IDirect3DDeviceImpl *This,
ENTER_GL();
if (glThis->state == SURFACE_MEMORY_DIRTY) {
This->flush_to_framebuffer(This, NULL);
This->flush_to_framebuffer(This, NULL, glThis->lock_surf);
}
LEAVE_GL();
......@@ -2466,7 +2466,7 @@ static HRESULT d3ddevice_clear(IDirect3DDeviceImpl *This,
if (glThis->state == SURFACE_MEMORY_DIRTY) {
/* TODO: optimize here the case where Clear changes all the screen... */
This->flush_to_framebuffer(This, NULL);
This->flush_to_framebuffer(This, NULL, glThis->lock_surf);
}
glThis->state = SURFACE_GL;
......@@ -2738,8 +2738,18 @@ static void d3ddevice_lock_update(IDirectDrawSurfaceImpl* This, LPCRECT pRect, D
if ((This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER|DDSCAPS_PRIMARYSURFACE)) != 0) {
is_front = TRUE;
if ((gl_d3d_dev->front_state != SURFACE_GL) &&
(gl_d3d_dev->front_lock_surf != This)) {
ERR("Change of front buffer.. Expect graphic corruptions !\n");
}
gl_d3d_dev->front_lock_surf = This;
} else if ((This->surface_desc.ddsCaps.dwCaps & (DDSCAPS_BACKBUFFER)) == (DDSCAPS_BACKBUFFER)) {
is_front = FALSE;
if ((gl_d3d_dev->state != SURFACE_GL) &&
(gl_d3d_dev->lock_surf != This)) {
ERR("Change of back buffer.. Expect graphic corruptions !\n");
}
gl_d3d_dev->lock_surf = This;
} else {
ERR("Wrong surface type for locking !\n");
return;
......@@ -2848,10 +2858,9 @@ static void d3ddevice_lock_update(IDirectDrawSurfaceImpl* This, LPCRECT pRect, D
#define UNLOCK_TEX_SIZE 256
static void d3ddevice_flush_to_frame_buffer(IDirect3DDeviceImpl *d3d_dev, LPCRECT pRect) {
static void d3ddevice_flush_to_frame_buffer(IDirect3DDeviceImpl *d3d_dev, LPCRECT pRect, IDirectDrawSurfaceImpl *surf) {
GLenum buffer_type, buffer_color;
RECT loc_rect;
IDirectDrawSurfaceImpl *surf = d3d_dev->surface;
IDirect3DDeviceGLImpl* gl_d3d_dev = (IDirect3DDeviceGLImpl*) d3d_dev;
GLint depth_test, alpha_test, cull_face, lighting, min_tex, max_tex, tex_env, blend, stencil_test;
GLuint initial_texture;
......@@ -3016,7 +3025,7 @@ static void d3ddevice_unlock_update(IDirectDrawSurfaceImpl* This, LPCRECT pRect)
ENTER_GL();
glGetIntegerv(GL_DRAW_BUFFER, &prev_draw);
glDrawBuffer(GL_FRONT);
d3d_dev->flush_to_framebuffer(d3d_dev, pRect);
d3d_dev->flush_to_framebuffer(d3d_dev, pRect, gl_d3d_dev->front_lock_surf);
glDrawBuffer(prev_draw);
LEAVE_GL();
} else {
......
......@@ -208,7 +208,7 @@ static void execute(IDirect3DExecuteBufferImpl *This,
ENTER_GL();
if (((IDirect3DDeviceGLImpl *) lpDevice)->state == SURFACE_MEMORY_DIRTY) {
lpDevice->flush_to_framebuffer(lpDevice, NULL);
lpDevice->flush_to_framebuffer(lpDevice, NULL, ((IDirect3DDeviceGLImpl *) lpDevice)->lock_surf);
}
((IDirect3DDeviceGLImpl *) lpDevice)->state = SURFACE_GL;
......
......@@ -30,6 +30,7 @@
#include "mesa_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(ddraw);
WINE_DECLARE_DEBUG_CHANNEL(ddraw_geom);
HRESULT WINAPI
Main_IDirect3DVertexBufferImpl_7_1T_QueryInterface(LPDIRECT3DVERTEXBUFFER7 iface,
......@@ -352,46 +353,46 @@ process_vertices_strided(IDirect3DVertexBufferImpl *This,
copy_and_next(dest_ptr, tex_coord, 2 * sizeof(D3DVALUE));
}
if (TRACE_ON(ddraw)) {
if (TRACE_ON(ddraw_geom)) {
if ((dwVertexTypeDesc & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) {
D3DVALUE *position =
(D3DVALUE *) (((char *) lpStrideData->position.lpvData) + i * lpStrideData->position.dwStride);
TRACE(" %f %f %f", position[0], position[1], position[2]);
TRACE_(ddraw_geom)(" %f %f %f", position[0], position[1], position[2]);
} else if ((dwVertexTypeDesc & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW) {
D3DVALUE *position =
(D3DVALUE *) (((char *) lpStrideData->position.lpvData) + i * lpStrideData->position.dwStride);
TRACE(" %f %f %f %f", position[0], position[1], position[2], position[3]);
TRACE_(ddraw_geom)(" %f %f %f %f", position[0], position[1], position[2], position[3]);
}
if (dwVertexTypeDesc & D3DFVF_NORMAL) {
D3DVALUE *normal =
(D3DVALUE *) (((char *) lpStrideData->normal.lpvData) + i * lpStrideData->normal.dwStride);
TRACE(" / %f %f %f", normal[0], normal[1], normal[2]);
TRACE_(ddraw_geom)(" / %f %f %f", normal[0], normal[1], normal[2]);
}
if (dwVertexTypeDesc & D3DFVF_DIFFUSE) {
DWORD *color_d =
(DWORD *) (((char *) lpStrideData->diffuse.lpvData) + i * lpStrideData->diffuse.dwStride);
TRACE(" / %02lx %02lx %02lx %02lx",
(*color_d >> 16) & 0xFF,
(*color_d >> 8) & 0xFF,
(*color_d >> 0) & 0xFF,
(*color_d >> 24) & 0xFF);
TRACE_(ddraw_geom)(" / %02lx %02lx %02lx %02lx",
(*color_d >> 16) & 0xFF,
(*color_d >> 8) & 0xFF,
(*color_d >> 0) & 0xFF,
(*color_d >> 24) & 0xFF);
}
if (dwVertexTypeDesc & D3DFVF_SPECULAR) {
DWORD *color_s =
(DWORD *) (((char *) lpStrideData->specular.lpvData) + i * lpStrideData->specular.dwStride);
TRACE(" / %02lx %02lx %02lx %02lx",
(*color_s >> 16) & 0xFF,
(*color_s >> 8) & 0xFF,
(*color_s >> 0) & 0xFF,
(*color_s >> 24) & 0xFF);
TRACE_(ddraw_geom)(" / %02lx %02lx %02lx %02lx",
(*color_s >> 16) & 0xFF,
(*color_s >> 8) & 0xFF,
(*color_s >> 0) & 0xFF,
(*color_s >> 24) & 0xFF);
}
for (tex_index = 0; tex_index < ((dwVertexTypeDesc & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT); tex_index++) {
D3DVALUE *tex_coord =
(D3DVALUE *) (((char *) lpStrideData->textureCoords[tex_index].lpvData) +
i * lpStrideData->textureCoords[tex_index].dwStride);
TRACE(" / %f %f", tex_coord[0], tex_coord[1]);
TRACE_(ddraw_geom)(" / %f %f", tex_coord[0], tex_coord[1]);
}
TRACE("\n");
TRACE_(ddraw_geom)("\n");
}
}
......
......@@ -1004,9 +1004,6 @@ Main_DirectDrawSurface_Lock(LPDIRECTDRAWSURFACE7 iface, LPRECT prect,
/* First, copy the Surface description */
DD_STRUCT_COPY_BYSIZE(pDDSD,&(This->surface_desc));
TRACE("locked surface returning description : \n");
if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(pDDSD);
/* Used to optimize the D3D Device locking */
This->lastlocktype = flags & (DDLOCK_READONLY|DDLOCK_WRITEONLY);
......@@ -1014,15 +1011,14 @@ Main_DirectDrawSurface_Lock(LPDIRECTDRAWSURFACE7 iface, LPRECT prect,
* (Not documented.) */
if (prect != NULL) {
TRACE(" lprect: %ldx%ld-%ldx%ld\n",
prect->top,prect->left,prect->bottom,prect->right
);
prect->top,prect->left,prect->bottom,prect->right);
if ((prect->top < 0) ||
(prect->left < 0) ||
(prect->bottom < 0) ||
(prect->right < 0)) {
ERR(" Negative values in LPRECT !!!\n");
return DDERR_INVALIDPARAMS;
}
ERR(" Negative values in LPRECT !!!\n");
return DDERR_INVALIDPARAMS;
}
This->lock_update(This, prect, flags);
......@@ -1033,6 +1029,9 @@ Main_DirectDrawSurface_Lock(LPDIRECTDRAWSURFACE7 iface, LPRECT prect,
This->lock_update(This, NULL, flags);
}
TRACE("locked surface returning description : \n");
if (TRACE_ON(ddraw)) DDRAW_dump_surface_desc(pDDSD);
return DD_OK;
}
......
......@@ -123,6 +123,7 @@ typedef struct IDirect3DDeviceGLImpl
GLuint unlock_tex;
SURFACE_STATE state, front_state;
IDirectDrawSurfaceImpl *lock_surf, *front_lock_surf;
} IDirect3DDeviceGLImpl;
/* This is for the OpenGL additions... */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment