Commit 3383ce5d authored by Lionel Ulmer's avatar Lionel Ulmer Committed by Alexandre Julliard

- 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)
parent 094f6bc9
......@@ -263,31 +263,6 @@ static void fill_opengl_caps_7(D3DDEVICEDESC7 *d)
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;
......
......@@ -120,7 +120,7 @@ gltex_upload_texture(IDirectDrawSurfaceImpl *surf_ptr) {
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 @@ gltex_bltfast(IDirectDrawSurfaceImpl *surf_ptr, DWORD dstx,
(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 @@ gltex_bltfast(IDirectDrawSurfaceImpl *surf_ptr, DWORD dstx,
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;
......
......@@ -576,16 +576,35 @@ static IDirectDrawSurfaceImpl *current_surface;
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
......@@ -780,7 +799,7 @@ HRESULT upload_surface_to_tex_memory_init(IDirectDrawSurfaceImpl *surf_ptr, GLui
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;
}
......@@ -793,7 +812,7 @@ HRESULT upload_surface_to_tex_memory(RECT *rect, void **temp_buffer)
{
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;
......
......@@ -148,17 +148,10 @@ extern void apply_render_state(IDirect3DDeviceImpl* This, STATEBLOCK* lpStateBlo
/* 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 */
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