mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 20:59:54 +00:00
d3d8: Always create textures for surfaces.
This commit is contained in:
parent
d0c9dbe763
commit
133bfe29e4
@ -36,6 +36,13 @@
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(d3d8);
|
||||
|
||||
static void STDMETHODCALLTYPE d3d8_null_wined3d_object_destroyed(void *parent) {}
|
||||
|
||||
static const struct wined3d_parent_ops d3d8_null_wined3d_parent_ops =
|
||||
{
|
||||
d3d8_null_wined3d_object_destroyed,
|
||||
};
|
||||
|
||||
D3DFORMAT d3dformat_from_wined3dformat(enum wined3d_format_id format)
|
||||
{
|
||||
BYTE *c = (BYTE *)&format;
|
||||
@ -871,7 +878,10 @@ static HRESULT d3d8_device_create_surface(struct d3d8_device *device, UINT width
|
||||
D3DFORMAT format, DWORD flags, IDirect3DSurface8 **surface, UINT usage, D3DPOOL pool,
|
||||
D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality)
|
||||
{
|
||||
struct d3d8_surface *object;
|
||||
struct wined3d_resource *sub_resource;
|
||||
struct wined3d_resource_desc desc;
|
||||
struct d3d8_surface *surface_impl;
|
||||
struct wined3d_texture *texture;
|
||||
HRESULT hr;
|
||||
|
||||
TRACE("device %p, width %u, height %u, format %#x, flags %#x, surface %p,\n"
|
||||
@ -879,22 +889,36 @@ static HRESULT d3d8_device_create_surface(struct d3d8_device *device, UINT width
|
||||
device, width, height, format, flags, surface,
|
||||
usage, pool, multisample_type, multisample_quality);
|
||||
|
||||
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
|
||||
{
|
||||
FIXME("Failed to allocate surface memory.\n");
|
||||
return D3DERR_OUTOFVIDEOMEMORY;
|
||||
}
|
||||
desc.resource_type = WINED3D_RTYPE_TEXTURE;
|
||||
desc.format = wined3dformat_from_d3dformat(format);
|
||||
desc.multisample_type = multisample_type;
|
||||
desc.multisample_quality = multisample_quality;
|
||||
desc.usage = usage & WINED3DUSAGE_MASK;
|
||||
desc.pool = pool;
|
||||
desc.width = width;
|
||||
desc.height = height;
|
||||
desc.depth = 1;
|
||||
desc.size = 0;
|
||||
|
||||
if (FAILED(hr = surface_init(object, device, width, height, format,
|
||||
flags, usage, pool, multisample_type, multisample_quality)))
|
||||
wined3d_mutex_lock();
|
||||
|
||||
if (FAILED(hr = wined3d_texture_create_2d(device->wined3d_device, &desc,
|
||||
1, flags, NULL, &d3d8_null_wined3d_parent_ops, &texture)))
|
||||
{
|
||||
WARN("Failed to initialize surface, hr %#x.\n", hr);
|
||||
HeapFree(GetProcessHeap(), 0, object);
|
||||
wined3d_mutex_unlock();
|
||||
WARN("Failed to create texture, hr %#x.\n", hr);
|
||||
return hr;
|
||||
}
|
||||
|
||||
TRACE("Created surface %p.\n", object);
|
||||
*surface = &object->IDirect3DSurface8_iface;
|
||||
sub_resource = wined3d_texture_get_sub_resource(texture, 0);
|
||||
surface_impl = wined3d_resource_get_parent(sub_resource);
|
||||
surface_impl->forwardReference = NULL;
|
||||
surface_impl->parent_device = &device->IDirect3DDevice8_iface;
|
||||
*surface = &surface_impl->IDirect3DSurface8_iface;
|
||||
IDirect3DSurface8_AddRef(*surface);
|
||||
wined3d_texture_decref(texture);
|
||||
|
||||
wined3d_mutex_unlock();
|
||||
|
||||
return D3D_OK;
|
||||
}
|
||||
@ -1910,13 +1934,6 @@ static HRESULT WINAPI d3d8_device_DrawIndexedPrimitive(IDirect3DDevice8 *iface,
|
||||
return hr;
|
||||
}
|
||||
|
||||
static void STDMETHODCALLTYPE d3d8_null_wined3d_object_destroyed(void *parent) {}
|
||||
|
||||
static const struct wined3d_parent_ops d3d8_null_wined3d_parent_ops =
|
||||
{
|
||||
d3d8_null_wined3d_object_destroyed,
|
||||
};
|
||||
|
||||
/* The caller is responsible for wined3d locking */
|
||||
static HRESULT d3d8_device_prepare_vertex_buffer(struct d3d8_device *device, UINT min_size)
|
||||
{
|
||||
@ -2907,14 +2924,23 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
|
||||
TRACE("device_parent %p, container_parent %p, desc %p, sub_resource_idx %u, flags %#x, surface %p.\n",
|
||||
device_parent, container_parent, desc, sub_resource_idx, flags, surface);
|
||||
|
||||
if (FAILED(hr = d3d8_device_create_surface(device, desc->width, desc->height,
|
||||
d3dformat_from_wined3dformat(desc->format), flags, (IDirect3DSurface8 **)&d3d_surface,
|
||||
desc->usage, desc->pool, desc->multisample_type, desc->multisample_quality)))
|
||||
if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface))))
|
||||
{
|
||||
WARN("Failed to create surface, hr %#x.\n", hr);
|
||||
FIXME("Failed to allocate surface memory.\n");
|
||||
return D3DERR_OUTOFVIDEOMEMORY;
|
||||
}
|
||||
|
||||
if (FAILED(hr = surface_init(d3d_surface, device, desc->width, desc->height,
|
||||
d3dformat_from_wined3dformat(desc->format), flags, desc->usage, desc->pool,
|
||||
desc->multisample_type, desc->multisample_quality)))
|
||||
{
|
||||
WARN("Failed to initialize surface, hr %#x.\n", hr);
|
||||
HeapFree(GetProcessHeap(), 0, d3d_surface);
|
||||
return hr;
|
||||
}
|
||||
|
||||
TRACE("Created surface %p.\n", d3d_surface);
|
||||
|
||||
*surface = d3d_surface->wined3d_surface;
|
||||
wined3d_surface_incref(*surface);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user