Commit 3b48660f authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Implement YV12 support for emulated overlays.

This is the prefered format of many codecs, and for some codecs this is the only supported output format. As usual I try to handle all the conversion in the GPU and keep the CPU involvement minimal to gain the full performance of PBO transfers.
parent 2e9603c4
......@@ -255,6 +255,11 @@ PixelFormat_WineD3DtoDD(DDPIXELFORMAT *DDPixelFormat,
break;
case WINED3DFMT_YV12:
DDPixelFormat->u1.dwYUVBitCount = 12;
DDPixelFormat->dwFlags = DDPF_FOURCC;
DDPixelFormat->dwFourCC = WineD3DFormat;
break;
case WINED3DFMT_DXT1:
case WINED3DFMT_DXT2:
case WINED3DFMT_DXT3:
......
......@@ -586,7 +586,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DSurfaceImpl *object; /*NOTE: impl ref allowed since this is a create function */
unsigned int Size = 1;
const StaticPixelFormatDesc *tableEntry = getFormatDescEntry(Format, NULL, NULL);
const GlPixelFormatDesc *glDesc;
const StaticPixelFormatDesc *tableEntry = getFormatDescEntry(Format, &GLINFO_LOCATION, &glDesc);
TRACE("(%p) Create surface\n",This);
/** FIXME: Check ranges on the inputs are valid
......@@ -637,9 +638,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
} else {
/* The pitch is a multiple of 4 bytes */
Size = ((Width * tableEntry->bpp) + This->surface_alignment - 1) & ~(This->surface_alignment - 1);
Size *= Height;
Size *= Height;
}
if(glDesc->heightscale != 0.0) Size *= glDesc->heightscale;
/** Create and initialise the surface resource **/
D3DCREATERESOURCEOBJECTINSTANCE(object,Surface,WINED3DRTYPE_SURFACE, Size)
/* "Standalone" surface */
......@@ -650,6 +653,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
object->currentDesc.MultiSampleType = MultiSample;
object->currentDesc.MultiSampleQuality = MultisampleQuality;
object->glDescription.level = Level;
object->heightscale = glDesc->heightscale != 0.0 ? glDesc->heightscale : 1.0;
list_init(&object->overlays);
/* Flags */
......
......@@ -231,6 +231,9 @@ static void surface_download_data(IWineD3DSurfaceImpl *This) {
/* This call just uploads data, the caller is responsible for activating the
* right context and binding the correct texture. */
static void surface_upload_data(IWineD3DSurfaceImpl *This, GLenum internal, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *data) {
if(This->heightscale != 1.0 && This->heightscale != 0.0) height *= This->heightscale;
if (This->resource.format == WINED3DFMT_DXT1 ||
This->resource.format == WINED3DFMT_DXT2 || This->resource.format == WINED3DFMT_DXT3 ||
This->resource.format == WINED3DFMT_DXT4 || This->resource.format == WINED3DFMT_DXT5 ||
......@@ -293,6 +296,8 @@ static void surface_allocate_surface(IWineD3DSurfaceImpl *This, GLenum internal,
BOOL enable_client_storage = FALSE;
BYTE *mem = NULL;
if(This->heightscale != 1.0 && This->heightscale != 0.0) height *= This->heightscale;
TRACE("(%p) : Creating surface (target %#x) level %d, d3d format %s, internal format %#x, width %d, height %d, gl format %#x, gl type=%#x\n", This,
This->glDescription.target, This->glDescription.level, debug_d3dformat(This->resource.format), internal, width, height, format, type);
......
......@@ -44,7 +44,7 @@ static const StaticPixelFormatDesc formats[] = {
/* FourCC formats, kept here to have WINED3DFMT_R8G8B8(=20) at position 20 */
{WINED3DFMT_UYVY ,0x0 ,0x0 ,0x0 ,0x0 ,2 ,0 ,0 ,TRUE },
{WINED3DFMT_YUY2 ,0x0 ,0x0 ,0x0 ,0x0 ,2 ,0 ,0 ,TRUE },
{WINED3DFMT_YV12 ,0x0 ,0x0 ,0x0 ,0x0 ,2 ,0 ,0 ,TRUE },
{WINED3DFMT_YV12 ,0x0 ,0x0 ,0x0 ,0x0 ,1 ,0 ,0 ,TRUE },
{WINED3DFMT_DXT1 ,0x0 ,0x0 ,0x0 ,0x0 ,1 ,0 ,0 ,TRUE },
{WINED3DFMT_DXT2 ,0x0 ,0x0 ,0x0 ,0x0 ,1 ,0 ,0 ,TRUE },
{WINED3DFMT_DXT3 ,0x0 ,0x0 ,0x0 ,0x0 ,1 ,0 ,0 ,TRUE },
......@@ -146,6 +146,8 @@ static const GlPixelFormatDescTemplate gl_formats_template[] = {
,WINED3DFMT_FLAG_FILTERING },
{WINED3DFMT_YUY2 ,GL_RGB ,GL_RGB , 0, GL_YCBCR_422_APPLE ,UNSIGNED_SHORT_8_8_REV_APPLE
,WINED3DFMT_FLAG_FILTERING },
{WINED3DFMT_YV12 ,GL_ALPHA ,GL_ALPHA , 0, GL_ALPHA ,GL_UNSIGNED_BYTE
,WINED3DFMT_FLAG_FILTERING },
{WINED3DFMT_DXT1 ,GL_COMPRESSED_RGBA_S3TC_DXT1_EXT ,GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT , 0, GL_RGBA ,GL_UNSIGNED_BYTE
,WINED3DFMT_FLAG_FILTERING },
{WINED3DFMT_DXT2 ,GL_COMPRESSED_RGBA_S3TC_DXT3_EXT ,GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT , 0, GL_RGBA ,GL_UNSIGNED_BYTE
......@@ -273,6 +275,10 @@ static const GlPixelFormatDescTemplate gl_formats_template[] = {
,0 },
/* Vendor-specific formats */
{WINED3DFMT_ATI2N ,0 ,0 , 0, GL_LUMINANCE_ALPHA ,GL_UNSIGNED_BYTE
,0 },
{WINED3DFMT_NVHU ,0 ,0 , 0, GL_LUMINANCE_ALPHA ,GL_UNSIGNED_BYTE
,0 },
{WINED3DFMT_NVHS ,0 ,0 , 0, GL_LUMINANCE_ALPHA ,GL_UNSIGNED_BYTE
,0 }
};
......@@ -314,6 +320,7 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
gl_info->gl_formats[dst].glType = gl_formats_template[src].glType;
gl_info->gl_formats[dst].conversion_group= WINED3DFMT_UNKNOWN;
gl_info->gl_formats[dst].Flags = gl_formats_template[src].Flags;
gl_info->gl_formats[dst].heightscale = 1.0;
if(wined3d_settings.offscreen_rendering_mode == ORM_FBO &&
gl_formats_template[src].rtInternal != 0) {
......@@ -430,6 +437,11 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
gl_info->gl_formats[dst].glType = GL_UNSIGNED_BYTE;
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_UYVY;
}
dst = getFmtIdx(WINED3DFMT_YV12);
gl_info->gl_formats[dst].heightscale = 1.5;
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_YV12;
return TRUE;
}
......
......@@ -703,7 +703,6 @@ typedef struct WineD3D_PixelFormat
} WineD3D_PixelFormat;
/* The adapter structure */
typedef struct GLPixelFormatDesc GLPixelFormatDesc;
struct WineD3DAdapter
{
UINT num;
......@@ -1312,6 +1311,7 @@ struct IWineD3DSurfaceImpl
UINT pow2Width;
UINT pow2Height;
float heightscale;
/* A method to retrieve the drawable size. Not in the Vtable to make it changeable */
void (*get_drawable_size)(IWineD3DSurfaceImpl *This, UINT *width, UINT *height);
......
......@@ -3813,6 +3813,7 @@ typedef struct {
GLint glInternal, glGammaInternal, rtInternal, glFormat, glType;
WINED3DFORMAT conversion_group;
unsigned int Flags;
float heightscale;
} GlPixelFormatDesc;
typedef struct _WINED3DGLTYPE {
......
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