[PATCH 3/5] wined3d: Disallow creation of stand-alone block resources smaller than the block size
Stefan Dösinger
stefan at codeweavers.com
Tue Sep 3 07:07:15 CDT 2013
Only mipmaps are allowed with smaller sizes. Since we create a d3d
texture for everything, this also (correctly) prevents the creation of
stand-alone surfaces.
Volumes follow the same rules as 2D and cube textures. Note that there's
no format with a block depth > 1.
---
dlls/wined3d/texture.c | 11 +++++++++++
dlls/wined3d/utils.c | 4 +++-
dlls/wined3d/wined3d_private.h | 1 +
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 75ae8af..ffc41d4 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -41,6 +41,17 @@ static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struc
debug_d3dusage(desc->usage), debug_d3dpool(desc->pool), desc->width, desc->height, desc->depth,
device, parent, parent_ops, resource_ops);
+ if ((format->flags & (WINED3DFMT_FLAG_BLOCKS | WINED3DFMT_FLAG_BLOCKS_NO_VERIFY)) == WINED3DFMT_FLAG_BLOCKS)
+ {
+ UINT width_mask = format->block_width - 1;
+ UINT height_mask = format->block_height - 1;
+ if (desc->width & width_mask || desc->height & height_mask)
+ {
+ WARN("Texture cannot be created - width or height not block size aligned.\n");
+ return WINED3DERR_INVALIDCALL;
+ }
+ }
+
if (FAILED(hr = resource_init(&texture->resource, device, desc->resource_type, format,
desc->multisample_type, desc->multisample_quality, desc->usage, desc->pool,
desc->width, desc->height, desc->depth, 0, parent, parent_ops, resource_ops)))
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 0744e03..fca7114 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -171,7 +171,7 @@ static const struct wined3d_format_base_flags format_base_flags[] =
{WINED3DFMT_B4G4R4X4_UNORM, WINED3DFMT_FLAG_GETDC},
{WINED3DFMT_R8G8B8A8_UNORM, WINED3DFMT_FLAG_GETDC},
{WINED3DFMT_R8G8B8X8_UNORM, WINED3DFMT_FLAG_GETDC},
- {WINED3DFMT_ATI2N, WINED3DFMT_FLAG_BROKEN_PITCH},
+ {WINED3DFMT_ATI2N, WINED3DFMT_FLAG_BROKEN_PITCH | WINED3DFMT_FLAG_BLOCKS_NO_VERIFY},
{WINED3DFMT_R32_FLOAT, WINED3DFMT_FLAG_FLOAT},
{WINED3DFMT_R32G32_FLOAT, WINED3DFMT_FLAG_FLOAT},
{WINED3DFMT_R32G32B32_FLOAT, WINED3DFMT_FLAG_FLOAT},
@@ -181,6 +181,8 @@ static const struct wined3d_format_base_flags format_base_flags[] =
{WINED3DFMT_R16G16B16A16_FLOAT, WINED3DFMT_FLAG_FLOAT},
{WINED3DFMT_D32_FLOAT, WINED3DFMT_FLAG_FLOAT},
{WINED3DFMT_S8_UINT_D24_FLOAT, WINED3DFMT_FLAG_FLOAT},
+ {WINED3DFMT_YUY2, WINED3DFMT_FLAG_BLOCKS_NO_VERIFY},
+ {WINED3DFMT_UYVY, WINED3DFMT_FLAG_BLOCKS_NO_VERIFY},
};
struct wined3d_format_block_info
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 688671d..b995c85 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2914,6 +2914,7 @@ extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN
#define WINED3DFMT_FLAG_BLOCKS 0x00020000
#define WINED3DFMT_FLAG_HEIGHT_SCALE 0x00040000
#define WINED3DFMT_FLAG_TEXTURE 0x00080000
+#define WINED3DFMT_FLAG_BLOCKS_NO_VERIFY 0x00100000
struct wined3d_rational
{
--
1.8.1.5
More information about the wine-patches
mailing list