glamor_create_picture: Fix the format matching method.
We should not simply set a TEXTURE_DRM pixmap to a separated texture pixmap. If the format is compatible with current fbo then it is just fine to keep it as TEXTURE_DRM type and we can safely fallback to DDX layer on it. Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
		
							parent
							
								
									28fcd7cd01
								
							
						
					
					
						commit
						994a9ff7f5
					
				| 
						 | 
					@ -65,15 +65,21 @@ glamor_create_picture(PicturePtr picture)
 | 
				
			||||||
 	 * the uploading, we need to know the picture format. */
 | 
					 	 * the uploading, we need to know the picture format. */
 | 
				
			||||||
		glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
 | 
							glamor_set_pixmap_type(pixmap, GLAMOR_MEMORY);
 | 
				
			||||||
		pixmap_priv = glamor_get_pixmap_private(pixmap);
 | 
							pixmap_priv = glamor_get_pixmap_private(pixmap);
 | 
				
			||||||
	}
 | 
						} else {
 | 
				
			||||||
	
 | 
							if (GLAMOR_PIXMAP_PRIV_HAS_FBO(pixmap_priv)) {
 | 
				
			||||||
	if (pixmap_priv) {
 | 
								/* If the picture format is not compatible with glamor fbo format,
 | 
				
			||||||
		pixmap_priv->is_picture = 1;
 | 
								 * we have to mark this pixmap as a separated texture, and don't
 | 
				
			||||||
		pixmap_priv->pict_format = picture->format;
 | 
								 * fallback to DDX layer. */
 | 
				
			||||||
		/* XXX Some formats are compatible between glamor and ddx driver*/
 | 
								if (pixmap_priv->type == GLAMOR_TEXTURE_DRM
 | 
				
			||||||
		if (pixmap_priv->type == GLAMOR_TEXTURE_DRM)
 | 
								    && !glamor_pict_format_is_compatible(picture->format,
 | 
				
			||||||
 | 
													 pixmap->drawable.depth))
 | 
				
			||||||
				glamor_set_pixmap_type(pixmap, GLAMOR_SEPARATE_TEXTURE);
 | 
									glamor_set_pixmap_type(pixmap, GLAMOR_SEPARATE_TEXTURE);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						pixmap_priv->is_picture = 1;
 | 
				
			||||||
 | 
						pixmap_priv->pict_format = picture->format;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return miCreatePicture(picture);
 | 
						return miCreatePicture(picture);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -232,18 +232,16 @@ gl_iformat_for_depth(int depth, GLenum * format)
 | 
				
			||||||
	case 8:
 | 
						case 8:
 | 
				
			||||||
		*format = GL_ALPHA;
 | 
							*format = GL_ALPHA;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	case 24:
 | 
						case 24:
 | 
				
			||||||
		*format = GL_RGB;
 | 
							*format = GL_RGB;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
 | 
					#endif
 | 
				
			||||||
	default:
 | 
						default:
 | 
				
			||||||
		*format = GL_RGBA;
 | 
							*format = GL_RGBA;
 | 
				
			||||||
		break;
 | 
							break;
 | 
				
			||||||
       }
 | 
					       }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
static inline CARD32
 | 
					static inline CARD32
 | 
				
			||||||
format_for_pixmap(PixmapPtr pixmap)
 | 
					format_for_pixmap(PixmapPtr pixmap)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					@ -561,6 +559,21 @@ glamor_get_rgba_from_pixel(CARD32 pixel,
 | 
				
			||||||
	return TRUE;
 | 
						return TRUE;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					inline static Bool glamor_pict_format_is_compatible(PictFormatShort pict_format, int depth)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
						GLenum iformat;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						gl_iformat_for_depth(depth, &iformat);
 | 
				
			||||||
 | 
						switch (iformat) {
 | 
				
			||||||
 | 
							case GL_RGBA:
 | 
				
			||||||
 | 
								return (pict_format == PICT_a8r8g8b8 || pict_format == PICT_x8r8g8b8);
 | 
				
			||||||
 | 
							case GL_ALPHA:
 | 
				
			||||||
 | 
								return (pict_format == PICT_a8);
 | 
				
			||||||
 | 
							default:
 | 
				
			||||||
 | 
								return FALSE;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* return TRUE if we can access this pixmap at DDX driver. */
 | 
					/* return TRUE if we can access this pixmap at DDX driver. */
 | 
				
			||||||
inline static Bool glamor_ddx_fallback_check_pixmap(DrawablePtr drawable)
 | 
					inline static Bool glamor_ddx_fallback_check_pixmap(DrawablePtr drawable)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue