Commit 7eefed14 authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: YUY2 and UYVY are block based.

parent 7fd75204
...@@ -663,6 +663,8 @@ static void test_surface_lockrect_blocks(IDirect3DDevice9 *device) ...@@ -663,6 +663,8 @@ static void test_surface_lockrect_blocks(IDirect3DDevice9 *device)
* which doesn't match the format spec. On newer Nvidia cards * which doesn't match the format spec. On newer Nvidia cards
* it has the correct 4x4 block size */ * it has the correct 4x4 block size */
{MAKEFOURCC('A','T','I','2'), "ATI2N", 4, 4, TRUE}, {MAKEFOURCC('A','T','I','2'), "ATI2N", 4, 4, TRUE},
{D3DFMT_YUY2, "D3DFMT_YUY2", 2, 1, FALSE},
{D3DFMT_UYVY, "D3DFMT_UYVY", 2, 1, FALSE},
}; };
static const struct static const struct
{ {
......
...@@ -2476,7 +2476,7 @@ HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const P ...@@ -2476,7 +2476,7 @@ HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const P
} }
/* NPOT block sizes would be silly. */ /* NPOT block sizes would be silly. */
if ((src_format->flags & WINED3DFMT_FLAG_COMPRESSED) if ((src_format->flags & WINED3DFMT_FLAG_BLOCKS)
&& ((update_w & (src_format->block_width - 1) || update_h & (src_format->block_height - 1)) && ((update_w & (src_format->block_width - 1) || update_h & (src_format->block_height - 1))
&& (src_w != update_w || dst_w != update_w || src_h != update_h || dst_h != update_h))) && (src_w != update_w || dst_w != update_w || src_h != update_h || dst_h != update_h)))
{ {
...@@ -3096,7 +3096,7 @@ DWORD CDECL wined3d_surface_get_pitch(const struct wined3d_surface *surface) ...@@ -3096,7 +3096,7 @@ DWORD CDECL wined3d_surface_get_pitch(const struct wined3d_surface *surface)
TRACE("surface %p.\n", surface); TRACE("surface %p.\n", surface);
if ((format->flags & (WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_COMPRESSED) if ((format->flags & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_BLOCKS)
{ {
/* Since compressed formats are block based, pitch means the amount of /* Since compressed formats are block based, pitch means the amount of
* bytes to the next row of block rather than the next row of pixels. */ * bytes to the next row of block rather than the next row of pixels. */
...@@ -3713,7 +3713,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface, ...@@ -3713,7 +3713,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
WARN("Surface is already mapped.\n"); WARN("Surface is already mapped.\n");
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
} }
if ((format->flags & WINED3DFMT_FLAG_COMPRESSED) if ((format->flags & WINED3DFMT_FLAG_BLOCKS)
&& rect && (rect->left || rect->top && rect && (rect->left || rect->top
|| rect->right != surface->resource.width || rect->right != surface->resource.width
|| rect->bottom != surface->resource.height)) || rect->bottom != surface->resource.height))
...@@ -3755,7 +3755,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface, ...@@ -3755,7 +3755,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
} }
else else
{ {
if ((format->flags & (WINED3DFMT_FLAG_COMPRESSED | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_COMPRESSED) if ((format->flags & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BROKEN_PITCH)) == WINED3DFMT_FLAG_BLOCKS)
{ {
/* Compressed textures are block based, so calculate the offset of /* Compressed textures are block based, so calculate the offset of
* the block that contains the top-left pixel of the locked rectangle. */ * the block that contains the top-left pixel of the locked rectangle. */
...@@ -6666,7 +6666,7 @@ static HRESULT surface_cpu_blt(struct wined3d_surface *dst_surface, const RECT * ...@@ -6666,7 +6666,7 @@ static HRESULT surface_cpu_blt(struct wined3d_surface *dst_surface, const RECT *
dstwidth = xdst.right - xdst.left; dstwidth = xdst.right - xdst.left;
width = (xdst.right - xdst.left) * bpp; width = (xdst.right - xdst.left) * bpp;
if (src_format->flags & dst_format->flags & WINED3DFMT_FLAG_COMPRESSED) if (src_format->flags & dst_format->flags & WINED3DFMT_FLAG_BLOCKS)
{ {
TRACE("%s -> %s copy.\n", debug_d3dformat(src_format->id), debug_d3dformat(dst_format->id)); TRACE("%s -> %s copy.\n", debug_d3dformat(src_format->id), debug_d3dformat(dst_format->id));
......
...@@ -189,7 +189,7 @@ static const struct wined3d_format_base_flags format_base_flags[] = ...@@ -189,7 +189,7 @@ static const struct wined3d_format_base_flags format_base_flags[] =
{WINED3DFMT_S8_UINT_D24_FLOAT, WINED3DFMT_FLAG_FLOAT}, {WINED3DFMT_S8_UINT_D24_FLOAT, WINED3DFMT_FLAG_FLOAT},
}; };
struct wined3d_format_compression_info struct wined3d_format_block_info
{ {
enum wined3d_format_id id; enum wined3d_format_id id;
UINT block_width; UINT block_width;
...@@ -197,7 +197,7 @@ struct wined3d_format_compression_info ...@@ -197,7 +197,7 @@ struct wined3d_format_compression_info
UINT block_byte_count; UINT block_byte_count;
}; };
static const struct wined3d_format_compression_info format_compression_info[] = static const struct wined3d_format_block_info format_block_info[] =
{ {
{WINED3DFMT_DXT1, 4, 4, 8}, {WINED3DFMT_DXT1, 4, 4, 8},
{WINED3DFMT_DXT2, 4, 4, 16}, {WINED3DFMT_DXT2, 4, 4, 16},
...@@ -205,6 +205,8 @@ static const struct wined3d_format_compression_info format_compression_info[] = ...@@ -205,6 +205,8 @@ static const struct wined3d_format_compression_info format_compression_info[] =
{WINED3DFMT_DXT4, 4, 4, 16}, {WINED3DFMT_DXT4, 4, 4, 16},
{WINED3DFMT_DXT5, 4, 4, 16}, {WINED3DFMT_DXT5, 4, 4, 16},
{WINED3DFMT_ATI2N, 4, 4, 16}, {WINED3DFMT_ATI2N, 4, 4, 16},
{WINED3DFMT_YUY2, 2, 1, 4},
{WINED3DFMT_UYVY, 2, 1, 4},
}; };
struct wined3d_format_vertex_info struct wined3d_format_vertex_info
...@@ -594,23 +596,28 @@ static const struct wined3d_format_texture_info format_texture_info[] = ...@@ -594,23 +596,28 @@ static const struct wined3d_format_texture_info format_texture_info[] =
WINED3D_GL_EXT_NONE, NULL}, WINED3D_GL_EXT_NONE, NULL},
{WINED3DFMT_DXT1, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, 0, {WINED3DFMT_DXT1, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, 0,
GL_RGBA, GL_UNSIGNED_BYTE, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0,
WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_SRGB_READ, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_SRGB_READ
| WINED3DFMT_FLAG_COMPRESSED,
EXT_TEXTURE_COMPRESSION_S3TC, NULL}, EXT_TEXTURE_COMPRESSION_S3TC, NULL},
{WINED3DFMT_DXT2, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, 0, {WINED3DFMT_DXT2, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, 0,
GL_RGBA, GL_UNSIGNED_BYTE, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0,
WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_SRGB_READ, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_SRGB_READ
| WINED3DFMT_FLAG_COMPRESSED,
EXT_TEXTURE_COMPRESSION_S3TC, NULL}, EXT_TEXTURE_COMPRESSION_S3TC, NULL},
{WINED3DFMT_DXT3, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, 0, {WINED3DFMT_DXT3, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, 0,
GL_RGBA, GL_UNSIGNED_BYTE, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0,
WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_SRGB_READ, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_SRGB_READ
| WINED3DFMT_FLAG_COMPRESSED,
EXT_TEXTURE_COMPRESSION_S3TC, NULL}, EXT_TEXTURE_COMPRESSION_S3TC, NULL},
{WINED3DFMT_DXT4, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, 0, {WINED3DFMT_DXT4, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, 0,
GL_RGBA, GL_UNSIGNED_BYTE, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0,
WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_SRGB_READ, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_SRGB_READ
| WINED3DFMT_FLAG_COMPRESSED,
EXT_TEXTURE_COMPRESSION_S3TC, NULL}, EXT_TEXTURE_COMPRESSION_S3TC, NULL},
{WINED3DFMT_DXT5, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, 0, {WINED3DFMT_DXT5, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, 0,
GL_RGBA, GL_UNSIGNED_BYTE, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0,
WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_SRGB_READ, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_SRGB_READ
| WINED3DFMT_FLAG_COMPRESSED,
EXT_TEXTURE_COMPRESSION_S3TC, NULL}, EXT_TEXTURE_COMPRESSION_S3TC, NULL},
/* IEEE formats */ /* IEEE formats */
{WINED3DFMT_R32_FLOAT, GL_RGB32F_ARB, GL_RGB32F_ARB, 0, {WINED3DFMT_R32_FLOAT, GL_RGB32F_ARB, GL_RGB32F_ARB, 0,
...@@ -857,11 +864,11 @@ static const struct wined3d_format_texture_info format_texture_info[] = ...@@ -857,11 +864,11 @@ static const struct wined3d_format_texture_info format_texture_info[] =
/* Vendor-specific formats */ /* Vendor-specific formats */
{WINED3DFMT_ATI2N, GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI, GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI, 0, {WINED3DFMT_ATI2N, GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI, GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI, 0,
GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 0,
WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_COMPRESSED,
ATI_TEXTURE_COMPRESSION_3DC, NULL}, ATI_TEXTURE_COMPRESSION_3DC, NULL},
{WINED3DFMT_ATI2N, GL_COMPRESSED_RED_GREEN_RGTC2, GL_COMPRESSED_RED_GREEN_RGTC2, 0, {WINED3DFMT_ATI2N, GL_COMPRESSED_RED_GREEN_RGTC2, GL_COMPRESSED_RED_GREEN_RGTC2, 0,
GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 0,
WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING, WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING | WINED3DFMT_FLAG_FILTERING | WINED3DFMT_FLAG_COMPRESSED,
ARB_TEXTURE_COMPRESSION_RGTC, NULL}, ARB_TEXTURE_COMPRESSION_RGTC, NULL},
{WINED3DFMT_INTZ, GL_DEPTH24_STENCIL8_EXT, GL_DEPTH24_STENCIL8_EXT, 0, {WINED3DFMT_INTZ, GL_DEPTH24_STENCIL8_EXT, GL_DEPTH24_STENCIL8_EXT, 0,
GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, 0,
...@@ -946,27 +953,27 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info) ...@@ -946,27 +953,27 @@ static BOOL init_format_base_info(struct wined3d_gl_info *gl_info)
return TRUE; return TRUE;
} }
static BOOL init_format_compression_info(struct wined3d_gl_info *gl_info) static BOOL init_format_block_info(struct wined3d_gl_info *gl_info)
{ {
unsigned int i; unsigned int i;
for (i = 0; i < (sizeof(format_compression_info) / sizeof(*format_compression_info)); ++i) for (i = 0; i < (sizeof(format_block_info) / sizeof(*format_block_info)); ++i)
{ {
struct wined3d_format *format; struct wined3d_format *format;
int fmt_idx = getFmtIdx(format_compression_info[i].id); int fmt_idx = getFmtIdx(format_block_info[i].id);
if (fmt_idx == -1) if (fmt_idx == -1)
{ {
ERR("Format %s (%#x) not found.\n", ERR("Format %s (%#x) not found.\n",
debug_d3dformat(format_compression_info[i].id), format_compression_info[i].id); debug_d3dformat(format_block_info[i].id), format_block_info[i].id);
return FALSE; return FALSE;
} }
format = &gl_info->formats[fmt_idx]; format = &gl_info->formats[fmt_idx];
format->block_width = format_compression_info[i].block_width; format->block_width = format_block_info[i].block_width;
format->block_height = format_compression_info[i].block_height; format->block_height = format_block_info[i].block_height;
format->block_byte_count = format_compression_info[i].block_byte_count; format->block_byte_count = format_block_info[i].block_byte_count;
format->flags |= WINED3DFMT_FLAG_COMPRESSED; format->flags |= WINED3DFMT_FLAG_BLOCKS;
} }
return TRUE; return TRUE;
...@@ -1623,7 +1630,7 @@ BOOL initPixelFormatsNoGL(struct wined3d_gl_info *gl_info) ...@@ -1623,7 +1630,7 @@ BOOL initPixelFormatsNoGL(struct wined3d_gl_info *gl_info)
{ {
if (!init_format_base_info(gl_info)) return FALSE; if (!init_format_base_info(gl_info)) return FALSE;
if (!init_format_compression_info(gl_info)) if (!init_format_block_info(gl_info))
{ {
HeapFree(GetProcessHeap(), 0, gl_info->formats); HeapFree(GetProcessHeap(), 0, gl_info->formats);
gl_info->formats = NULL; gl_info->formats = NULL;
...@@ -1638,7 +1645,7 @@ BOOL initPixelFormats(struct wined3d_gl_info *gl_info, enum wined3d_pci_vendor v ...@@ -1638,7 +1645,7 @@ BOOL initPixelFormats(struct wined3d_gl_info *gl_info, enum wined3d_pci_vendor v
{ {
if (!init_format_base_info(gl_info)) return FALSE; if (!init_format_base_info(gl_info)) return FALSE;
if (!init_format_compression_info(gl_info)) goto fail; if (!init_format_block_info(gl_info)) goto fail;
if (!init_format_texture_info(gl_info)) goto fail; if (!init_format_texture_info(gl_info)) goto fail;
if (!init_format_vertex_info(gl_info)) goto fail; if (!init_format_vertex_info(gl_info)) goto fail;
...@@ -1678,7 +1685,7 @@ UINT wined3d_format_calculate_size(const struct wined3d_format *format, UINT ali ...@@ -1678,7 +1685,7 @@ UINT wined3d_format_calculate_size(const struct wined3d_format *format, UINT ali
{ {
size = 0; size = 0;
} }
else if (format->flags & WINED3DFMT_FLAG_COMPRESSED) else if (format->flags & WINED3DFMT_FLAG_BLOCKS)
{ {
UINT row_block_count = (width + format->block_width - 1) / format->block_width; UINT row_block_count = (width + format->block_width - 1) / format->block_width;
UINT row_count = (height + format->block_height - 1) / format->block_height; UINT row_count = (height + format->block_height - 1) / format->block_height;
......
...@@ -2788,6 +2788,7 @@ extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN ...@@ -2788,6 +2788,7 @@ extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN
#define WINED3DFMT_FLAG_SHADOW 0x00004000 #define WINED3DFMT_FLAG_SHADOW 0x00004000
#define WINED3DFMT_FLAG_COMPRESSED 0x00008000 #define WINED3DFMT_FLAG_COMPRESSED 0x00008000
#define WINED3DFMT_FLAG_BROKEN_PITCH 0x00010000 #define WINED3DFMT_FLAG_BROKEN_PITCH 0x00010000
#define WINED3DFMT_FLAG_BLOCKS 0x00020000
struct wined3d_format struct wined3d_format
{ {
......
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