wined3d: Set texture_level in surface_set_texture_target() as well.

This commit is contained in:
Henri Verbeet 2012-10-23 21:01:05 +02:00 committed by Alexandre Julliard
parent cb876cdb97
commit ddbe791d37
16 changed files with 77 additions and 108 deletions

View File

@ -1448,8 +1448,8 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
"\tpool %#x, level %u, face %u, surface %p.\n", "\tpool %#x, level %u, face %u, surface %p.\n",
device_parent, container_parent, width, height, format, usage, pool, level, face, surface); device_parent, container_parent, width, height, format, usage, pool, level, face, surface);
return wined3d_surface_create(device->wined3d_device, width, height, format, level, return wined3d_surface_create(device->wined3d_device, width, height, format, usage, pool,
usage, pool, WINED3D_MULTISAMPLE_NONE, 0, WINED3D_SURFACE_TYPE_OPENGL, 0, container_parent, WINED3D_MULTISAMPLE_NONE, 0, WINED3D_SURFACE_TYPE_OPENGL, 0, container_parent,
&d3d10_null_wined3d_parent_ops, surface); &d3d10_null_wined3d_parent_ops, surface);
} }

View File

@ -203,9 +203,9 @@ struct d3d8_surface
IUnknown *forwardReference; IUnknown *forwardReference;
}; };
HRESULT surface_init(struct d3d8_surface *surface, struct d3d8_device *device, HRESULT surface_init(struct d3d8_surface *surface, struct d3d8_device *device, UINT width, UINT height,
UINT width, UINT height, D3DFORMAT format, BOOL lockable, BOOL discard, UINT level, D3DFORMAT format, BOOL lockable, BOOL discard, DWORD usage, D3DPOOL pool,
DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality) DECLSPEC_HIDDEN; D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality) DECLSPEC_HIDDEN;
struct d3d8_surface *unsafe_impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface) DECLSPEC_HIDDEN; struct d3d8_surface *unsafe_impl_from_IDirect3DSurface8(IDirect3DSurface8 *iface) DECLSPEC_HIDDEN;
struct d3d8_vertexbuffer struct d3d8_vertexbuffer

View File

@ -848,17 +848,16 @@ static HRESULT WINAPI d3d8_device_CreateIndexBuffer(IDirect3DDevice8 *iface, UIN
return D3D_OK; return D3D_OK;
} }
static HRESULT d3d8_device_CreateSurface(struct d3d8_device *device, UINT width, static HRESULT d3d8_device_create_surface(struct d3d8_device *device, UINT width, UINT height,
UINT height, D3DFORMAT format, BOOL lockable, BOOL discard, UINT level, D3DFORMAT format, BOOL lockable, BOOL discard, IDirect3DSurface8 **surface, UINT usage,
IDirect3DSurface8 **surface, UINT usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality)
DWORD multisample_quality)
{ {
struct d3d8_surface *object; struct d3d8_surface *object;
HRESULT hr; HRESULT hr;
TRACE("device %p, width %u, height %u, format %#x, lockable %#x, discard %#x, level %u, surface %p,\n" TRACE("device %p, width %u, height %u, format %#x, lockable %#x, discard %#x, surface %p,\n"
"\tusage %#x, pool %#x, multisample_type %#x, multisample_quality %u.\n", "\tusage %#x, pool %#x, multisample_type %#x, multisample_quality %u.\n",
device, width, height, format, lockable, discard, level, surface, device, width, height, format, lockable, discard, surface,
usage, pool, multisample_type, multisample_quality); usage, pool, multisample_type, multisample_quality);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
@ -867,9 +866,8 @@ static HRESULT d3d8_device_CreateSurface(struct d3d8_device *device, UINT width,
return D3DERR_OUTOFVIDEOMEMORY; return D3DERR_OUTOFVIDEOMEMORY;
} }
hr = surface_init(object, device, width, height, format, lockable, discard, level, usage, if (FAILED(hr = surface_init(object, device, width, height, format, lockable,
pool, multisample_type, multisample_quality); discard, usage, pool, multisample_type, multisample_quality)))
if (FAILED(hr))
{ {
WARN("Failed to initialize surface, hr %#x.\n", hr); WARN("Failed to initialize surface, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object); HeapFree(GetProcessHeap(), 0, object);
@ -887,16 +885,12 @@ static HRESULT WINAPI d3d8_device_CreateRenderTarget(IDirect3DDevice8 *iface, UI
IDirect3DSurface8 **surface) IDirect3DSurface8 **surface)
{ {
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, lockable %#x, surface %p.\n", 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); iface, width, height, format, multisample_type, lockable, surface);
hr = d3d8_device_CreateSurface(device, width, height, format, lockable, return d3d8_device_create_surface(device, width, height, format, lockable, FALSE,
FALSE, 0, surface, D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT, surface, D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT, multisample_type, 0);
multisample_type, 0);
return hr;
} }
static HRESULT WINAPI d3d8_device_CreateDepthStencilSurface(IDirect3DDevice8 *iface, static HRESULT WINAPI d3d8_device_CreateDepthStencilSurface(IDirect3DDevice8 *iface,
@ -904,16 +898,13 @@ static HRESULT WINAPI d3d8_device_CreateDepthStencilSurface(IDirect3DDevice8 *if
IDirect3DSurface8 **surface) IDirect3DSurface8 **surface)
{ {
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, surface %p.\n", TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, surface %p.\n",
iface, width, height, format, multisample_type, surface); iface, width, height, format, multisample_type, surface);
/* TODO: Verify that Discard is false */ /* TODO: Verify that Discard is false */
hr = d3d8_device_CreateSurface(device, width, height, format, TRUE, FALSE, return d3d8_device_create_surface(device, width, height, format, TRUE, FALSE,
0, surface, D3DUSAGE_DEPTHSTENCIL, D3DPOOL_DEFAULT, multisample_type, 0); surface, D3DUSAGE_DEPTHSTENCIL, D3DPOOL_DEFAULT, multisample_type, 0);
return hr;
} }
/* IDirect3DDevice8Impl::CreateImageSurface returns surface with pool type SYSTEMMEM */ /* IDirect3DDevice8Impl::CreateImageSurface returns surface with pool type SYSTEMMEM */
@ -921,15 +912,12 @@ static HRESULT WINAPI d3d8_device_CreateImageSurface(IDirect3DDevice8 *iface, UI
UINT height, D3DFORMAT format, IDirect3DSurface8 **surface) UINT height, D3DFORMAT format, IDirect3DSurface8 **surface)
{ {
struct d3d8_device *device = impl_from_IDirect3DDevice8(iface); struct d3d8_device *device = impl_from_IDirect3DDevice8(iface);
HRESULT hr;
TRACE("iface %p, width %u, height %u, format %#x, surface %p.\n", TRACE("iface %p, width %u, height %u, format %#x, surface %p.\n",
iface, width, height, format, surface); iface, width, height, format, surface);
hr = d3d8_device_CreateSurface(device, width, height, format, TRUE, FALSE, return d3d8_device_create_surface(device, width, height, format, TRUE, FALSE,
0, surface, 0, D3DPOOL_SYSTEMMEM, D3DMULTISAMPLE_NONE, 0); surface, 0, D3DPOOL_SYSTEMMEM, D3DMULTISAMPLE_NONE, 0);
return hr;
} }
static HRESULT WINAPI d3d8_device_CopyRects(IDirect3DDevice8 *iface, static HRESULT WINAPI d3d8_device_CopyRects(IDirect3DDevice8 *iface,
@ -2766,10 +2754,8 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
if (pool == WINED3D_POOL_DEFAULT && !(usage & WINED3DUSAGE_DYNAMIC)) if (pool == WINED3D_POOL_DEFAULT && !(usage & WINED3DUSAGE_DYNAMIC))
lockable = FALSE; lockable = FALSE;
hr = d3d8_device_CreateSurface(device, width, height, if (FAILED(hr = d3d8_device_create_surface(device, width, height, d3dformat_from_wined3dformat(format),
d3dformat_from_wined3dformat(format), lockable, FALSE /* Discard */, level, lockable, FALSE, (IDirect3DSurface8 **)&d3d_surface, usage, pool, D3DMULTISAMPLE_NONE, 0)))
(IDirect3DSurface8 **)&d3d_surface, usage, pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
if (FAILED(hr))
{ {
WARN("Failed to create surface, hr %#x.\n", hr); WARN("Failed to create surface, hr %#x.\n", hr);
return hr; return hr;
@ -2801,8 +2787,8 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
device_parent, container_parent, width, height, format_id, usage, device_parent, container_parent, width, height, format_id, usage,
multisample_type, multisample_quality, surface); multisample_type, multisample_quality, surface);
if (FAILED(hr = d3d8_device_CreateSurface(device, width, height, d3dformat_from_wined3dformat(format_id), if (FAILED(hr = d3d8_device_create_surface(device, width, height, d3dformat_from_wined3dformat(format_id),
TRUE, FALSE, 0, (IDirect3DSurface8 **)&d3d_surface, usage, D3DPOOL_DEFAULT, multisample_type, TRUE, FALSE, (IDirect3DSurface8 **)&d3d_surface, usage, D3DPOOL_DEFAULT, multisample_type,
multisample_quality))) multisample_quality)))
{ {
WARN("Failed to create surface, hr %#x.\n", hr); WARN("Failed to create surface, hr %#x.\n", hr);

View File

@ -325,9 +325,9 @@ static const struct wined3d_parent_ops d3d8_surface_wined3d_parent_ops =
surface_wined3d_object_destroyed, surface_wined3d_object_destroyed,
}; };
HRESULT surface_init(struct d3d8_surface *surface, struct d3d8_device *device, HRESULT surface_init(struct d3d8_surface *surface, struct d3d8_device *device, UINT width, UINT height,
UINT width, UINT height, D3DFORMAT format, BOOL lockable, BOOL discard, UINT level, D3DFORMAT format, BOOL lockable, BOOL discard, DWORD usage, D3DPOOL pool,
DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality) D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality)
{ {
DWORD flags = 0; DWORD flags = 0;
HRESULT hr; HRESULT hr;
@ -349,7 +349,7 @@ HRESULT surface_init(struct d3d8_surface *surface, struct d3d8_device *device,
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_surface_create(device->wined3d_device, width, height, wined3dformat_from_d3dformat(format), hr = wined3d_surface_create(device->wined3d_device, width, height, wined3dformat_from_d3dformat(format),
level, usage & WINED3DUSAGE_MASK, (enum wined3d_pool)pool, multisample_type, multisample_quality, usage & WINED3DUSAGE_MASK, (enum wined3d_pool)pool, multisample_type, multisample_quality,
WINED3D_SURFACE_TYPE_OPENGL, flags, surface, &d3d8_surface_wined3d_parent_ops, &surface->wined3d_surface); WINED3D_SURFACE_TYPE_OPENGL, flags, surface, &d3d8_surface_wined3d_parent_ops, &surface->wined3d_surface);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
if (FAILED(hr)) if (FAILED(hr))

View File

@ -193,9 +193,9 @@ struct d3d9_surface
BOOL getdc_supported; BOOL getdc_supported;
}; };
HRESULT surface_init(struct d3d9_surface *surface, struct d3d9_device *device, HRESULT surface_init(struct d3d9_surface *surface, struct d3d9_device *device, UINT width, UINT height,
UINT width, UINT height, D3DFORMAT format, BOOL lockable, BOOL discard, UINT level, D3DFORMAT format, BOOL lockable, BOOL discard, DWORD usage, D3DPOOL pool,
DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality) DECLSPEC_HIDDEN; D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality) DECLSPEC_HIDDEN;
struct d3d9_surface *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) DECLSPEC_HIDDEN; struct d3d9_surface *unsafe_impl_from_IDirect3DSurface9(IDirect3DSurface9 *iface) DECLSPEC_HIDDEN;
struct d3d9_vertexbuffer struct d3d9_vertexbuffer

View File

@ -886,15 +886,15 @@ static HRESULT WINAPI d3d9_device_CreateIndexBuffer(IDirect3DDevice9Ex *iface, U
} }
static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width, UINT height, static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width, UINT height,
D3DFORMAT format, BOOL lockable, BOOL discard, UINT level, IDirect3DSurface9 **surface, D3DFORMAT format, BOOL lockable, BOOL discard, IDirect3DSurface9 **surface, UINT usage,
UINT usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality) D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality)
{ {
struct d3d9_surface *object; struct d3d9_surface *object;
HRESULT hr; HRESULT hr;
TRACE("device %p, width %u, height %u, format %#x, lockable %#x, discard %#x, level %u, surface %p.\n" TRACE("device %p, width %u, height %u, format %#x, lockable %#x, discard %#x, surface %p.\n"
"usage %#x, pool %#x, multisample_type %#x, multisample_quality %u.\n", "usage %#x, pool %#x, multisample_type %#x, multisample_quality %u.\n",
device, width, height, format, lockable, discard, level, surface, usage, pool, device, width, height, format, lockable, discard, surface, usage, pool,
multisample_type, multisample_quality); multisample_type, multisample_quality);
if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object)))) if (!(object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object))))
@ -903,9 +903,8 @@ static HRESULT d3d9_device_create_surface(struct d3d9_device *device, UINT width
return D3DERR_OUTOFVIDEOMEMORY; return D3DERR_OUTOFVIDEOMEMORY;
} }
hr = surface_init(object, device, width, height, format, lockable, discard, if (FAILED(hr = surface_init(object, device, width, height, format, lockable,
level, usage, pool, multisample_type, multisample_quality); discard, usage, pool, multisample_type, multisample_quality)))
if (FAILED(hr))
{ {
WARN("Failed to initialize surface, hr %#x.\n", hr); WARN("Failed to initialize surface, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object); HeapFree(GetProcessHeap(), 0, object);
@ -923,7 +922,6 @@ static HRESULT WINAPI d3d9_device_CreateRenderTarget(IDirect3DDevice9Ex *iface,
BOOL lockable, IDirect3DSurface9 **surface, HANDLE *shared_handle) BOOL lockable, IDirect3DSurface9 **surface, HANDLE *shared_handle)
{ {
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u.\n" TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u.\n"
"lockable %#x, surface %p, shared_handle %p.\n", "lockable %#x, surface %p, shared_handle %p.\n",
@ -933,10 +931,8 @@ static HRESULT WINAPI d3d9_device_CreateRenderTarget(IDirect3DDevice9Ex *iface,
if (shared_handle) if (shared_handle)
FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle); FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle);
hr = d3d9_device_create_surface(device, width, height, format, lockable, FALSE, 0, surface, return d3d9_device_create_surface(device, width, height, format, lockable, FALSE, surface,
D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT, multisample_type, multisample_quality); D3DUSAGE_RENDERTARGET, D3DPOOL_DEFAULT, multisample_type, multisample_quality);
return hr;
} }
static HRESULT WINAPI d3d9_device_CreateDepthStencilSurface(IDirect3DDevice9Ex *iface, UINT width, UINT height, static HRESULT WINAPI d3d9_device_CreateDepthStencilSurface(IDirect3DDevice9Ex *iface, UINT width, UINT height,
@ -944,7 +940,6 @@ static HRESULT WINAPI d3d9_device_CreateDepthStencilSurface(IDirect3DDevice9Ex *
BOOL discard, IDirect3DSurface9 **surface, HANDLE *shared_handle) BOOL discard, IDirect3DSurface9 **surface, HANDLE *shared_handle)
{ {
struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface); struct d3d9_device *device = impl_from_IDirect3DDevice9Ex(iface);
HRESULT hr;
TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u.\n" TRACE("iface %p, width %u, height %u, format %#x, multisample_type %#x, multisample_quality %u.\n"
"discard %#x, surface %p, shared_handle %p.\n", "discard %#x, surface %p, shared_handle %p.\n",
@ -954,10 +949,8 @@ static HRESULT WINAPI d3d9_device_CreateDepthStencilSurface(IDirect3DDevice9Ex *
if (shared_handle) if (shared_handle)
FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle); FIXME("Resource sharing not implemented, *shared_handle %p.\n", *shared_handle);
hr = d3d9_device_create_surface(device, width, height, format, TRUE, discard, 0, surface, return d3d9_device_create_surface(device, width, height, format, TRUE, discard, surface,
D3DUSAGE_DEPTHSTENCIL, D3DPOOL_DEFAULT, multisample_type, multisample_quality); D3DUSAGE_DEPTHSTENCIL, D3DPOOL_DEFAULT, multisample_type, multisample_quality);
return hr;
} }
@ -1158,7 +1151,7 @@ static HRESULT WINAPI d3d9_device_CreateOffscreenPlainSurface(IDirect3DDevice9Ex
* regardless of the pool they're created in. Should we set dynamic usage * regardless of the pool they're created in. Should we set dynamic usage
* here? */ * here? */
return d3d9_device_create_surface(device, width, height, format, TRUE, return d3d9_device_create_surface(device, width, height, format, TRUE,
FALSE, 0, surface, 0, pool, D3DMULTISAMPLE_NONE, 0); FALSE, surface, 0, pool, D3DMULTISAMPLE_NONE, 0);
} }
static HRESULT WINAPI d3d9_device_SetRenderTarget(IDirect3DDevice9Ex *iface, DWORD idx, IDirect3DSurface9 *surface) static HRESULT WINAPI d3d9_device_SetRenderTarget(IDirect3DDevice9Ex *iface, DWORD idx, IDirect3DSurface9 *surface)
@ -3127,10 +3120,8 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
if (pool == WINED3D_POOL_DEFAULT && !(usage & D3DUSAGE_DYNAMIC)) if (pool == WINED3D_POOL_DEFAULT && !(usage & D3DUSAGE_DYNAMIC))
lockable = FALSE; lockable = FALSE;
hr = d3d9_device_create_surface(device, width, height, if (FAILED(hr = d3d9_device_create_surface(device, width, height, d3dformat_from_wined3dformat(format),
d3dformat_from_wined3dformat(format), lockable, FALSE /* Discard */, level, lockable, FALSE, (IDirect3DSurface9 **)&d3d_surface, usage, pool, D3DMULTISAMPLE_NONE, 0)))
(IDirect3DSurface9 **)&d3d_surface, usage, pool, D3DMULTISAMPLE_NONE, 0 /* MultisampleQuality */);
if (FAILED(hr))
{ {
WARN("Failed to create surface, hr %#x.\n", hr); WARN("Failed to create surface, hr %#x.\n", hr);
return hr; return hr;
@ -3163,7 +3154,7 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
multisample_type, multisample_quality, surface); multisample_type, multisample_quality, surface);
if (FAILED(hr = d3d9_device_create_surface(device, width, height, d3dformat_from_wined3dformat(format_id), if (FAILED(hr = d3d9_device_create_surface(device, width, height, d3dformat_from_wined3dformat(format_id),
TRUE, FALSE, 0, (IDirect3DSurface9 **)&d3d_surface, usage, D3DPOOL_DEFAULT, multisample_type, TRUE, FALSE, (IDirect3DSurface9 **)&d3d_surface, usage, D3DPOOL_DEFAULT, multisample_type,
multisample_quality))) multisample_quality)))
{ {
WARN("Failed to create surface, hr %#x.\n", hr); WARN("Failed to create surface, hr %#x.\n", hr);

View File

@ -390,9 +390,9 @@ static const struct wined3d_parent_ops d3d9_surface_wined3d_parent_ops =
surface_wined3d_object_destroyed, surface_wined3d_object_destroyed,
}; };
HRESULT surface_init(struct d3d9_surface *surface, struct d3d9_device *device, HRESULT surface_init(struct d3d9_surface *surface, struct d3d9_device *device, UINT width, UINT height,
UINT width, UINT height, D3DFORMAT format, BOOL lockable, BOOL discard, UINT level, D3DFORMAT format, BOOL lockable, BOOL discard, DWORD usage, D3DPOOL pool,
DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality) D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality)
{ {
DWORD flags = 0; DWORD flags = 0;
HRESULT hr; HRESULT hr;
@ -430,7 +430,7 @@ HRESULT surface_init(struct d3d9_surface *surface, struct d3d9_device *device,
wined3d_mutex_lock(); wined3d_mutex_lock();
hr = wined3d_surface_create(device->wined3d_device, width, height, wined3dformat_from_d3dformat(format), hr = wined3d_surface_create(device->wined3d_device, width, height, wined3dformat_from_d3dformat(format),
level, usage & WINED3DUSAGE_MASK, (enum wined3d_pool)pool, multisample_type, multisample_quality, usage & WINED3DUSAGE_MASK, (enum wined3d_pool)pool, multisample_type, multisample_quality,
WINED3D_SURFACE_TYPE_OPENGL, flags, surface, &d3d9_surface_wined3d_parent_ops, &surface->wined3d_surface); WINED3D_SURFACE_TYPE_OPENGL, flags, surface, &d3d9_surface_wined3d_parent_ops, &surface->wined3d_surface);
wined3d_mutex_unlock(); wined3d_mutex_unlock();
if (FAILED(hr)) if (FAILED(hr))

View File

@ -2544,12 +2544,11 @@ static HRESULT WINAPI ddraw7_StartModeTest(IDirectDraw7 *iface, SIZE *Modes, DWO
* *
*****************************************************************************/ *****************************************************************************/
static HRESULT ddraw_create_surface(struct ddraw *ddraw, DDSURFACEDESC2 *pDDSD, static HRESULT ddraw_create_surface(struct ddraw *ddraw, DDSURFACEDESC2 *pDDSD,
struct ddraw_surface **surface, UINT level, UINT version) struct ddraw_surface **surface, UINT version)
{ {
HRESULT hr; HRESULT hr;
TRACE("ddraw %p, surface_desc %p, surface %p, level %u.\n", TRACE("ddraw %p, surface_desc %p, surface %p.\n", ddraw, pDDSD, surface);
ddraw, pDDSD, surface, level);
if (TRACE_ON(ddraw)) if (TRACE_ON(ddraw))
{ {
@ -2571,8 +2570,7 @@ static HRESULT ddraw_create_surface(struct ddraw *ddraw, DDSURFACEDESC2 *pDDSD,
return DDERR_OUTOFVIDEOMEMORY; return DDERR_OUTOFVIDEOMEMORY;
} }
hr = ddraw_surface_init(*surface, ddraw, pDDSD, level, version); if (FAILED(hr = ddraw_surface_init(*surface, ddraw, pDDSD, version)))
if (FAILED(hr))
{ {
WARN("Failed to initialize surface, hr %#x.\n", hr); WARN("Failed to initialize surface, hr %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, *surface); HeapFree(GetProcessHeap(), 0, *surface);
@ -2878,8 +2876,7 @@ static HRESULT CreateSurface(struct ddraw *ddraw, DDSURFACEDESC2 *DDSD,
} }
/* Create the first surface */ /* Create the first surface */
hr = ddraw_create_surface(ddraw, &desc2, &object, 0, version); if (FAILED(hr = ddraw_create_surface(ddraw, &desc2, &object, version)))
if (FAILED(hr))
{ {
WARN("ddraw_create_surface failed, hr %#x.\n", hr); WARN("ddraw_create_surface failed, hr %#x.\n", hr);
return hr; return hr;
@ -2906,7 +2903,7 @@ static HRESULT CreateSurface(struct ddraw *ddraw, DDSURFACEDESC2 *DDSD,
{ {
struct ddraw_surface *object2 = NULL; struct ddraw_surface *object2 = NULL;
if (FAILED(hr = ddraw_create_surface(ddraw, &desc2, &object2, 0, version))) if (FAILED(hr = ddraw_create_surface(ddraw, &desc2, &object2, version)))
{ {
if (version == 7) if (version == 7)
IDirectDrawSurface7_Release(&object->IDirectDrawSurface7_iface); IDirectDrawSurface7_Release(&object->IDirectDrawSurface7_iface);
@ -5264,7 +5261,7 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
} }
/* FIXME: Validate that format, usage, pool, etc. really make sense. */ /* FIXME: Validate that format, usage, pool, etc. really make sense. */
if (FAILED(hr = ddraw_create_surface(ddraw, &desc, &ddraw_surface, level, tex_root->version))) if (FAILED(hr = ddraw_create_surface(ddraw, &desc, &ddraw_surface, tex_root->version)))
return hr; return hr;
done: done:
@ -5303,7 +5300,7 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
return E_FAIL; return E_FAIL;
} }
if (SUCCEEDED(hr = wined3d_surface_create(ddraw->wined3d_device, width, height, format_id, 0, if (SUCCEEDED(hr = wined3d_surface_create(ddraw->wined3d_device, width, height, format_id,
usage, WINED3D_POOL_DEFAULT, multisample_type, multisample_quality, DefaultSurfaceType, usage, WINED3D_POOL_DEFAULT, multisample_type, multisample_quality, DefaultSurfaceType,
WINED3D_SURFACE_MAPPABLE, ddraw, &ddraw_frontbuffer_parent_ops, surface))) WINED3D_SURFACE_MAPPABLE, ddraw, &ddraw_frontbuffer_parent_ops, surface)))
ddraw->wined3d_frontbuffer = *surface; ddraw->wined3d_frontbuffer = *surface;

View File

@ -185,7 +185,7 @@ struct ddraw_surface
HRESULT ddraw_surface_create_texture(struct ddraw_surface *surface) DECLSPEC_HIDDEN; HRESULT ddraw_surface_create_texture(struct ddraw_surface *surface) DECLSPEC_HIDDEN;
HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
DDSURFACEDESC2 *desc, UINT mip_level, UINT version) DECLSPEC_HIDDEN; DDSURFACEDESC2 *desc, UINT version) DECLSPEC_HIDDEN;
ULONG ddraw_surface_release_iface(struct ddraw_surface *This) DECLSPEC_HIDDEN; ULONG ddraw_surface_release_iface(struct ddraw_surface *This) DECLSPEC_HIDDEN;
static inline struct ddraw_surface *impl_from_IDirect3DTexture(IDirect3DTexture *iface) static inline struct ddraw_surface *impl_from_IDirect3DTexture(IDirect3DTexture *iface)

View File

@ -5646,8 +5646,7 @@ HRESULT ddraw_surface_create_texture(struct ddraw_surface *surface)
return DD_OK; return DD_OK;
} }
HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw, DDSURFACEDESC2 *desc, UINT version)
DDSURFACEDESC2 *desc, UINT mip_level, UINT version)
{ {
enum wined3d_pool pool = WINED3D_POOL_DEFAULT; enum wined3d_pool pool = WINED3D_POOL_DEFAULT;
DWORD flags = WINED3D_SURFACE_MAPPABLE; DWORD flags = WINED3D_SURFACE_MAPPABLE;
@ -5749,10 +5748,9 @@ HRESULT ddraw_surface_init(struct ddraw_surface *surface, struct ddraw *ddraw,
surface->first_attached = surface; surface->first_attached = surface;
hr = wined3d_surface_create(ddraw->wined3d_device, desc->dwWidth, desc->dwHeight, format, mip_level, if (FAILED(hr = wined3d_surface_create(ddraw->wined3d_device, desc->dwWidth, desc->dwHeight, format,
usage, pool, WINED3D_MULTISAMPLE_NONE, 0, DefaultSurfaceType, flags, usage, pool, WINED3D_MULTISAMPLE_NONE, 0, DefaultSurfaceType, flags, surface,
surface, &ddraw_surface_wined3d_parent_ops, &surface->wined3d_surface); &ddraw_surface_wined3d_parent_ops, &surface->wined3d_surface)))
if (FAILED(hr))
{ {
WARN("Failed to create wined3d surface, hr %#x.\n", hr); WARN("Failed to create wined3d surface, hr %#x.\n", hr);
return hr; return hr;

View File

@ -937,7 +937,7 @@ static void device_load_logo(struct wined3d_device *device, const char *filename
bm.bmHeight = 32; bm.bmHeight = 32;
} }
hr = wined3d_surface_create(device, bm.bmWidth, bm.bmHeight, WINED3DFMT_B5G6R5_UNORM, 0, 0, hr = wined3d_surface_create(device, bm.bmWidth, bm.bmHeight, WINED3DFMT_B5G6R5_UNORM, 0,
WINED3D_POOL_SYSTEM_MEM, WINED3D_MULTISAMPLE_NONE, 0, WINED3D_SURFACE_TYPE_OPENGL, WINED3D_SURFACE_MAPPABLE, WINED3D_POOL_SYSTEM_MEM, WINED3D_MULTISAMPLE_NONE, 0, WINED3D_SURFACE_TYPE_OPENGL, WINED3D_SURFACE_MAPPABLE,
NULL, &wined3d_null_parent_ops, &device->logo_surface); NULL, &wined3d_null_parent_ops, &device->logo_surface);
if (FAILED(hr)) if (FAILED(hr))

View File

@ -2104,7 +2104,7 @@ void surface_set_texture_name(struct wined3d_surface *surface, GLuint new_name,
surface_force_reload(surface); surface_force_reload(surface);
} }
void surface_set_texture_target(struct wined3d_surface *surface, GLenum target) void surface_set_texture_target(struct wined3d_surface *surface, GLenum target, GLint level)
{ {
TRACE("surface %p, target %#x.\n", surface, target); TRACE("surface %p, target %#x.\n", surface, target);
@ -2120,6 +2120,7 @@ void surface_set_texture_target(struct wined3d_surface *surface, GLenum target)
} }
} }
surface->texture_target = target; surface->texture_target = target;
surface->texture_level = level;
surface_force_reload(surface); surface_force_reload(surface);
} }
@ -3764,12 +3765,10 @@ static struct wined3d_surface *surface_convert_format(struct wined3d_surface *so
return NULL; return NULL;
} }
wined3d_surface_create(source->resource.device, source->resource.width, /* FIXME: Multisampled conversion? */
source->resource.height, to_fmt, 0 /* level */, 0 /* usage */, WINED3D_POOL_SCRATCH, if (FAILED(hr = wined3d_surface_create(source->resource.device, source->resource.width, source->resource.height,
WINED3D_MULTISAMPLE_NONE /* TODO: Multisampled conversion */, 0 /* MultiSampleQuality */, to_fmt, 0, WINED3D_POOL_SCRATCH, WINED3D_MULTISAMPLE_NONE, 0, source->surface_type,
source->surface_type, WINED3D_SURFACE_MAPPABLE | WINED3D_SURFACE_DISCARD, WINED3D_SURFACE_MAPPABLE | WINED3D_SURFACE_DISCARD, NULL, &wined3d_null_parent_ops, &ret)))
NULL /* parent */, &wined3d_null_parent_ops, &ret);
if (!ret)
{ {
ERR("Failed to create a destination surface for conversion.\n"); ERR("Failed to create a destination surface for conversion.\n");
return NULL; return NULL;
@ -7186,8 +7185,8 @@ const struct blit_shader cpu_blit = {
cpu_blit_depth_fill, cpu_blit_depth_fill,
}; };
static HRESULT surface_init(struct wined3d_surface *surface, enum wined3d_surface_type surface_type, UINT alignment, static HRESULT surface_init(struct wined3d_surface *surface, enum wined3d_surface_type surface_type,
UINT width, UINT height, UINT level, enum wined3d_multisample_type multisample_type, 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, 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, void *parent, const struct wined3d_parent_ops *parent_ops)
{ {
@ -7276,7 +7275,6 @@ static HRESULT surface_init(struct wined3d_surface *surface, enum wined3d_surfac
/* "Standalone" surface. */ /* "Standalone" surface. */
surface_set_container(surface, WINED3D_CONTAINER_NONE, NULL); surface_set_container(surface, WINED3D_CONTAINER_NONE, NULL);
surface->texture_level = level;
list_init(&surface->overlays); list_init(&surface->overlays);
/* Flags */ /* Flags */
@ -7328,7 +7326,7 @@ static HRESULT surface_init(struct wined3d_surface *surface, enum wined3d_surfac
} }
HRESULT CDECL wined3d_surface_create(struct wined3d_device *device, UINT width, UINT height, HRESULT CDECL wined3d_surface_create(struct wined3d_device *device, UINT width, UINT height,
enum wined3d_format_id format_id, UINT level, DWORD usage, enum wined3d_pool pool, enum wined3d_format_id format_id, DWORD usage, enum wined3d_pool pool,
enum wined3d_multisample_type multisample_type, DWORD multisample_quality, enum wined3d_multisample_type multisample_type, DWORD multisample_quality,
enum wined3d_surface_type surface_type, DWORD flags, void *parent, enum wined3d_surface_type surface_type, DWORD flags, void *parent,
const struct wined3d_parent_ops *parent_ops, struct wined3d_surface **surface) const struct wined3d_parent_ops *parent_ops, struct wined3d_surface **surface)
@ -7336,8 +7334,8 @@ HRESULT CDECL wined3d_surface_create(struct wined3d_device *device, UINT width,
struct wined3d_surface *object; struct wined3d_surface *object;
HRESULT hr; HRESULT hr;
TRACE("device %p, width %u, height %u, format %s, level %u\n", TRACE("device %p, width %u, height %u, format %s\n",
device, width, height, debug_d3dformat(format_id), level); device, width, height, debug_d3dformat(format_id));
TRACE("surface %p, usage %s (%#x), pool %s, multisample_type %#x, multisample_quality %u\n", 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); surface, debug_d3dusage(usage), usage, debug_d3dpool(pool), multisample_type, multisample_quality);
TRACE("surface_type %#x, flags %#x, parent %p, parent_ops %p.\n", surface_type, flags, parent, parent_ops); TRACE("surface_type %#x, flags %#x, parent %p, parent_ops %p.\n", surface_type, flags, parent, parent_ops);
@ -7355,9 +7353,8 @@ HRESULT CDECL wined3d_surface_create(struct wined3d_device *device, UINT width,
return WINED3DERR_OUTOFVIDEOMEMORY; return WINED3DERR_OUTOFVIDEOMEMORY;
} }
hr = surface_init(object, surface_type, device->surface_alignment, width, height, level, if (FAILED(hr = surface_init(object, surface_type, device->surface_alignment, width, height,
multisample_type, multisample_quality, device, usage, format_id, pool, flags, parent, parent_ops); multisample_type, multisample_quality, device, usage, format_id, pool, flags, parent, parent_ops)))
if (FAILED(hr))
{ {
WARN("Failed to initialize surface, returning %#x.\n", hr); WARN("Failed to initialize surface, returning %#x.\n", hr);
HeapFree(GetProcessHeap(), 0, object); HeapFree(GetProcessHeap(), 0, object);

View File

@ -720,7 +720,7 @@ static void texture2d_sub_resource_cleanup(struct wined3d_resource *sub_resource
* surface doesn't try and release it. */ * surface doesn't try and release it. */
surface_set_texture_name(surface, 0, TRUE); surface_set_texture_name(surface, 0, TRUE);
surface_set_texture_name(surface, 0, FALSE); surface_set_texture_name(surface, 0, FALSE);
surface_set_texture_target(surface, 0); surface_set_texture_target(surface, 0, 0);
surface_set_container(surface, WINED3D_CONTAINER_NONE, NULL); surface_set_container(surface, WINED3D_CONTAINER_NONE, NULL);
wined3d_surface_decref(surface); wined3d_surface_decref(surface);
} }
@ -868,7 +868,7 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt
} }
surface_set_container(surface, WINED3D_CONTAINER_TEXTURE, texture); surface_set_container(surface, WINED3D_CONTAINER_TEXTURE, texture);
surface_set_texture_target(surface, cube_targets[j]); surface_set_texture_target(surface, cube_targets[j], i);
texture->sub_resources[idx] = &surface->resource; texture->sub_resources[idx] = &surface->resource;
TRACE("Created surface level %u @ %p.\n", i, surface); TRACE("Created surface level %u @ %p.\n", i, surface);
} }
@ -1023,7 +1023,7 @@ static HRESULT texture_init(struct wined3d_texture *texture, UINT width, UINT he
} }
surface_set_container(surface, WINED3D_CONTAINER_TEXTURE, texture); surface_set_container(surface, WINED3D_CONTAINER_TEXTURE, texture);
surface_set_texture_target(surface, texture->target); surface_set_texture_target(surface, texture->target, i);
texture->sub_resources[i] = &surface->resource; texture->sub_resources[i] = &surface->resource;
TRACE("Created surface level %u @ %p.\n", i, surface); TRACE("Created surface level %u @ %p.\n", i, surface);
/* Calculate the next mipmap level. */ /* Calculate the next mipmap level. */

View File

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

View File

@ -2121,7 +2121,7 @@ void surface_set_compatible_renderbuffer(struct wined3d_surface *surface,
void surface_set_container(struct wined3d_surface *surface, void surface_set_container(struct wined3d_surface *surface,
enum wined3d_container_type type, void *container) DECLSPEC_HIDDEN; enum wined3d_container_type type, void *container) DECLSPEC_HIDDEN;
void surface_set_texture_name(struct wined3d_surface *surface, GLuint name, BOOL srgb_name) DECLSPEC_HIDDEN; void surface_set_texture_name(struct wined3d_surface *surface, GLuint name, BOOL srgb_name) DECLSPEC_HIDDEN;
void surface_set_texture_target(struct wined3d_surface *surface, GLenum target) DECLSPEC_HIDDEN; void surface_set_texture_target(struct wined3d_surface *surface, GLenum target, GLint level) DECLSPEC_HIDDEN;
void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN; void surface_translate_drawable_coords(const struct wined3d_surface *surface, HWND window, RECT *rect) DECLSPEC_HIDDEN;
void surface_update_draw_binding(struct wined3d_surface *surface) DECLSPEC_HIDDEN; void surface_update_draw_binding(struct wined3d_surface *surface) DECLSPEC_HIDDEN;
HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const POINT *dst_point, HRESULT surface_upload_from_surface(struct wined3d_surface *dst_surface, const POINT *dst_point,

View File

@ -2315,7 +2315,7 @@ HRESULT __cdecl wined3d_surface_blt(struct wined3d_surface *dst_surface, const R
struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags, struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
const WINEDDBLTFX *blt_fx, enum wined3d_texture_filter_type filter); const WINEDDBLTFX *blt_fx, enum wined3d_texture_filter_type filter);
HRESULT __cdecl wined3d_surface_create(struct wined3d_device *device, UINT width, UINT height, HRESULT __cdecl wined3d_surface_create(struct wined3d_device *device, UINT width, UINT height,
enum wined3d_format_id format_id, UINT level, DWORD usage, enum wined3d_pool pool, enum wined3d_format_id format_id, DWORD usage, enum wined3d_pool pool,
enum wined3d_multisample_type multisample_type, DWORD multisample_quality, enum wined3d_multisample_type multisample_type, DWORD multisample_quality,
enum wined3d_surface_type surface_type, DWORD flags, void *parent, enum wined3d_surface_type surface_type, DWORD flags, void *parent,
const struct wined3d_parent_ops *parent_ops, struct wined3d_surface **surface); const struct wined3d_parent_ops *parent_ops, struct wined3d_surface **surface);