wined3d: Create surfaces inside wined3d.

This commit is contained in:
Henri Verbeet 2013-11-15 08:24:31 +01:00 committed by Alexandre Julliard
parent 9443c95a89
commit afc3d2ab70
15 changed files with 129 additions and 201 deletions

View File

@ -1830,18 +1830,17 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic
TRACE("device_parent %p.\n", device_parent);
}
static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_parent *device_parent,
void *container_parent, const struct wined3d_resource_desc *desc, UINT sub_resource_idx,
DWORD flags, struct wined3d_surface **surface)
static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
void *container_parent, struct wined3d_surface *surface, void **parent,
const struct wined3d_parent_ops **parent_ops)
{
struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
device_parent, container_parent, surface, parent, parent_ops);
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);
*parent = container_parent;
*parent_ops = &d3d10_null_wined3d_parent_ops;
return wined3d_surface_create(device->wined3d_device, desc->width, desc->height, desc->format,
desc->usage, desc->pool, desc->multisample_type, desc->multisample_quality, flags,
container_parent, &d3d10_null_wined3d_parent_ops, surface);
return S_OK;
}
static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
@ -1942,8 +1941,8 @@ static const struct wined3d_device_parent_ops d3d10_wined3d_device_parent_ops =
{
device_parent_wined3d_device_created,
device_parent_mode_changed,
device_parent_surface_created,
device_parent_create_swapchain_surface,
device_parent_create_texture_surface,
device_parent_create_volume,
device_parent_create_swapchain,
};

View File

@ -212,9 +212,8 @@ struct d3d8_surface
IUnknown *forwardReference;
};
HRESULT surface_init(struct d3d8_surface *surface, struct d3d8_device *device, UINT width, UINT height,
D3DFORMAT format, DWORD flags, DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type,
DWORD multisample_quality) DECLSPEC_HIDDEN;
void surface_init(struct d3d8_surface *surface, struct wined3d_surface *wined3d_surface,
struct d3d8_device *device, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
struct d3d8_surface *unsafe_impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface) DECLSPEC_HIDDEN;
struct d3d8_vertexbuffer

View File

@ -2921,16 +2921,15 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic
TRACE("device_parent %p.\n", device_parent);
}
static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_parent *device_parent,
void *container_parent, const struct wined3d_resource_desc *desc, UINT sub_resource_idx,
DWORD flags, struct wined3d_surface **surface)
static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
void *container_parent, struct wined3d_surface *surface, void **parent,
const struct wined3d_parent_ops **parent_ops)
{
struct d3d8_device *device = device_from_device_parent(device_parent);
struct d3d8_surface *d3d_surface;
HRESULT hr;
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);
TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
device_parent, container_parent, surface, parent, parent_ops);
if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface))))
{
@ -2938,20 +2937,10 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
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;
}
surface_init(d3d_surface, surface, device, parent_ops);
*parent = d3d_surface;
TRACE("Created surface %p.\n", d3d_surface);
*surface = d3d_surface->wined3d_surface;
wined3d_surface_incref(*surface);
d3d_surface->container = container_parent;
IDirect3DDevice8_Release(d3d_surface->parent_device);
d3d_surface->parent_device = NULL;
@ -2959,7 +2948,7 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
IDirect3DSurface8_Release(&d3d_surface->IDirect3DSurface8_iface);
d3d_surface->forwardReference = container_parent;
return hr;
return D3D_OK;
}
static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
@ -3063,8 +3052,8 @@ static const struct wined3d_device_parent_ops d3d8_wined3d_device_parent_ops =
{
device_parent_wined3d_device_created,
device_parent_mode_changed,
device_parent_surface_created,
device_parent_create_swapchain_surface,
device_parent_create_texture_surface,
device_parent_create_volume,
device_parent_create_swapchain,
};

View File

@ -333,37 +333,17 @@ static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops =
surface_wined3d_object_destroyed,
};
HRESULT surface_init(struct d3d8_surface *surface, struct d3d8_device *device, UINT width, UINT height,
D3DFORMAT format, DWORD flags, DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type,
DWORD multisample_quality)
void surface_init(struct d3d8_surface *surface, struct wined3d_surface *wined3d_surface,
struct d3d8_device *device, const struct wined3d_parent_ops **parent_ops)
{
HRESULT hr;
surface->IDirect3DSurface8_iface.lpVtbl = &d3d8_surface_vtbl;
surface->refcount = 1;
/* FIXME: Check MAX bounds of MultisampleQuality. */
if (multisample_quality > 0)
{
FIXME("Multisample quality set to %u, substituting 0.\n", multisample_quality);
multisample_quality = 0;
}
wined3d_mutex_lock();
hr = wined3d_surface_create(device->wined3d_device, width, height, wined3dformat_from_d3dformat(format),
usage, (enum wined3d_pool)pool, multisample_type, multisample_quality,
flags, surface, &d3d8_surface_wined3d_parent_ops, &surface->wined3d_surface);
wined3d_mutex_unlock();
if (FAILED(hr))
{
WARN("Failed to create wined3d surface, hr %#x.\n", hr);
return hr;
}
wined3d_surface_incref(wined3d_surface);
surface->wined3d_surface = wined3d_surface;
surface->parent_device = &device->IDirect3DDevice8_iface;
IDirect3DDevice8_AddRef(surface->parent_device);
return D3D_OK;
*parent_ops = &d3d8_surface_wined3d_parent_ops;
}
struct d3d8_surface *unsafe_impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface)

View File

@ -201,9 +201,8 @@ struct d3d9_surface
BOOL getdc_supported;
};
HRESULT surface_init(struct d3d9_surface *surface, struct d3d9_device *device, UINT width, UINT height,
D3DFORMAT format, DWORD flags, DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type,
DWORD multisample_quality) DECLSPEC_HIDDEN;
void surface_init(struct d3d9_surface *surface, struct wined3d_surface *wined3d_surface,
struct d3d9_device *device, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
struct d3d9_surface *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) DECLSPEC_HIDDEN;
struct d3d9_vertexbuffer

View File

@ -3307,16 +3307,15 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic
TRACE("device_parent %p.\n", device_parent);
}
static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_parent *device_parent,
void *container_parent, const struct wined3d_resource_desc *desc, UINT sub_resource_idx,
DWORD flags, struct wined3d_surface **surface)
static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
void *container_parent, struct wined3d_surface *surface, void **parent,
const struct wined3d_parent_ops **parent_ops)
{
struct d3d9_device *device = device_from_device_parent(device_parent);
struct d3d9_surface *d3d_surface;
HRESULT hr;
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);
TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
device_parent, container_parent, surface, parent, parent_ops);
if (!(d3d_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*d3d_surface))))
{
@ -3324,20 +3323,10 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
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;
}
surface_init(d3d_surface, surface, device, parent_ops);
*parent = d3d_surface;
TRACE("Created surface %p.\n", d3d_surface);
*surface = d3d_surface->wined3d_surface;
wined3d_surface_incref(*surface);
d3d_surface->container = container_parent;
IDirect3DDevice9Ex_Release(d3d_surface->parent_device);
d3d_surface->parent_device = NULL;
@ -3345,7 +3334,7 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
IDirect3DSurface9_Release(&d3d_surface->IDirect3DSurface9_iface);
d3d_surface->forwardReference = container_parent;
return hr;
return D3D_OK;
}
static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
@ -3453,8 +3442,8 @@ static const struct wined3d_device_parent_ops d3d9_wined3d_device_parent_ops =
{
device_parent_wined3d_device_created,
device_parent_mode_changed,
device_parent_surface_created,
device_parent_create_swapchain_surface,
device_parent_create_texture_surface,
device_parent_create_volume,
device_parent_create_swapchain,
};

View File

@ -393,16 +393,16 @@ static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops =
surface_wined3d_object_destroyed,
};
HRESULT surface_init(struct d3d9_surface *surface, struct d3d9_device *device, UINT width, UINT height,
D3DFORMAT format, DWORD flags, DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type,
DWORD multisample_quality)
void surface_init(struct d3d9_surface *surface, struct wined3d_surface *wined3d_surface,
struct d3d9_device *device, const struct wined3d_parent_ops **parent_ops)
{
HRESULT hr;
struct wined3d_resource_desc desc;
surface->IDirect3DSurface9_iface.lpVtbl = &d3d9_surface_vtbl;
surface->refcount = 1;
switch (format)
wined3d_resource_get_desc(wined3d_surface_get_resource(wined3d_surface), &desc);
switch (d3dformat_from_wined3dformat(desc.format))
{
case D3DFMT_A8R8G8B8:
case D3DFMT_X8R8G8B8:
@ -418,28 +418,12 @@ HRESULT surface_init(struct d3d9_surface *surface, struct d3d9_device *device, U
break;
}
/* FIXME: Check MAX bounds of MultisampleQuality. */
if (multisample_quality > 0)
{
FIXME("Multisample quality set to %u, substituting 0.\n", multisample_quality);
multisample_quality = 0;
}
wined3d_mutex_lock();
hr = wined3d_surface_create(device->wined3d_device, width, height, wined3dformat_from_d3dformat(format),
usage, (enum wined3d_pool)pool, multisample_type, multisample_quality,
flags, surface, &d3d9_surface_wined3d_parent_ops, &surface->wined3d_surface);
wined3d_mutex_unlock();
if (FAILED(hr))
{
WARN("Failed to create wined3d surface, hr %#x.\n", hr);
return hr;
}
wined3d_surface_incref(wined3d_surface);
surface->wined3d_surface = wined3d_surface;
surface->parent_device = &device->IDirect3DDevice9Ex_iface;
IDirect3DDevice9Ex_AddRef(surface->parent_device);
return D3D_OK;
*parent_ops = &d3d9_surface_wined3d_parent_ops;
}
struct d3d9_surface *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface)

View File

@ -2722,37 +2722,6 @@ static HRESULT WINAPI ddraw7_StartModeTest(IDirectDraw7 *iface, SIZE *Modes, DWO
return DD_OK;
}
static HRESULT ddraw_create_surface(struct ddraw *ddraw, struct ddraw_texture *texture,
const struct wined3d_resource_desc *wined3d_desc, DWORD flags, struct ddraw_surface **surface)
{
HRESULT hr;
TRACE("ddraw %p, texture %p, wined3d_desc %p, flags %#x, surface %p.\n",
ddraw, texture, wined3d_desc, flags, surface);
/* Create the Surface object */
*surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(**surface));
if (!*surface)
{
ERR("Failed to allocate surface memory.\n");
return DDERR_OUTOFVIDEOMEMORY;
}
if (FAILED(hr = ddraw_surface_init(*surface, ddraw, texture, wined3d_desc, flags)))
{
WARN("Failed to initialize surface, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, *surface);
return hr;
}
/* Increase the surface counter, and attach the surface */
list_add_head(&ddraw->surface_list, &(*surface)->surface_list_entry);
TRACE("Created surface %p.\n", *surface);
return DD_OK;
}
/*****************************************************************************
* IDirectDraw7::CreateSurface
*
@ -4968,30 +4937,43 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic
ERR("Failed to resize window.\n");
}
static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_parent *device_parent,
void *container_parent, const struct wined3d_resource_desc *wined3d_desc, UINT sub_resource_idx,
DWORD flags, struct wined3d_surface **surface)
static HRESULT CDECL device_parent_surface_created(struct wined3d_device_parent *device_parent,
void *container_parent, struct wined3d_surface *surface,
void **parent, const struct wined3d_parent_ops **parent_ops)
{
struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
struct ddraw_surface *ddraw_surface;
HRESULT hr;
TRACE("device_parent %p, container_parent %p, wined3d_desc %p, sub_resource_idx %u, flags %#x, surface %p.\n",
device_parent, container_parent, wined3d_desc, sub_resource_idx, flags, surface);
TRACE("device_parent %p, container_parent %p, surface %p, parent %p, parent_ops %p.\n",
device_parent, container_parent, surface, parent, parent_ops);
/* We have a swapchain texture. */
if (container_parent == ddraw)
return wined3d_surface_create(ddraw->wined3d_device, wined3d_desc->width, wined3d_desc->height,
wined3d_desc->format, wined3d_desc->usage, wined3d_desc->pool, wined3d_desc->multisample_type,
wined3d_desc->multisample_quality, WINED3D_SURFACE_MAPPABLE, NULL,
&ddraw_null_wined3d_parent_ops, surface);
{
*parent = NULL;
*parent_ops = &ddraw_null_wined3d_parent_ops;
/* FIXME: Validate that format, usage, pool, etc. really make sense. */
if (FAILED(hr = ddraw_create_surface(ddraw, container_parent, wined3d_desc, flags, &ddraw_surface)))
return DD_OK;
}
if (!(ddraw_surface = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*ddraw_surface))))
{
ERR("Failed to allocate surface memory.\n");
return DDERR_OUTOFVIDEOMEMORY;
}
if (FAILED(hr = ddraw_surface_init(ddraw_surface, ddraw, container_parent, surface, parent_ops)))
{
WARN("Failed to initialize surface, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, ddraw_surface);
return hr;
}
*surface = ddraw_surface->wined3d_surface;
wined3d_surface_incref(*surface);
*parent = ddraw_surface;
list_add_head(&ddraw->surface_list, &ddraw_surface->surface_list_entry);
TRACE("Created ddraw surface %p.\n", ddraw_surface);
return DD_OK;
}
@ -5081,8 +5063,8 @@ static const struct wined3d_device_parent_ops ddraw_wined3d_device_parent_ops =
{
device_parent_wined3d_device_created,
device_parent_mode_changed,
device_parent_surface_created,
device_parent_create_swapchain_surface,
device_parent_create_texture_surface,
device_parent_create_volume,
device_parent_create_swapchain,
};

View File

@ -196,7 +196,7 @@ struct ddraw_texture
HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
unsigned int version, struct ddraw_surface **surface) DECLSPEC_HIDDEN;
HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture,
const struct wined3d_resource_desc *wined3d_desc, DWORD flags) DECLSPEC_HIDDEN;
struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops) DECLSPEC_HIDDEN;
ULONG ddraw_surface_release_iface(struct ddraw_surface *This) DECLSPEC_HIDDEN;
static inline struct ddraw_surface *impl_from_IDirect3DTexture(IDirect3DTexture *iface)

View File

@ -5901,9 +5901,10 @@ HRESULT ddraw_surface_create_texture(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
}
HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, struct ddraw_texture *texture,
const struct wined3d_resource_desc *wined3d_desc, DWORD flags)
struct wined3d_surface *wined3d_surface, const struct wined3d_parent_ops **parent_ops)
{
DDSURFACEDESC2 *desc = &surface->surface_desc;
struct wined3d_resource_desc wined3d_desc;
unsigned int version = texture->version;
HRESULT hr;
@ -5936,27 +5937,19 @@ HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, s
}
*desc = texture->surface_desc;
desc->dwWidth = wined3d_desc->width;
desc->dwHeight = wined3d_desc->height;
wined3d_resource_get_desc(wined3d_surface_get_resource(wined3d_surface), &wined3d_desc);
desc->dwWidth = wined3d_desc.width;
desc->dwHeight = wined3d_desc.height;
surface->first_attached = surface;
if (FAILED(hr = wined3d_surface_create(ddraw->wined3d_device, wined3d_desc->width, wined3d_desc->height,
wined3d_desc->format, wined3d_desc->usage, wined3d_desc->pool, wined3d_desc->multisample_type,
wined3d_desc->multisample_quality, flags, surface, &ddraw_surface_wined3d_parent_ops,
&surface->wined3d_surface)))
{
WARN("Failed to create wined3d surface, hr %#x.\n", hr);
return hr;
}
/* Anno 1602 stores the pitch right after surface creation, so make sure
* it's there. TODO: Test other fourcc formats. */
if (wined3d_desc->format == WINED3DFMT_DXT1 || wined3d_desc->format == WINED3DFMT_DXT2
|| wined3d_desc->format == WINED3DFMT_DXT3 || wined3d_desc->format == WINED3DFMT_DXT4
|| wined3d_desc->format == WINED3DFMT_DXT5)
if (wined3d_desc.format == WINED3DFMT_DXT1 || wined3d_desc.format == WINED3DFMT_DXT2
|| wined3d_desc.format == WINED3DFMT_DXT3 || wined3d_desc.format == WINED3DFMT_DXT4
|| wined3d_desc.format == WINED3DFMT_DXT5)
{
surface->surface_desc.dwFlags |= DDSD_LINEARSIZE;
if (wined3d_desc->format == WINED3DFMT_DXT1)
if (wined3d_desc.format == WINED3DFMT_DXT1)
surface->surface_desc.u1.dwLinearSize = max(4, desc->dwWidth) * max(4, desc->dwHeight) / 2;
else
surface->surface_desc.u1.dwLinearSize = max(4, desc->dwWidth) * max(4, desc->dwHeight);
@ -5964,27 +5957,27 @@ HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, s
else
{
surface->surface_desc.dwFlags |= DDSD_PITCH;
surface->surface_desc.u1.lPitch = wined3d_surface_get_pitch(surface->wined3d_surface);
surface->surface_desc.u1.lPitch = wined3d_surface_get_pitch(wined3d_surface);
}
if (desc->dwFlags & DDSD_CKDESTOVERLAY)
{
wined3d_surface_set_color_key(surface->wined3d_surface, DDCKEY_DESTOVERLAY,
wined3d_surface_set_color_key(wined3d_surface, DDCKEY_DESTOVERLAY,
(struct wined3d_color_key *)&desc->u3.ddckCKDestOverlay);
}
if (desc->dwFlags & DDSD_CKDESTBLT)
{
wined3d_surface_set_color_key(surface->wined3d_surface, DDCKEY_DESTBLT,
wined3d_surface_set_color_key(wined3d_surface, DDCKEY_DESTBLT,
(struct wined3d_color_key *)&desc->ddckCKDestBlt);
}
if (desc->dwFlags & DDSD_CKSRCOVERLAY)
{
wined3d_surface_set_color_key(surface->wined3d_surface, DDCKEY_SRCOVERLAY,
wined3d_surface_set_color_key(wined3d_surface, DDCKEY_SRCOVERLAY,
(struct wined3d_color_key *)&desc->ddckCKSrcOverlay);
}
if (desc->dwFlags & DDSD_CKSRCBLT)
{
wined3d_surface_set_color_key(surface->wined3d_surface, DDCKEY_SRCBLT,
wined3d_surface_set_color_key(wined3d_surface, DDCKEY_SRCBLT,
(struct wined3d_color_key *)&desc->ddckCKSrcBlt);
}
if (desc->dwFlags & DDSD_LPSURFACE)
@ -5997,13 +5990,16 @@ HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, s
surface->surface_desc.u1.lPitch = pitch;
}
if (FAILED(hr = wined3d_surface_set_mem(surface->wined3d_surface, desc->lpSurface, pitch)))
if (FAILED(hr = wined3d_surface_set_mem(wined3d_surface, desc->lpSurface, pitch)))
{
ERR("Failed to set surface memory, hr %#x.\n", hr);
wined3d_surface_decref(surface->wined3d_surface);
return hr;
}
}
wined3d_surface_incref(wined3d_surface);
surface->wined3d_surface = wined3d_surface;
*parent_ops = &ddraw_surface_wined3d_parent_ops;
return DD_OK;
}

View File

@ -6769,7 +6769,7 @@ cpu:
static HRESULT surface_init(struct wined3d_surface *surface, UINT alignment, UINT width, UINT height,
enum wined3d_multisample_type multisample_type, UINT multisample_quality,
struct wined3d_device *device, DWORD usage, enum wined3d_format_id format_id,
enum wined3d_pool pool, DWORD flags, void *parent, const struct wined3d_parent_ops *parent_ops)
enum wined3d_pool pool, DWORD flags)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
@ -6822,10 +6822,9 @@ static HRESULT surface_init(struct wined3d_surface *surface, UINT alignment, UIN
else
surface->surface_ops = &surface_ops;
hr = resource_init(&surface->resource, device, WINED3D_RTYPE_SURFACE, format,
if (FAILED(hr = resource_init(&surface->resource, device, WINED3D_RTYPE_SURFACE, format,
multisample_type, multisample_quality, usage, pool, width, height, 1,
resource_size, parent, parent_ops, &surface_resource_ops);
if (FAILED(hr))
resource_size, NULL, &wined3d_null_parent_ops, &surface_resource_ops)))
{
WARN("Failed to initialize resource, returning %#x.\n", hr);
return hr;
@ -6884,33 +6883,46 @@ static HRESULT surface_init(struct wined3d_surface *surface, UINT alignment, UIN
return hr;
}
HRESULT CDECL wined3d_surface_create(struct wined3d_device *device, UINT width, UINT height,
enum wined3d_format_id format_id, DWORD usage, enum wined3d_pool pool,
HRESULT CDECL wined3d_surface_create(struct wined3d_device *device, void *container_parent,
UINT width, UINT height, enum wined3d_format_id format_id, DWORD usage, enum wined3d_pool pool,
enum wined3d_multisample_type multisample_type, DWORD multisample_quality, DWORD flags,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_surface **surface)
struct wined3d_surface **surface)
{
const struct wined3d_parent_ops *parent_ops;
struct wined3d_surface *object;
void *parent;
HRESULT hr;
TRACE("device %p, width %u, height %u, format %s\n",
device, width, height, debug_d3dformat(format_id));
TRACE("device %p, container_parent %p, width %u, height %u, format %s\n",
device, container_parent, width, height, debug_d3dformat(format_id));
TRACE("surface %p, usage %s (%#x), pool %s, multisample_type %#x, multisample_quality %u\n",
surface, debug_d3dusage(usage), usage, debug_d3dpool(pool), multisample_type, multisample_quality);
TRACE("flags %#x, parent %p, parent_ops %p.\n", flags, parent, parent_ops);
TRACE("flags %#x.\n", flags);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
return WINED3DERR_OUTOFVIDEOMEMORY;
if (FAILED(hr = surface_init(object, device->surface_alignment, width, height, multisample_type,
multisample_quality, device, usage, format_id, pool, flags, parent, parent_ops)))
multisample_quality, device, usage, format_id, pool, flags)))
{
WARN("Failed to initialize surface, returning %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
return hr;
}
TRACE("Created surface %p.\n", object);
if (FAILED(hr = device->device_parent->ops->surface_created(device->device_parent,
container_parent, object, &parent, &parent_ops)))
{
WARN("Failed to create surface parent, hr %#x.\n", hr);
wined3d_surface_decref(object);
return hr;
}
TRACE("Created surface %p, parent %p, parent_ops %p.\n", object, parent, parent_ops);
object->resource.parent = parent;
object->resource.parent_ops = parent_ops;
*surface = object;
return hr;

View File

@ -860,10 +860,11 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, const struct wi
UINT idx = j * texture->level_count + i;
struct wined3d_surface *surface;
if (FAILED(hr = device->device_parent->ops->create_texture_surface(device->device_parent,
parent, &surface_desc, idx, surface_flags, &surface)))
if (FAILED(hr = wined3d_surface_create(device, parent, surface_desc.width, surface_desc.height,
surface_desc.format, surface_desc.usage, surface_desc.pool, surface_desc.multisample_type,
surface_desc.multisample_quality, surface_flags, &surface)))
{
FIXME("(%p) Failed to create surface, hr %#x.\n", texture, hr);
WARN("Failed to create surface, hr %#x.\n", hr);
wined3d_texture_cleanup(texture);
return hr;
}
@ -1016,11 +1017,11 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
{
struct wined3d_surface *surface;
/* Use the callback to create the texture surface. */
if (FAILED(hr = device->device_parent->ops->create_texture_surface(device->device_parent,
parent, &surface_desc, i, surface_flags, &surface)))
if (FAILED(hr = wined3d_surface_create(device, parent, surface_desc.width, surface_desc.height,
surface_desc.format, surface_desc.usage, surface_desc.pool, surface_desc.multisample_type,
surface_desc.multisample_quality, surface_flags, &surface)))
{
FIXME("Failed to create surface %p, hr %#x\n", texture, hr);
WARN("Failed to create surface, hr %#x.\n", hr);
wined3d_texture_cleanup(texture);
return hr;
}

View File

@ -205,7 +205,6 @@
@ cdecl wined3d_stateblock_incref(ptr)
@ cdecl wined3d_surface_blt(ptr ptr ptr ptr long ptr long)
@ cdecl wined3d_surface_create(ptr long long long long long long long long ptr ptr ptr)
@ cdecl wined3d_surface_decref(ptr)
@ cdecl wined3d_surface_flip(ptr ptr long)
@ cdecl wined3d_surface_from_resource(ptr)

View File

@ -2273,6 +2273,10 @@ void surface_update_draw_binding(struct wined3d_surface *surface) DECLSPEC_HIDDE
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;
HRESULT wined3d_surface_create(struct wined3d_device *device, void *container_parent,
UINT width, UINT height, enum wined3d_format_id format_id, DWORD usage, enum wined3d_pool pool,
enum wined3d_multisample_type multisample_type, DWORD multisample_quality, DWORD flags,
struct wined3d_surface **surface) DECLSPEC_HIDDEN;
void get_drawable_size_swapchain(const struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;
void get_drawable_size_backbuffer(const struct wined3d_context *context, UINT *width, UINT *height) DECLSPEC_HIDDEN;

View File

@ -1980,11 +1980,10 @@ struct wined3d_device_parent_ops
{
void (__cdecl *wined3d_device_created)(struct wined3d_device_parent *device_parent, struct wined3d_device *device);
void (__cdecl *mode_changed)(struct wined3d_device_parent *device_parent);
HRESULT (__cdecl *surface_created)(struct wined3d_device_parent *device_parent, void *container_parent,
struct wined3d_surface *surface, void **parent, const struct wined3d_parent_ops **parent_ops);
HRESULT (__cdecl *create_swapchain_surface)(struct wined3d_device_parent *device_parent, void *container_parent,
const struct wined3d_resource_desc *desc, struct wined3d_surface **surface);
HRESULT (__cdecl *create_texture_surface)(struct wined3d_device_parent *device_parent, void *container_parent,
const struct wined3d_resource_desc *desc, UINT sub_resource_idx, DWORD flags,
struct wined3d_surface **surface);
HRESULT (__cdecl *create_volume)(struct wined3d_device_parent *device_parent, void *container_parent,
UINT width, UINT height, UINT depth, UINT level, enum wined3d_format_id format_id,
enum wined3d_pool pool, DWORD usage, struct wined3d_volume **volume);
@ -2304,10 +2303,6 @@ ULONG __cdecl wined3d_stateblock_incref(struct wined3d_stateblock *stateblock);
HRESULT __cdecl wined3d_surface_blt(struct wined3d_surface *dst_surface, const RECT *dst_rect,
struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
const WINEDDBLTFX *blt_fx, enum wined3d_texture_filter_type filter);
HRESULT __cdecl wined3d_surface_create(struct wined3d_device *device, UINT width, UINT height,
enum wined3d_format_id format_id, DWORD usage, enum wined3d_pool pool,
enum wined3d_multisample_type multisample_type, DWORD multisample_quality, DWORD flags,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_surface **surface);
ULONG __cdecl wined3d_surface_decref(struct wined3d_surface *surface);
HRESULT __cdecl wined3d_surface_flip(struct wined3d_surface *surface, struct wined3d_surface *override, DWORD flags);
struct wined3d_surface * __cdecl wined3d_surface_from_resource(struct wined3d_resource *resource);