wined3d: Add a flags parameter to wined3d_surface_create().

This commit is contained in:
Henri Verbeet 2011-11-30 06:01:45 +01:00 committed by Alexandre Julliard
parent 82dd612d50
commit 3430e11605
8 changed files with 50 additions and 30 deletions

View File

@ -237,9 +237,9 @@ HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d10_devic
FIXME("Implement DXGI<->wined3d usage conversion\n");
hr = wined3d_surface_create(device->wined3d_device, desc->Width, desc->Height,
wined3dformat_from_dxgi_format(desc->Format), FALSE, FALSE, 0, desc->Usage, WINED3DPOOL_DEFAULT,
wined3dformat_from_dxgi_format(desc->Format), 0, desc->Usage, WINED3DPOOL_DEFAULT,
desc->SampleDesc.Count > 1 ? desc->SampleDesc.Count : WINED3DMULTISAMPLE_NONE,
desc->SampleDesc.Quality, SURFACE_OPENGL, texture, &d3d10_texture2d_wined3d_parent_ops,
desc->SampleDesc.Quality, SURFACE_OPENGL, 0, texture, &d3d10_texture2d_wined3d_parent_ops,
&texture->wined3d_surface);
if (FAILED(hr))
{

View File

@ -318,6 +318,7 @@ HRESULT surface_init(IDirect3DSurface8Impl *surface, IDirect3DDevice8Impl *devic
UINT width, UINT height, D3DFORMAT format, BOOL lockable, BOOL discard, UINT level,
DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality)
{
DWORD flags = 0;
HRESULT hr;
surface->IDirect3DSurface8_iface.lpVtbl = &Direct3DSurface8_Vtbl;
@ -330,10 +331,15 @@ HRESULT surface_init(IDirect3DSurface8Impl *surface, IDirect3DDevice8Impl *devic
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),
lockable, discard, level, usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool, multisample_type,
multisample_quality, SURFACE_OPENGL, surface, &d3d8_surface_wined3d_parent_ops, &surface->wined3d_surface);
level, usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool, multisample_type, multisample_quality,
SURFACE_OPENGL, flags, surface, &d3d8_surface_wined3d_parent_ops, &surface->wined3d_surface);
wined3d_mutex_unlock();
if (FAILED(hr))
{

View File

@ -395,6 +395,7 @@ HRESULT surface_init(IDirect3DSurface9Impl *surface, IDirect3DDevice9Impl *devic
UINT width, UINT height, D3DFORMAT format, BOOL lockable, BOOL discard, UINT level,
DWORD usage, D3DPOOL pool, D3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality)
{
DWORD flags = 0;
HRESULT hr;
surface->IDirect3DSurface9_iface.lpVtbl = &Direct3DSurface9_Vtbl;
@ -423,10 +424,15 @@ HRESULT surface_init(IDirect3DSurface9Impl *surface, IDirect3DDevice9Impl *devic
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),
lockable, discard, level, usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool, multisample_type,
multisample_quality, SURFACE_OPENGL, surface, &d3d9_surface_wined3d_parent_ops, &surface->wined3d_surface);
level, usage & WINED3DUSAGE_MASK, (WINED3DPOOL)pool, multisample_type, multisample_quality,
SURFACE_OPENGL, flags, surface, &d3d9_surface_wined3d_parent_ops, &surface->wined3d_surface);
wined3d_mutex_unlock();
if (FAILED(hr))
{

View File

@ -5384,6 +5384,7 @@ static HRESULT CDECL device_parent_create_rendertarget(struct wined3d_device_par
struct wined3d_surface **surface)
{
struct IDirectDrawImpl *ddraw = ddraw_from_device_parent(device_parent);
DWORD flags = 0;
HRESULT hr;
TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, multisample_type %#x,\n"
@ -5397,9 +5398,12 @@ static HRESULT CDECL device_parent_create_rendertarget(struct wined3d_device_par
return E_FAIL;
}
hr = wined3d_surface_create(ddraw->wined3d_device, width, height, format, lockable, FALSE, 0,
if (lockable)
flags |= WINED3D_SURFACE_MAPPABLE;
hr = wined3d_surface_create(ddraw->wined3d_device, width, height, format, 0,
WINED3DUSAGE_RENDERTARGET, WINED3DPOOL_DEFAULT, multisample_type, multisample_quality,
DefaultSurfaceType, ddraw, &ddraw_frontbuffer_parent_ops, surface);
DefaultSurfaceType, flags, ddraw, &ddraw_frontbuffer_parent_ops, surface);
if (SUCCEEDED(hr))
ddraw->wined3d_frontbuffer = *surface;

View File

@ -5342,10 +5342,9 @@ HRESULT ddraw_surface_init(IDirectDrawSurfaceImpl *surface, IDirectDrawImpl *ddr
surface->first_attached = surface;
hr = wined3d_surface_create(ddraw->wined3d_device, desc->dwWidth, desc->dwHeight, format,
TRUE /* Lockable */, FALSE /* Discard */, mip_level, usage, pool,
WINED3DMULTISAMPLE_NONE, 0 /* MultiSampleQuality */, DefaultSurfaceType, surface,
&ddraw_surface_wined3d_parent_ops, &surface->wined3d_surface);
hr = wined3d_surface_create(ddraw->wined3d_device, desc->dwWidth, desc->dwHeight, format, mip_level,
usage, pool, WINED3DMULTISAMPLE_NONE, 0, DefaultSurfaceType, WINED3D_SURFACE_MAPPABLE,
surface, &ddraw_surface_wined3d_parent_ops, &surface->wined3d_surface);
if (FAILED(hr))
{
WARN("Failed to create wined3d surface, hr %#x.\n", hr);

View File

@ -934,9 +934,9 @@ static void device_load_logo(struct wined3d_device *device, const char *filename
bm.bmHeight = 32;
}
hr = wined3d_surface_create(device, bm.bmWidth, bm.bmHeight, WINED3DFMT_B5G6R5_UNORM, TRUE,
FALSE, 0, 0, WINED3DPOOL_DEFAULT, WINED3DMULTISAMPLE_NONE, 0, SURFACE_OPENGL, NULL,
&wined3d_null_parent_ops, &device->logo_surface);
hr = wined3d_surface_create(device, bm.bmWidth, bm.bmHeight, WINED3DFMT_B5G6R5_UNORM, 0, 0,
WINED3DPOOL_DEFAULT, WINED3DMULTISAMPLE_NONE, 0, SURFACE_OPENGL, WINED3D_SURFACE_MAPPABLE,
NULL, &wined3d_null_parent_ops, &device->logo_surface);
if (FAILED(hr))
{
ERR("Wine logo requested, but failed to create surface, hr %#x.\n", hr);

View File

@ -3569,9 +3569,10 @@ static struct wined3d_surface *surface_convert_format(struct wined3d_surface *so
}
wined3d_surface_create(source->resource.device, source->resource.width,
source->resource.height, to_fmt, TRUE /* lockable */, TRUE /* discard */, 0 /* level */,
0 /* usage */, WINED3DPOOL_SCRATCH, WINED3DMULTISAMPLE_NONE /* TODO: Multisampled conversion */,
0 /* MultiSampleQuality */, source->surface_type, NULL /* parent */, &wined3d_null_parent_ops, &ret);
source->resource.height, to_fmt, 0 /* level */, 0 /* usage */, WINED3DPOOL_SCRATCH,
WINED3DMULTISAMPLE_NONE /* TODO: Multisampled conversion */, 0 /* MultiSampleQuality */,
source->surface_type, WINED3D_SURFACE_MAPPABLE | WINED3D_SURFACE_DISCARD,
NULL /* parent */, &wined3d_null_parent_ops, &ret);
if (!ret)
{
ERR("Failed to create a destination surface for conversion.\n");
@ -7089,12 +7090,13 @@ const struct blit_shader cpu_blit = {
};
static HRESULT surface_init(struct wined3d_surface *surface, WINED3DSURFTYPE surface_type, UINT alignment,
UINT width, UINT height, UINT level, BOOL lockable, BOOL discard, WINED3DMULTISAMPLE_TYPE multisample_type,
UINT width, UINT height, UINT level, WINED3DMULTISAMPLE_TYPE multisample_type,
UINT multisample_quality, struct wined3d_device *device, DWORD usage, enum wined3d_format_id format_id,
WINED3DPOOL pool, void *parent, const struct wined3d_parent_ops *parent_ops)
WINED3DPOOL pool, DWORD flags, void *parent, const struct wined3d_parent_ops *parent_ops)
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
BOOL lockable = flags & WINED3D_SURFACE_MAPPABLE;
unsigned int resource_size;
HRESULT hr;
@ -7182,7 +7184,7 @@ static HRESULT surface_init(struct wined3d_surface *surface, WINED3DSURFTYPE sur
/* Flags */
surface->flags = SFLAG_NORMCOORD; /* Default to normalized coords. */
if (discard)
if (flags & WINED3D_SURFACE_DISCARD)
surface->flags |= SFLAG_DISCARD;
if (lockable || format_id == WINED3DFMT_D16_LOCKABLE)
surface->flags |= SFLAG_LOCKABLE;
@ -7227,18 +7229,18 @@ static HRESULT surface_init(struct wined3d_surface *surface, WINED3DSURFTYPE sur
}
HRESULT CDECL wined3d_surface_create(struct wined3d_device *device, UINT width, UINT height,
enum wined3d_format_id format_id, BOOL lockable, BOOL discard, UINT level, DWORD usage, WINED3DPOOL pool,
enum wined3d_format_id format_id, UINT level, DWORD usage, WINED3DPOOL pool,
WINED3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality, WINED3DSURFTYPE surface_type,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_surface **surface)
DWORD flags, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_surface **surface)
{
struct wined3d_surface *object;
HRESULT hr;
TRACE("device %p, width %u, height %u, format %s, lockable %#x, discard %#x, level %u\n",
device, width, height, debug_d3dformat(format_id), lockable, discard, level);
TRACE("device %p, width %u, height %u, format %s, level %u\n",
device, width, height, debug_d3dformat(format_id), level);
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("surface_type %#x, parent %p, parent_ops %p.\n", surface_type, parent, parent_ops);
TRACE("surface_type %#x, flags %#x, parent %p, parent_ops %p.\n", surface_type, flags, parent, parent_ops);
if (surface_type == SURFACE_OPENGL && !device->adapter)
{
@ -7253,8 +7255,8 @@ HRESULT CDECL wined3d_surface_create(struct wined3d_device *device, UINT width,
return WINED3DERR_OUTOFVIDEOMEMORY;
}
hr = surface_init(object, surface_type, device->surface_alignment, width, height, level, lockable,
discard, multisample_type, multisample_quality, device, usage, format_id, pool, parent, parent_ops);
hr = surface_init(object, surface_type, device->surface_alignment, width, height, level,
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);

View File

@ -1509,6 +1509,9 @@ enum wined3d_sysval_semantic
#define WINEDDPCAPS_2BIT 0x00000200
#define WINEDDPCAPS_ALPHA 0x00000400
#define WINED3D_SURFACE_MAPPABLE 0x00000001
#define WINED3D_SURFACE_DISCARD 0x00000002
struct wined3d_display_mode
{
UINT width;
@ -2395,9 +2398,9 @@ HRESULT __cdecl wined3d_surface_blt(struct wined3d_surface *dst_surface, const R
struct wined3d_surface *src_surface, const RECT *src_rect, DWORD flags,
const WINEDDBLTFX *blt_fx, WINED3DTEXTUREFILTERTYPE filter);
HRESULT __cdecl wined3d_surface_create(struct wined3d_device *device, UINT width, UINT height,
enum wined3d_format_id format_id, BOOL lockable, BOOL discard, UINT level, DWORD usage, WINED3DPOOL pool,
enum wined3d_format_id format_id, UINT level, DWORD usage, WINED3DPOOL pool,
WINED3DMULTISAMPLE_TYPE multisample_type, DWORD multisample_quality, WINED3DSURFTYPE surface_type,
void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_surface **surface);
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);
HRESULT __cdecl wined3d_surface_get_blt_status(const struct wined3d_surface *surface, DWORD flags);