Commit 97856bcf authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Replace wined3d_surface_update_desc() with wined3d_texture_update_desc().

parent 5000eba6
......@@ -787,16 +787,9 @@ static HRESULT WINAPI d3d9_device_CreateTexture(IDirect3DDevice9Ex *iface,
}
if (set_mem)
{
struct wined3d_resource *resource;
struct d3d9_surface *surface;
resource = wined3d_texture_get_sub_resource(object->wined3d_texture, 0);
surface = wined3d_resource_get_parent(resource);
wined3d_surface_update_desc(surface->wined3d_surface, width, height,
wined3d_texture_update_desc(object->wined3d_texture, width, height,
wined3dformat_from_d3dformat(format), WINED3D_MULTISAMPLE_NONE, 0,
*shared_handle, 0);
}
TRACE("Created texture %p.\n", object);
*texture = (IDirect3DTexture9 *)&object->IDirect3DBaseTexture9_iface;
......@@ -1029,12 +1022,13 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width
surface_impl->parent_device = &device->IDirect3DDevice9Ex_iface;
*surface = &surface_impl->IDirect3DSurface9_iface;
IDirect3DSurface9_AddRef(*surface);
wined3d_texture_decref(texture);
if (user_mem)
wined3d_surface_update_desc(surface_impl->wined3d_surface, width, height,
wined3d_texture_update_desc(texture, width, height,
desc.format, multisample_type, multisample_quality, user_mem, 0);
wined3d_texture_decref(texture);
wined3d_mutex_unlock();
return D3D_OK;
......
......@@ -4466,7 +4466,7 @@ static HRESULT WINAPI ddraw_surface7_SetSurfaceDesc(IDirectDrawSurface7 *iface,
format_id = wined3dformat_from_ddrawformat(&This->surface_desc.u4.ddpfPixelFormat);
}
if (FAILED(hr = wined3d_surface_update_desc(This->wined3d_surface, width, height,
if (FAILED(hr = wined3d_texture_update_desc(This->wined3d_texture, width, height,
format_id, WINED3D_MULTISAMPLE_NONE, 0, DDSD->lpSurface, pitch)))
{
WARN("Failed to update surface desc, hr %#x.\n", hr);
......@@ -6076,7 +6076,7 @@ HRESULT ddraw_surface_create(struct ddraw *ddraw, const DDSURFACEDESC2 *surface_
}
}
if ((desc->dwFlags & DDSD_LPSURFACE) && FAILED(hr = wined3d_surface_update_desc(root->wined3d_surface,
if ((desc->dwFlags & DDSD_LPSURFACE) && FAILED(hr = wined3d_texture_update_desc(wined3d_texture,
wined3d_desc.width, wined3d_desc.height, wined3d_desc.format,
WINED3D_MULTISAMPLE_NONE, 0, desc->lpSurface, pitch)))
{
......
......@@ -4497,16 +4497,14 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
{
UINT i;
if (FAILED(hr = wined3d_surface_update_desc(surface_from_resource(
wined3d_texture_get_sub_resource(swapchain->front_buffer, 0)), swapchain->desc.backbuffer_width,
if (FAILED(hr = wined3d_texture_update_desc(swapchain->front_buffer, swapchain->desc.backbuffer_width,
swapchain->desc.backbuffer_height, swapchain->desc.backbuffer_format,
swapchain->desc.multisample_type, swapchain->desc.multisample_quality, NULL, 0)))
return hr;
for (i = 0; i < swapchain->desc.backbuffer_count; ++i)
{
if (FAILED(hr = wined3d_surface_update_desc(surface_from_resource(
wined3d_texture_get_sub_resource(swapchain->back_buffers[i], 0)), swapchain->desc.backbuffer_width,
if (FAILED(hr = wined3d_texture_update_desc(swapchain->back_buffers[i], swapchain->desc.backbuffer_width,
swapchain->desc.backbuffer_height, swapchain->desc.backbuffer_format,
swapchain->desc.multisample_type, swapchain->desc.multisample_quality, NULL, 0)))
return hr;
......
......@@ -2363,35 +2363,14 @@ HRESULT CDECL wined3d_surface_update_overlay(struct wined3d_surface *surface, co
return WINED3D_OK;
}
HRESULT CDECL wined3d_surface_update_desc(struct wined3d_surface *surface,
UINT width, UINT height, enum wined3d_format_id format_id,
enum wined3d_multisample_type multisample_type, UINT multisample_quality,
void *mem, UINT pitch)
HRESULT wined3d_surface_update_desc(struct wined3d_surface *surface,
const struct wined3d_gl_info *gl_info, void *mem, unsigned int pitch)
{
struct wined3d_device *device = surface->resource.device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
UINT resource_size = wined3d_format_calculate_size(format, device->surface_alignment, width, height, 1);
struct wined3d_texture *texture;
struct wined3d_resource *texture_resource = &surface->container->resource;
unsigned int width, height;
BOOL create_dib = FALSE;
HRESULT hr;
DWORD valid_location = 0;
TRACE("surface %p, width %u, height %u, format %s, multisample_type %#x, multisample_quality %u, "
"mem %p, pitch %u.\n",
surface, width, height, debug_d3dformat(format_id), multisample_type, multisample_type, mem, pitch);
if (!resource_size)
return WINED3DERR_INVALIDCALL;
if (surface->resource.map_count || (surface->flags & SFLAG_DCINUSE))
{
WARN("Surface is mapped or the DC is in use.\n");
return WINED3DERR_INVALIDCALL;
}
if (device->d3d_initialized)
surface->resource.resource_ops->resource_unload(&surface->resource);
HRESULT hr;
if (surface->flags & SFLAG_DIBSECTION)
{
......@@ -2405,6 +2384,8 @@ HRESULT CDECL wined3d_surface_update_desc(struct wined3d_surface *surface,
surface->locations = 0;
wined3d_resource_free_sysmem(&surface->resource);
width = texture_resource->width;
height = texture_resource->height;
surface->resource.width = width;
surface->resource.height = height;
if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] || gl_info->supported[ARB_TEXTURE_RECTANGLE]
......@@ -2427,20 +2408,20 @@ HRESULT CDECL wined3d_surface_update_desc(struct wined3d_surface *surface,
else
surface->flags &= ~SFLAG_NONPOW2;
surface->user_memory = mem;
if (surface->user_memory)
if ((surface->user_memory = mem))
{
surface->resource.map_binding = WINED3D_LOCATION_USER_MEMORY;
valid_location = WINED3D_LOCATION_USER_MEMORY;
}
surface->pitch = pitch;
surface->resource.format = format;
surface->resource.multisample_type = multisample_type;
surface->resource.multisample_quality = multisample_quality;
surface->resource.format = texture_resource->format;
surface->resource.multisample_type = texture_resource->multisample_type;
surface->resource.multisample_quality = texture_resource->multisample_quality;
if (surface->pitch)
surface->resource.size = height * surface->pitch;
else
surface->resource.size = resource_size;
surface->resource.size = wined3d_format_calculate_size(texture_resource->format,
texture_resource->device->surface_alignment, width, height, 1);
/* The format might be changed to a format that needs conversion.
* If the surface didn't use PBOs previously but could now, don't
......@@ -2449,13 +2430,6 @@ HRESULT CDECL wined3d_surface_update_desc(struct wined3d_surface *surface,
if (surface->resource.map_binding == WINED3D_LOCATION_BUFFER && !surface_use_pbo(surface))
surface->resource.map_binding = create_dib ? WINED3D_LOCATION_DIB : WINED3D_LOCATION_SYSMEM;
texture = surface->container;
texture->resource.format = format;
texture->resource.multisample_type = multisample_type;
texture->resource.multisample_quality = multisample_quality;
texture->resource.width = width;
texture->resource.height = height;
if (create_dib)
{
if (FAILED(hr = surface_create_dib_section(surface)))
......
......@@ -701,6 +701,54 @@ HRESULT CDECL wined3d_texture_set_color_key(struct wined3d_texture *texture,
return WINED3D_OK;
}
HRESULT CDECL wined3d_texture_update_desc(struct wined3d_texture *texture, UINT width, UINT height,
enum wined3d_format_id format_id, enum wined3d_multisample_type multisample_type,
UINT multisample_quality, void *mem, UINT pitch)
{
struct wined3d_device *device = texture->resource.device;
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
UINT resource_size = wined3d_format_calculate_size(format, device->surface_alignment, width, height, 1);
struct wined3d_surface *surface;
TRACE("texture %p, width %u, height %u, format %s, multisample_type %#x, multisample_quality %u, "
"mem %p, pitch %u.\n",
texture, width, height, debug_d3dformat(format_id), multisample_type, multisample_type, mem, pitch);
if (!resource_size)
return WINED3DERR_INVALIDCALL;
if (texture->level_count * texture->layer_count > 1)
{
WARN("Texture has multiple sub-resources, not supported.\n");
return WINED3DERR_INVALIDCALL;
}
if (texture->resource.type == WINED3D_RTYPE_VOLUME_TEXTURE)
{
WARN("Not supported on volume textures.\n");
return WINED3DERR_INVALIDCALL;
}
surface = surface_from_resource(texture->sub_resources[0]);
if (surface->resource.map_count || (surface->flags & SFLAG_DCINUSE))
{
WARN("Surface is mapped or the DC is in use.\n");
return WINED3DERR_INVALIDCALL;
}
if (device->d3d_initialized)
texture->resource.resource_ops->resource_unload(&texture->resource);
texture->resource.format = format;
texture->resource.multisample_type = multisample_type;
texture->resource.multisample_quality = multisample_quality;
texture->resource.width = width;
texture->resource.height = height;
return wined3d_surface_update_desc(surface, gl_info, mem, pitch);
}
void CDECL wined3d_texture_generate_mipmaps(struct wined3d_texture *texture)
{
/* TODO: Implement filters using GL_SGI_generate_mipmaps. */
......
......@@ -238,7 +238,6 @@
@ cdecl wined3d_surface_restore(ptr)
@ cdecl wined3d_surface_set_overlay_position(ptr long long)
@ cdecl wined3d_surface_unmap(ptr)
@ cdecl wined3d_surface_update_desc(ptr long long long long long ptr long)
@ cdecl wined3d_surface_update_overlay(ptr ptr ptr ptr long ptr)
@ cdecl wined3d_surface_update_overlay_z_order(ptr long ptr)
......@@ -273,6 +272,7 @@
@ cdecl wined3d_texture_set_autogen_filter_type(ptr long)
@ cdecl wined3d_texture_set_color_key(ptr long ptr)
@ cdecl wined3d_texture_set_lod(ptr long)
@ cdecl wined3d_texture_update_desc(ptr long long long long long ptr long)
@ cdecl wined3d_vertex_declaration_create(ptr ptr long ptr ptr ptr)
@ cdecl wined3d_vertex_declaration_create_from_fvf(ptr long ptr ptr ptr)
......
......@@ -2320,6 +2320,8 @@ void surface_set_compatible_renderbuffer(struct wined3d_surface *surface,
const struct wined3d_surface *rt) 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_update_desc(struct wined3d_surface *surface,
const struct wined3d_gl_info *gl_info, void *mem, unsigned int pitch) DECLSPEC_HIDDEN;
HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const POINT *dst_point,
struct wined3d_surface *src_surface, const RECT *src_rect) DECLSPEC_HIDDEN;
void surface_validate_location(struct wined3d_surface *surface, DWORD location) DECLSPEC_HIDDEN;
......
......@@ -2465,10 +2465,6 @@ HRESULT __cdecl wined3d_surface_releasedc(struct wined3d_surface *surface, HDC d
HRESULT __cdecl wined3d_surface_restore(struct wined3d_surface *surface);
HRESULT __cdecl wined3d_surface_set_overlay_position(struct wined3d_surface *surface, LONG x, LONG y);
HRESULT __cdecl wined3d_surface_unmap(struct wined3d_surface *surface);
HRESULT __cdecl wined3d_surface_update_desc(struct wined3d_surface *surface,
UINT width, UINT height, enum wined3d_format_id format_id,
enum wined3d_multisample_type multisample_type, UINT multisample_quality,
void *mem, UINT pitch);
HRESULT __cdecl wined3d_surface_update_overlay(struct wined3d_surface *surface, const RECT *src_rect,
struct wined3d_surface *dst_surface, const RECT *dst_rect, DWORD flags, const WINEDDOVERLAYFX *fx);
HRESULT __cdecl wined3d_surface_update_overlay_z_order(struct wined3d_surface *surface,
......@@ -2521,6 +2517,10 @@ HRESULT __cdecl wined3d_texture_set_autogen_filter_type(struct wined3d_texture *
HRESULT __cdecl wined3d_texture_set_color_key(struct wined3d_texture *texture,
DWORD flags, const struct wined3d_color_key *color_key);
DWORD __cdecl wined3d_texture_set_lod(struct wined3d_texture *texture, DWORD lod);
HRESULT __cdecl wined3d_texture_update_desc(struct wined3d_texture *texture,
UINT width, UINT height, enum wined3d_format_id format_id,
enum wined3d_multisample_type multisample_type, UINT multisample_quality,
void *mem, UINT pitch);
HRESULT __cdecl wined3d_vertex_declaration_create(struct wined3d_device *device,
const struct wined3d_vertex_element *elements, UINT element_count, void *parent,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment