Henri Verbeet : wined3d: Check texture usage/pool/flags in texture_init().

Alexandre Julliard julliard at wine.codeweavers.com
Fri Apr 15 10:00:23 CDT 2016


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

Author: Henri Verbeet <hverbeet at codeweavers.com>
Date:   Thu Apr 14 19:32:48 2016 +0200

wined3d: Check texture usage/pool/flags in texture_init().

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

---

 dlls/wined3d/surface.c         | 38 ++------------------------------------
 dlls/wined3d/texture.c         | 10 +++++++++-
 dlls/wined3d/wined3d_private.h |  2 +-
 3 files changed, 12 insertions(+), 38 deletions(-)

diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 9b5a192..e5bc4d4 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -4469,48 +4469,16 @@ cpu:
 }
 
 HRESULT wined3d_surface_init(struct wined3d_surface *surface, struct wined3d_texture *container,
-        const struct wined3d_resource_desc *desc, GLenum target, unsigned int level, unsigned int layer, DWORD flags)
+        const struct wined3d_resource_desc *desc, GLenum target, unsigned int level, unsigned int layer)
 {
     unsigned int sub_resource_idx = layer * container->level_count + level;
     struct wined3d_device *device = container->resource.device;
     const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
     const struct wined3d_format *format = wined3d_get_format(gl_info, desc->format);
-    BOOL lockable = flags & WINED3D_TEXTURE_CREATE_MAPPABLE;
     UINT multisample_quality = desc->multisample_quality;
     unsigned int resource_size;
     HRESULT hr;
 
-    /* Quick lockable sanity check.
-     * TODO: remove this after surfaces, usage and lockability have been debugged properly
-     * this function is too deep to need to care about things like this.
-     * Levels need to be checked too, since they all affect what can be done. */
-    switch (desc->pool)
-    {
-        case WINED3D_POOL_MANAGED:
-            if (desc->usage & WINED3DUSAGE_DYNAMIC)
-                FIXME("Called with a pool of MANAGED and a usage of DYNAMIC which are mutually exclusive.\n");
-            break;
-
-        case WINED3D_POOL_DEFAULT:
-            if (lockable && !(desc->usage & (WINED3DUSAGE_DYNAMIC
-                    | WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL)))
-                WARN("Creating a lockable surface with a POOL of DEFAULT, that doesn't specify DYNAMIC usage.\n");
-            break;
-
-        case WINED3D_POOL_SCRATCH:
-        case WINED3D_POOL_SYSTEM_MEM:
-            break;
-
-        default:
-            FIXME("Unknown pool %#x.\n", desc->pool);
-            break;
-    };
-
-    if (desc->usage & WINED3DUSAGE_RENDERTARGET && desc->pool != WINED3D_POOL_DEFAULT)
-        FIXME("Trying to create a render target that isn't in the default pool.\n");
-
-    /* FIXME: Check that the format is supported by the device. */
-
     resource_size = wined3d_format_calculate_size(format, device->surface_alignment, desc->width, desc->height, 1);
     if (!resource_size)
         return WINED3DERR_INVALIDCALL;
@@ -4522,6 +4490,7 @@ HRESULT wined3d_surface_init(struct wined3d_surface *surface, struct wined3d_tex
         WARN("Failed to initialize resource, returning %#x.\n", hr);
         return hr;
     }
+    surface->resource.access_flags = container->resource.access_flags;
 
     surface->container = container;
     surface->pow2Width = wined3d_texture_get_level_pow2_width(container, level);
@@ -4533,9 +4502,6 @@ HRESULT wined3d_surface_init(struct wined3d_surface *surface, struct wined3d_tex
     list_init(&surface->renderbuffers);
     list_init(&surface->overlays);
 
-    if (lockable || desc->format == WINED3DFMT_D16_LOCKABLE)
-        surface->resource.access_flags |= WINED3D_RESOURCE_ACCESS_CPU;
-
     wined3d_texture_validate_location(container, sub_resource_idx, WINED3D_LOCATION_SYSMEM);
     if (container->resource.usage & WINED3DUSAGE_DEPTHSTENCIL)
         container->sub_resources[sub_resource_idx].locations = WINED3D_LOCATION_DISCARDED;
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c
index 2faaaa8..52b026b 100644
--- a/dlls/wined3d/texture.c
+++ b/dlls/wined3d/texture.c
@@ -1507,6 +1507,14 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
         return WINED3DERR_INVALIDCALL;
     }
 
+    if (desc->usage & WINED3DUSAGE_DYNAMIC && desc->pool == WINED3D_POOL_MANAGED)
+        FIXME("Trying to create a managed texture with dynamic usage.\n");
+    if (!(desc->usage & (WINED3DUSAGE_DYNAMIC | WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL))
+            && (flags & WINED3D_TEXTURE_CREATE_MAPPABLE))
+        WARN("Creating a mappable texture in the default pool that doesn't specify dynamic usage.\n");
+    if (desc->usage & WINED3DUSAGE_RENDERTARGET && desc->pool != WINED3D_POOL_DEFAULT)
+        FIXME("Trying to create a render target that isn't in the default pool.\n");
+
     pow2_width = desc->width;
     pow2_height = desc->height;
     if (((desc->width & (desc->width - 1)) || (desc->height & (desc->height - 1)))
@@ -1653,7 +1661,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
             struct wined3d_surface *surface;
 
             surface = &surfaces[idx];
-            if (FAILED(hr = wined3d_surface_init(surface, texture, &surface_desc, target, i, j, flags)))
+            if (FAILED(hr = wined3d_surface_init(surface, texture, &surface_desc, target, i, j)))
             {
                 WARN("Failed to initialize surface, returning %#x.\n", hr);
                 wined3d_texture_cleanup(texture);
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index b69db4d..7c3ea65 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -2711,7 +2711,7 @@ void surface_get_drawable_size(const struct wined3d_surface *surface, const stru
         unsigned int *width, unsigned int *height) DECLSPEC_HIDDEN;
 HRESULT wined3d_surface_init(struct wined3d_surface *surface,
         struct wined3d_texture *container, const struct wined3d_resource_desc *desc,
-        GLenum target, unsigned int level, unsigned int layer, DWORD flags) DECLSPEC_HIDDEN;
+        GLenum target, unsigned int level, unsigned int layer) DECLSPEC_HIDDEN;
 void surface_load_fb_texture(struct wined3d_surface *surface, BOOL srgb,
         struct wined3d_context *context) DECLSPEC_HIDDEN;
 HRESULT surface_load_location(struct wined3d_surface *surface,




More information about the wine-cvs mailing list