Commit ee65d59c authored by Lionel Ulmer's avatar Lionel Ulmer Committed by Alexandre Julliard

Fix a memory leak and optimize a little bit the generic path.

parent c301b390
......@@ -282,6 +282,8 @@ GL_IDirect3DDeviceImpl_7_3T_2T_1T_Release(LPDIRECT3DDEVICE7 iface)
if (This->current_texture[0] != NULL)
IDirect3DTexture2_Release(ICOM_INTERFACE(This->current_texture[0], IDirect3DTexture2));
if (glThis->handler) HeapFree(GetProcessHeap(), 0, This);
ENTER_GL();
glXDestroyContext(glThis->display, glThis->gl_context);
LEAVE_GL();
......@@ -902,12 +904,6 @@ typedef struct {
float tu1, tv1;
} D3DFVF_TLVERTEX_1;
typedef struct {
int offset;
int extra;
void (*handler)(char *vertex, int offset, int extra);
} D3DFVF_GENERIC;
/* These are the various handler used in the generic path */
static void handle_xyz(char *vertex, int offset, int extra) {
glVertex3fv((float *) (vertex + offset));
......@@ -1018,14 +1014,22 @@ static void draw_primitive_7(IDirect3DDeviceImpl *This,
Note that people should write a fast path for all vertex formats out there...
*/
DWORD elements;
DWORD size = get_flexible_vertex_size(d3dvtVertexType, &elements);
DWORD size;
char *vertices = (char *) lpvVertices;
int index;
int current_offset = 0;
int current_position = 0;
D3DFVF_GENERIC *handler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, elements * sizeof(D3DFVF_GENERIC));
D3DFVF_GENERIC *handler;
WARN(" using draw_primitive generic path - for better performance, add a fast path for your vertex case !\n");
if ((glThis->last_vertex_format != d3dvtVertexType) ||
(glThis->handler == NULL)) {
if (glThis->handler == NULL) HeapFree(GetProcessHeap(), 0, glThis->handler);
size = get_flexible_vertex_size(d3dvtVertexType, &elements);
glThis->handler = handler = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, elements * sizeof(D3DFVF_GENERIC));
glThis->last_vertex_format = d3dvtVertexType;
glThis->last_vertex_format_size = size;
glThis->last_vertex_format_elements = elements;
if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) {
handler[elements - 1].handler = handle_xyz;
......@@ -1070,6 +1074,13 @@ static void draw_primitive_7(IDirect3DDeviceImpl *This,
current_offset += 2 * sizeof(D3DVALUE);
}
}
} else {
handler = glThis->handler;
size = glThis->last_vertex_format_size;
elements = glThis->last_vertex_format_elements;
}
WARN(" using draw_primitive generic path - for better performance, add a fast path for your vertex case !\n");
for (index = 0; index < dwIndexCount; index++) {
int i = (dwIndices == NULL) ? index : dwIndices[index];
......
......@@ -99,6 +99,12 @@ typedef struct IDirect3DTextureGLImpl
void (*unlock_update)(IDirectDrawSurfaceImpl* This, LPCRECT pRect);
} IDirect3DTextureGLImpl;
typedef struct {
int offset;
int extra;
void (*handler)(char *vertex, int offset, int extra);
} D3DFVF_GENERIC;
typedef struct IDirect3DDeviceGLImpl
{
struct IDirect3DDeviceImpl parent;
......@@ -112,6 +118,12 @@ typedef struct IDirect3DDeviceGLImpl
BOOLEAN last_vertices_transformed;
BOOLEAN last_vertices_lit;
/* This is to optimize a little bit the 'slow generic' path for the DrawPrimitive stuff */
D3DFVF_GENERIC *handler;
DWORD last_vertex_format;
DWORD last_vertex_format_size;
DWORD last_vertex_format_elements;
D3DMATRIX *world_mat;
D3DMATRIX *view_mat;
D3DMATRIX *proj_mat;
......
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