Module: wine Branch: master Commit: 34a123631d2c4ff3ef747a1e4603f2bf4cd8d151 URL: http://source.winehq.org/git/wine.git/?a=commit;h=34a123631d2c4ff3ef747a1e46...
Author: Henri Verbeet hverbeet@codeweavers.com Date: Wed Feb 22 00:53:22 2017 +0100
wined3d: Merge surface_convert_depth_to_float() into wined3d_format_convert_color_to_float().
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/wined3d/surface.c | 37 +++---------------------------------- dlls/wined3d/utils.c | 10 +++++++++- 2 files changed, 12 insertions(+), 35 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 15e020e..449c1fa 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -641,37 +641,6 @@ static BOOL fbo_blit_supported(const struct wined3d_gl_info *gl_info, enum wined return TRUE; }
-static BOOL surface_convert_depth_to_float(const struct wined3d_surface *surface, DWORD depth, float *float_depth) -{ - const struct wined3d_format *format = surface->container->resource.format; - - switch (format->id) - { - case WINED3DFMT_S1_UINT_D15_UNORM: - *float_depth = depth / (float)0x00007fff; - break; - - case WINED3DFMT_D16_UNORM: - *float_depth = depth / (float)0x0000ffff; - break; - - case WINED3DFMT_D24_UNORM_S8_UINT: - case WINED3DFMT_X8D24_UNORM: - *float_depth = depth / (float)0x00ffffff; - break; - - case WINED3DFMT_D32_UNORM: - *float_depth = depth / (float)0xffffffff; - break; - - default: - ERR("Unhandled conversion from %s to floating point.\n", debug_d3dformat(format->id)); - return FALSE; - } - - return TRUE; -} - static HRESULT wined3d_surface_depth_fill(struct wined3d_surface *surface, const RECT *rect, float depth) { struct wined3d_resource *resource = &surface->container->resource; @@ -3814,14 +3783,14 @@ HRESULT wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst { if (flags & WINED3D_BLT_DEPTH_FILL) { - float depth; + struct wined3d_color color;
TRACE("Depth fill.\n");
- if (!surface_convert_depth_to_float(dst_surface, fx->fill_color, &depth)) + if (!wined3d_format_convert_color_to_float(dst_texture->resource.format, NULL, fx->fill_color, &color)) return WINED3DERR_INVALIDCALL;
- if (SUCCEEDED(wined3d_surface_depth_fill(dst_surface, dst_rect, depth))) + if (SUCCEEDED(wined3d_surface_depth_fill(dst_surface, dst_rect, color.r))) return WINED3D_OK; } else diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 6c3fd5e..9041c53 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -4974,7 +4974,7 @@ DWORD wined3d_format_convert_from_float(const struct wined3d_format *format, con
static float color_to_float(DWORD color, DWORD size, DWORD offset) { - DWORD mask = (1u << size) - 1; + DWORD mask = size < 32 ? (1u << size) - 1 : ~0u;
if (!size) return 1.0f; @@ -5030,6 +5030,14 @@ BOOL wined3d_format_convert_color_to_float(const struct wined3d_format *format, float_color->a = color / 255.0f; return TRUE;
+ case WINED3DFMT_S1_UINT_D15_UNORM: + case WINED3DFMT_D16_UNORM: + case WINED3DFMT_D24_UNORM_S8_UINT: + case WINED3DFMT_X8D24_UNORM: + case WINED3DFMT_D32_UNORM: + float_color->r = color_to_float(color, format->depth_size, 0); + return TRUE; + default: ERR("Unhandled conversion from %s to floating point.\n", debug_d3dformat(format->id)); return FALSE;