Commit 2b4c72b1 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

d3d10core: Always create a wined3d texture for d3d10core textures.

parent 4a013688
......@@ -90,7 +90,7 @@ struct d3d10_texture2d
LONG refcount;
IUnknown *dxgi_surface;
struct wined3d_surface *wined3d_surface;
struct wined3d_texture *wined3d_texture;
D3D10_TEXTURE2D_DESC desc;
};
......
......@@ -24,6 +24,13 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
static void STDMETHODCALLTYPE d3d10_null_wined3d_object_destroyed(void *parent) {}
const struct wined3d_parent_ops d3d10_null_wined3d_parent_ops =
{
d3d10_null_wined3d_object_destroyed,
};
/* Inner IUnknown methods */
static inline struct d3d10_device *impl_from_IUnknown(IUnknown *iface)
......@@ -1361,41 +1368,14 @@ static HRESULT CDECL device_parent_create_texture_surface(struct wined3d_device_
enum wined3d_pool pool, UINT level, enum wined3d_cubemap_face face, struct wined3d_surface **surface)
{
struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
struct d3d10_texture2d *texture;
D3D10_TEXTURE2D_DESC desc;
HRESULT hr;
FIXME("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n"
"\tpool %#x, level %u, face %u, surface %p partial stub!\n",
TRACE("device_parent %p, container_parent %p, width %u, height %u, format %#x, usage %#x,\n"
"\tpool %#x, level %u, face %u, surface %p.\n",
device_parent, container_parent, width, height, format, usage, pool, level, face, surface);
FIXME("Implement DXGI<->wined3d usage conversion\n");
desc.Width = width;
desc.Height = height;
desc.MipLevels = 1;
desc.ArraySize = 1;
desc.Format = dxgi_format_from_wined3dformat(format);
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Usage = usage;
desc.BindFlags = 0;
desc.CPUAccessFlags = 0;
desc.MiscFlags = 0;
hr = d3d10_device_CreateTexture2D(&device->ID3D10Device_iface, &desc, NULL,
(ID3D10Texture2D **)&texture);
if (FAILED(hr))
{
ERR("CreateTexture2D failed, returning %#x\n", hr);
return hr;
}
*surface = texture->wined3d_surface;
wined3d_surface_incref(*surface);
ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
return S_OK;
return wined3d_surface_create(device->wined3d_device, width, height, format, level,
usage, pool, WINED3D_MULTISAMPLE_NONE, 0, WINED3D_SURFACE_TYPE_OPENGL, 0, container_parent,
&d3d10_null_wined3d_parent_ops, surface);
}
static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_device_parent *device_parent,
......@@ -1403,6 +1383,7 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
enum wined3d_multisample_type multisample_type, DWORD multisample_quality, struct wined3d_surface **surface)
{
struct d3d10_device *device = device_from_wined3d_device_parent(device_parent);
struct wined3d_resource *sub_resource;
struct d3d10_texture2d *texture;
D3D10_TEXTURE2D_DESC desc;
HRESULT hr;
......@@ -1434,7 +1415,8 @@ static HRESULT CDECL device_parent_create_swapchain_surface(struct wined3d_devic
return hr;
}
*surface = texture->wined3d_surface;
sub_resource = wined3d_texture_get_sub_resource(texture->wined3d_texture, 0);
*surface = wined3d_surface_from_resource(sub_resource);
wined3d_surface_incref(*surface);
ID3D10Texture2D_Release(&texture->ID3D10Texture2D_iface);
......
......@@ -66,8 +66,8 @@ static ULONG STDMETHODCALLTYPE d3d10_texture2d_AddRef(ID3D10Texture2D *iface)
TRACE("%p increasing refcount to %u\n", This, refcount);
if (refcount == 1 && This->wined3d_surface)
wined3d_surface_incref(This->wined3d_surface);
if (refcount == 1)
wined3d_texture_incref(This->wined3d_texture);
return refcount;
}
......@@ -88,12 +88,7 @@ static ULONG STDMETHODCALLTYPE d3d10_texture2d_Release(ID3D10Texture2D *iface)
TRACE("%p decreasing refcount to %u\n", This, refcount);
if (!refcount)
{
if (This->wined3d_surface)
wined3d_surface_decref(This->wined3d_surface);
else
d3d10_texture2d_wined3d_object_released(This);
}
wined3d_texture_decref(This->wined3d_texture);
return refcount;
}
......@@ -233,20 +228,23 @@ HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d10_devic
ERR("Failed to create DXGI surface, returning %#x\n", hr);
return hr;
}
}
FIXME("Implement DXGI<->wined3d usage conversion\n");
FIXME("Implement DXGI<->wined3d usage conversion\n");
if (desc->ArraySize != 1)
FIXME("Array textures not implemented.\n");
if (desc->SampleDesc.Count > 1)
FIXME("Multisampled textures not implemented.\n");
hr = wined3d_surface_create(device->wined3d_device, desc->Width, desc->Height,
wined3dformat_from_dxgi_format(desc->Format), 0, desc->Usage, WINED3D_POOL_DEFAULT,
desc->SampleDesc.Count > 1 ? desc->SampleDesc.Count : WINED3D_MULTISAMPLE_NONE,
desc->SampleDesc.Quality, WINED3D_SURFACE_TYPE_OPENGL, 0, texture, &d3d10_texture2d_wined3d_parent_ops,
&texture->wined3d_surface);
if (FAILED(hr))
{
ERR("CreateSurface failed, returning %#x\n", hr);
hr = wined3d_texture_create_2d(device->wined3d_device, desc->Width, desc->Height,
desc->MipLevels, desc->Usage, wined3dformat_from_dxgi_format(desc->Format), WINED3D_POOL_DEFAULT,
texture, &d3d10_texture2d_wined3d_parent_ops, &texture->wined3d_texture);
if (FAILED(hr))
{
WARN("Failed to create wined3d texture, hr %#x.\n", hr);
if (texture->dxgi_surface)
IDXGISurface_Release(texture->dxgi_surface);
return hr;
}
return hr;
}
return S_OK;
......
......@@ -37,7 +37,7 @@ static struct wined3d_resource *wined3d_resource_from_resource(ID3D10Resource *r
return wined3d_buffer_get_resource(((struct d3d10_buffer *)resource)->wined3d_buffer);
case D3D10_RESOURCE_DIMENSION_TEXTURE2D:
return wined3d_surface_get_resource(((struct d3d10_texture2d *)resource)->wined3d_surface);
return wined3d_texture_get_resource(((struct d3d10_texture2d *)resource)->wined3d_texture);
default:
FIXME("Unhandled resource dimension %#x.\n", dimension);
......
......@@ -189,9 +189,10 @@ static HRESULT STDMETHODCALLTYPE dxgi_device_CreateSurface(IWineDXGIDevice *ifac
struct wined3d_surface *wined3d_surface;
IUnknown *parent;
hr = device_parent->ops->create_texture_surface(device_parent, NULL, desc->Width, desc->Height,
wined3dformat_from_dxgi_format(desc->Format), usage, WINED3D_POOL_DEFAULT, 0,
WINED3D_CUBEMAP_FACE_POSITIVE_X, &wined3d_surface);
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))
{
ERR("CreateSurface failed, returning %#x\n", hr);
......
......@@ -3852,6 +3852,11 @@ do { \
return WINED3D_OK;
}
struct wined3d_surface * CDECL wined3d_surface_from_resource(struct wined3d_resource *resource)
{
return surface_from_resource(resource);
}
HRESULT CDECL wined3d_surface_unmap(struct wined3d_surface *surface)
{
TRACE("surface %p.\n", surface);
......
......@@ -193,6 +193,7 @@
@ cdecl wined3d_surface_create(ptr long long long long long long long long long long ptr ptr ptr)
@ cdecl wined3d_surface_decref(ptr)
@ cdecl wined3d_surface_flip(ptr ptr long)
@ cdecl wined3d_surface_from_resource(ptr)
@ cdecl wined3d_surface_get_blt_status(ptr long)
@ cdecl wined3d_surface_get_flip_status(ptr long)
@ cdecl wined3d_surface_get_overlay_position(ptr ptr ptr)
......
......@@ -2325,6 +2325,7 @@ HRESULT __cdecl wined3d_surface_create(struct wined3d_device *device, UINT width
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);
struct wined3d_surface * __cdecl wined3d_surface_from_resource(struct wined3d_resource *resource);
HRESULT __cdecl wined3d_surface_get_blt_status(const struct wined3d_surface *surface, DWORD flags);
HRESULT __cdecl wined3d_surface_get_flip_status(const struct wined3d_surface *surface, DWORD flags);
HRESULT __cdecl wined3d_surface_get_overlay_position(const struct wined3d_surface *surface, LONG *x, LONG *y);
......
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