wined3d: Sanitise resource map flags in wined3d_resource_map().
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
66e54fd682
commit
8232f371d8
|
@ -942,7 +942,6 @@ static HRESULT wined3d_buffer_map(struct wined3d_buffer *buffer, UINT offset, UI
|
|||
|
||||
TRACE("buffer %p, offset %u, size %u, data %p, flags %#x.\n", buffer, offset, size, data, flags);
|
||||
|
||||
flags = wined3d_resource_sanitize_map_flags(&buffer->resource, flags);
|
||||
/* Filter redundant WINED3D_MAP_DISCARD maps. The 3DMark2001 multitexture
|
||||
* fill rate test seems to depend on this. When we map a buffer with
|
||||
* GL_MAP_INVALIDATE_BUFFER_BIT, the driver is free to discard the
|
||||
|
|
|
@ -311,12 +311,47 @@ void CDECL wined3d_resource_get_desc(const struct wined3d_resource *resource, st
|
|||
desc->size = resource->size;
|
||||
}
|
||||
|
||||
static DWORD wined3d_resource_sanitise_map_flags(const struct wined3d_resource *resource, DWORD flags)
|
||||
{
|
||||
/* Not all flags make sense together, but Windows never returns an error.
|
||||
* Catch the cases that could cause issues. */
|
||||
if (flags & WINED3D_MAP_READONLY)
|
||||
{
|
||||
if (flags & WINED3D_MAP_DISCARD)
|
||||
{
|
||||
WARN("WINED3D_MAP_READONLY combined with WINED3D_MAP_DISCARD, ignoring flags.\n");
|
||||
return 0;
|
||||
}
|
||||
if (flags & WINED3D_MAP_NOOVERWRITE)
|
||||
{
|
||||
WARN("WINED3D_MAP_READONLY combined with WINED3D_MAP_NOOVERWRITE, ignoring flags.\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if ((flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
|
||||
== (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
|
||||
{
|
||||
WARN("WINED3D_MAP_DISCARD and WINED3D_MAP_NOOVERWRITE used together, ignoring.\n");
|
||||
return 0;
|
||||
}
|
||||
else if (flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)
|
||||
&& !(resource->usage & WINED3DUSAGE_DYNAMIC))
|
||||
{
|
||||
WARN("DISCARD or NOOVERWRITE map on non-dynamic buffer, ignoring.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
HRESULT CDECL wined3d_resource_map(struct wined3d_resource *resource, unsigned int sub_resource_idx,
|
||||
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags)
|
||||
{
|
||||
TRACE("resource %p, sub_resource_idx %u, map_desc %p, box %s, flags %#x.\n",
|
||||
resource, sub_resource_idx, map_desc, debug_box(box), flags);
|
||||
|
||||
flags = wined3d_resource_sanitise_map_flags(resource, flags);
|
||||
|
||||
return wined3d_cs_map(resource->device->cs, resource, sub_resource_idx, map_desc, box, flags);
|
||||
}
|
||||
|
||||
|
@ -360,39 +395,6 @@ void wined3d_resource_free_sysmem(struct wined3d_resource *resource)
|
|||
resource->heap_memory = NULL;
|
||||
}
|
||||
|
||||
DWORD wined3d_resource_sanitize_map_flags(const struct wined3d_resource *resource, DWORD flags)
|
||||
{
|
||||
/* Not all flags make sense together, but Windows never returns an error.
|
||||
* Catch the cases that could cause issues. */
|
||||
if (flags & WINED3D_MAP_READONLY)
|
||||
{
|
||||
if (flags & WINED3D_MAP_DISCARD)
|
||||
{
|
||||
WARN("WINED3D_MAP_READONLY combined with WINED3D_MAP_DISCARD, ignoring flags.\n");
|
||||
return 0;
|
||||
}
|
||||
if (flags & WINED3D_MAP_NOOVERWRITE)
|
||||
{
|
||||
WARN("WINED3D_MAP_READONLY combined with WINED3D_MAP_NOOVERWRITE, ignoring flags.\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if ((flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
|
||||
== (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE))
|
||||
{
|
||||
WARN("WINED3D_MAP_DISCARD and WINED3D_MAP_NOOVERWRITE used together, ignoring.\n");
|
||||
return 0;
|
||||
}
|
||||
else if (flags & (WINED3D_MAP_DISCARD | WINED3D_MAP_NOOVERWRITE)
|
||||
&& !(resource->usage & WINED3DUSAGE_DYNAMIC))
|
||||
{
|
||||
WARN("DISCARD or NOOVERWRITE map on non-dynamic buffer, ignoring.\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags)
|
||||
{
|
||||
GLbitfield ret = 0;
|
||||
|
|
|
@ -1700,8 +1700,6 @@ static HRESULT texture_resource_sub_resource_map(struct wined3d_resource *resour
|
|||
return WINED3DERR_INVALIDCALL;
|
||||
}
|
||||
|
||||
flags = wined3d_resource_sanitize_map_flags(resource, flags);
|
||||
|
||||
if (device->d3d_initialized)
|
||||
{
|
||||
context = context_acquire(device, NULL);
|
||||
|
|
|
@ -2605,7 +2605,6 @@ void wined3d_resource_free_sysmem(struct wined3d_resource *resource) DECLSPEC_HI
|
|||
GLbitfield wined3d_resource_gl_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
|
||||
GLenum wined3d_resource_gl_legacy_map_flags(DWORD d3d_flags) DECLSPEC_HIDDEN;
|
||||
BOOL wined3d_resource_is_offscreen(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
|
||||
DWORD wined3d_resource_sanitize_map_flags(const struct wined3d_resource *resource, DWORD flags) DECLSPEC_HIDDEN;
|
||||
void wined3d_resource_update_draw_binding(struct wined3d_resource *resource) DECLSPEC_HIDDEN;
|
||||
|
||||
/* Tests show that the start address of resources is 32 byte aligned */
|
||||
|
|
Loading…
Reference in New Issue