d3d8: Create textures for swapchain surfaces.

This commit is contained in:
Henri Verbeet 2013-06-07 10:17:51 +02:00 committed by Alexandre Julliard
parent e635952459
commit d97a8b3e83
1 changed files with 27 additions and 8 deletions

View File

@ -571,6 +571,21 @@ static HRESULT CDECL reset_enum_callback(struct wined3d_resource *resource)
{ {
struct d3d8_surface *surface; struct d3d8_surface *surface;
if (desc.resource_type == WINED3D_RTYPE_TEXTURE)
{
IUnknown *parent = wined3d_resource_get_parent(resource);
IDirect3DBaseTexture8 *texture;
if (SUCCEEDED(IUnknown_QueryInterface(parent, &IID_IDirect3DBaseTexture8, (void **)&texture)))
{
IDirect3DBaseTexture8_Release(texture);
WARN("Texture %p (resource %p) in pool D3DPOOL_DEFAULT blocks the Reset call.\n", texture, resource);
return D3DERR_DEVICELOST;
}
return D3D_OK;
}
if (desc.resource_type != WINED3D_RTYPE_SURFACE) if (desc.resource_type != WINED3D_RTYPE_SURFACE)
{ {
WARN("Resource %p in pool D3DPOOL_DEFAULT blocks the Reset call.\n", resource); WARN("Resource %p in pool D3DPOOL_DEFAULT blocks the Reset call.\n", resource);
@ -2917,26 +2932,30 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
void *container_parent, const struct wined3d_resource_desc *desc, struct wined3d_surface **surface) void *container_parent, const struct wined3d_resource_desc *desc, struct wined3d_surface **surface)
{ {
struct d3d8_device *device = device_from_device_parent(device_parent); struct d3d8_device *device = device_from_device_parent(device_parent);
struct wined3d_resource_desc texture_desc;
struct d3d8_surface *d3d_surface; struct d3d8_surface *d3d_surface;
struct wined3d_texture *texture;
HRESULT hr; HRESULT hr;
TRACE("device_parent %p, container_parent %p, desc %p, surface %p.\n", TRACE("device_parent %p, container_parent %p, desc %p, surface %p.\n",
device_parent, container_parent, desc, surface); device_parent, container_parent, desc, surface);
if (FAILED(hr = d3d8_device_create_surface(device, desc->width, desc->height, texture_desc = *desc;
d3dformat_from_wined3dformat(desc->format), WINED3D_SURFACE_MAPPABLE, (IDirect3DSurface8 **)&d3d_surface, texture_desc.resource_type = WINED3D_RTYPE_TEXTURE;
desc->usage, desc->pool, desc->multisample_type, desc->multisample_quality))) if (FAILED(hr = wined3d_texture_create_2d(device->wined3d_device, &texture_desc, 1,
WINED3D_SURFACE_MAPPABLE, &device->IDirect3DDevice8_iface, &d3d8_null_wined3d_parent_ops, &texture)))
{ {
WARN("Failed to create surface, hr %#x.\n", hr); WARN("Failed to create texture, hr %#x.\n", hr);
return hr; return hr;
} }
*surface = d3d_surface->wined3d_surface; *surface = wined3d_surface_from_resource(wined3d_texture_get_sub_resource(texture, 0));
wined3d_surface_incref(*surface); wined3d_surface_incref(*surface);
wined3d_texture_decref(texture);
d3d_surface->container = (IUnknown *)&device->IDirect3DDevice8_iface; d3d_surface = wined3d_surface_get_parent(*surface);
/* Implicit surfaces are created with an refcount of 0 */ d3d_surface->forwardReference = NULL;
IDirect3DSurface8_Release(&d3d_surface->IDirect3DSurface8_iface); d3d_surface->parent_device = &device->IDirect3DDevice8_iface;
return hr; return hr;
} }