Commit d6bc4fe7 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Allow surface flags to be passed to texture creation functions.

parent 91096dd7
......@@ -1832,15 +1832,15 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic
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,
struct wined3d_surface **surface)
DWORD flags, struct wined3d_surface **surface)
{
struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
TRACE("device_parent %p, container_parent %p, desc %p, sub_resource_idx %u, surface %p.\n",
device_parent, container_parent, desc, sub_resource_idx, surface);
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);
return wined3d_surface_create(device->wined3d_device, desc->width, desc->height, desc->format,
desc->usage, desc->pool, desc->multisample_type, desc->multisample_quality, 0,
desc->usage, desc->pool, desc->multisample_type, desc->multisample_quality, flags,
container_parent, &d3d10_null_wined3d_parent_ops, surface);
}
......
......@@ -276,7 +276,7 @@ HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d10_devic
wined3d_desc.size = 0;
if (FAILED(hr = wined3d_texture_create_2d(device->wined3d_device, &wined3d_desc, desc->MipLevels,
texture, &d3d10_texture2d_wined3d_parent_ops, &texture->wined3d_texture)))
0, texture, &d3d10_texture2d_wined3d_parent_ops, &texture->wined3d_texture)))
{
WARN("Failed to create wined3d texture, hr %#x.\n", hr);
if (texture->dxgi_surface)
......
......@@ -212,8 +212,8 @@ struct d3d8_surface
};
HRESULT surface_init(struct d3d8_surface *surface, struct d3d8_device *device, UINT width, UINT height,
D3DFORMAT format, BOOL lockable, BOOL discard, DWORD usage, D3DPOOL pool,
D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality) DECLSPEC_HIDDEN;
D3DFORMAT format, DWORD flags, DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type,
DWORD multisample_quality) DECLSPEC_HIDDEN;
struct d3d8_surface *unsafe_impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface) DECLSPEC_HIDDEN;
struct d3d8_vertexbuffer
......
......@@ -853,15 +853,15 @@ static HRESULT WINAPI d3d8_device_CreateIndexBuffer(IDirect3DDevice8 *iface, UIN
}
static HRESULT d3d8_device_create_surface(struct d3d8_device *device, UINT width, UINT height,
D3DFORMAT format, BOOL lockable, BOOL discard, IDirect3DSurface8 **surface, UINT usage,
D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality)
D3DFORMAT format, DWORD flags, IDirect3DSurface8 **surface, UINT usage, D3DPOOL pool,
D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality)
{
struct d3d8_surface *object;
HRESULT hr;
TRACE("device %p, width %u, height %u, format %#x, lockable %#x, discard %#x, surface %p,\n"
TRACE("device %p, width %u, height %u, format %#x, flags %#x, surface %p,\n"
"\tusage %#x, pool %#x, multisample_type %#x, multisample_quality %u.\n",
device, width, height, format, lockable, discard, surface,
device, width, height, format, flags, surface,
usage, pool, multisample_type, multisample_quality);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
......@@ -870,8 +870,8 @@ static HRESULT d3d8_device_create_surface(struct d3d8_device *device, UINT width
return D3DERR_OUTOFVIDEOMEMORY;
}
if (FAILED(hr = surface_init(object, device, width, height, format, lockable,
discard, usage, pool, multisample_type, multisample_quality)))
if (FAILED(hr = surface_init(object, device, width, height, format,
flags, usage, pool, multisample_type, multisample_quality)))
{
WARN("Failed to initialize surface, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
......@@ -889,12 +889,16 @@ static HRESULT WINAPI d3d8_device_CreateRenderTarget(IDirect3DDevice8 *iface, UI
IDirect3DSurface8 **surface)
{
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
DWORD flags = 0;
TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, lockable %#x, surface %p.\n",
iface, width, height, format, multisample_type, lockable, surface);
return d3d8_device_create_surface(device, width, height, format, lockable, FALSE,
surface, D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT, multisample_type, 0);
if (lockable)
flags |= WINED3D_SURFACE_MAPPABLE;
return d3d8_device_create_surface(device, width, height, format, flags, surface,
D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT, multisample_type, 0);
}
static HRESULT WINAPI d3d8_device_CreateDepthStencilSurface(IDirect3DDevice8 *iface,
......@@ -907,7 +911,7 @@ static HRESULT WINAPI d3d8_device_CreateDepthStencilSurface(IDirect3DDevice8 *if
iface, width, height, format, multisample_type, surface);
/* TODO: Verify that Discard is false */
return d3d8_device_create_surface(device, width, height, format, TRUE, FALSE,
return d3d8_device_create_surface(device, width, height, format, WINED3D_SURFACE_MAPPABLE,
surface, D3DUSAGE_DEPTHSTENCIL, D3DPOOL_DEFAULT, multisample_type, 0);
}
......@@ -920,7 +924,7 @@ static HRESULT WINAPI d3d8_device_CreateImageSurface(IDirect3DDevice8 *iface, UI
TRACE("iface %p, width %u, height %u, format %#x, surface %p.\n",
iface, width, height, format, surface);
return d3d8_device_create_surface(device, width, height, format, TRUE, FALSE,
return d3d8_device_create_surface(device, width, height, format, WINED3D_SURFACE_MAPPABLE,
surface, 0, D3DPOOL_SYSTEMMEM, D3DMULTISAMPLE_NONE, 0);
}
......@@ -2879,21 +2883,17 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic
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,
struct wined3d_surface **surface)
DWORD flags, struct wined3d_surface **surface)
{
struct d3d8_device *device = device_from_device_parent(device_parent);
struct d3d8_surface *d3d_surface;
BOOL lockable = TRUE;
HRESULT hr;
TRACE("device_parent %p, container_parent %p, desc %p, sub_resource_idx %u, surface %p.\n",
device_parent, container_parent, desc, sub_resource_idx, surface);
if (desc->pool == WINED3D_POOL_DEFAULT && !(desc->usage & WINED3DUSAGE_DYNAMIC))
lockable = FALSE;
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), lockable, FALSE, (IDirect3DSurface8 **)&d3d_surface,
d3dformat_from_wined3dformat(desc->format), flags, (IDirect3DSurface8 **)&d3d_surface,
desc->usage, desc->pool, desc->multisample_type, desc->multisample_quality)))
{
WARN("Failed to create surface, hr %#x.\n", hr);
......@@ -2924,7 +2924,7 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
device_parent, container_parent, desc, surface);
if (FAILED(hr = d3d8_device_create_surface(device, desc->width, desc->height,
d3dformat_from_wined3dformat(desc->format), TRUE, FALSE, (IDirect3DSurface8 **)&d3d_surface,
d3dformat_from_wined3dformat(desc->format), WINED3D_SURFACE_MAPPABLE, (IDirect3DSurface8 **)&d3d_surface,
desc->usage, desc->pool, desc->multisample_type, desc->multisample_quality)))
{
WARN("Failed to create surface, hr %#x.\n", hr);
......
......@@ -326,10 +326,9 @@ static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops =
};
HRESULT surface_init(struct d3d8_surface *surface, struct d3d8_device *device, UINT width, UINT height,
D3DFORMAT format, BOOL lockable, BOOL discard, DWORD usage, D3DPOOL pool,
D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality)
D3DFORMAT format, DWORD flags, DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type,
DWORD multisample_quality)
{
DWORD flags = 0;
HRESULT hr;
surface->IDirect3DSurface8_iface.lpVtbl = &d3d8_surface_vtbl;
......@@ -342,11 +341,6 @@ HRESULT surface_init(struct d3d8_surface *surface, struct d3d8_device *device, U
multisample_quality = 0;
}
if (lockable)
flags |= WINED3D_SURFACE_MAPPABLE;
if (discard)
flags |= WINED3D_SURFACE_DISCARD;
wined3d_mutex_lock();
hr = wined3d_surface_create(device->wined3d_device, width, height, wined3dformat_from_d3dformat(format),
usage & WINED3DUSAGE_MASK, (enum wined3d_pool)pool, multisample_type, multisample_quality,
......
......@@ -1186,6 +1186,7 @@ HRESULT texture_init(struct d3d8_texture *texture, struct d3d8_device *device,
UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
{
struct wined3d_resource_desc desc;
DWORD surface_flags = 0;
HRESULT hr;
texture->IDirect3DBaseTexture8_iface.lpVtbl = (const IDirect3DBaseTexture8Vtbl *)&Direct3DTexture8_Vtbl;
......@@ -1202,8 +1203,11 @@ HRESULT texture_init(struct d3d8_texture *texture, struct d3d8_device *device,
desc.depth = 1;
desc.size = 0;
if (pool != D3DPOOL_DEFAULT || (usage & D3DUSAGE_DYNAMIC))
surface_flags |= WINED3D_SURFACE_MAPPABLE;
wined3d_mutex_lock();
hr = wined3d_texture_create_2d(device->wined3d_device, &desc, levels,
hr = wined3d_texture_create_2d(device->wined3d_device, &desc, levels, surface_flags,
texture, &d3d8_texture_wined3d_parent_ops, &texture->wined3d_texture);
wined3d_mutex_unlock();
if (FAILED(hr))
......@@ -1222,6 +1226,7 @@ HRESULT cubetexture_init(struct d3d8_texture *texture, struct d3d8_device *devic
UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
{
struct wined3d_resource_desc desc;
DWORD surface_flags = 0;
HRESULT hr;
texture->IDirect3DBaseTexture8_iface.lpVtbl = (const IDirect3DBaseTexture8Vtbl *)&Direct3DCubeTexture8_Vtbl;
......@@ -1238,8 +1243,11 @@ HRESULT cubetexture_init(struct d3d8_texture *texture, struct d3d8_device *devic
desc.depth = 1;
desc.size = 0;
if (pool != D3DPOOL_DEFAULT || (usage & D3DUSAGE_DYNAMIC))
surface_flags |= WINED3D_SURFACE_MAPPABLE;
wined3d_mutex_lock();
hr = wined3d_texture_create_cube(device->wined3d_device, &desc, levels,
hr = wined3d_texture_create_cube(device->wined3d_device, &desc, levels, surface_flags,
texture, &d3d8_texture_wined3d_parent_ops, &texture->wined3d_texture);
wined3d_mutex_unlock();
if (FAILED(hr))
......
......@@ -201,8 +201,8 @@ struct d3d9_surface
};
HRESULT surface_init(struct d3d9_surface *surface, struct d3d9_device *device, UINT width, UINT height,
D3DFORMAT format, BOOL lockable, BOOL discard, DWORD usage, D3DPOOL pool,
D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality) DECLSPEC_HIDDEN;
D3DFORMAT format, DWORD flags, DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type,
DWORD multisample_quality) DECLSPEC_HIDDEN;
struct d3d9_surface *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) DECLSPEC_HIDDEN;
struct d3d9_vertexbuffer
......
......@@ -891,15 +891,15 @@ static HRESULT WINAPI d3d9_device_CreateIndexBuffer(IDirect3DDevice9Ex *iface, U
}
static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width, UINT height,
D3DFORMAT format, BOOL lockable, BOOL discard, IDirect3DSurface9 **surface, UINT usage,
D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality)
D3DFORMAT format, DWORD flags, IDirect3DSurface9 **surface, UINT usage, D3DPOOL pool,
D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality)
{
struct d3d9_surface *object;
HRESULT hr;
TRACE("device %p, width %u, height %u, format %#x, lockable %#x, discard %#x, surface %p.\n"
TRACE("device %p, width %u, height %u, format %#x, flags %#x, surface %p.\n"
"usage %#x, pool %#x, multisample_type %#x, multisample_quality %u.\n",
device, width, height, format, lockable, discard, surface, usage, pool,
device, width, height, format, flags, surface, usage, pool,
multisample_type, multisample_quality);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
......@@ -908,8 +908,8 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width
return D3DERR_OUTOFVIDEOMEMORY;
}
if (FAILED(hr = surface_init(object, device, width, height, format, lockable,
discard, usage, pool, multisample_type, multisample_quality)))
if (FAILED(hr = surface_init(object, device, width, height, format,
flags, usage, pool, multisample_type, multisample_quality)))
{
WARN("Failed to initialize surface, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
......@@ -927,6 +927,7 @@ static HRESULT WINAPI d3d9_device_CreateRenderTarget(IDirect3DDevice9Ex *iface,
BOOL lockable, IDirect3DSurface9 **surface, HANDLE *shared_handle)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
DWORD flags = 0;
TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u.\n"
"lockable %#x, surface %p, shared_handle %p.\n",
......@@ -936,7 +937,10 @@ static HRESULT WINAPI d3d9_device_CreateRenderTarget(IDirect3DDevice9Ex *iface,
if (shared_handle)
FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle);
return d3d9_device_create_surface(device, width, height, format, lockable, FALSE, surface,
if (lockable)
flags |= WINED3D_SURFACE_MAPPABLE;
return d3d9_device_create_surface(device, width, height, format, flags, surface,
D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT, multisample_type, multisample_quality);
}
......@@ -945,6 +949,7 @@ static HRESULT WINAPI d3d9_device_CreateDepthStencilSurface(IDirect3DDevice9Ex *
BOOL discard, IDirect3DSurface9 **surface, HANDLE *shared_handle)
{
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
DWORD flags = WINED3D_SURFACE_MAPPABLE;
TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u.\n"
"discard %#x, surface %p, shared_handle %p.\n",
......@@ -954,7 +959,10 @@ static HRESULT WINAPI d3d9_device_CreateDepthStencilSurface(IDirect3DDevice9Ex *
if (shared_handle)
FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle);
return d3d9_device_create_surface(device, width, height, format, TRUE, discard, surface,
if (discard)
flags |= WINED3D_SURFACE_DISCARD;
return d3d9_device_create_surface(device, width, height, format, flags, surface,
D3DUSAGE_DEPTHSTENCIL, D3DPOOL_DEFAULT, multisample_type, multisample_quality);
}
......@@ -1155,8 +1163,8 @@ static HRESULT WINAPI d3d9_device_CreateOffscreenPlainSurface(IDirect3DDevice9Ex
/* FIXME: Offscreen surfaces are supposed to be always lockable,
* regardless of the pool they're created in. Should we set dynamic usage
* here? */
return d3d9_device_create_surface(device, width, height, format, TRUE,
FALSE, surface, 0, pool, D3DMULTISAMPLE_NONE, 0);
return d3d9_device_create_surface(device, width, height, format,
WINED3D_SURFACE_MAPPABLE, surface, 0, pool, D3DMULTISAMPLE_NONE, 0);
}
static HRESULT WINAPI d3d9_device_SetRenderTarget(IDirect3DDevice9Ex *iface, DWORD idx, IDirect3DSurface9 *surface)
......@@ -3260,21 +3268,17 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic
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,
struct wined3d_surface **surface)
DWORD flags, struct wined3d_surface **surface)
{
struct d3d9_device *device = device_from_device_parent(device_parent);
struct d3d9_surface *d3d_surface;
BOOL lockable = TRUE;
HRESULT hr;
TRACE("device_parent %p, container_parent %p, desc %p, sub_resource_idx %u, surface %p.\n",
device_parent, container_parent, desc, sub_resource_idx, surface);
if (desc->pool == WINED3D_POOL_DEFAULT && !(desc->usage & WINED3DUSAGE_DYNAMIC))
lockable = FALSE;
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 = d3d9_device_create_surface(device, desc->width, desc->height,
d3dformat_from_wined3dformat(desc->format), lockable, FALSE, (IDirect3DSurface9 **)&d3d_surface,
d3dformat_from_wined3dformat(desc->format), flags, (IDirect3DSurface9 **)&d3d_surface,
desc->usage, desc->pool, desc->multisample_type, desc->multisample_quality)))
{
WARN("Failed to create surface, hr %#x.\n", hr);
......@@ -3305,7 +3309,7 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
device_parent, container_parent, desc, surface);
if (FAILED(hr = d3d9_device_create_surface(device, desc->width, desc->height,
d3dformat_from_wined3dformat(desc->format), TRUE, FALSE, (IDirect3DSurface9 **)&d3d_surface,
d3dformat_from_wined3dformat(desc->format), WINED3D_SURFACE_MAPPABLE, (IDirect3DSurface9 **)&d3d_surface,
desc->usage, desc->pool, desc->multisample_type, desc->multisample_quality)))
{
WARN("Failed to create surface, hr %#x.\n", hr);
......
......@@ -391,10 +391,9 @@ static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops =
};
HRESULT surface_init(struct d3d9_surface *surface, struct d3d9_device *device, UINT width, UINT height,
D3DFORMAT format, BOOL lockable, BOOL discard, DWORD usage, D3DPOOL pool,
D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality)
D3DFORMAT format, DWORD flags, DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type,
DWORD multisample_quality)
{
DWORD flags = 0;
HRESULT hr;
surface->IDirect3DSurface9_iface.lpVtbl = &d3d9_surface_vtbl;
......@@ -423,11 +422,6 @@ HRESULT surface_init(struct d3d9_surface *surface, struct d3d9_device *device, U
multisample_quality = 0;
}
if (lockable)
flags |= WINED3D_SURFACE_MAPPABLE;
if (discard)
flags |= WINED3D_SURFACE_DISCARD;
wined3d_mutex_lock();
hr = wined3d_surface_create(device->wined3d_device, width, height, wined3dformat_from_d3dformat(format),
usage & WINED3DUSAGE_MASK, (enum wined3d_pool)pool, multisample_type, multisample_quality,
......
......@@ -1310,6 +1310,7 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device,
UINT width, UINT height, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
{
struct wined3d_resource_desc desc;
DWORD surface_flags = 0;
HRESULT hr;
texture->IDirect3DBaseTexture9_iface.lpVtbl = (const IDirect3DBaseTexture9Vtbl *)&d3d9_texture_2d_vtbl;
......@@ -1326,8 +1327,11 @@ HRESULT texture_init(struct d3d9_texture *texture, struct d3d9_device *device,
desc.depth = 1;
desc.size = 0;
if (pool != D3DPOOL_DEFAULT || (usage & D3DUSAGE_DYNAMIC))
surface_flags |= WINED3D_SURFACE_MAPPABLE;
wined3d_mutex_lock();
hr = wined3d_texture_create_2d(device->wined3d_device, &desc, levels,
hr = wined3d_texture_create_2d(device->wined3d_device, &desc, levels, surface_flags,
texture, &d3d9_texture_wined3d_parent_ops, &texture->wined3d_texture);
wined3d_mutex_unlock();
if (FAILED(hr))
......@@ -1346,6 +1350,7 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *devic
UINT edge_length, UINT levels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
{
struct wined3d_resource_desc desc;
DWORD surface_flags = 0;
HRESULT hr;
texture->IDirect3DBaseTexture9_iface.lpVtbl = (const IDirect3DBaseTexture9Vtbl *)&d3d9_texture_cube_vtbl;
......@@ -1362,8 +1367,11 @@ HRESULT cubetexture_init(struct d3d9_texture *texture, struct d3d9_device *devic
desc.depth = 1;
desc.size = 0;
if (pool != D3DPOOL_DEFAULT || (usage & D3DUSAGE_DYNAMIC))
surface_flags |= WINED3D_SURFACE_MAPPABLE;
wined3d_mutex_lock();
hr = wined3d_texture_create_cube(device->wined3d_device, &desc, levels,
hr = wined3d_texture_create_cube(device->wined3d_device, &desc, levels, surface_flags,
texture, &d3d9_texture_wined3d_parent_ops, &texture->wined3d_texture);
wined3d_mutex_unlock();
if (FAILED(hr))
......
......@@ -2471,20 +2471,20 @@ static HRESULT WINAPI ddraw7_StartModeTest(IDirectDraw7 *iface, SIZE *Modes, DWO
* DD_OK on success
*
*****************************************************************************/
static HRESULT ddraw_create_surface(struct ddraw *ddraw, DDSURFACEDESC2 *pDDSD,
struct ddraw_surface **surface, UINT version)
static HRESULT ddraw_create_surface(struct ddraw *ddraw, DDSURFACEDESC2 *desc,
DWORD flags, struct ddraw_surface **surface, UINT version)
{
HRESULT hr;
TRACE("ddraw %p, surface_desc %p, surface %p.\n", ddraw, pDDSD, surface);
TRACE("ddraw %p, desc %p, flags %#x, surface %p.\n", ddraw, desc, flags, surface);
if (TRACE_ON(ddraw))
{
TRACE("Requesting surface desc:\n");
DDRAW_dump_surface_desc(pDDSD);
DDRAW_dump_surface_desc(desc);
}
if ((pDDSD->ddsCaps.dwCaps & DDSCAPS_3DDEVICE) && (ddraw->flags & DDRAW_NO3D))
if ((desc->ddsCaps.dwCaps & DDSCAPS_3DDEVICE) && (ddraw->flags & DDRAW_NO3D))
{
WARN("The application requests a 3D capable surface, but the ddraw object was created without 3D support.\n");
/* Do not fail surface creation, only fail 3D device creation. */
......@@ -2498,7 +2498,7 @@ static HRESULT ddraw_create_surface(struct ddraw *ddraw, DDSURFACEDESC2 *pDDSD,
return DDERR_OUTOFVIDEOMEMORY;
}
if (FAILED(hr = ddraw_surface_init(*surface, ddraw, pDDSD, version)))
if (FAILED(hr = ddraw_surface_init(*surface, ddraw, desc, flags, version)))
{
WARN("Failed to initialize surface, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, *surface);
......@@ -2603,6 +2603,12 @@ static HRESULT CreateSurface(struct ddraw *ddraw, DDSURFACEDESC2 *DDSD,
HRESULT hr;
DDSURFACEDESC2 desc2;
const DWORD sysvidmem = DDSCAPS_VIDEOMEMORY | DDSCAPS_SYSTEMMEMORY;
/* Some applications assume surfaces will always be mapped at the same
* address. Some of those also assume that this address is valid even when
* the surface isn't mapped, and that updates done this way will be
* visible on the screen. The game Nox is such an application,
* Commandos: Behind Enemy Lines is another. */
const DWORD flags = WINED3D_SURFACE_MAPPABLE | WINED3D_SURFACE_PIN_SYSMEM;
TRACE("ddraw %p, surface_desc %p, surface %p, outer_unknown %p.\n", ddraw, DDSD, surface, UnkOuter);
......@@ -2804,7 +2810,7 @@ static HRESULT CreateSurface(struct ddraw *ddraw, DDSURFACEDESC2 *DDSD,
}
/* Create the first surface */
if (FAILED(hr = ddraw_create_surface(ddraw, &desc2, &object, version)))
if (FAILED(hr = ddraw_create_surface(ddraw, &desc2, flags, &object, version)))
{
WARN("ddraw_create_surface failed, hr %#x.\n", hr);
return hr;
......@@ -2831,7 +2837,7 @@ static HRESULT CreateSurface(struct ddraw *ddraw, DDSURFACEDESC2 *DDSD,
{
struct ddraw_surface *object2 = NULL;
if (FAILED(hr = ddraw_create_surface(ddraw, &desc2, &object2, version)))
if (FAILED(hr = ddraw_create_surface(ddraw, &desc2, flags, &object2, version)))
{
if (version == 7)
IDirectDrawSurface7_Release(&object->IDirectDrawSurface7_iface);
......@@ -2860,7 +2866,7 @@ static HRESULT CreateSurface(struct ddraw *ddraw, DDSURFACEDESC2 *DDSD,
/* Create a WineD3DTexture if a texture was requested */
if (desc2.ddsCaps.dwCaps & DDSCAPS_TEXTURE)
ddraw_surface_create_texture(object);
ddraw_surface_create_texture(object, flags);
return hr;
}
......@@ -5117,7 +5123,7 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic
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,
struct wined3d_surface **surface)
DWORD flags, struct wined3d_surface **surface)
{
struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
struct ddraw_surface *tex_root = container_parent;
......@@ -5125,8 +5131,8 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
struct ddraw_surface *ddraw_surface;
HRESULT hr;
TRACE("device_parent %p, container_parent %p, wined3d_desc %p, sub_resource_idx %u, surface %p.\n",
device_parent, container_parent, wined3d_desc, sub_resource_idx, surface);
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);
/* The ddraw root surface is created before the wined3d texture. */
if (!sub_resource_idx)
......@@ -5139,7 +5145,7 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
desc.dwHeight = wined3d_desc->height;
/* FIXME: Validate that format, usage, pool, etc. really make sense. */
if (FAILED(hr = ddraw_create_surface(ddraw, &desc, &ddraw_surface, tex_root->version)))
if (FAILED(hr = ddraw_create_surface(ddraw, &desc, flags, &ddraw_surface, tex_root->version)))
return hr;
done:
......
......@@ -180,9 +180,9 @@ struct ddraw_surface
DWORD Handle;
};
HRESULT ddraw_surface_create_texture(struct ddraw_surface *surface) DECLSPEC_HIDDEN;
HRESULT ddraw_surface_create_texture(struct ddraw_surface *surface, DWORD surface_flags) DECLSPEC_HIDDEN;
HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
DDSURFACEDESC2 *desc, UINT version) DECLSPEC_HIDDEN;
DDSURFACEDESC2 *desc, DWORD flags, UINT version) DECLSPEC_HIDDEN;
ULONG ddraw_surface_release_iface(struct ddraw_surface *This) DECLSPEC_HIDDEN;
static inline struct ddraw_surface *impl_from_IDirect3DTexture(IDirect3DTexture *iface)
......
......@@ -5585,7 +5585,7 @@ static const struct wined3d_parent_ops ddraw_texture_wined3d_parent_ops =
ddraw_texture_wined3d_object_destroyed,
};
HRESULT ddraw_surface_create_texture(struct ddraw_surface *surface)
HRESULT ddraw_surface_create_texture(struct ddraw_surface *surface, DWORD surface_flags)
{
const DDSURFACEDESC2 *desc = &surface->surface_desc;
struct wined3d_resource_desc wined3d_desc;
......@@ -5627,13 +5627,13 @@ HRESULT ddraw_surface_create_texture(struct ddraw_surface *surface)
{
wined3d_desc.resource_type = WINED3D_RTYPE_CUBE_TEXTURE;
hr = wined3d_texture_create_cube(surface->ddraw->wined3d_device, &wined3d_desc, levels,
surface, &ddraw_texture_wined3d_parent_ops, &surface->wined3d_texture);
surface_flags, surface, &ddraw_texture_wined3d_parent_ops, &surface->wined3d_texture);
}
else
{
wined3d_desc.resource_type = WINED3D_RTYPE_TEXTURE;
hr = wined3d_texture_create_2d(surface->ddraw->wined3d_device, &wined3d_desc, levels,
surface, &ddraw_texture_wined3d_parent_ops, &surface->wined3d_texture);
surface_flags, surface, &ddraw_texture_wined3d_parent_ops, &surface->wined3d_texture);
}
if (FAILED(hr))
......@@ -5697,10 +5697,10 @@ HRESULT ddraw_surface_create_texture(struct ddraw_surface *surface)
return DD_OK;
}
HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, DDSURFACEDESC2 *desc, UINT version)
HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
DDSURFACEDESC2 *desc, DWORD flags, UINT version)
{
enum wined3d_pool pool = WINED3D_POOL_DEFAULT;
DWORD flags = WINED3D_SURFACE_MAPPABLE;
enum wined3d_format_id format;
DWORD usage = 0;
HRESULT hr;
......@@ -5714,13 +5714,6 @@ HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, D
desc->ddsCaps.dwCaps |= DDSCAPS_LOCALVIDMEM | DDSCAPS_VIDEOMEMORY;
}
/* Some applications assume surfaces will always be mapped at the same
* address. Some of those also assume that this address is valid even when
* the surface isn't mapped, and that updates done this way will be
* visible on the screen. The game Nox is such an application,
* Commandos: Behind Enemy Lines is another. */
flags |= WINED3D_SURFACE_PIN_SYSMEM;
if (desc->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
{
usage |= WINED3DUSAGE_RENDERTARGET;
......
......@@ -762,7 +762,8 @@ static const struct wined3d_resource_ops texture2d_resource_ops =
};
static HRESULT cubetexture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc,
UINT levels, struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops)
UINT levels, DWORD surface_flags, struct wined3d_device *device, void *parent,
const struct wined3d_parent_ops *parent_ops)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct wined3d_resource_desc surface_desc;
......@@ -861,7 +862,7 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, const struct wi
struct wined3d_surface *surface;
if (FAILED(hr = device->device_parent->ops->create_texture_surface(device->device_parent,
parent, &surface_desc, idx, &surface)))
parent, &surface_desc, idx, surface_flags, &surface)))
{
FIXME("(%p) Failed to create surface, hr %#x.\n", texture, hr);
wined3d_texture_cleanup(texture);
......@@ -881,7 +882,8 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, const struct wi
}
static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc,
UINT levels, struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops)
UINT levels, DWORD surface_flags, struct wined3d_device *device, void *parent,
const struct wined3d_parent_ops *parent_ops)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
struct wined3d_resource_desc surface_desc;
......@@ -1021,7 +1023,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, const struct wined3
/* 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)))
parent, &surface_desc, i, surface_flags, &surface)))
{
FIXME("Failed to create surface %p, hr %#x\n", texture, hr);
wined3d_texture_cleanup(texture);
......@@ -1272,13 +1274,14 @@ static HRESULT volumetexture_init(struct wined3d_texture *texture, const struct
}
HRESULT CDECL wined3d_texture_create_2d(struct wined3d_device *device, const struct wined3d_resource_desc *desc,
UINT level_count, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture)
UINT level_count, DWORD surface_flags, void *parent, const struct wined3d_parent_ops *parent_ops,
struct wined3d_texture **texture)
{
struct wined3d_texture *object;
HRESULT hr;
TRACE("device %p, desc %p, level_count %u, parent %p, parent_ops %p, texture %p.\n",
device, desc, level_count, parent, parent_ops, texture);
TRACE("device %p, desc %p, level_count %u, surface_flags %#x, parent %p, parent_ops %p, texture %p.\n",
device, desc, level_count, surface_flags, parent, parent_ops, texture);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
......@@ -1287,7 +1290,7 @@ HRESULT CDECL wined3d_texture_create_2d(struct wined3d_device *device, const str
return WINED3DERR_OUTOFVIDEOMEMORY;
}
if (FAILED(hr = texture_init(object, desc, level_count, device, parent, parent_ops)))
if (FAILED(hr = texture_init(object, desc, level_count, surface_flags, device, parent, parent_ops)))
{
WARN("Failed to initialize texture, returning %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object);
......@@ -1332,13 +1335,14 @@ HRESULT CDECL wined3d_texture_create_3d(struct wined3d_device *device, const str
}
HRESULT CDECL wined3d_texture_create_cube(struct wined3d_device *device, const struct wined3d_resource_desc *desc,
UINT level_count, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture)
UINT level_count, DWORD surface_flags, void *parent, const struct wined3d_parent_ops *parent_ops,
struct wined3d_texture **texture)
{
struct wined3d_texture *object;
HRESULT hr;
TRACE("device %p, desc %p, level_count %u, parent %p, parent_ops %p, texture %p.\n",
device, desc, level_count, parent, parent_ops, texture);
TRACE("device %p, desc %p, level_count %u, surface_flags %#x, parent %p, parent_ops %p, texture %p.\n",
device, desc, level_count, surface_flags, parent, parent_ops, texture);
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
......@@ -1347,7 +1351,7 @@ HRESULT CDECL wined3d_texture_create_cube(struct wined3d_device *device, const s
return WINED3DERR_OUTOFVIDEOMEMORY;
}
if (FAILED(hr = cubetexture_init(object, desc, level_count, device, parent, parent_ops)))
if (FAILED(hr = cubetexture_init(object, desc, level_count, surface_flags, device, parent, parent_ops)))
{
WARN("Failed to initialize cubetexture, returning %#x\n", hr);
HeapFree(GetProcessHeap(), 0, object);
......
......@@ -251,9 +251,9 @@
@ cdecl wined3d_swapchain_set_window(ptr ptr)
@ cdecl wined3d_texture_add_dirty_region(ptr long ptr)
@ cdecl wined3d_texture_create_2d(ptr ptr long ptr ptr ptr)
@ cdecl wined3d_texture_create_2d(ptr ptr long long ptr ptr ptr)
@ cdecl wined3d_texture_create_3d(ptr ptr long ptr ptr ptr)
@ cdecl wined3d_texture_create_cube(ptr ptr long ptr ptr ptr)
@ cdecl wined3d_texture_create_cube(ptr ptr long long ptr ptr ptr)
@ cdecl wined3d_texture_decref(ptr)
@ cdecl wined3d_texture_generate_mipmaps(ptr)
@ cdecl wined3d_texture_get_autogen_filter_type(ptr)
......
......@@ -1984,7 +1984,8 @@ struct wined3d_device_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, struct wined3d_surface **surface);
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, enum wined3d_format_id format_id, enum wined3d_pool pool, DWORD usage,
struct wined3d_volume **volume);
......@@ -2372,11 +2373,13 @@ void __cdecl wined3d_swapchain_set_window(struct wined3d_swapchain *swapchain, H
HRESULT __cdecl wined3d_texture_add_dirty_region(struct wined3d_texture *texture,
UINT layer, const struct wined3d_box *dirty_region);
HRESULT __cdecl wined3d_texture_create_2d(struct wined3d_device *device, const struct wined3d_resource_desc *desc,
UINT level_count, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
UINT level_count, DWORD surface_flags, void *parent, const struct wined3d_parent_ops *parent_ops,
struct wined3d_texture **texture);
HRESULT __cdecl wined3d_texture_create_3d(struct wined3d_device *device, const struct wined3d_resource_desc *desc,
UINT level_count, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
HRESULT __cdecl wined3d_texture_create_cube(struct wined3d_device *device, const struct wined3d_resource_desc *desc,
UINT level_count, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_texture **texture);
UINT level_count, DWORD surface_flags, void *parent, const struct wined3d_parent_ops *parent_ops,
struct wined3d_texture **texture);
ULONG __cdecl wined3d_texture_decref(struct wined3d_texture *texture);
void __cdecl wined3d_texture_generate_mipmaps(struct wined3d_texture *texture);
enum wined3d_texture_filter_type __cdecl wined3d_texture_get_autogen_filter_type(const struct wined3d_texture *texture);
......
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