[PATCH 1/1] wined3d: Use a format flag instead of a floating point comparison to determine if we need to apply heightscale.

Henri Verbeet hverbeet at codeweavers.com
Mon Feb 13 11:40:13 CST 2012


The floating point comparison doesn't work so well when the FPU stack is in
a less than optimal state, which for some reason is more common than we'd
perhaps like with ddraw-era applications. We should probably do the actual
scaling in fixed point as well (and avoiding floating point where possible in
wined3d seems a good idea in general), but since it's only really used for
YV12 surfaces that can probably wait until after 1.4.

This is for bug 29800.
---
 dlls/wined3d/surface.c         |    5 +++--
 dlls/wined3d/utils.c           |    3 ++-
 dlls/wined3d/wined3d_private.h |    1 +
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 30dc63e..ac44194 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -2281,7 +2281,7 @@ static void surface_upload_data(struct wined3d_surface *surface, const struct wi
         surface->flags |= SFLAG_PIN_SYSMEM;
     }
 
-    if (format->heightscale != 1.0f && format->heightscale != 0.0f)
+    if (format->flags & WINED3DFMT_FLAG_HEIGHT_SCALE)
         update_h *= format->heightscale;
 
     ENTER_GL();
@@ -2516,7 +2516,8 @@ static void surface_allocate_surface(struct wined3d_surface *surface, const stru
         internal = format->glInternal;
     }
 
-    if (format->heightscale != 1.0f && format->heightscale != 0.0f) height *= format->heightscale;
+    if (format->flags & WINED3DFMT_FLAG_HEIGHT_SCALE)
+        height *= format->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",
             surface, surface->texture_target, surface->texture_level, debug_d3dformat(format->id),
diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c
index 2ade261..e570a13 100644
--- a/dlls/wined3d/utils.c
+++ b/dlls/wined3d/utils.c
@@ -1580,6 +1580,7 @@ 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].color_fixup = create_complex_fixup_desc(COMPLEX_FIXUP_YV12);
 
@@ -1705,7 +1706,7 @@ UINT wined3d_format_calculate_size(const struct wined3d_format *format, UINT ali
         size = height * (((width * format->byte_count) + alignment - 1) & ~(alignment - 1));
     }
 
-    if (format->heightscale != 0.0f)
+    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);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 416d970..3cabe76 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2800,6 +2800,7 @@ extern enum wined3d_format_id pixelformat_for_depth(DWORD depth) DECLSPEC_HIDDEN
 #define WINED3DFMT_FLAG_COMPRESSED                  0x00008000
 #define WINED3DFMT_FLAG_BROKEN_PITCH                0x00010000
 #define WINED3DFMT_FLAG_BLOCKS                      0x00020000
+#define WINED3DFMT_FLAG_HEIGHT_SCALE                0x00040000
 
 struct wined3d_format
 {
-- 
1.7.3.4




More information about the wine-patches mailing list