ddraw: Create textures for "standalone" surfaces.

This commit is contained in:
Henri Verbeet 2013-11-13 10:12:07 +01:00 committed by Alexandre Julliard
parent d6f12fcdc8
commit 6ea9afe701
3 changed files with 23 additions and 16 deletions

View File

@ -3116,17 +3116,9 @@ static HRESULT CreateSurface(struct ddraw *ddraw, DDSURFACEDESC2 *DDSD,
}
}
if (desc2.ddsCaps.dwCaps & DDSCAPS_TEXTURE)
if (FAILED(hr = ddraw_surface_create_texture(ddraw, &desc2, version, flags, &object)))
{
if (FAILED(hr = ddraw_surface_create_texture(ddraw, &desc2, version, flags, &object)))
{
WARN("Failed to create texture, hr %#x.\n", hr);
return hr;
}
}
else if (FAILED(hr = ddraw_create_surface(ddraw, &desc2, flags, &object, version)))
{
WARN("ddraw_create_surface failed, hr %#x.\n", hr);
WARN("Failed to create texture, hr %#x.\n", hr);
return hr;
}
object->is_complex_root = TRUE;

View File

@ -4668,14 +4668,16 @@ static HRESULT d3d_device7_SetTexture(IDirect3DDevice7 *iface,
{
struct d3d_device *device = impl_from_IDirect3DDevice7(iface);
struct ddraw_surface *surf = unsafe_impl_from_IDirectDrawSurface7(texture);
struct wined3d_texture *wined3d_texture = NULL;
HRESULT hr;
TRACE("iface %p, stage %u, texture %p.\n", iface, stage, texture);
/* Texture may be NULL here */
if (surf && (surf->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE))
wined3d_texture = surf->wined3d_texture;
wined3d_mutex_lock();
hr = wined3d_device_set_texture(device->wined3d_device,
stage, surf ? surf->wined3d_texture : NULL);
hr = wined3d_device_set_texture(device->wined3d_device, stage, wined3d_texture);
wined3d_mutex_unlock();
return hr;

View File

@ -484,6 +484,9 @@ static void ddraw_surface_cleanup(struct ddraw_surface *surface)
surface, surface->ref7, surface->ref4, surface->ref3, surface->ref2, surface->ref1);
}
if (surface->wined3d_texture
&& !(surface->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE))
wined3d_texture_decref(surface->wined3d_texture);
if (surface->wined3d_surface)
wined3d_surface_decref(surface->wined3d_surface);
}
@ -505,7 +508,8 @@ ULONG ddraw_surface_release_iface(struct ddraw_surface *This)
wined3d_mutex_unlock();
return iface_count;
}
if (This->wined3d_texture) /* If it's a texture, destroy the wined3d texture. */
/* If it's a texture, destroy the wined3d texture. */
if (This->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE)
wined3d_texture_decref(This->wined3d_texture);
else
ddraw_surface_cleanup(This);
@ -5579,7 +5583,8 @@ static void STDMETHODCALLTYPE ddraw_texture_wined3d_object_destroyed(void *paren
TRACE("texture %p.\n", texture);
ddraw_surface_cleanup(texture->root);
if (texture->surface_desc.ddsCaps.dwCaps & DDSCAPS_TEXTURE)
ddraw_surface_cleanup(texture->root);
HeapFree(GetProcessHeap(), 0, parent);
}
@ -5632,11 +5637,19 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, const DDSURFACEDESC2 *
}
else
{
wined3d_desc.usage = WINED3DUSAGE_TEXTURE | WINED3DUSAGE_DYNAMIC;
wined3d_desc.usage = WINED3DUSAGE_DYNAMIC;
if (desc->ddsCaps.dwCaps & DDSCAPS_TEXTURE)
wined3d_desc.usage |= WINED3DUSAGE_TEXTURE;
pool = WINED3D_POOL_DEFAULT;
}
wined3d_desc.format = wined3dformat_from_ddrawformat(&desc->u4.ddpfPixelFormat);
if (wined3d_desc.format == WINED3DFMT_UNKNOWN)
{
WARN("Unsupported / unknown pixelformat.\n");
return DDERR_INVALIDPIXELFORMAT;
}
wined3d_desc.multisample_type = WINED3D_MULTISAMPLE_NONE;
wined3d_desc.multisample_quality = 0;
wined3d_desc.pool = pool;