From: Henri Verbeet Subject: [PATCH 4/5] wined3d: Move the "map_binding" field from struct wined3d_surface to struct wined3d_resource. Message-Id: <1408432950-5991-4-git-send-email-hverbeet@codeweavers.com> Date: Tue, 19 Aug 2014 09:22:28 +0200 Like "draw_binding". --- dlls/wined3d/surface.c | 74 ++++++++++++++++++++-------------------- dlls/wined3d/texture.c | 4 +-- dlls/wined3d/wined3d_private.h | 2 +- 3 files changed, 40 insertions(+), 40 deletions(-) diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index d8ee07f..14d9133 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -578,7 +578,7 @@ static void surface_prepare_system_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: surface_prepare_system_memory(surface); @@ -599,7 +599,7 @@ void surface_prepare_map_memory(struct wined3d_surface *surface) break; 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; if (surface_use_pbo(surface)) - surface->map_binding = WINED3D_LOCATION_BUFFER; + surface->resource.map_binding = WINED3D_LOCATION_BUFFER; return WINED3D_OK; } @@ -739,7 +739,7 @@ static void surface_unmap(struct wined3d_surface *surface) memset(&surface->lockedRect, 0, sizeof(surface->lockedRect)); - switch (surface->map_binding) + switch (surface->resource.map_binding) { case WINED3D_LOCATION_SYSMEM: case WINED3D_LOCATION_USER_MEMORY: @@ -758,7 +758,7 @@ static void surface_unmap(struct wined3d_surface *surface) break; 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)) @@ -1211,8 +1211,8 @@ static void surface_unload(struct wined3d_resource *resource) else { surface_prepare_map_memory(surface); - surface_load_location(surface, surface->map_binding); - surface_invalidate_location(surface, ~surface->map_binding); + surface_load_location(surface, surface->resource.map_binding); + surface_invalidate_location(surface, ~surface->resource.map_binding); } 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); if (FAILED(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. */ 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. */ surface_prepare_map_memory(surface); - surface_load_location(surface, surface->map_binding); - surface_invalidate_location(surface, ~surface->map_binding); + surface_load_location(surface, surface->resource.map_binding); + surface_invalidate_location(surface, ~surface->resource.map_binding); /* Switching color keying on / off may change the internal format. */ if (ck_changed) surface_force_reload(surface); @@ -2446,7 +2446,7 @@ HRESULT CDECL wined3d_surface_update_desc(struct wined3d_surface *surface, surface->user_memory = mem; 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; } 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 * change it - whatever made us not use PBOs might come back, e.g. * color keys. */ - if (surface->map_binding == WINED3D_LOCATION_BUFFER && !surface_use_pbo(surface)) - surface->map_binding = create_dib ? WINED3D_LOCATION_DIB : WINED3D_LOCATION_SYSMEM; + if (surface->resource.map_binding == WINED3D_LOCATION_BUFFER && !surface_use_pbo(surface)) + surface->resource.map_binding = create_dib ? WINED3D_LOCATION_DIB : WINED3D_LOCATION_SYSMEM; 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 * the need to download the surface from OpenGL all the time. The surface * 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) { @@ -2871,21 +2871,21 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface, if (flags & WINED3D_MAP_DISCARD) { TRACE("WINED3D_MAP_DISCARD flag passed, marking %s as up to date.\n", - wined3d_debug_location(surface->map_binding)); - surface_validate_location(surface, surface->map_binding); + wined3d_debug_location(surface->resource.map_binding)); + surface_validate_location(surface, surface->resource.map_binding); } else { if (surface->resource.usage & WINED3DUSAGE_DYNAMIC) 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))) - 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: base_memory = surface->resource.heap_memory; @@ -2912,7 +2912,7 @@ HRESULT CDECL wined3d_surface_map(struct wined3d_surface *surface, break; 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; } @@ -2983,10 +2983,10 @@ HRESULT CDECL wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc) hr = surface_create_dib_section(surface); if (FAILED(hr)) 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->pbo)) - surface->map_binding = WINED3D_LOCATION_DIB; + surface->resource.map_binding = 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->flags &= ~SFLAG_DCINUSE; - if (surface->map_binding == WINED3D_LOCATION_USER_MEMORY || (surface->flags & SFLAG_PIN_SYSMEM - && surface->map_binding != WINED3D_LOCATION_DIB)) + if (surface->resource.map_binding == WINED3D_LOCATION_USER_MEMORY || (surface->flags & SFLAG_PIN_SYSMEM + && surface->resource.map_binding != WINED3D_LOCATION_DIB)) { /* 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 @@ -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. * * 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); } @@ -4603,24 +4603,24 @@ static HRESULT surface_load_texture(struct wined3d_surface *surface, 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) { /* Performance warning... */ FIXME("Downloading RGB surface %p to reload it as sRGB.\n", surface); surface_prepare_map_memory(surface); - surface_load_location(surface, surface->map_binding); + surface_load_location(surface, surface->resource.map_binding); } } 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) { /* Performance warning... */ FIXME("Downloading sRGB surface %p to reload it as RGB.\n", 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); if (surface->flags & SFLAG_DIBSECTION) - surface->map_binding = WINED3D_LOCATION_DIB; + surface->resource.map_binding = WINED3D_LOCATION_DIB; else - surface->map_binding = WINED3D_LOCATION_SYSMEM; + surface->resource.map_binding = WINED3D_LOCATION_SYSMEM; 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); } @@ -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 * implement those in the CPU blitter at the moment. */ - if ((dst_surface->locations & dst_surface->map_binding) - && (!src_surface || (src_surface->locations & src_surface->map_binding))) + if ((dst_surface->locations & dst_surface->resource.map_binding) + && (!src_surface || (src_surface->locations & src_surface->resource.map_binding))) { if (scale) 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) 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_level = level; @@ -6025,9 +6025,9 @@ static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_text * after a wined3d_surface_getdc() call. */ if ((desc->usage & WINED3DUSAGE_OWNDC) && !surface->hDC && 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); surface_validate_location(surface, WINED3D_LOCATION_DIB); diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 392f84d..060dabc 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -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); surface_prepare_map_memory(surface); - surface_load_location(surface, surface->map_binding); - surface_invalidate_location(surface, ~surface->map_binding); + surface_load_location(surface, surface->resource.map_binding); + surface_invalidate_location(surface, ~surface->resource.map_binding); } static void texture2d_sub_resource_cleanup(struct wined3d_resource *sub_resource) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 4c79ddb..9566066 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -2037,6 +2037,7 @@ struct wined3d_resource enum wined3d_pool pool; DWORD access_flags; DWORD draw_binding; + DWORD map_binding; UINT width; UINT height; UINT depth; @@ -2233,7 +2234,6 @@ struct wined3d_surface const struct wined3d_surface_ops *surface_ops; struct wined3d_texture *container; struct wined3d_swapchain *swapchain; - DWORD map_binding; void *user_memory; DWORD locations; -- 1.7.10.4