wined3d: Move the "map_binding" field from struct wined3d_surface to struct wined3d_resource.

Like "draw_binding".
This commit is contained in:
Henri Verbeet 2014-08-19 09:22:28 +02:00 committed by Alexandre Julliard
parent ed230a426a
commit 694cdcc41c
3 changed files with 40 additions and 40 deletions

View File

@ -578,7 +578,7 @@ static void surface_prepare_system_memory(struct wined3d_surface *surface)
void surface_prepare_map_memory(struct wined3d_surface *surface) void surface_prepare_map_memory(struct wined3d_surface *surface)
{ {
switch (surface->map_binding) switch (surface->resource.map_binding)
{ {
case WINED3D_LOCATION_SYSMEM: case WINED3D_LOCATION_SYSMEM:
surface_prepare_system_memory(surface); surface_prepare_system_memory(surface);
@ -599,7 +599,7 @@ void surface_prepare_map_memory(struct wined3d_surface *surface)
break; break;
default: default:
ERR("Unexpected map binding %s.\n", wined3d_debug_location(surface->map_binding)); ERR("Unexpected map binding %s.\n", wined3d_debug_location(surface->resource.map_binding));
} }
} }
@ -724,7 +724,7 @@ static HRESULT surface_private_setup(struct wined3d_surface *surface)
surface->locations = WINED3D_LOCATION_DISCARDED; surface->locations = WINED3D_LOCATION_DISCARDED;
if (surface_use_pbo(surface)) if (surface_use_pbo(surface))
surface->map_binding = WINED3D_LOCATION_BUFFER; surface->resource.map_binding = WINED3D_LOCATION_BUFFER;
return WINED3D_OK; return WINED3D_OK;
} }
@ -739,7 +739,7 @@ static void surface_unmap(struct wined3d_surface *surface)
memset(&surface->lockedRect, 0, sizeof(surface->lockedRect)); memset(&surface->lockedRect, 0, sizeof(surface->lockedRect));
switch (surface->map_binding) switch (surface->resource.map_binding)
{ {
case WINED3D_LOCATION_SYSMEM: case WINED3D_LOCATION_SYSMEM:
case WINED3D_LOCATION_USER_MEMORY: case WINED3D_LOCATION_USER_MEMORY:
@ -758,7 +758,7 @@ static void surface_unmap(struct wined3d_surface *surface)
break; break;
default: default:
ERR("Unexpected map binding %s.\n", wined3d_debug_location(surface->map_binding)); ERR("Unexpected map binding %s.\n", wined3d_debug_location(surface->resource.map_binding));
} }
if (surface->locations & (WINED3D_LOCATION_DRAWABLE | WINED3D_LOCATION_TEXTURE_RGB)) if (surface->locations & (WINED3D_LOCATION_DRAWABLE | WINED3D_LOCATION_TEXTURE_RGB))
@ -1211,8 +1211,8 @@ static void surface_unload(struct wined3d_resource *resource)
else else
{ {
surface_prepare_map_memory(surface); surface_prepare_map_memory(surface);
surface_load_location(surface, surface->map_binding); surface_load_location(surface, surface->resource.map_binding);
surface_invalidate_location(surface, ~surface->map_binding); surface_invalidate_location(surface, ~surface->resource.map_binding);
} }
surface->flags &= ~(SFLAG_ALLOCATED | SFLAG_SRGBALLOCATED); surface->flags &= ~(SFLAG_ALLOCATED | SFLAG_SRGBALLOCATED);
@ -1295,7 +1295,7 @@ static HRESULT gdi_surface_private_setup(struct wined3d_surface *surface)
hr = surface_create_dib_section(surface); hr = surface_create_dib_section(surface);
if (FAILED(hr)) if (FAILED(hr))
return hr; return hr;
surface->map_binding = WINED3D_LOCATION_DIB; surface->resource.map_binding = WINED3D_LOCATION_DIB;
/* We don't mind the nonpow2 stuff in GDI. */ /* We don't mind the nonpow2 stuff in GDI. */
surface->pow2Width = surface->resource.width; surface->pow2Width = surface->resource.width;
@ -2051,8 +2051,8 @@ void surface_load(struct wined3d_surface *surface, BOOL srgb)
* the surface. Make sure we have it. */ * the surface. Make sure we have it. */
surface_prepare_map_memory(surface); surface_prepare_map_memory(surface);
surface_load_location(surface, surface->map_binding); surface_load_location(surface, surface->resource.map_binding);
surface_invalidate_location(surface, ~surface->map_binding); surface_invalidate_location(surface, ~surface->resource.map_binding);
/* Switching color keying on / off may change the internal format. */ /* Switching color keying on / off may change the internal format. */
if (ck_changed) if (ck_changed)
surface_force_reload(surface); surface_force_reload(surface);
@ -2446,7 +2446,7 @@ HRESULT CDECL wined3d_surface_update_desc(struct wined3d_surface *surface,
surface->user_memory = mem; surface->user_memory = mem;
if (surface->user_memory) if (surface->user_memory)
{ {
surface->map_binding = WINED3D_LOCATION_USER_MEMORY; surface->resource.map_binding = WINED3D_LOCATION_USER_MEMORY;
valid_location = WINED3D_LOCATION_USER_MEMORY; valid_location = WINED3D_LOCATION_USER_MEMORY;
} }
surface->pitch = pitch; surface->pitch = pitch;
@ -2462,8 +2462,8 @@ HRESULT CDECL wined3d_surface_update_desc(struct wined3d_surface *surface,
* If the surface didn't use PBOs previously but could now, don't * 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. * change it - whatever made us not use PBOs might come back, e.g.
* color keys. */ * color keys. */
if (surface->map_binding == WINED3D_LOCATION_BUFFER && !surface_use_pbo(surface)) if (surface->resource.map_binding == WINED3D_LOCATION_BUFFER && !surface_use_pbo(surface))
surface->map_binding = create_dib ? WINED3D_LOCATION_DIB : WINED3D_LOCATION_SYSMEM; surface->resource.map_binding = create_dib ? WINED3D_LOCATION_DIB : WINED3D_LOCATION_SYSMEM;
if (create_dib) if (create_dib)
{ {
@ -2858,7 +2858,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
* mapped regularly do not throw away the system memory copy. This avoids * mapped regularly do not throw away the system memory copy. This avoids
* the need to download the surface from OpenGL all the time. The surface * the need to download the surface from OpenGL all the time. The surface
* is still downloaded if the OpenGL texture is changed. */ * is still downloaded if the OpenGL texture is changed. */
if (!(surface->flags & SFLAG_DYNLOCK) && surface->map_binding == WINED3D_LOCATION_SYSMEM) if (!(surface->flags & SFLAG_DYNLOCK) && surface->resource.map_binding == WINED3D_LOCATION_SYSMEM)
{ {
if (++surface->lockCount > MAXLOCKCOUNT) if (++surface->lockCount > MAXLOCKCOUNT)
{ {
@ -2871,21 +2871,21 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
if (flags & WINED3D_MAP_DISCARD) if (flags & WINED3D_MAP_DISCARD)
{ {
TRACE("WINED3D_MAP_DISCARD flag passed, marking %s as up to date.\n", TRACE("WINED3D_MAP_DISCARD flag passed, marking %s as up to date.\n",
wined3d_debug_location(surface->map_binding)); wined3d_debug_location(surface->resource.map_binding));
surface_validate_location(surface, surface->map_binding); surface_validate_location(surface, surface->resource.map_binding);
} }
else else
{ {
if (surface->resource.usage & WINED3DUSAGE_DYNAMIC) if (surface->resource.usage & WINED3DUSAGE_DYNAMIC)
WARN_(d3d_perf)("Mapping a dynamic surface without WINED3D_MAP_DISCARD.\n"); WARN_(d3d_perf)("Mapping a dynamic surface without WINED3D_MAP_DISCARD.\n");
surface_load_location(surface, surface->map_binding); surface_load_location(surface, surface->resource.map_binding);
} }
if (!(flags & (WINED3D_MAP_NO_DIRTY_UPDATE | WINED3D_MAP_READONLY))) if (!(flags & (WINED3D_MAP_NO_DIRTY_UPDATE | WINED3D_MAP_READONLY)))
surface_invalidate_location(surface, ~surface->map_binding); surface_invalidate_location(surface, ~surface->resource.map_binding);
switch (surface->map_binding) switch (surface->resource.map_binding)
{ {
case WINED3D_LOCATION_SYSMEM: case WINED3D_LOCATION_SYSMEM:
base_memory = surface->resource.heap_memory; base_memory = surface->resource.heap_memory;
@ -2912,7 +2912,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface,
break; break;
default: default:
ERR("Unexpected map binding %s.\n", wined3d_debug_location(surface->map_binding)); ERR("Unexpected map binding %s.\n", wined3d_debug_location(surface->resource.map_binding));
base_memory = NULL; base_memory = NULL;
} }
@ -2983,10 +2983,10 @@ HRESULT CDECL wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc)
hr = surface_create_dib_section(surface); hr = surface_create_dib_section(surface);
if (FAILED(hr)) if (FAILED(hr))
return WINED3DERR_INVALIDCALL; return WINED3DERR_INVALIDCALL;
if (!(surface->map_binding == WINED3D_LOCATION_USER_MEMORY if (!(surface->resource.map_binding == WINED3D_LOCATION_USER_MEMORY
|| surface->flags & SFLAG_PIN_SYSMEM || surface->flags & SFLAG_PIN_SYSMEM
|| surface->pbo)) || surface->pbo))
surface->map_binding = WINED3D_LOCATION_DIB; surface->resource.map_binding = WINED3D_LOCATION_DIB;
} }
surface_load_location(surface, WINED3D_LOCATION_DIB); surface_load_location(surface, WINED3D_LOCATION_DIB);
@ -3018,8 +3018,8 @@ HRESULT CDECL wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc)
surface->resource.map_count--; surface->resource.map_count--;
surface->flags &= ~SFLAG_DCINUSE; surface->flags &= ~SFLAG_DCINUSE;
if (surface->map_binding == WINED3D_LOCATION_USER_MEMORY || (surface->flags & SFLAG_PIN_SYSMEM if (surface->resource.map_binding == WINED3D_LOCATION_USER_MEMORY || (surface->flags & SFLAG_PIN_SYSMEM
&& surface->map_binding != WINED3D_LOCATION_DIB)) && surface->resource.map_binding != WINED3D_LOCATION_DIB))
{ {
/* The game Salammbo modifies the surface contents without mapping the surface between /* The game Salammbo modifies the surface contents without mapping the surface between
* a GetDC/ReleaseDC operation and flipping the surface. If the DIB remains the active * a GetDC/ReleaseDC operation and flipping the surface. If the DIB remains the active
@ -3028,7 +3028,7 @@ HRESULT CDECL wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc)
* copied back to the DIB in the next getdc call. * copied back to the DIB in the next getdc call.
* *
* The same consideration applies to user memory surfaces. */ * The same consideration applies to user memory surfaces. */
surface_load_location(surface, surface->map_binding); surface_load_location(surface, surface->resource.map_binding);
surface_invalidate_location(surface, WINED3D_LOCATION_DIB); surface_invalidate_location(surface, WINED3D_LOCATION_DIB);
} }
@ -4603,24 +4603,24 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
if (srgb) if (srgb)
{ {
if ((surface->locations & (WINED3D_LOCATION_TEXTURE_RGB | surface->map_binding)) if ((surface->locations & (WINED3D_LOCATION_TEXTURE_RGB | surface->resource.map_binding))
== WINED3D_LOCATION_TEXTURE_RGB) == WINED3D_LOCATION_TEXTURE_RGB)
{ {
/* Performance warning... */ /* Performance warning... */
FIXME("Downloading RGB surface %p to reload it as sRGB.\n", surface); FIXME("Downloading RGB surface %p to reload it as sRGB.\n", surface);
surface_prepare_map_memory(surface); surface_prepare_map_memory(surface);
surface_load_location(surface, surface->map_binding); surface_load_location(surface, surface->resource.map_binding);
} }
} }
else else
{ {
if ((surface->locations & (WINED3D_LOCATION_TEXTURE_SRGB | surface->map_binding)) if ((surface->locations & (WINED3D_LOCATION_TEXTURE_SRGB | surface->resource.map_binding))
== WINED3D_LOCATION_TEXTURE_SRGB) == WINED3D_LOCATION_TEXTURE_SRGB)
{ {
/* Performance warning... */ /* Performance warning... */
FIXME("Downloading sRGB surface %p to reload it as RGB.\n", surface); FIXME("Downloading sRGB surface %p to reload it as RGB.\n", surface);
surface_prepare_map_memory(surface); surface_prepare_map_memory(surface);
surface_load_location(surface, surface->map_binding); surface_load_location(surface, surface->resource.map_binding);
} }
} }
@ -4656,12 +4656,12 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface,
TRACE("Removing the pbo attached to surface %p.\n", surface); TRACE("Removing the pbo attached to surface %p.\n", surface);
if (surface->flags & SFLAG_DIBSECTION) if (surface->flags & SFLAG_DIBSECTION)
surface->map_binding = WINED3D_LOCATION_DIB; surface->resource.map_binding = WINED3D_LOCATION_DIB;
else else
surface->map_binding = WINED3D_LOCATION_SYSMEM; surface->resource.map_binding = WINED3D_LOCATION_SYSMEM;
surface_prepare_map_memory(surface); surface_prepare_map_memory(surface);
surface_load_location(surface, surface->map_binding); surface_load_location(surface, surface->resource.map_binding);
surface_remove_pbo(surface, gl_info); surface_remove_pbo(surface, gl_info);
} }
@ -5816,8 +5816,8 @@ HRESULT CDECL wined3d_surface_blt(struct wined3d_surface *dst_surface, const REC
{ {
/* In principle this would apply to depth blits as well, but we don't /* In principle this would apply to depth blits as well, but we don't
* implement those in the CPU blitter at the moment. */ * implement those in the CPU blitter at the moment. */
if ((dst_surface->locations & dst_surface->map_binding) if ((dst_surface->locations & dst_surface->resource.map_binding)
&& (!src_surface || (src_surface->locations & src_surface->map_binding))) && (!src_surface || (src_surface->locations & src_surface->resource.map_binding)))
{ {
if (scale) if (scale)
TRACE("Not doing sysmem blit because of scaling.\n"); TRACE("Not doing sysmem blit because of scaling.\n");
@ -6008,7 +6008,7 @@ static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_text
if (lockable || desc->format == WINED3DFMT_D16_LOCKABLE) if (lockable || desc->format == WINED3DFMT_D16_LOCKABLE)
surface->resource.access_flags |= WINED3D_RESOURCE_ACCESS_CPU; surface->resource.access_flags |= WINED3D_RESOURCE_ACCESS_CPU;
surface->map_binding = WINED3D_LOCATION_SYSMEM; surface->resource.map_binding = WINED3D_LOCATION_SYSMEM;
surface->texture_target = target; surface->texture_target = target;
surface->texture_level = level; surface->texture_level = level;
@ -6025,9 +6025,9 @@ static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_text
* after a wined3d_surface_getdc() call. */ * after a wined3d_surface_getdc() call. */
if ((desc->usage & WINED3DUSAGE_OWNDC) && !surface->hDC if ((desc->usage & WINED3DUSAGE_OWNDC) && !surface->hDC
&& SUCCEEDED(surface_create_dib_section(surface))) && SUCCEEDED(surface_create_dib_section(surface)))
surface->map_binding = WINED3D_LOCATION_DIB; surface->resource.map_binding = WINED3D_LOCATION_DIB;
if (surface->map_binding == WINED3D_LOCATION_DIB) if (surface->resource.map_binding == WINED3D_LOCATION_DIB)
{ {
wined3d_resource_free_sysmem(&surface->resource); wined3d_resource_free_sysmem(&surface->resource);
surface_validate_location(surface, WINED3D_LOCATION_DIB); surface_validate_location(surface, WINED3D_LOCATION_DIB);

View File

@ -734,8 +734,8 @@ static void texture2d_sub_resource_add_dirty_region(struct wined3d_resource *sub
struct wined3d_surface *surface = surface_from_resource(sub_resource); struct wined3d_surface *surface = surface_from_resource(sub_resource);
surface_prepare_map_memory(surface); surface_prepare_map_memory(surface);
surface_load_location(surface, surface->map_binding); surface_load_location(surface, surface->resource.map_binding);
surface_invalidate_location(surface, ~surface->map_binding); surface_invalidate_location(surface, ~surface->resource.map_binding);
} }
static void texture2d_sub_resource_cleanup(struct wined3d_resource *sub_resource) static void texture2d_sub_resource_cleanup(struct wined3d_resource *sub_resource)

View File

@ -2037,6 +2037,7 @@ struct wined3d_resource
enum wined3d_pool pool; enum wined3d_pool pool;
DWORD access_flags; DWORD access_flags;
DWORD draw_binding; DWORD draw_binding;
DWORD map_binding;
UINT width; UINT width;
UINT height; UINT height;
UINT depth; UINT depth;
@ -2233,7 +2234,6 @@ struct wined3d_surface
const struct wined3d_surface_ops *surface_ops; const struct wined3d_surface_ops *surface_ops;
struct wined3d_texture *container; struct wined3d_texture *container;
struct wined3d_swapchain *swapchain; struct wined3d_swapchain *swapchain;
DWORD map_binding;
void *user_memory; void *user_memory;
DWORD locations; DWORD locations;