wined3d: Don't lock directly into the DIB.

This commit is contained in:
Stefan Dösinger 2014-01-14 13:59:21 +01:00 committed by Alexandre Julliard
parent d5b72bbcdc
commit 353b3ba6d3
3 changed files with 13 additions and 55 deletions

View File

@ -85,7 +85,6 @@ static void surface_cleanup(struct wined3d_surface *surface)
DeleteDC(surface->hDC); DeleteDC(surface->hDC);
DeleteObject(surface->dib.DIBsection); DeleteObject(surface->dib.DIBsection);
surface->dib.bitmap_data = NULL; surface->dib.bitmap_data = NULL;
surface->resource.allocatedMemory = NULL;
} }
if (surface->overlay_dest) if (surface->overlay_dest)
@ -488,17 +487,6 @@ static HRESULT surface_create_dib_section(struct wined3d_surface *surface)
} }
TRACE("DIBSection at %p.\n", surface->dib.bitmap_data); TRACE("DIBSection at %p.\n", surface->dib.bitmap_data);
/* Copy the existing surface to the dib section. */
if (surface->resource.allocatedMemory)
{
memcpy(surface->dib.bitmap_data, surface->resource.allocatedMemory,
surface->resource.height * wined3d_surface_get_pitch(surface));
}
else if (!surface->user_memory)
{
/* This is to make maps read the GL texture although memory is allocated. */
surface->flags &= ~SFLAG_INSYSMEM;
}
surface->dib.bitmap_size = b_info->bmiHeader.biSizeImage; surface->dib.bitmap_size = b_info->bmiHeader.biSizeImage;
HeapFree(GetProcessHeap(), 0, b_info); HeapFree(GetProcessHeap(), 0, b_info);
@ -1302,12 +1290,6 @@ HRESULT CDECL wined3d_surface_get_render_target_data(struct wined3d_surface *sur
/* Context activation is done by the caller. */ /* Context activation is done by the caller. */
static void surface_remove_pbo(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info) static void surface_remove_pbo(struct wined3d_surface *surface, const struct wined3d_gl_info *gl_info)
{ {
if (surface->flags & SFLAG_DIBSECTION)
{
surface->resource.allocatedMemory = surface->dib.bitmap_data;
}
else
{
if (!surface->resource.heap_memory) if (!surface->resource.heap_memory)
wined3d_resource_allocate_sysmem(&surface->resource); wined3d_resource_allocate_sysmem(&surface->resource);
else if (!(surface->flags & SFLAG_CLIENT)) else if (!(surface->flags & SFLAG_CLIENT))
@ -1315,7 +1297,6 @@ static void surface_remove_pbo(struct wined3d_surface *surface, const struct win
surface, surface->resource.heap_memory, surface->flags); surface, surface->resource.heap_memory, surface->flags);
surface->resource.allocatedMemory = surface->resource.heap_memory; surface->resource.allocatedMemory = surface->resource.heap_memory;
}
GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, surface->pbo)); GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, surface->pbo));
checkGLcall("glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, surface->pbo)"); checkGLcall("glBindBufferARB(GL_PIXEL_UNPACK_BUFFER, surface->pbo)");
@ -1477,11 +1458,8 @@ static HRESULT gdi_surface_private_setup(struct wined3d_surface *surface)
/* Sysmem textures have memory already allocated - release it, /* Sysmem textures have memory already allocated - release it,
* this avoids an unnecessary memcpy. */ * this avoids an unnecessary memcpy. */
hr = surface_create_dib_section(surface); hr = surface_create_dib_section(surface);
if (SUCCEEDED(hr)) if (FAILED(hr))
{ return hr;
wined3d_resource_free_sysmem(&surface->resource);
surface->resource.allocatedMemory = surface->dib.bitmap_data;
}
/* 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;
@ -2801,9 +2779,8 @@ HRESULT CDECL wined3d_surface_update_desc(struct wined3d_surface *surface,
ERR("Failed to create dib section, hr %#x.\n", hr); ERR("Failed to create dib section, hr %#x.\n", hr);
return hr; return hr;
} }
surface->resource.allocatedMemory = surface->dib.bitmap_data;
} }
else if (!surface_init_sysmem(surface)) if (!surface_init_sysmem(surface))
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
surface_validate_location(surface, surface->map_binding); surface_validate_location(surface, surface->map_binding);
@ -3276,13 +3253,6 @@ 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;
/* Use the DIB section from now on if we are not using a PBO or user memory. */
if (!(surface->flags & (SFLAG_PBO | SFLAG_PIN_SYSMEM) || surface->user_memory))
{
wined3d_resource_free_sysmem(&surface->resource);
surface->resource.allocatedMemory = surface->dib.bitmap_data;
}
} }
/* Map the surface. */ /* Map the surface. */
@ -3294,7 +3264,6 @@ HRESULT CDECL wined3d_surface_getdc(struct wined3d_surface *surface, HDC *dc)
} }
surface->getdc_map_mem = map.data; surface->getdc_map_mem = map.data;
if (surface->dib.bitmap_data != surface->getdc_map_mem)
memcpy(surface->dib.bitmap_data, surface->getdc_map_mem, surface->resource.size); memcpy(surface->dib.bitmap_data, surface->getdc_map_mem, surface->resource.size);
if (surface->resource.format->id == WINED3DFMT_P8_UINT if (surface->resource.format->id == WINED3DFMT_P8_UINT
@ -3356,7 +3325,6 @@ HRESULT CDECL wined3d_surface_releasedc(struct wined3d_surface *surface, HDC dc)
return WINEDDERR_NODC; return WINEDDERR_NODC;
} }
if (surface->dib.bitmap_data != surface->getdc_map_mem)
memcpy(surface->getdc_map_mem, surface->dib.bitmap_data, surface->resource.size); memcpy(surface->getdc_map_mem, surface->dib.bitmap_data, surface->resource.size);
/* We locked first, so unlock now. */ /* We locked first, so unlock now. */
@ -6450,16 +6418,6 @@ static HRESULT surface_init(struct wined3d_surface *surface, struct wined3d_text
return hr; return hr;
} }
/* Similar to lockable rendertargets above, creating the DIB section
* during surface initialization prevents the sysmem pointer from changing
* after a wined3d_surface_getdc() call. */
if ((desc->usage & WINED3DUSAGE_OWNDC) && !surface->hDC
&& SUCCEEDED(surface_create_dib_section(surface)))
{
wined3d_resource_free_sysmem(&surface->resource);
surface->resource.allocatedMemory = surface->dib.bitmap_data;
}
surface->map_binding = SFLAG_INSYSMEM; surface->map_binding = SFLAG_INSYSMEM;
return hr; return hr;

View File

@ -623,6 +623,8 @@ void x11_copy_to_screen(const struct wined3d_swapchain *swapchain, const RECT *r
TRACE("Copying surface %p to screen.\n", front); TRACE("Copying surface %p to screen.\n", front);
memcpy(front->dib.bitmap_data, front->resource.heap_memory, front->resource.size);
src_dc = front->hDC; src_dc = front->hDC;
window = swapchain->win_handle; window = swapchain->win_handle;
dst_dc = GetDCEx(window, 0, DCX_CLIPSIBLINGS | DCX_CACHE); dst_dc = GetDCEx(window, 0, DCX_CLIPSIBLINGS | DCX_CACHE);

View File

@ -2309,7 +2309,6 @@ void flip_surface(struct wined3d_surface *front, struct wined3d_surface *back) D
/* In some conditions the surface memory must not be freed: /* In some conditions the surface memory must not be freed:
* SFLAG_CONVERTED: Converting the data back would take too long * SFLAG_CONVERTED: Converting the data back would take too long
* SFLAG_DIBSECTION: The dib code manages the memory
* SFLAG_DYNLOCK: Avoid freeing the data for performance * SFLAG_DYNLOCK: Avoid freeing the data for performance
* SFLAG_PBO: PBOs don't use 'normal' memory. It is either allocated by the driver or must be NULL. * SFLAG_PBO: PBOs don't use 'normal' memory. It is either allocated by the driver or must be NULL.
* SFLAG_CLIENT: OpenGL uses our memory as backup * SFLAG_CLIENT: OpenGL uses our memory as backup
@ -2317,7 +2316,6 @@ void flip_surface(struct wined3d_surface *front, struct wined3d_surface *back) D
#define SFLAG_DONOTFREE (SFLAG_CONVERTED | \ #define SFLAG_DONOTFREE (SFLAG_CONVERTED | \
SFLAG_DYNLOCK | \ SFLAG_DYNLOCK | \
SFLAG_CLIENT | \ SFLAG_CLIENT | \
SFLAG_DIBSECTION | \
SFLAG_PBO | \ SFLAG_PBO | \
SFLAG_PIN_SYSMEM) SFLAG_PIN_SYSMEM)