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

wined3d: Pass a wined3d_resource_desc structure to device_parent_create_texture_surface().

parent 1276a3db
...@@ -1831,17 +1831,17 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic ...@@ -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, 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, void *container_parent, const struct wined3d_resource_desc *desc, UINT sub_resource_idx,
enum wined3d_pool pool, UINT sub_resource_idx, struct wined3d_surface **surface) struct wined3d_surface **surface)
{ {
struct d3d10_device *device = device_from_wined3d_device_parent(device_parent); 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" TRACE("device_parent %p, container_parent %p, desc %p, sub_resource_idx %u, surface %p.\n",
"\tpool %#x, sub_resource_idx %u, surface %p.\n", device_parent, container_parent, desc, sub_resource_idx, surface);
device_parent, container_parent, width, height, format, usage, pool, sub_resource_idx, surface);
return wined3d_surface_create(device->wined3d_device, width, height, format, usage, pool, return wined3d_surface_create(device->wined3d_device, desc->width, desc->height, desc->format,
WINED3D_MULTISAMPLE_NONE, 0, 0, container_parent, &d3d10_null_wined3d_parent_ops, surface); 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, static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
......
...@@ -2878,24 +2878,23 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic ...@@ -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, 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, void *container_parent, const struct wined3d_resource_desc *desc, UINT sub_resource_idx,
enum wined3d_pool pool, UINT sub_resource_idx, struct wined3d_surface **surface) struct wined3d_surface **surface)
{ {
struct d3d8_device *device = device_from_device_parent(device_parent); struct d3d8_device *device = device_from_device_parent(device_parent);
struct d3d8_surface *d3d_surface; struct d3d8_surface *d3d_surface;
BOOL lockable = TRUE; BOOL lockable = TRUE;
HRESULT hr; HRESULT hr;
TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n" TRACE("device_parent %p, container_parent %p, desc %p, sub_resource_idx %u, surface %p.\n",
"\tpool %#x, sub_resource_idx %u, surface %p.\n", device_parent, container_parent, desc, sub_resource_idx, surface);
device_parent, container_parent, width, height, format, usage, pool, sub_resource_idx, surface);
if (desc->pool == WINED3D_POOL_DEFAULT && !(desc->usage & WINED3DUSAGE_DYNAMIC))
if (pool == WINED3D_POOL_DEFAULT && !(usage & WINED3DUSAGE_DYNAMIC))
lockable = FALSE; lockable = FALSE;
if (FAILED(hr = d3d8_device_create_surface(device, width, height, d3dformat_from_wined3dformat(format), if (FAILED(hr = d3d8_device_create_surface(device, desc->width, desc->height,
lockable, FALSE, (IDirect3DSurface8 **)&d3d_surface, usage, pool, D3DMULTISAMPLE_NONE, 0))) 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); WARN("Failed to create surface, hr %#x.\n", hr);
return hr; return hr;
......
...@@ -3259,23 +3259,23 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic ...@@ -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, 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, void *container_parent, const struct wined3d_resource_desc *desc, UINT sub_resource_idx,
enum wined3d_pool pool, UINT sub_resource_idx, struct wined3d_surface **surface) struct wined3d_surface **surface)
{ {
struct d3d9_device *device = device_from_device_parent(device_parent); struct d3d9_device *device = device_from_device_parent(device_parent);
struct d3d9_surface *d3d_surface; struct d3d9_surface *d3d_surface;
BOOL lockable = TRUE; BOOL lockable = TRUE;
HRESULT hr; HRESULT hr;
TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n" TRACE("device_parent %p, container_parent %p, desc %p, sub_resource_idx %u, surface %p.\n",
"\tpool %#x, sub_resource_idx %u, surface %p.\n", device_parent, container_parent, desc, sub_resource_idx, surface);
device_parent, container_parent, width, height, format, usage, pool, sub_resource_idx, surface);
if (pool == WINED3D_POOL_DEFAULT && !(usage & D3DUSAGE_DYNAMIC)) if (desc->pool == WINED3D_POOL_DEFAULT && !(desc->usage & WINED3DUSAGE_DYNAMIC))
lockable = FALSE; lockable = FALSE;
if (FAILED(hr = d3d9_device_create_surface(device, width, height, d3dformat_from_wined3dformat(format), if (FAILED(hr = d3d9_device_create_surface(device, desc->width, desc->height,
lockable, FALSE, (IDirect3DSurface9 **)&d3d_surface, usage, pool, D3DMULTISAMPLE_NONE, 0))) 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); WARN("Failed to create surface, hr %#x.\n", hr);
return hr; return hr;
......
...@@ -5094,8 +5094,8 @@ static void CDECL device_parent_mode_changed(struct wined3d_device_parent *devic ...@@ -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, 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, void *container_parent, const struct wined3d_resource_desc *wined3d_desc, UINT sub_resource_idx,
enum wined3d_pool pool, UINT sub_resource_idx, struct wined3d_surface **surface) struct wined3d_surface **surface)
{ {
struct ddraw *ddraw = ddraw_from_device_parent(device_parent); struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
struct ddraw_surface *tex_root = container_parent; struct ddraw_surface *tex_root = container_parent;
...@@ -5103,9 +5103,8 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_ ...@@ -5103,9 +5103,8 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
struct ddraw_surface *ddraw_surface; struct ddraw_surface *ddraw_surface;
HRESULT hr; HRESULT hr;
TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n" TRACE("device_parent %p, container_parent %p, wined3d_desc %p, sub_resource_idx %u, surface %p.\n",
"\tpool %#x, sub_resource_idx %u, surface %p.\n", device_parent, container_parent, wined3d_desc, sub_resource_idx, surface);
device_parent, container_parent, width, height, format, usage, pool, sub_resource_idx, surface);
/* The ddraw root surface is created before the wined3d texture. */ /* The ddraw root surface is created before the wined3d texture. */
if (!sub_resource_idx) if (!sub_resource_idx)
...@@ -5114,8 +5113,8 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_ ...@@ -5114,8 +5113,8 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
goto done; goto done;
} }
desc.dwWidth = width; desc.dwWidth = wined3d_desc->width;
desc.dwHeight = height; desc.dwHeight = wined3d_desc->height;
/* 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, tex_root->version))) if (FAILED(hr = ddraw_create_surface(ddraw, &desc, &ddraw_surface, tex_root->version)))
......
...@@ -760,8 +760,8 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt ...@@ -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_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_format *format = wined3d_get_format(gl_info, format_id); const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
struct wined3d_resource_desc desc;
unsigned int i, j; unsigned int i, j;
UINT tmp_w;
HRESULT hr; HRESULT hr;
/* TODO: It should only be possible to create textures for formats /* 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 ...@@ -836,7 +836,8 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt
texture->target = GL_TEXTURE_CUBE_MAP_ARB; texture->target = GL_TEXTURE_CUBE_MAP_ARB;
/* Generate all the surfaces. */ /* 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) for (i = 0; i < texture->level_count; ++i)
{ {
/* Create the 6 faces. */ /* Create the 6 faces. */
...@@ -855,7 +856,7 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt ...@@ -855,7 +856,7 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt
struct wined3d_surface *surface; struct wined3d_surface *surface;
if (FAILED(hr = device->device_parent->ops->create_texture_surface(device->device_parent, 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); FIXME("(%p) Failed to create surface, hr %#x.\n", texture, hr);
wined3d_texture_cleanup(texture); wined3d_texture_cleanup(texture);
...@@ -867,7 +868,8 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt ...@@ -867,7 +868,8 @@ static HRESULT cubetexture_init(struct wined3d_texture *texture, UINT edge_lengt
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);
} }
tmp_w = max(1, tmp_w >> 1); desc.width = max(1, desc.width >> 1);
desc.height = desc.width;
} }
return WINED3D_OK; return WINED3D_OK;
...@@ -879,8 +881,8 @@ static HRESULT texture_init(struct wined3d_texture *texture, UINT width, UINT he ...@@ -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_gl_info *gl_info = &device->adapter->gl_info;
const struct wined3d_format *format = wined3d_get_format(gl_info, format_id); const struct wined3d_format *format = wined3d_get_format(gl_info, format_id);
struct wined3d_resource_desc desc;
UINT pow2_width, pow2_height; UINT pow2_width, pow2_height;
UINT tmp_w, tmp_h;
unsigned int i; unsigned int i;
HRESULT hr; HRESULT hr;
...@@ -1005,15 +1007,15 @@ static HRESULT texture_init(struct wined3d_texture *texture, UINT width, UINT he ...@@ -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]); TRACE("xf(%f) yf(%f)\n", texture->pow2_matrix[0], texture->pow2_matrix[5]);
/* Generate all the surfaces. */ /* Generate all the surfaces. */
tmp_w = width; wined3d_resource_get_desc(&texture->resource, &desc);
tmp_h = height; desc.resource_type = WINED3D_RTYPE_SURFACE;
for (i = 0; i < texture->level_count; ++i) for (i = 0; i < texture->level_count; ++i)
{ {
struct wined3d_surface *surface; struct wined3d_surface *surface;
/* Use the callback to create the texture surface. */ /* Use the callback to create the texture surface. */
if (FAILED(hr = device->device_parent->ops->create_texture_surface(device->device_parent, 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); FIXME("Failed to create surface %p, hr %#x\n", texture, hr);
wined3d_texture_cleanup(texture); wined3d_texture_cleanup(texture);
...@@ -1025,8 +1027,8 @@ static HRESULT texture_init(struct wined3d_texture *texture, UINT width, UINT he ...@@ -1025,8 +1027,8 @@ static HRESULT texture_init(struct wined3d_texture *texture, UINT width, UINT he
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. */
tmp_w = max(1, tmp_w >> 1); desc.width = max(1, desc.width >> 1);
tmp_h = max(1, tmp_h >> 1); desc.height = max(1, desc.height >> 1);
} }
return WINED3D_OK; return WINED3D_OK;
......
...@@ -1986,8 +1986,7 @@ struct wined3d_device_parent_ops ...@@ -1986,8 +1986,7 @@ struct wined3d_device_parent_ops
enum wined3d_multisample_type multisample_type, DWORD multisample_quality, enum wined3d_multisample_type multisample_type, DWORD multisample_quality,
struct wined3d_surface **surface); struct wined3d_surface **surface);
HRESULT (__cdecl *create_texture_surface)(struct wined3d_device_parent *device_parent, void *container_parent, 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, const struct wined3d_resource_desc *desc, UINT sub_resource_idx, struct wined3d_surface **surface);
UINT sub_resource_idx, struct wined3d_surface **surface);
HRESULT (__cdecl *create_volume)(struct wined3d_device_parent *device_parent, void *container_parent, 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, UINT width, UINT height, UINT depth, enum wined3d_format_id format_id, enum wined3d_pool pool, DWORD usage,
struct wined3d_volume **volume); struct wined3d_volume **volume);
......
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