wined3d: Pass a wined3d_resource_desc structure to device_parent_create_swapchain_surface().

This commit is contained in:
Henri Verbeet 2013-06-04 09:57:08 +02:00 committed by Alexandre Julliard
parent a4d2660c9b
commit 13a38e8d5e
8 changed files with 75 additions and 64 deletions

View File

@ -1845,8 +1845,7 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
}
static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
void *container_parent, UINT width, UINT height, enum wined3d_format_id format_id, DWORD usage,
enum wined3d_multisample_type multisample_type, DWORD multisample_quality, struct wined3d_surface **surface)
void *container_parent, const struct wined3d_resource_desc *wined3d_desc, struct wined3d_surface **surface)
{
struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
struct wined3d_resource *sub_resource;
@ -1854,20 +1853,18 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
D3D10_TEXTURE2D_DESC desc;
HRESULT hr;
FIXME("device_parent %p, container_parent %p, width %u, height %u, format_id %#x, usage %#x,\n"
"\tmultisample_type %#x, multisample_quality %u, surface %p partial stub!\n",
device_parent, container_parent, width, height, format_id, usage,
multisample_type, multisample_quality, surface);
FIXME("device_parent %p, container_parent %p, wined3d_desc %p, surface %p partial stub!\n",
device_parent, container_parent, wined3d_desc, surface);
FIXME("Implement DXGI<->wined3d usage conversion\n");
desc.Width = width;
desc.Height = height;
desc.Width = wined3d_desc->width;
desc.Height = wined3d_desc->height;
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.Format = dxgi_format_from_wined3dformat(format_id);
desc.SampleDesc.Count = multisample_type ? multisample_type : 1;
desc.SampleDesc.Quality = multisample_quality;
desc.Format = dxgi_format_from_wined3dformat(wined3d_desc->format);
desc.SampleDesc.Count = wined3d_desc->multisample_type ? wined3d_desc->multisample_type : 1;
desc.SampleDesc.Quality = wined3d_desc->multisample_quality;
desc.Usage = D3D10_USAGE_DEFAULT;
desc.BindFlags = D3D10_BIND_RENDER_TARGET;
desc.CPUAccessFlags = 0;

View File

@ -2914,21 +2914,18 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
}
static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
void *container_parent, UINT width, UINT height, enum wined3d_format_id format_id, DWORD usage,
enum wined3d_multisample_type multisample_type, DWORD multisample_quality, struct wined3d_surface **surface)
void *container_parent, const struct wined3d_resource_desc *desc, struct wined3d_surface **surface)
{
struct d3d8_device *device = device_from_device_parent(device_parent);
struct d3d8_surface *d3d_surface;
HRESULT hr;
TRACE("device_parent %p, container_parent %p, width %u, height %u, format_id %#x, usage %#x,\n"
"\tmultisample_type %#x, multisample_quality %u, surface %p.\n",
device_parent, container_parent, width, height, format_id, usage,
multisample_type, multisample_quality, surface);
TRACE("device_parent %p, container_parent %p, desc %p, surface %p.\n",
device_parent, container_parent, desc, surface);
if (FAILED(hr = d3d8_device_create_surface(device, width, height, d3dformat_from_wined3dformat(format_id),
TRUE, FALSE, (IDirect3DSurface8 **)&d3d_surface, usage, D3DPOOL_DEFAULT, multisample_type,
multisample_quality)))
if (FAILED(hr = d3d8_device_create_surface(device, desc->width, desc->height,
d3dformat_from_wined3dformat(desc->format), TRUE, 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

@ -3295,21 +3295,18 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
}
static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
void *container_parent, UINT width, UINT height, enum wined3d_format_id format_id, DWORD usage,
enum wined3d_multisample_type multisample_type, DWORD multisample_quality, struct wined3d_surface **surface)
void *container_parent, const struct wined3d_resource_desc *desc, struct wined3d_surface **surface)
{
struct d3d9_device *device = device_from_device_parent(device_parent);
struct d3d9_surface *d3d_surface;
HRESULT hr;
TRACE("device_parent %p, container_parent %p, width %u, height %u, format_id %#x, usage %#x,\n"
"\tmultisample_type %#x, multisample_quality %u, surface %p.\n",
device_parent, container_parent, width, height, format_id, usage,
multisample_type, multisample_quality, surface);
TRACE("device_parent %p, container_parent %p, desc %p, surface %p.\n",
device_parent, container_parent, desc, surface);
if (FAILED(hr = d3d9_device_create_surface(device, width, height, d3dformat_from_wined3dformat(format_id),
TRUE, FALSE, (IDirect3DSurface9 **)&d3d_surface, usage, D3DPOOL_DEFAULT, multisample_type,
multisample_quality)))
if (FAILED(hr = d3d9_device_create_surface(device, desc->width, desc->height,
d3dformat_from_wined3dformat(desc->format), TRUE, 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

@ -5139,16 +5139,13 @@ static const struct wined3d_parent_ops ddraw_frontbuffer_parent_ops =
};
static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
void *container_parent, UINT width, UINT height, enum wined3d_format_id format_id, DWORD usage,
enum wined3d_multisample_type multisample_type, DWORD multisample_quality, struct wined3d_surface **surface)
void *container_parent, const struct wined3d_resource_desc *desc, struct wined3d_surface **surface)
{
struct ddraw *ddraw = ddraw_from_device_parent(device_parent);
HRESULT hr;
TRACE("device_parent %p, container_parent %p, width %u, height %u, format_id %#x, usage %#x,\n"
"\tmultisample_type %#x, multisample_quality %u, surface %p.\n",
device_parent, container_parent, width, height, format_id, usage,
multisample_type, multisample_quality, surface);
TRACE("device_parent %p, container_parent %p, desc %p, surface %p.\n",
device_parent, container_parent, desc, surface);
if (ddraw->wined3d_frontbuffer)
{
@ -5156,8 +5153,8 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
return E_FAIL;
}
if (SUCCEEDED(hr = wined3d_surface_create(ddraw->wined3d_device, width, height, format_id, usage,
WINED3D_POOL_DEFAULT, multisample_type, multisample_quality, WINED3D_SURFACE_MAPPABLE,
if (SUCCEEDED(hr = wined3d_surface_create(ddraw->wined3d_device, desc->width, desc->height, desc->format,
desc->usage, desc->pool, desc->multisample_type, desc->multisample_quality, WINED3D_SURFACE_MAPPABLE,
ddraw, &ddraw_frontbuffer_parent_ops, surface)))
ddraw->wined3d_frontbuffer = *surface;

View File

@ -156,6 +156,7 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *ifac
const DXGI_SHARED_RESOURCE *shared_resource, IDXGISurface **surface)
{
struct wined3d_device_parent *device_parent;
struct wined3d_resource_desc surface_desc;
IWineDXGIDeviceParent *dxgi_device_parent;
HRESULT hr;
UINT i;
@ -174,6 +175,16 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *ifac
device_parent = IWineDXGIDeviceParent_get_wined3d_device_parent(dxgi_device_parent);
FIXME("Implement DXGI<->wined3d usage conversion\n");
surface_desc.resource_type = WINED3D_RTYPE_SURFACE;
surface_desc.format = wined3dformat_from_dxgi_format(desc->Format);
surface_desc.multisample_type = desc->SampleDesc.Count > 1 ? desc->SampleDesc.Count : WINED3D_MULTISAMPLE_NONE;
surface_desc.multisample_quality = desc->SampleDesc.Quality;
surface_desc.usage = usage;
surface_desc.pool = WINED3D_POOL_DEFAULT;
surface_desc.width = desc->Width;
surface_desc.height = desc->Height;
surface_desc.depth = 1;
surface_desc.size = 0;
memset(surface, 0, surface_count * sizeof(*surface));
for (i = 0; i < surface_count; ++i)
@ -181,13 +192,10 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *ifac
struct wined3d_surface *wined3d_surface;
IUnknown *parent;
hr = device_parent->ops->create_swapchain_surface(device_parent, NULL,
desc->Width, desc->Height, wined3dformat_from_dxgi_format(desc->Format), usage,
desc->SampleDesc.Count > 1 ? desc->SampleDesc.Count : WINED3D_MULTISAMPLE_NONE,
desc->SampleDesc.Quality, &wined3d_surface);
if (FAILED(hr))
if (FAILED(hr = device_parent->ops->create_swapchain_surface(device_parent,
NULL, &surface_desc, &wined3d_surface)))
{
ERR("CreateSurface failed, returning %#x\n", hr);
ERR("Failed to create surface, hr %#x.\n", hr);
goto fail;
}

View File

@ -5002,13 +5002,23 @@ HRESULT CDECL wined3d_device_reset(struct wined3d_device *device,
if (swapchain_desc->enable_auto_depth_stencil && !device->auto_depth_stencil)
{
struct wined3d_resource_desc surface_desc;
TRACE("Creating the depth stencil buffer\n");
surface_desc.resource_type = WINED3D_RTYPE_SURFACE;
surface_desc.format = swapchain_desc->auto_depth_stencil_format;
surface_desc.multisample_type = swapchain_desc->multisample_type;
surface_desc.multisample_quality = swapchain_desc->multisample_quality;
surface_desc.usage = WINED3DUSAGE_DEPTHSTENCIL;
surface_desc.pool = WINED3D_POOL_DEFAULT;
surface_desc.width = swapchain_desc->backbuffer_width;
surface_desc.height = swapchain_desc->backbuffer_height;
surface_desc.depth = 1;
surface_desc.size = 0;
if (FAILED(hr = device->device_parent->ops->create_swapchain_surface(device->device_parent,
device->device_parent, swapchain_desc->backbuffer_width, swapchain_desc->backbuffer_height,
swapchain_desc->auto_depth_stencil_format, WINED3DUSAGE_DEPTHSTENCIL,
swapchain_desc->multisample_type, swapchain_desc->multisample_quality,
&device->auto_depth_stencil)))
device->device_parent, &surface_desc, &device->auto_depth_stencil)))
{
ERR("Failed to create the depth stencil buffer, hr %#x.\n", hr);
return WINED3DERR_INVALIDCALL;

View File

@ -817,6 +817,7 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
struct wined3d_swapchain_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
{
const struct wined3d_adapter *adapter = device->adapter;
struct wined3d_resource_desc surface_desc;
const struct wined3d_format *format;
struct wined3d_display_mode mode;
BOOL displaymode_set = FALSE;
@ -886,11 +887,20 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
swapchain_update_render_to_fbo(swapchain);
TRACE("Creating front buffer.\n");
if (FAILED(hr = device->device_parent->ops->create_swapchain_surface(device->device_parent, parent,
swapchain->desc.backbuffer_width, swapchain->desc.backbuffer_height,
swapchain->desc.backbuffer_format, WINED3DUSAGE_RENDERTARGET,
swapchain->desc.multisample_type, swapchain->desc.multisample_quality,
&swapchain->front_buffer)))
surface_desc.resource_type = WINED3D_RTYPE_SURFACE;
surface_desc.format = swapchain->desc.backbuffer_format;
surface_desc.multisample_type = swapchain->desc.multisample_type;
surface_desc.multisample_quality = swapchain->desc.multisample_quality;
surface_desc.usage = WINED3DUSAGE_RENDERTARGET;
surface_desc.pool = WINED3D_POOL_DEFAULT;
surface_desc.width = swapchain->desc.backbuffer_width;
surface_desc.height = swapchain->desc.backbuffer_height;
surface_desc.depth = 1;
surface_desc.size = 0;
if (FAILED(hr = device->device_parent->ops->create_swapchain_surface(device->device_parent,
parent, &surface_desc, &swapchain->front_buffer)))
{
WARN("Failed to create front buffer, hr %#x.\n", hr);
goto err;
@ -995,11 +1005,8 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
for (i = 0; i < swapchain->desc.backbuffer_count; ++i)
{
TRACE("Creating back buffer %u.\n", i);
if (FAILED(hr = device->device_parent->ops->create_swapchain_surface(device->device_parent, parent,
swapchain->desc.backbuffer_width, swapchain->desc.backbuffer_height,
swapchain->desc.backbuffer_format, WINED3DUSAGE_RENDERTARGET,
swapchain->desc.multisample_type, swapchain->desc.multisample_quality,
&swapchain->back_buffers[i])))
if (FAILED(hr = device->device_parent->ops->create_swapchain_surface(device->device_parent,
parent, &surface_desc, &swapchain->back_buffers[i])))
{
WARN("Failed to create back buffer %u, hr %#x.\n", i, hr);
goto err;
@ -1014,11 +1021,11 @@ static HRESULT swapchain_init(struct wined3d_swapchain *swapchain, struct wined3
TRACE("Creating depth/stencil buffer.\n");
if (!device->auto_depth_stencil)
{
surface_desc.format = swapchain->desc.auto_depth_stencil_format;
surface_desc.usage = WINED3DUSAGE_DEPTHSTENCIL;
if (FAILED(hr = device->device_parent->ops->create_swapchain_surface(device->device_parent,
device->device_parent, swapchain->desc.backbuffer_width, swapchain->desc.backbuffer_height,
swapchain->desc.auto_depth_stencil_format, WINED3DUSAGE_DEPTHSTENCIL,
swapchain->desc.multisample_type, swapchain->desc.multisample_quality,
&device->auto_depth_stencil)))
device->device_parent, &surface_desc, &device->auto_depth_stencil)))
{
WARN("Failed to create the auto depth stencil, hr %#x.\n", hr);
goto err;

View File

@ -1982,9 +1982,7 @@ struct wined3d_device_parent_ops
void (__cdecl *wined3d_device_created)(struct wined3d_device_parent *device_parent, struct wined3d_device *device);
void (__cdecl *mode_changed)(struct wined3d_device_parent *device_parent);
HRESULT (__cdecl *create_swapchain_surface)(struct wined3d_device_parent *device_parent, void *container_parent,
UINT width, UINT height, enum wined3d_format_id format_id, DWORD usage,
enum wined3d_multisample_type multisample_type, DWORD multisample_quality,
struct wined3d_surface **surface);
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);
HRESULT (__cdecl *create_volume)(struct wined3d_device_parent *device_parent, void *container_parent,