wined3d: Pass a wined3d_resource_desc structure to device_parent_create_texture_surface().

This commit is contained in:
Henri Verbeet 2013-06-04 09:57:07 +02:00 committed by Alexandre Julliard
parent 1276a3db04
commit a4d2660c9b
6 changed files with 42 additions and 43 deletions
dlls
d3d10core
d3d8
d3d9
ddraw
wined3d
include/wine

View File

@ -1831,17 +1831,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, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
enum wined3d_pool pool, UINT sub_resource_idx, struct wined3d_surface **surface)
void *container_parent, const struct wined3d_resource_desc *desc, UINT sub_resource_idx,
struct wined3d_surface **surface)
{
struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n"
"\tpool %#x, sub_resource_idx %u, surface %p.\n",
device_parent, container_parent, width, height, format, usage, pool, sub_resource_idx, surface);
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);
return wined3d_surface_create(device->wined3d_device, width, height, format, usage, pool,
WINED3D_MULTISAMPLE_NONE, 0, 0, container_parent, &d3d10_null_wined3d_parent_ops, 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,
container_parent, &d3d10_null_wined3d_parent_ops, surface);
}
static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,

View File

@ -2878,24 +2878,23 @@ 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, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
enum wined3d_pool pool, UINT sub_resource_idx, struct wined3d_surface **surface)
void *container_parent, const struct wined3d_resource_desc *desc, UINT sub_resource_idx,
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, width %u, height %u, format %#x, usage %#x,\n"
"\tpool %#x, sub_resource_idx %u, surface %p.\n",
device_parent, container_parent, width, height, format, usage, pool, sub_resource_idx, surface);
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 (pool == WINED3D_POOL_DEFAULT && !(usage & WINED3DUSAGE_DYNAMIC))
if (desc->pool == WINED3D_POOL_DEFAULT && !(desc->usage & WINED3DUSAGE_DYNAMIC))
lockable = FALSE;
if (FAILED(hr = d3d8_device_create_surface(device, width, height, d3dformat_from_wined3dformat(format),
lockable, FALSE, (IDirect3DSurface8 **)&d3d_surface, usage, pool, D3DMULTISAMPLE_NONE, 0)))
if (FAILED(hr = d3d8_device_create_surface(device, desc->width, desc->height,
d3dformat_from_wined3dformat(desc->format), lockable, FALSE, (IDirect3DSurface8 **)&d3d_surface,
desc->usage, desc->pool, desc->multisample_type, desc->multisample_quality)))
{
WARN("Failed to create surface, hr %#x.\n", hr);
return hr;

View File

@ -3259,23 +3259,23 @@ 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, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
enum wined3d_pool pool, UINT sub_resource_idx, struct wined3d_surface **surface)
void *container_parent, const struct wined3d_resource_desc *desc, UINT sub_resource_idx,
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, width %u, height %u, format %#x, usage %#x,\n"
"\tpool %#x, sub_resource_idx %u, surface %p.\n",
device_parent, container_parent, width, height, format, usage, pool, sub_resource_idx, surface);
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 (pool == WINED3D_POOL_DEFAULT && !(usage & D3DUSAGE_DYNAMIC))
if (desc->pool == WINED3D_POOL_DEFAULT && !(desc->usage & WINED3DUSAGE_DYNAMIC))
lockable = FALSE;
if (FAILED(hr = d3d9_device_create_surface(device, width, height, d3dformat_from_wined3dformat(format),
lockable, FALSE, (IDirect3DSurface9 **)&d3d_surface, usage, pool, D3DMULTISAMPLE_NONE, 0)))
if (FAILED(hr = d3d9_device_create_surface(device, desc->width, desc->height,
d3dformat_from_wined3dformat(desc->format), lockable, FALSE, (IDirect3DSurface9 **)&d3d_surface,
desc->usage, desc->pool, desc->multisample_type, desc->multisample_quality)))
{
WARN("Failed to create surface, hr %#x.\n", hr);
return hr;

View File

@ -5094,8 +5094,8 @@ 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, UINT width, UINT height, enum wined3d_format_id format, DWORD usage,
enum wined3d_pool pool, UINT sub_resource_idx, struct wined3d_surface **surface)
void *container_parent, const struct wined3d_resource_desc *wined3d_desc, UINT sub_resource_idx,
struct wined3d_surface **surface)
{
struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
struct ddraw_surface *tex_root = container_parent;
@ -5103,9 +5103,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, width %u, height %u, format %#x, usage %#x,\n"
"\tpool %#x, sub_resource_idx %u, surface %p.\n",
device_parent, container_parent, width, height, format, usage, pool, sub_resource_idx, surface);
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);
/* The ddraw root surface is created before the wined3d texture. */
if (!sub_resource_idx)
@ -5114,8 +5113,8 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
goto done;
}
desc.dwWidth = width;
desc.dwHeight = height;
desc.dwWidth = wined3d_desc->width;
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)))

View File

@ -760,8 +760,8 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
struct wined3d_resource_desc desc;
unsigned int i, j;
UINT tmp_w;
HRESULT hr;
/* TODO: It should only be possible to create textures for formats
@ -836,7 +836,8 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt
texture->target = GL_TEXTURE_CUBE_MAP_ARB;
/* Generate all the surfaces. */
tmp_w = edge_length;
wined3d_resource_get_desc(&texture->resource, &desc);
desc.resource_type = WINED3D_RTYPE_SURFACE;
for (i = 0; i < texture->level_count; ++i)
{
/* Create the 6 faces. */
@ -855,7 +856,7 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt
struct wined3d_surface *surface;
if (FAILED(hr = device->device_parent->ops->create_texture_surface(device->device_parent,
parent, tmp_w, tmp_w, format_id, usage, pool, idx, &surface)))
parent, &desc, idx, &surface)))
{
FIXME("(%p) Failed to create surface, hr %#x.\n", texture, hr);
wined3d_texture_cleanup(texture);
@ -867,7 +868,8 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt
texture->sub_resources[idx] = &surface->resource;
TRACE("Created surface level %u @ %p.\n", i, surface);
}
tmp_w = max(1, tmp_w >> 1);
desc.width = max(1, desc.width >> 1);
desc.height = desc.width;
}
return WINED3D_OK;
@ -879,8 +881,8 @@ static HRESULT texture_init(struct wined3d_texture *texture, UINT width, UINT he
{
const struct wined3d_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
struct wined3d_resource_desc desc;
UINT pow2_width, pow2_height;
UINT tmp_w, tmp_h;
unsigned int i;
HRESULT hr;
@ -1005,15 +1007,15 @@ static HRESULT texture_init(struct wined3d_texture *texture, UINT width, UINT he
TRACE("xf(%f) yf(%f)\n", texture->pow2_matrix[0], texture->pow2_matrix[5]);
/* Generate all the surfaces. */
tmp_w = width;
tmp_h = height;
wined3d_resource_get_desc(&texture->resource, &desc);
desc.resource_type = WINED3D_RTYPE_SURFACE;
for (i = 0; i < texture->level_count; ++i)
{
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, tmp_w, tmp_h, format->id, usage, pool, i, &surface)))
parent, &desc, i, &surface)))
{
FIXME("Failed to create surface %p, hr %#x\n", texture, hr);
wined3d_texture_cleanup(texture);
@ -1025,8 +1027,8 @@ static HRESULT texture_init(struct wined3d_texture *texture, UINT width, UINT he
texture->sub_resources[i] = &surface->resource;
TRACE("Created surface level %u @ %p.\n", i, surface);
/* Calculate the next mipmap level. */
tmp_w = max(1, tmp_w >> 1);
tmp_h = max(1, tmp_h >> 1);
desc.width = max(1, desc.width >> 1);
desc.height = max(1, desc.height >> 1);
}
return WINED3D_OK;

View File

@ -1986,8 +1986,7 @@ struct wined3d_device_parent_ops
enum wined3d_multisample_type multisample_type, DWORD multisample_quality,
struct wined3d_surface **surface);
HRESULT (__cdecl *create_texture_surface)(struct wined3d_device_parent *device_parent, void *container_parent,
UINT width, UINT height, enum wined3d_format_id format_id, DWORD usage, enum wined3d_pool pool,
UINT sub_resource_idx, struct wined3d_surface **surface);
const struct wined3d_resource_desc *desc, UINT sub_resource_idx, 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);