Henri Verbeet : wined3d: Don' t use floating point for surface height scaling.
Alexandre Julliard
julliard at winehq.org
Thu Mar 8 14:26:22 CST 2012
Module: wine
Branch: master
Commit: 6d483c2d9d1075df26fb51b1fc34f12e71fc5f5f
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6d483c2d9d1075df26fb51b1fc34f12e71fc5f5f
Author: Henri Verbeet <hverbeet at codeweavers.com>
Date: Wed Mar 7 18:38:52 2012 +0100
wined3d: Don't use floating point for surface height scaling.
This is the follow-up to commit a4e5bcff4c66aa1041ea32f971b92b40d73e7d72.
---
dlls/wined3d/surface.c | 10 ++++++++--
dlls/wined3d/utils.c | 9 ++++++---
dlls/wined3d/wined3d_private.h | 8 +++++++-
3 files changed, 21 insertions(+), 6 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 9ec3db3..b7273f7 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -2282,7 +2282,10 @@ static void surface_upload_data(struct wined3d_surface *surface, const struct wi
}
if (format->flags & WINED3DFMT_FLAG_HEIGHT_SCALE)
- update_h *= format->heightscale;
+ {
+ update_h *= format->height_scale.numerator;
+ update_h /= format->height_scale.denominator;
+ }
ENTER_GL();
@@ -2517,7 +2520,10 @@ static void surface_allocate_surface(struct wined3d_surface *surface, const stru
}
if (format->flags & WINED3DFMT_FLAG_HEIGHT_SCALE)
- height *= format->heightscale;
+ {
+ height *= format->height_scale.numerator;
+ height /= format->height_scale.denominator;
+ }
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",
surface, surface->texture_target, surface->texture_level, debug_d3dformat(format->id),
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index e570a13..847366e 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -1285,7 +1285,8 @@ static BOOL init_format_texture_info(struct wined3d_gl_info *gl_info)
format->glType = format_texture_info[i].gl_type;
format->color_fixup = COLOR_FIXUP_IDENTITY;
format->flags |= format_texture_info[i].flags;
- format->heightscale = 1.0f;
+ format->height_scale.numerator = 1;
+ format->height_scale.denominator = 1;
if (format->glGammaInternal != format->glInternal)
{
@@ -1581,7 +1582,8 @@ static void apply_format_fixups(struct wined3d_gl_info *gl_info)
idx = getFmtIdx(WINED3DFMT_YV12);
gl_info->formats[idx].flags |= WINED3DFMT_FLAG_HEIGHT_SCALE;
- gl_info->formats[idx].heightscale = 1.5f;
+ gl_info->formats[idx].height_scale.numerator = 3;
+ gl_info->formats[idx].height_scale.denominator = 2;
gl_info->formats[idx].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12);
if (gl_info->supported[EXT_PALETTED_TEXTURE] || gl_info->supported[ARB_FRAGMENT_PROGRAM])
@@ -1709,7 +1711,8 @@ UINT wined3d_format_calculate_size(const struct wined3d_format *format, UINT ali
if (format->flags & WINED3DFMT_FLAG_HEIGHT_SCALE)
{
/* The D3D format requirements make sure that the resulting format is an integer again */
- size = (UINT) (size * format->heightscale);
+ size *= format->height_scale.numerator;
+ size /= format->height_scale.denominator;
}
return size;
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index cd9690c..472c21a 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2805,6 +2805,12 @@ extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN
#define WINED3DFMT_FLAG_BLOCKS 0x00020000
#define WINED3DFMT_FLAG_HEIGHT_SCALE 0x00040000
+struct wined3d_rational
+{
+ UINT numerator;
+ UINT denominator;
+};
+
struct wined3d_format
{
enum wined3d_format_id id;
@@ -2835,7 +2841,7 @@ struct wined3d_format
GLint glType;
UINT conv_byte_count;
unsigned int flags;
- float heightscale;
+ struct wined3d_rational height_scale;
struct color_fixup_desc color_fixup;
void (*convert)(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height);
};
More information about the wine-cvs
mailing list