wined3d: Don't use floating point for surface height scaling.

This is the follow-up to commit a4e5bcff4c.
This commit is contained in:
Henri Verbeet 2012-03-07 18:38:52 +01:00 committed by Alexandre Julliard
parent 639ea0f49c
commit 6d483c2d9d
3 changed files with 21 additions and 6 deletions

View File

@ -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),

View File

@ -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;

View File

@ -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);
};