[D3D] Some addition and regression fixes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Now that I am back home and have more games to test (not to speak about a
faster 3D rendering :-) ), I fixed most regressions introduced by the last
series of patch.

There is still one 'poblem' remaining with FIFA2002 + Mesa (FIFA2002 does
not work with the NVIDIA drivers). As it's terribly slow on my box, I did
not really investigate more.

Will see how many people will complain (ie if it's present in more games
than just FIFA2002) :-)

Changelog:
 - fix (stupid) regressions introduced by last series of patch
 - 24 bpp handling for lock / unlock code
 - some better checks for AlphaPixel value
 - better TRACEing to better catch threading problems
    
-- 
		 Lionel Ulmer - http://www.bbrox.org/
--- dlls/ddraw_CVS/d3ddevice/mesa.c	Mon Jun  2 22:26:33 2003
+++ dlls/ddraw/d3ddevice/mesa.c	Tue Jun  3 11:44:49 2003
@@ -126,8 +126,8 @@
 {
     IDirect3DDeviceGLImpl* glThis = (IDirect3DDeviceGLImpl*) This;
    
-    ENTER_GL();
     TRACE("glxMakeCurrent %p, %ld, %p\n",glThis->display,glThis->drawable, glThis->gl_context);
+    ENTER_GL();
     if (glXMakeCurrent(glThis->display, glThis->drawable, glThis->gl_context) == False) {
 	ERR("Error in setting current context (context %p drawable %ld)!\n",
 	    glThis->gl_context, glThis->drawable);
@@ -1066,6 +1066,11 @@
     IDirect3DDeviceGLImpl* glThis = (IDirect3DDeviceGLImpl*) This;
     int num_active_stages = 0;
 
+    /* I put the trace before the various locks... So as to better understand where locks occur :-) */
+    if (TRACE_ON(ddraw)) {
+        TRACE(" Vertex format : "); dump_flexible_vertex(d3dvtVertexType);
+    }
+
     /* This is to prevent 'thread contention' between a thread locking the device and another
        doing 3D display on it... */
     EnterCriticalSection(&(This->crit));   
@@ -1077,10 +1082,6 @@
 
     glThis->state = SURFACE_GL;
     
-    if (TRACE_ON(ddraw)) {
-        TRACE(" Vertex format : "); dump_flexible_vertex(d3dvtVertexType);
-    }
-
     /* Just a hack for now.. Will have to find better algorithm :-/ */
     if ((d3dvtVertexType & D3DFVF_POSITION_MASK) != D3DFVF_XYZ) {
         vertex_lighted = TRUE;
@@ -1898,6 +1899,7 @@
 		
 		if (glThis->current_bound_texture[stage] == NULL) {
 		    if (This->state_block.texture_stage_state[stage][D3DTSS_COLOROP - 1] != D3DTOP_DISABLE) {
+			TRACE(" enabling 2D texturing and");
 			glEnable(GL_TEXTURE_2D);
 		    }
 		}
@@ -1906,6 +1908,13 @@
 	    }
 
 	    glThis->current_bound_texture[stage] = This->current_texture[stage];
+	} else {
+	    if (glThis->current_bound_texture[stage] == NULL) {
+		TRACE(" displaying without texturing activated for stage %ld.\n", stage);
+	    } else {
+		TRACE(" using already bound texture id %d for stage %ld.\n",
+		      ((IDirect3DTextureGLImpl *) (glThis->current_bound_texture[stage])->tex_private)->tex_name, stage);
+	    }
 	}
 
 	/* If no texure valid for this stage, go out of the loop */
@@ -2515,6 +2524,8 @@
 {
     GLfloat height, width;
     GLfloat trans_mat[16];
+
+    TRACE("(%p)\n", This);
     
     width = This->surface->surface_desc.dwWidth;
     height = This->surface->surface_desc.dwHeight;
@@ -2549,6 +2560,8 @@
 d3ddevice_set_matrices(IDirect3DDeviceImpl *This, DWORD matrices,
 		       D3DMATRIX *world_mat, D3DMATRIX *view_mat, D3DMATRIX *proj_mat)
 {
+    TRACE("(%p,%08lx,%p,%p,%p)\n", This, matrices, world_mat, view_mat, proj_mat);
+    
     ENTER_GL();
     if ((matrices & (VIEWMAT_CHANGED|WORLDMAT_CHANGED)) != 0) {
         glMatrixMode(GL_MODELVIEW);
@@ -2660,7 +2673,10 @@
 {
     IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This;
     DWORD tex_mat, tex_stage;
-    if ((matrices & (VIEWMAT_CHANGED|WORLDMAT_CHANGED|PROJMAT_CHANGED)) != 0) {
+
+    TRACE("(%p,%08lx)\n", This, matrices);
+    
+    if (matrices & (VIEWMAT_CHANGED|WORLDMAT_CHANGED|PROJMAT_CHANGED)) {
         if (glThis->transform_state == GL_TRANSFORM_NORMAL) {
 	    /* This will force an update of the transform state at the next drawing. */
 	    glThis->transform_state = GL_TRANSFORM_NONE;
@@ -2737,24 +2753,34 @@
 	/* Note that here we cannot do 'optmizations' about the WriteOnly flag... Indeed, a game
 	   may only write to the device... But when we will blit it back to the screen, we need
 	   also to blit correctly the parts the application did not overwrite... */
-	
-	if ((This->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 16) &&
-	    (This->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask ==        0xF800) &&
-	    (This->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask ==        0x07E0) &&
-	    (This->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask ==        0x001F) &&
-	    (This->surface_desc.u4.ddpfPixelFormat.u5.dwRGBAlphaBitMask == 0x0000)) {
-	    buffer_type = GL_UNSIGNED_SHORT_5_6_5;
-	    buffer_color = GL_RGB;
-	} else if ((This->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 32) &&
-		   (This->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask ==        0x00FF0000) &&
-		   (This->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask ==        0x0000FF00) &&
-		   (This->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask ==        0x000000FF) &&
-		   (This->surface_desc.u4.ddpfPixelFormat.u5.dwRGBAlphaBitMask == 0x00000000)) {
-	    buffer_type = GL_UNSIGNED_BYTE;
-	    buffer_color = GL_BGRA;
-	    glPixelStorei(GL_PACK_SWAP_BYTES, TRUE);
+
+	if (((This->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_RGB) != 0) &&
+	    (((This->surface_desc.u4.ddpfPixelFormat.dwFlags & DDPF_ALPHAPIXELS) == 0) ||
+	     (This->surface_desc.u4.ddpfPixelFormat.u5.dwRGBAlphaBitMask == 0x00000000))) {
+	    if ((This->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 16) &&
+		(This->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask == 0xF800) &&
+		(This->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask == 0x07E0) &&
+		(This->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask == 0x001F)) {
+		buffer_type = GL_UNSIGNED_SHORT_5_6_5;
+		buffer_color = GL_RGB;
+	    } else if ((This->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 24) &&
+		       (This->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask == 0xFF0000) &&
+		       (This->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask == 0x00FF00) &&
+		       (This->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask == 0x0000FF)) {
+		buffer_type = GL_UNSIGNED_BYTE;
+		buffer_color = GL_RGB;
+	    } else if ((This->surface_desc.u4.ddpfPixelFormat.u1.dwRGBBitCount == 32) &&
+		       (This->surface_desc.u4.ddpfPixelFormat.u2.dwRBitMask == 0x00FF0000) &&
+		       (This->surface_desc.u4.ddpfPixelFormat.u3.dwGBitMask == 0x0000FF00) &&
+		       (This->surface_desc.u4.ddpfPixelFormat.u4.dwBBitMask == 0x000000FF)) {
+		buffer_type = GL_UNSIGNED_INT_8_8_8_8_REV;
+		buffer_color = GL_BGRA;
+	    } else {
+		ERR(" unsupported pixel format at device locking.\n");
+		return;
+	    }
 	} else {
-	    ERR(" unsupported pixel format at device locking.\n");
+	    ERR(" unsupported pixel format at device locking - alpha on frame buffer.\n");
 	    return;
 	}
 
@@ -2789,8 +2815,6 @@
 	    dst += This->surface_desc.u1.lPitch;
 	}
 
-	glPixelStorei(GL_PACK_SWAP_BYTES, FALSE);
-	
 	if (is_front)
 	    gl_d3d_dev->front_state = SURFACE_MEMORY;
 	else
@@ -2849,7 +2873,7 @@
 
     
     if (upload_surface_to_tex_memory_init(surf, 0, &gl_d3d_dev->current_internal_format,
-					  initial, FALSE, UNLOCK_TEX_SIZE, UNLOCK_TEX_SIZE) != D3D_OK) {
+					  initial, FALSE, UNLOCK_TEX_SIZE, UNLOCK_TEX_SIZE) != DD_OK) {
         ERR(" unsupported pixel format at frame buffer flush.\n");
 	return;
     }
@@ -2963,6 +2987,9 @@
     if ((This->lastlocktype & DDLOCK_READONLY) == 0) {
         if (is_front == TRUE) {
 	    GLenum prev_draw;
+
+	    TRACE(" flushing front buffer immediatly on screen.\n");
+	    
 	    ENTER_GL();
 	    glGetIntegerv(GL_DRAW_BUFFER, &prev_draw);
 	    glDrawBuffer(GL_FRONT);
@@ -3023,10 +3050,12 @@
     object->matrices_updated = d3ddevice_matrices_updated;
     object->flush_to_framebuffer = d3ddevice_flush_to_frame_buffer;
     
-    InitializeCriticalSection(&(object->crit));
-    
     TRACE(" creating OpenGL device for surface = %p, d3d = %p\n", surface, d3d);
 
+    InitializeCriticalSection(&(object->crit));
+
+    TRACE(" device critical section : %p\n", &(object->crit));
+    
     device_context = GetDC(surface->ddraw_owner->window);
     gl_object->display = get_display(device_context);
     gl_object->drawable = get_drawable(device_context);
--- dlls/ddraw_CVS/d3dlight.c	Sun Jun  1 20:56:09 2003
+++ dlls/ddraw/d3dlight.c	Tue Jun  3 00:28:13 2003
@@ -161,6 +161,9 @@
 
 static void activate(IDirect3DLightImpl* This) {
     IDirect3DLightGLImpl *glThis = (IDirect3DLightGLImpl *) This;
+
+    TRACE("(%p)\n", This);
+    
     ENTER_GL();
     update(This);
     /* If was not active, activate it */
@@ -173,6 +176,9 @@
 
 static void desactivate(IDirect3DLightImpl* This) {
     IDirect3DLightGLImpl *glThis = (IDirect3DLightGLImpl *) This;
+    
+    TRACE("(%p)\n", This);
+    
     ENTER_GL();
     /* If was not active, activate it */
     if ((glThis->parent.light.dwFlags & D3DLIGHT_ACTIVE) != 0) {
--- dlls/ddraw_CVS/d3dtexture.c	Mon Jun  2 22:26:33 2003
+++ dlls/ddraw/d3dtexture.c	Tue Jun  3 10:35:43 2003
@@ -266,10 +266,13 @@
 	    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, 0, 0) == D3D_OK) {
+						  gl_surf_ptr->initial_upload_done == FALSE, TRUE, 0, 0) == DD_OK) {
 	        upload_surface_to_tex_memory(NULL, 0, 0, &(gl_surf_ptr->surface_ptr));
 		upload_surface_to_tex_memory_release();
 		gl_surf_ptr->dirty_flag = SURFACE_MEMORY;
+	    } else {
+		ERR("Problem for upload of texture %d (level = %d / initial done = %d).\n",
+		    gl_surf_ptr->tex_name, surf_ptr->mipmap_level, gl_surf_ptr->initial_upload_done);
 	    }
 	}
 	
@@ -302,6 +305,8 @@
 
     if (glThis->dirty_flag == SURFACE_GL) {
 	GLuint cur_tex;
+
+	TRACE(" flushing GL texture back to memory.\n");
 	
 	ENTER_GL();
 	glGetIntegerv(GL_TEXTURE_BINDING_2D, &cur_tex);
@@ -368,6 +373,10 @@
 		return DDERR_INVALIDPARAMS;
 	    }
 
+	    if ((width == 0) || (height == 0)) {
+		return DD_OK;
+	    }
+	    
 	    TRACE(" direct frame buffer => texture BltFast override.\n");
 	    
 	    ENTER_GL();
@@ -380,24 +389,29 @@
 		  (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, 0, 0) != D3D_OK) {
+						      gl_surf_ptr->initial_upload_done == FALSE, TRUE, 0, 0) == DD_OK) {
 		    upload_surface_to_tex_memory(NULL, 0, 0, &(gl_surf_ptr->surface_ptr));
 		    upload_surface_to_tex_memory_release();
 		    gl_surf_ptr->dirty_flag = SURFACE_MEMORY;
 		} else {
+		    glBindTexture(GL_TEXTURE_2D, cur_tex);
+		    LEAVE_GL();
+		    ERR("Error at texture upload !\n");
 		    return DDERR_INVALIDPARAMS;
 		}
 	    }
 
 	    /* This is a hack and would need some clean-up :-) */
 	    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, 0, 0) != D3D_OK) {
+						      TRUE, TRUE, 0, 0) == DD_OK) {
 		    upload_surface_to_tex_memory(NULL, 0, 0, &(gl_surf_ptr->surface_ptr));
 		    upload_surface_to_tex_memory_release();
 		    gl_surf_ptr->dirty_flag = SURFACE_MEMORY;
 		} else {
+		    glBindTexture(GL_TEXTURE_2D, cur_tex);
+		    LEAVE_GL();
+		    ERR("Error at texture upload (initial case) !\n");
 		    return DDERR_INVALIDPARAMS;
 		}
 	    }
@@ -490,6 +504,8 @@
     if (glThis->dirty_flag == SURFACE_GL) {
 	GLuint 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);
@@ -836,18 +852,19 @@
 	   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);
+	
 	ENTER_GL();
 	if (surf->mipmap_level == 0) {
 	    glGenTextures(1, &(private->tex_name));
 	    if (private->tex_name == 0) ERR("Error at creation of OpenGL texture ID !\n");
-	    TRACE(" GL texture created for surface %p (private data at %p and GL id %d).\n", surf, private, private->tex_name);
+	    TRACE(" GL texture id is : %d.\n", private->tex_name);
 	    private->__global_dirty_flag = (at_creation == FALSE ? SURFACE_MEMORY_DIRTY : SURFACE_MEMORY);
 	    private->global_dirty_flag = &(private->__global_dirty_flag);
 	} else {
 	    private->tex_name = ((IDirect3DTextureGLImpl *) (main->tex_private))->tex_name;
-	    TRACE(" GL texture created for surface %p (private data at %p and GL id reusing id %d from surface %p (%p)).\n",
-		  surf, private, private->tex_name, main, main->tex_private);
+	    TRACE(" GL texture id reusing id %d from surface %p (private at %p)).\n", private->tex_name, main, main->tex_private);
 	    private->global_dirty_flag = &(((IDirect3DTextureGLImpl *) (main->tex_private))->__global_dirty_flag);
 	}
 	LEAVE_GL();
--- dlls/ddraw_CVS/mesa.c	Sun Jun  1 20:56:09 2003
+++ dlls/ddraw/mesa.c	Tue Jun  3 10:34:42 2003
@@ -88,8 +88,7 @@
     DWORD dwRenderState = lpStateBlock->render_state[dwRenderStateType - 1];
     IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This;
     
-    if (TRACE_ON(ddraw))
-        TRACE("%s = %08lx\n", _get_renderstate(dwRenderStateType), dwRenderState);
+    TRACE("%s = %08lx\n", _get_renderstate(dwRenderStateType), dwRenderState);
 
     /* First, all the stipple patterns */
     if ((dwRenderStateType >= D3DRENDERSTATE_STIPPLEPATTERN00) &&
@@ -635,169 +634,189 @@
 	   RGB Textures
 	   ************ */
 	if (src_pf->u1.dwRGBBitCount == 8) {
-	    if ((src_pf->u2.dwRBitMask == 0xE0) &&
-		(src_pf->u3.dwGBitMask == 0x1C) &&
-		(src_pf->u4.dwBBitMask == 0x03)) {
-		/* **********************
-		   GL_UNSIGNED_BYTE_3_3_2
-		   ********************** */
-		if (colorkey_active) {
-		    /* This texture format will never be used.. So do not care about color keying
-		       up until the point in time it will be needed :-) */
-		    FIXME(" ColorKeying not supported in the RGB 332 format !");
-		}
-		current_format = GL_RGB;
-		internal_format = GL_RGB;
-		current_pixel_format = GL_UNSIGNED_BYTE_3_3_2;
-		convert_type = NO_CONVERSION;
-	    } else {
+	    if ((src_pf->dwFlags & DDPF_ALPHAPIXELS) &&
+		(src_pf->u5.dwRGBAlphaBitMask != 0x00)) {
 		error = TRUE;
-	    }
-	} else if (src_pf->u1.dwRGBBitCount == 16) {
-	    if ((src_pf->u2.dwRBitMask ==        0xF800) &&
-		(src_pf->u3.dwGBitMask ==        0x07E0) &&
-		(src_pf->u4.dwBBitMask ==        0x001F) &&
-		(src_pf->u5.dwRGBAlphaBitMask == 0x0000)) {
-		if (colorkey_active) {
-		    convert_type = CONVERT_CK_565;
-		    current_format = GL_RGBA;
-		    internal_format = GL_RGBA;
-		    current_pixel_format = GL_UNSIGNED_SHORT_5_5_5_1;
-		} else {
-		    convert_type = NO_CONVERSION;
+	    } else {
+		if ((src_pf->u2.dwRBitMask == 0xE0) &&
+		    (src_pf->u3.dwGBitMask == 0x1C) &&
+		    (src_pf->u4.dwBBitMask == 0x03)) {
+		    /* **********************
+		       GL_UNSIGNED_BYTE_3_3_2
+		       ********************** */
+		    if (colorkey_active) {
+			/* This texture format will never be used.. So do not care about color keying
+			   up until the point in time it will be needed :-) */
+			FIXME(" ColorKeying not supported in the RGB 332 format !");
+		    }
 		    current_format = GL_RGB;
 		    internal_format = GL_RGB;
-		    current_pixel_format = GL_UNSIGNED_SHORT_5_6_5;
-		}
-	    } else if ((src_pf->u2.dwRBitMask ==        0xF800) &&
-		       (src_pf->u3.dwGBitMask ==        0x07C0) &&
-		       (src_pf->u4.dwBBitMask ==        0x003E) &&
-		       (src_pf->u5.dwRGBAlphaBitMask == 0x0001)) {
-		current_format = GL_RGBA;
-		internal_format = GL_RGBA;
-		current_pixel_format = GL_UNSIGNED_SHORT_5_5_5_1;
-		if (colorkey_active) {
-		    convert_type = CONVERT_CK_5551;
-		} else {
+		    current_pixel_format = GL_UNSIGNED_BYTE_3_3_2;
 		    convert_type = NO_CONVERSION;
-		}
-	    } else if ((src_pf->u2.dwRBitMask ==        0xF000) &&
-		       (src_pf->u3.dwGBitMask ==        0x0F00) &&
-		       (src_pf->u4.dwBBitMask ==        0x00F0) &&
-		       (src_pf->u5.dwRGBAlphaBitMask == 0x000F)) {
-		current_format = GL_RGBA;
-		internal_format = GL_RGBA;
-		current_pixel_format = GL_UNSIGNED_SHORT_4_4_4_4;
-		if (colorkey_active) {
-		    convert_type = CONVERT_CK_4444;
 		} else {
-		    convert_type = NO_CONVERSION;
+		    error = TRUE;
 		}
-	    } else if ((src_pf->u2.dwRBitMask ==        0x0F00) &&
-		       (src_pf->u3.dwGBitMask ==        0x00F0) &&
-		       (src_pf->u4.dwBBitMask ==        0x000F) &&
-		       (src_pf->u5.dwRGBAlphaBitMask == 0xF000)) {
-		if (colorkey_active) {
-		    convert_type = CONVERT_CK_4444_ARGB;
+	    }
+	} else if (src_pf->u1.dwRGBBitCount == 16) {
+	    if ((src_pf->dwFlags & DDPF_ALPHAPIXELS) &&
+		(src_pf->u5.dwRGBAlphaBitMask != 0x0000)) {
+		if ((src_pf->u2.dwRBitMask ==        0xF800) &&
+		    (src_pf->u3.dwGBitMask ==        0x07C0) &&
+		    (src_pf->u4.dwBBitMask ==        0x003E) &&
+		    (src_pf->u5.dwRGBAlphaBitMask == 0x0001)) {
+		    current_format = GL_RGBA;
+		    internal_format = GL_RGBA;
+		    current_pixel_format = GL_UNSIGNED_SHORT_5_5_5_1;
+		    if (colorkey_active) {
+			convert_type = CONVERT_CK_5551;
+		    } else {
+			convert_type = NO_CONVERSION;
+		    }
+		} else if ((src_pf->u2.dwRBitMask ==        0xF000) &&
+			   (src_pf->u3.dwGBitMask ==        0x0F00) &&
+			   (src_pf->u4.dwBBitMask ==        0x00F0) &&
+			   (src_pf->u5.dwRGBAlphaBitMask == 0x000F)) {
 		    current_format = GL_RGBA;
 		    internal_format = GL_RGBA;
 		    current_pixel_format = GL_UNSIGNED_SHORT_4_4_4_4;
+		    if (colorkey_active) {
+			convert_type = CONVERT_CK_4444;
+		    } else {
+			convert_type = NO_CONVERSION;
+		    }
+		} else if ((src_pf->u2.dwRBitMask ==        0x0F00) &&
+			   (src_pf->u3.dwGBitMask ==        0x00F0) &&
+			   (src_pf->u4.dwBBitMask ==        0x000F) &&
+			   (src_pf->u5.dwRGBAlphaBitMask == 0xF000)) {
+		    if (colorkey_active) {
+			convert_type = CONVERT_CK_4444_ARGB;
+			current_format = GL_RGBA;
+			internal_format = GL_RGBA;
+			current_pixel_format = GL_UNSIGNED_SHORT_4_4_4_4;
+		    } else {
+			convert_type = NO_CONVERSION;
+			current_format = GL_BGRA;
+			internal_format = GL_RGBA;
+			current_pixel_format = GL_UNSIGNED_SHORT_4_4_4_4_REV;
+		    }
+		} else if ((src_pf->u2.dwRBitMask ==        0x7C00) &&
+			   (src_pf->u3.dwGBitMask ==        0x03E0) &&
+			   (src_pf->u4.dwBBitMask ==        0x001F) &&
+			   (src_pf->u5.dwRGBAlphaBitMask == 0x8000)) {
+		    if (colorkey_active) {
+			convert_type = CONVERT_CK_1555;
+			current_format = GL_RGBA;
+			internal_format = GL_RGBA;
+			current_pixel_format = GL_UNSIGNED_SHORT_5_5_5_1;
+		    } else {
+			convert_type = NO_CONVERSION;
+			current_format = GL_BGRA;
+			internal_format = GL_RGBA;
+			current_pixel_format = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+		    }
 		} else {
-		    convert_type = NO_CONVERSION;
-		    current_format = GL_BGRA;
-		    internal_format = GL_RGBA;
-		    current_pixel_format = GL_UNSIGNED_SHORT_4_4_4_4_REV;
+		    error = TRUE;
 		}
-	    } else if ((src_pf->u2.dwRBitMask ==        0x7C00) &&
-		       (src_pf->u3.dwGBitMask ==        0x03E0) &&
-		       (src_pf->u4.dwBBitMask ==        0x001F) &&
-		       (src_pf->u5.dwRGBAlphaBitMask == 0x8000)) {
-		if (colorkey_active) {
-		    convert_type = CONVERT_CK_1555;
+	    } else {
+		if ((src_pf->u2.dwRBitMask == 0xF800) &&
+		    (src_pf->u3.dwGBitMask == 0x07E0) &&
+		    (src_pf->u4.dwBBitMask == 0x001F)) {
+		    if (colorkey_active) {
+			convert_type = CONVERT_CK_565;
+			current_format = GL_RGBA;
+			internal_format = GL_RGBA;
+			current_pixel_format = GL_UNSIGNED_SHORT_5_5_5_1;
+		    } else {
+			convert_type = NO_CONVERSION;
+			current_format = GL_RGB;
+			internal_format = GL_RGB;
+			current_pixel_format = GL_UNSIGNED_SHORT_5_6_5;
+		    }
+		} else if ((src_pf->u2.dwRBitMask == 0x7C00) &&
+			   (src_pf->u3.dwGBitMask == 0x03E0) &&
+			   (src_pf->u4.dwBBitMask == 0x001F)) {
+		    convert_type = CONVERT_555;
 		    current_format = GL_RGBA;
 		    internal_format = GL_RGBA;
 		    current_pixel_format = GL_UNSIGNED_SHORT_5_5_5_1;
 		} else {
-		    convert_type = NO_CONVERSION;
-		    current_format = GL_BGRA;
-		    internal_format = GL_RGBA;
-		    current_pixel_format = GL_UNSIGNED_SHORT_1_5_5_5_REV;
+		    error = TRUE;
 		}
-	    } else if ((src_pf->u2.dwRBitMask ==        0x7C00) &&
-		       (src_pf->u3.dwGBitMask ==        0x03E0) &&
-		       (src_pf->u4.dwBBitMask ==        0x001F) &&
-		       (src_pf->u5.dwRGBAlphaBitMask == 0x0000)) {
-		convert_type = CONVERT_555;
-		current_format = GL_RGBA;
-		internal_format = GL_RGBA;
-		current_pixel_format = GL_UNSIGNED_SHORT_5_5_5_1;
-	    } else {
-		error = TRUE;
 	    }
 	} else if (src_pf->u1.dwRGBBitCount == 24) {
-	    if ((src_pf->u2.dwRBitMask ==        0x00FF0000) &&
-		(src_pf->u3.dwGBitMask ==        0x0000FF00) &&
-		(src_pf->u4.dwBBitMask ==        0x000000FF) &&
-		(src_pf->u5.dwRGBAlphaBitMask == 0x00000000)) {
-		if (colorkey_active) {
-		    convert_type = CONVERT_CK_RGB24;
-		    current_format = GL_RGBA;
-		    internal_format = GL_RGBA;
-		    current_pixel_format = GL_UNSIGNED_INT_8_8_8_8;
+	    if ((src_pf->dwFlags & DDPF_ALPHAPIXELS) &&
+		(src_pf->u5.dwRGBAlphaBitMask != 0x000000)) {
+		error = TRUE;
+	    } else {
+		if ((src_pf->u2.dwRBitMask == 0xFF0000) &&
+		    (src_pf->u3.dwGBitMask == 0x00FF00) &&
+		    (src_pf->u4.dwBBitMask == 0x0000FF)) {
+		    if (colorkey_active) {
+			convert_type = CONVERT_CK_RGB24;
+			current_format = GL_RGBA;
+			internal_format = GL_RGBA;
+			current_pixel_format = GL_UNSIGNED_INT_8_8_8_8;
+		    } else {
+			convert_type = NO_CONVERSION;
+			current_format = GL_BGR;
+			internal_format = GL_RGB;
+			current_pixel_format = GL_UNSIGNED_BYTE;
+		    }
 		} else {
-		    convert_type = NO_CONVERSION;
-		    current_format = GL_BGR;
-		    internal_format = GL_RGB;
-		    current_pixel_format = GL_UNSIGNED_BYTE;
+		    error = TRUE;
 		}
-	    } else {
-		error = TRUE;
 	    }
 	} else if (src_pf->u1.dwRGBBitCount == 32) {
-	    if ((src_pf->u2.dwRBitMask ==        0xFF000000) &&
-		(src_pf->u3.dwGBitMask ==        0x00FF0000) &&
-		(src_pf->u4.dwBBitMask ==        0x0000FF00) &&
-		(src_pf->u5.dwRGBAlphaBitMask == 0x000000FF)) {
-		if (colorkey_active) {
-		    convert_type = CONVERT_CK_8888;
-		} else {
-		    convert_type = NO_CONVERSION;
-		}
-		current_format = GL_RGBA;
-		internal_format = GL_RGBA;
-		current_pixel_format = GL_UNSIGNED_INT_8_8_8_8;
-	    } else if ((src_pf->u2.dwRBitMask ==        0x00FF0000) &&
-		       (src_pf->u3.dwGBitMask ==        0x0000FF00) &&
-		       (src_pf->u4.dwBBitMask ==        0x000000FF) &&
-		       (src_pf->u5.dwRGBAlphaBitMask == 0xFF000000)) {
-		if (colorkey_active) {
-		    convert_type = CONVERT_CK_8888_ARGB;
+	    if ((src_pf->dwFlags & DDPF_ALPHAPIXELS) &&
+		(src_pf->u5.dwRGBAlphaBitMask != 0x00000000)) {
+		if ((src_pf->u2.dwRBitMask ==        0xFF000000) &&
+		    (src_pf->u3.dwGBitMask ==        0x00FF0000) &&
+		    (src_pf->u4.dwBBitMask ==        0x0000FF00) &&
+		    (src_pf->u5.dwRGBAlphaBitMask == 0x000000FF)) {
+		    if (colorkey_active) {
+			convert_type = CONVERT_CK_8888;
+		    } else {
+			convert_type = NO_CONVERSION;
+		    }
 		    current_format = GL_RGBA;
 		    internal_format = GL_RGBA;
 		    current_pixel_format = GL_UNSIGNED_INT_8_8_8_8;
+		} else if ((src_pf->u2.dwRBitMask ==        0x00FF0000) &&
+			   (src_pf->u3.dwGBitMask ==        0x0000FF00) &&
+			   (src_pf->u4.dwBBitMask ==        0x000000FF) &&
+			   (src_pf->u5.dwRGBAlphaBitMask == 0xFF000000)) {
+		    if (colorkey_active) {
+			convert_type = CONVERT_CK_8888_ARGB;
+			current_format = GL_RGBA;
+			internal_format = GL_RGBA;
+			current_pixel_format = GL_UNSIGNED_INT_8_8_8_8;
+		    } else {
+			convert_type = NO_CONVERSION;
+			current_format = GL_BGRA;
+			internal_format = GL_RGBA;
+			current_pixel_format = GL_UNSIGNED_INT_8_8_8_8_REV;
+		    }
 		} else {
-		    convert_type = NO_CONVERSION;
-		    current_format = GL_BGRA;
-		    internal_format = GL_RGBA;
-		    current_pixel_format = GL_UNSIGNED_INT_8_8_8_8_REV;
+		    error = TRUE;
 		}
-	    } else if ((src_pf->u2.dwRBitMask ==        0x00FF0000) &&
-		       (src_pf->u3.dwGBitMask ==        0x0000FF00) &&
-		       (src_pf->u4.dwBBitMask ==        0x000000FF) &&
-		       (src_pf->u5.dwRGBAlphaBitMask == 0x00000000)) {
-		if (need_alpha_ck == TRUE) {
-		    convert_type = CONVERT_RGB32_888;
-		    current_format = GL_RGBA;
-		    internal_format = GL_RGBA;
-		    current_pixel_format = GL_UNSIGNED_INT_8_8_8_8;
+	    } else {
+		if ((src_pf->u2.dwRBitMask == 0x00FF0000) &&
+		    (src_pf->u3.dwGBitMask == 0x0000FF00) &&
+		    (src_pf->u4.dwBBitMask == 0x000000FF)) {
+		    if (need_alpha_ck == TRUE) {
+			convert_type = CONVERT_RGB32_888;
+			current_format = GL_RGBA;
+			internal_format = GL_RGBA;
+			current_pixel_format = GL_UNSIGNED_INT_8_8_8_8;
+		    } else {
+			convert_type = NO_CONVERSION;
+			current_format = GL_BGRA;
+			internal_format = GL_RGBA;
+			current_pixel_format = GL_UNSIGNED_INT_8_8_8_8_REV;
+		    }
 		} else {
-		    convert_type = NO_CONVERSION;
-		    current_format = GL_BGRA;
-		    internal_format = GL_RGBA;
-		    current_pixel_format = GL_UNSIGNED_INT_8_8_8_8_REV;
+		    error = TRUE;
 		}
-	    } else {
-		error = TRUE;
 	    }
 	} else {
 	    error = TRUE;
@@ -807,8 +826,8 @@
     } 
 
     if (error == TRUE) {
+	ERR("Unsupported pixel format for textures : \n");
 	if (ERR_ON(ddraw)) {
-	    ERR("  unsupported pixel format for textures : \n");
 	    DDRAW_dump_pixelformat(src_pf);
 	}
 	return DDERR_INVALIDPIXELFORMAT;

[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux