From ecee205f6c20b7b877373ee60e9d5a28654da722 Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 14 Apr 2016 19:32:48 +0200 Subject: [PATCH] wined3d: Check texture usage/pool/flags in texture_init(). Signed-off-by: Henri Verbeet Signed-off-by: Alexandre Julliard --- 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 9b5a1925f6a..e5bc4d4a2ee 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 2faaaa82429..52b026bcfc6 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 b69db4d1f67..7c3ea65b802 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,