=?UTF-8?Q?Stefan=20D=C3=B6singer=20?=: wined3d: Merge wined3d_surface_update_desc() into wined3d_texture_update_desc().

Alexandre Julliard julliard at wine.codeweavers.com
Tue Mar 15 10:12:16 CDT 2016


Module: wine
Branch: master
Commit: 2efaddc74ee86a1a3d4b799b00ea12e260003e40
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2efaddc74ee86a1a3d4b799b00ea12e260003e40

Author: Stefan Dösinger <stefan at codeweavers.com>
Date:   Mon Mar 14 17:02:18 2016 +0100

wined3d: Merge wined3d_surface_update_desc() into wined3d_texture_update_desc().

Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/wined3d/surface.c         | 79 ------------------------------------------
 dlls/wined3d/texture.c         | 75 ++++++++++++++++++++++++++++++++++-----
 dlls/wined3d/wined3d_private.h |  2 --
 3 files changed, 67 insertions(+), 89 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 64ed04a..f7ca370 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -1677,85 +1677,6 @@ static inline unsigned short float_32_to_16(const float *in)
     return ret;
 }
 
-HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info)
-{
-    struct wined3d_resource *texture_resource = &surface->container->resource;
-    unsigned int width, height;
-    BOOL create_dib = FALSE;
-    DWORD valid_location = 0;
-    HRESULT hr;
-
-    if (surface->flags & SFLAG_DIBSECTION)
-    {
-        DeleteDC(surface->hDC);
-        DeleteObject(surface->dib.DIBsection);
-        surface->dib.bitmap_data = NULL;
-        surface->flags &= ~SFLAG_DIBSECTION;
-        create_dib = TRUE;
-    }
-
-    surface->locations = 0;
-    wined3d_resource_free_sysmem(&surface->resource);
-
-    width = texture_resource->width;
-    height = texture_resource->height;
-    surface->resource.width = width;
-    surface->resource.height = height;
-    if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] || gl_info->supported[ARB_TEXTURE_RECTANGLE]
-            || gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT])
-    {
-        surface->pow2Width = width;
-        surface->pow2Height = height;
-    }
-    else
-    {
-        surface->pow2Width = surface->pow2Height = 1;
-        while (surface->pow2Width < width)
-            surface->pow2Width <<= 1;
-        while (surface->pow2Height < height)
-            surface->pow2Height <<= 1;
-    }
-
-    if (surface->container->user_memory)
-    {
-        surface->resource.map_binding = WINED3D_LOCATION_USER_MEMORY;
-        valid_location = WINED3D_LOCATION_USER_MEMORY;
-    }
-    surface->resource.format = texture_resource->format;
-    surface->resource.multisample_type = texture_resource->multisample_type;
-    surface->resource.multisample_quality = texture_resource->multisample_quality;
-    surface->resource.size = surface->container->slice_pitch;
-
-    /* The format might be changed to a format that needs conversion.
-     * If the surface didn't use PBOs previously but could now, don't
-     * change it - whatever made us not use PBOs might come back, e.g.
-     * color keys. */
-    if (surface->resource.map_binding == WINED3D_LOCATION_BUFFER
-            && !wined3d_texture_use_pbo(surface->container, gl_info))
-        surface->resource.map_binding = create_dib ? WINED3D_LOCATION_DIB : WINED3D_LOCATION_SYSMEM;
-
-    if (create_dib)
-    {
-        if (FAILED(hr = surface_create_dib_section(surface)))
-        {
-            ERR("Failed to create dib section, hr %#x.\n", hr);
-            return hr;
-        }
-        if (!valid_location)
-            valid_location = WINED3D_LOCATION_DIB;
-    }
-
-    if (!valid_location)
-    {
-        surface_prepare_system_memory(surface);
-        valid_location = WINED3D_LOCATION_SYSMEM;
-    }
-
-    surface_validate_location(surface, valid_location);
-
-    return WINED3D_OK;
-}
-
 static void convert_r32_float_r16_float(const BYTE *src, BYTE *dst,
         DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h)
 {
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index c86d640..cdde12c 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -670,6 +670,8 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
     const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
     UINT resource_size = wined3d_format_calculate_size(format, device->surface_alignment, width, height, 1);
     struct wined3d_surface *surface;
+    DWORD valid_location = 0;
+    BOOL create_dib = FALSE;
 
     TRACE("texture %p, width %u, height %u, format %s, multisample_type %#x, multisample_quality %u, "
             "mem %p, pitch %u.\n",
@@ -713,13 +715,19 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
     if (device->d3d_initialized)
         texture->resource.resource_ops->resource_unload(&texture->resource);
 
-    texture->resource.format = format;
-    texture->resource.multisample_type = multisample_type;
-    texture->resource.multisample_quality = multisample_quality;
-    texture->resource.width = width;
-    texture->resource.height = height;
+    if (surface->flags & SFLAG_DIBSECTION)
+    {
+        DeleteDC(surface->hDC);
+        surface->hDC = NULL;
+        DeleteObject(surface->dib.DIBsection);
+        surface->dib.DIBsection = NULL;
+        surface->dib.bitmap_data = NULL;
+        surface->flags &= ~SFLAG_DIBSECTION;
+        create_dib = TRUE;
+    }
+
+    wined3d_resource_free_sysmem(&surface->resource);
 
-    texture->user_memory = mem;
     if ((texture->row_pitch = pitch))
         texture->slice_pitch = height * pitch;
     else
@@ -727,12 +735,63 @@ HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT
         wined3d_format_calculate_pitch(format, 1, width, height,
                 &texture->row_pitch, &texture->slice_pitch);
 
-    texture->flags &= ~WINED3D_TEXTURE_COND_NP2_EMULATED;
+    texture->resource.format = format;
+    texture->resource.multisample_type = multisample_type;
+    texture->resource.multisample_quality = multisample_quality;
+    texture->resource.width = width;
+    texture->resource.height = height;
+
+    surface->resource.format = format;
+    surface->resource.multisample_type = multisample_type;
+    surface->resource.multisample_quality = multisample_quality;
+    surface->resource.width = width;
+    surface->resource.height = height;
+    surface->resource.size = texture->slice_pitch;
+
     if (((width & (width - 1)) || (height & (height - 1))) && !gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO]
             && !gl_info->supported[ARB_TEXTURE_RECTANGLE] && !gl_info->supported[WINED3D_GL_NORMALIZED_TEXRECT])
+    {
         texture->flags |= WINED3D_TEXTURE_COND_NP2_EMULATED;
+        surface->pow2Width = surface->pow2Height = 1;
+        while (surface->pow2Width < width)
+            surface->pow2Width <<= 1;
+        while (surface->pow2Height < height)
+            surface->pow2Height <<= 1;
+    }
+    else
+    {
+        texture->flags &= ~WINED3D_TEXTURE_COND_NP2_EMULATED;
+        surface->pow2Width = width;
+        surface->pow2Height = height;
+    }
+
+    surface->locations = 0;
+
+    if ((texture->user_memory = mem))
+    {
+        surface->resource.map_binding = WINED3D_LOCATION_USER_MEMORY;
+        valid_location = WINED3D_LOCATION_USER_MEMORY;
+    }
+    else if (create_dib && SUCCEEDED(surface_create_dib_section(surface)))
+    {
+        valid_location = WINED3D_LOCATION_DIB;
+    }
+    else
+    {
+        wined3d_surface_prepare(surface, NULL, WINED3D_LOCATION_SYSMEM);
+        valid_location = WINED3D_LOCATION_SYSMEM;
+    }
+
+    /* The format might be changed to a format that needs conversion.
+     * If the surface didn't use PBOs previously but could now, don't
+     * change it - whatever made us not use PBOs might come back, e.g.
+     * color keys. */
+    if (surface->resource.map_binding == WINED3D_LOCATION_BUFFER && !wined3d_texture_use_pbo(texture, gl_info))
+        surface->resource.map_binding = surface->dib.DIBsection ? WINED3D_LOCATION_DIB : WINED3D_LOCATION_SYSMEM;
 
-    return wined3d_surface_update_desc(surface, gl_info);
+    surface_validate_location(surface, valid_location);
+
+    return WINED3D_OK;
 }
 
 /* Context activation is done by the caller. */
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 15fe6c9..df16d63 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2623,8 +2623,6 @@ void surface_set_compatible_renderbuffer(struct wined3d_surface *surface,
 void surface_set_dirty(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
 void surface_set_texture_target(struct wined3d_surface *surface, GLenum target, GLint level) DECLSPEC_HIDDEN;
 void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN;
-HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
-        const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
 HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const POINT *dst_point,
         struct wined3d_surface *src_surface, const RECT *src_rect) DECLSPEC_HIDDEN;
 void surface_validate_location(struct wined3d_surface *surface, DWORD location) DECLSPEC_HIDDEN;




More information about the wine-cvs mailing list