wined3d: Merge wined3d_surface_unmap() and wined3d_volume_unmap().

Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Stefan Dösinger 2016-03-09 16:21:58 +01:00 committed by Alexandre Julliard
parent a59f70d29c
commit beb8986e48
6 changed files with 59 additions and 98 deletions

View File

@ -168,6 +168,8 @@ static HRESULT WINAPI d3d8_volume_UnlockBox(IDirect3DVolume8 *iface)
hr = wined3d_resource_unmap(wined3d_texture_get_resource(volume->wined3d_texture), volume->sub_resource_idx);
wined3d_mutex_unlock();
if (hr == WINEDDERR_NOTLOCKED)
return D3DERR_INVALIDCALL;
return hr;
}

View File

@ -168,6 +168,8 @@ static HRESULT WINAPI d3d9_volume_UnlockBox(IDirect3DVolume9 *iface)
hr = wined3d_resource_unmap(wined3d_texture_get_resource(volume->wined3d_texture), volume->sub_resource_idx);
wined3d_mutex_unlock();
if (hr == WINEDDERR_NOTLOCKED)
return D3DERR_INVALIDCALL;
return hr;
}

View File

@ -2078,57 +2078,6 @@ do { \
return WINED3D_OK;
}
HRESULT wined3d_surface_unmap(struct wined3d_surface *surface)
{
struct wined3d_device *device = surface->resource.device;
struct wined3d_texture *texture = surface->container;
const struct wined3d_gl_info *gl_info;
struct wined3d_context *context;
TRACE("surface %p.\n", surface);
if (!surface->resource.map_count)
{
WARN("Trying to unmap unmapped surface.\n");
return WINEDDERR_NOTLOCKED;
}
--surface->resource.map_count;
switch (surface->resource.map_binding)
{
case WINED3D_LOCATION_SYSMEM:
case WINED3D_LOCATION_USER_MEMORY:
case WINED3D_LOCATION_DIB:
break;
case WINED3D_LOCATION_BUFFER:
context = context_acquire(device, NULL);
gl_info = context->gl_info;
GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER,
texture->sub_resources[surface_get_sub_resource_idx(surface)].buffer_object));
GL_EXTCALL(glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER));
GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));
checkGLcall("glUnmapBuffer");
context_release(context);
break;
default:
ERR("Unexpected map binding %s.\n", wined3d_debug_location(surface->resource.map_binding));
break;
}
if (!(surface->locations & (WINED3D_LOCATION_DRAWABLE | WINED3D_LOCATION_TEXTURE_RGB)))
{
if (texture->swapchain && texture->swapchain->front_buffer == texture)
texture->swapchain->swapchain_ops->swapchain_frontbuffer_updated(texture->swapchain);
else if (texture->resource.format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
FIXME("Depth / stencil buffer locking is not implemented.\n");
}
return WINED3D_OK;
}
HRESULT wined3d_surface_map(struct wined3d_surface *surface, struct wined3d_map_desc *map_desc,
const struct wined3d_box *box, DWORD flags)
{

View File

@ -1028,14 +1028,64 @@ static HRESULT texture2d_resource_sub_resource_map(struct wined3d_resource *reso
return wined3d_surface_map(surface_from_resource(sub_resource), map_desc, box, flags);
}
static HRESULT texture2d_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
static HRESULT texture_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
{
const struct wined3d_gl_info *gl_info;
struct wined3d_resource *sub_resource;
struct wined3d_texture *texture;
struct wined3d_context *context;
if (!(sub_resource = wined3d_texture_get_sub_resource(wined3d_texture_from_resource(resource), sub_resource_idx)))
TRACE("resource %p, sub_resource_idx %u.\n", resource, sub_resource_idx);
texture = wined3d_texture_from_resource(resource);
if (!(sub_resource = wined3d_texture_get_sub_resource(texture, sub_resource_idx)))
return E_INVALIDARG;
return wined3d_surface_unmap(surface_from_resource(sub_resource));
if (!sub_resource->map_count)
{
WARN("Trying to unmap unmapped sub-resource.\n");
return WINEDDERR_NOTLOCKED;
}
switch (sub_resource->map_binding)
{
case WINED3D_LOCATION_SYSMEM:
case WINED3D_LOCATION_USER_MEMORY:
case WINED3D_LOCATION_DIB:
break;
case WINED3D_LOCATION_BUFFER:
context = context_acquire(resource->device, NULL);
gl_info = context->gl_info;
GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER,
texture->sub_resources[sub_resource_idx].buffer_object));
GL_EXTCALL(glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER));
GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));
checkGLcall("glUnmapBuffer");
context_release(context);
break;
default:
ERR("Unexpected map binding %s.\n", wined3d_debug_location(sub_resource->map_binding));
break;
}
if (texture->swapchain && texture->swapchain->front_buffer == texture)
{
struct wined3d_surface *surface = texture->sub_resources[sub_resource_idx].u.surface;
if (!(surface->locations & (WINED3D_LOCATION_DRAWABLE | WINED3D_LOCATION_TEXTURE_RGB)))
texture->swapchain->swapchain_ops->swapchain_frontbuffer_updated(texture->swapchain);
}
else if (resource->format_flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL))
{
FIXME("Depth / stencil buffer locking is not implemented.\n");
}
--sub_resource->map_count;
return WINED3D_OK;
}
static const struct wined3d_resource_ops texture2d_resource_ops =
@ -1044,7 +1094,7 @@ static const struct wined3d_resource_ops texture2d_resource_ops =
texture_resource_decref,
wined3d_texture_unload,
texture2d_resource_sub_resource_map,
texture2d_resource_sub_resource_unmap,
texture_resource_sub_resource_unmap,
};
static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc,
@ -1358,23 +1408,13 @@ static HRESULT texture3d_resource_sub_resource_map(struct wined3d_resource *reso
return wined3d_volume_map(volume_from_resource(sub_resource), map_desc, box, flags);
}
static HRESULT texture3d_resource_sub_resource_unmap(struct wined3d_resource *resource, unsigned int sub_resource_idx)
{
struct wined3d_resource *sub_resource;
if (!(sub_resource = wined3d_texture_get_sub_resource(wined3d_texture_from_resource(resource), sub_resource_idx)))
return E_INVALIDARG;
return wined3d_volume_unmap(volume_from_resource(sub_resource));
}
static const struct wined3d_resource_ops texture3d_resource_ops =
{
texture_resource_incref,
texture_resource_decref,
wined3d_texture_unload,
texture3d_resource_sub_resource_map,
texture3d_resource_sub_resource_unmap,
texture_resource_sub_resource_unmap,
};
static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc,

View File

@ -579,36 +579,6 @@ HRESULT wined3d_volume_map(struct wined3d_volume *volume,
return WINED3D_OK;
}
HRESULT wined3d_volume_unmap(struct wined3d_volume *volume)
{
TRACE("volume %p.\n", volume);
if (!volume->resource.map_count)
{
WARN("Trying to unlock an unlocked volume %p.\n", volume);
return WINED3DERR_INVALIDCALL;
}
if (volume->resource.map_binding == WINED3D_LOCATION_BUFFER)
{
struct wined3d_device *device = volume->resource.device;
struct wined3d_context *context = context_acquire(device, NULL);
const struct wined3d_gl_info *gl_info = context->gl_info;
GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER,
volume->container->sub_resources[volume->texture_level].buffer_object));
GL_EXTCALL(glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER));
GL_EXTCALL(glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0));
checkGLcall("Unmap PBO");
context_release(context);
}
volume->resource.map_count--;
return WINED3D_OK;
}
static ULONG volume_resource_incref(struct wined3d_resource *resource)
{
struct wined3d_volume *volume = volume_from_resource(resource);

View File

@ -2491,7 +2491,6 @@ void wined3d_volume_load(struct wined3d_volume *volume, struct wined3d_context *
HRESULT wined3d_volume_map(struct wined3d_volume *volume,
struct wined3d_map_desc *map_desc, const struct wined3d_box *box, DWORD flags) DECLSPEC_HIDDEN;
void wined3d_volume_validate_location(struct wined3d_volume *volume, DWORD location) DECLSPEC_HIDDEN;
HRESULT wined3d_volume_unmap(struct wined3d_volume *volume) DECLSPEC_HIDDEN;
void wined3d_volume_upload_data(struct wined3d_volume *volume, const struct wined3d_context *context,
const struct wined3d_const_bo_address *data) DECLSPEC_HIDDEN;
@ -2618,7 +2617,6 @@ void surface_set_compatible_renderbuffer(struct wined3d_surface *surface,
void surface_set_dirty(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
void surface_set_texture_target(struct wined3d_surface *surface, GLenum target, GLint level) DECLSPEC_HIDDEN;
void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN;
HRESULT wined3d_surface_unmap(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
const struct wined3d_gl_info *gl_info) DECLSPEC_HIDDEN;
HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const POINT *dst_point,