Changelog: - some clean-ups (extension code to be added soon) - some interface changes for future reuse for Blt / Lock code - fixed some Pitch problems in texture uploads (mostly for 'small' mip-mapping levels) -- Lionel Ulmer - http://www.bbrox.org/
--- dlls/ddraw_CVS/d3ddevice/mesa.c 2003-05-26 16:05:55.000000000 +0200 +++ dlls/ddraw/d3ddevice/mesa.c 2003-05-29 21:41:46.000000000 +0200 @@ -263,31 +263,6 @@ d->dwReserved4 = 0; } -#if 0 /* TODO : fix this and add multitexturing and other needed stuff */ -static void fill_device_capabilities(IDirectDrawImpl* ddraw) -{ - x11_dd_private *private = (x11_dd_private *) ddraw->d->private; - const char *ext_string; - Mesa_DeviceCapabilities *devcap; - - private->device_capabilities = HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,sizeof(Mesa_DeviceCapabilities)); - devcap = (Mesa_DeviceCapabilities *) private->device_capabilities; - - ENTER_GL(); - ext_string = glGetString(GL_EXTENSIONS); - /* Query for the ColorTable Extension */ - if (strstr(ext_string, "GL_EXT_paletted_texture")) { - devcap->ptr_ColorTableEXT = (PFNGLCOLORTABLEEXTPROC) glXGetProcAddressARB("glColorTableEXT"); - TRACE("Color table extension supported (function at %p)\n", devcap->ptr_ColorTableEXT); - } else { - TRACE("Color table extension not found.\n"); - } - LEAVE_GL(); -} -#endif - - - HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD version) { D3DDEVICEDESC dref, d1, d2; --- dlls/ddraw_CVS/d3dtexture.c 2003-05-29 21:39:53.000000000 +0200 +++ dlls/ddraw/d3dtexture.c 2003-05-30 11:30:03.000000000 +0200 @@ -120,7 +120,7 @@ snoop_texture(surf_ptr); if (upload_surface_to_tex_memory_init(surf_ptr, surf_ptr->mipmap_level, &(gl_surf_ptr->current_internal_format), - gl_surf_ptr->initial_upload_done == FALSE, TRUE) == D3D_OK) { + gl_surf_ptr->initial_upload_done == FALSE, TRUE, 0, 0) == D3D_OK) { upload_surface_to_tex_memory(NULL, &(gl_surf_ptr->surface_ptr)); upload_surface_to_tex_memory_release(); gl_surf_ptr->dirty_flag = SURFACE_MEMORY; @@ -231,7 +231,7 @@ (width == surf_ptr->surface_desc.dwWidth) && (height == surf_ptr->surface_desc.dwHeight))) { /* If not 'full size' and the surface is dirty, first flush it to GL before doing the copy. */ if (upload_surface_to_tex_memory_init(surf_ptr, surf_ptr->mipmap_level, &(gl_surf_ptr->current_internal_format), - gl_surf_ptr->initial_upload_done == FALSE, TRUE) != D3D_OK) { + gl_surf_ptr->initial_upload_done == FALSE, TRUE, 0, 0) != D3D_OK) { upload_surface_to_tex_memory(NULL, &(gl_surf_ptr->surface_ptr)); upload_surface_to_tex_memory_release(); gl_surf_ptr->dirty_flag = SURFACE_MEMORY; @@ -244,7 +244,7 @@ if (gl_surf_ptr->initial_upload_done == FALSE) { gl_surf_ptr->dirty_flag = SURFACE_MEMORY_DIRTY; if (upload_surface_to_tex_memory_init(surf_ptr, surf_ptr->mipmap_level, &(gl_surf_ptr->current_internal_format), - gl_surf_ptr->initial_upload_done == FALSE, TRUE) != D3D_OK) { + gl_surf_ptr->initial_upload_done == FALSE, TRUE, 0, 0) != D3D_OK) { upload_surface_to_tex_memory(NULL, &(gl_surf_ptr->surface_ptr)); upload_surface_to_tex_memory_release(); gl_surf_ptr->dirty_flag = SURFACE_MEMORY; --- dlls/ddraw_CVS/mesa.c 2003-05-29 21:39:53.000000000 +0200 +++ dlls/ddraw/mesa.c 2003-05-30 11:45:14.000000000 +0200 @@ -588,16 +588,35 @@ static GLuint current_level; HRESULT upload_surface_to_tex_memory_init(IDirectDrawSurfaceImpl *surf_ptr, GLuint level, GLenum *current_internal_format, - BOOLEAN need_to_alloc, BOOLEAN need_alpha_ck) + BOOLEAN need_to_alloc, BOOLEAN need_alpha_ck, DWORD tex_width, DWORD tex_height) { const DDPIXELFORMAT * const src_pf = &(surf_ptr->surface_desc.u4.ddpfPixelFormat); BOOL error = FALSE; BOOL colorkey_active = need_alpha_ck && (surf_ptr->surface_desc.dwFlags & DDSD_CKSRCBLT); GLenum internal_format = GL_LUMINANCE; /* A bogus value to be sure to have a nice Mesa warning :-) */ + BYTE bpp = GET_BPP(surf_ptr->surface_desc); current_surface = surf_ptr; current_level = level; + /* First, do some sanity checks ... */ + if ((surf_ptr->surface_desc.u1.lPitch % bpp) != 0) { + FIXME("Warning : pitch is not a multiple of BPP - not supported yet !\n"); + } + + /* Note: we only check width here as you cannot have width non-zero while height is set to zero */ + if (tex_width != 0) { + glPixelStorei(GL_UNPACK_ROW_LENGTH, surf_ptr->surface_desc.u1.lPitch / bpp); + } else { + if (surf_ptr->surface_desc.u1.lPitch == (surf_ptr->surface_desc.dwWidth * bpp)) { + glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); + } else { + glPixelStorei(GL_UNPACK_ROW_LENGTH, surf_ptr->surface_desc.u1.lPitch / bpp); + } + tex_width = surf_ptr->surface_desc.dwWidth; + tex_height = surf_ptr->surface_desc.dwHeight; + } + if (src_pf->dwFlags & DDPF_PALETTEINDEXED8) { /* **************** Paletted Texture @@ -792,7 +811,7 @@ if ((need_to_alloc) || (internal_format != *current_internal_format)) { glTexImage2D(GL_TEXTURE_2D, level, internal_format, - surf_ptr->surface_desc.dwWidth, surf_ptr->surface_desc.dwHeight, 0, + tex_width, tex_height, 0, current_format, current_pixel_format, NULL); *current_internal_format = internal_format; } @@ -805,7 +824,7 @@ { const DDSURFACEDESC * const src_d = (DDSURFACEDESC *)&(current_surface->surface_desc); void *surf_buffer = NULL; - + switch (convert_type) { case CONVERT_PALETTED: { IDirectDrawPaletteImpl* pal = current_surface->palette; --- dlls/ddraw_CVS/mesa_private.h 2003-05-29 21:39:53.000000000 +0200 +++ dlls/ddraw/mesa_private.h 2003-05-30 11:27:02.000000000 +0200 @@ -148,17 +148,10 @@ /* Memory to texture conversion code. Split in three functions to do some optimizations. */ extern HRESULT upload_surface_to_tex_memory_init(IDirectDrawSurfaceImpl *surface, GLuint level, GLenum *prev_internal_format, - BOOLEAN need_to_alloc, BOOLEAN need_alpha_ck); + BOOLEAN need_to_alloc, BOOLEAN need_alpha_ck, DWORD tex_width, DWORD tex_height); extern HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer); extern HRESULT upload_surface_to_tex_memory_release(void); -/* This structure contains all the function pointers to OpenGL extensions - that are used by Wine */ -typedef struct { - void (*ptr_ColorTableEXT) (GLenum target, GLenum internalformat, - GLsizei width, GLenum format, GLenum type, const GLvoid *table); -} Mesa_DeviceCapabilities; - #endif /* HAVE_OPENGL */ #endif /* __GRAPHICS_WINE_MESA_PRIVATE_H */