Commit 74a923c3 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

d3d11: Enabled GetDC() capability for 2D textures.

parent ccc6a576
...@@ -8462,9 +8462,7 @@ static void test_getdc(void) ...@@ -8462,9 +8462,7 @@ static void test_getdc(void)
/* STAGING usage, requesting GDI compatibility mode. */ /* STAGING usage, requesting GDI compatibility mode. */
desc.MiscFlags = D3D11_RESOURCE_MISC_GDI_COMPATIBLE; desc.MiscFlags = D3D11_RESOURCE_MISC_GDI_COMPATIBLE;
hr = ID3D11Device_CreateTexture2D(device, &desc, NULL, &texture); hr = ID3D11Device_CreateTexture2D(device, &desc, NULL, &texture);
todo_wine ok(FAILED(hr), "Expected CreateTexture2D to fail, hr %#x.\n", hr); ok(FAILED(hr), "Expected CreateTexture2D to fail, hr %#x.\n", hr);
if (SUCCEEDED(hr))
ID3D11Texture2D_Release(texture);
desc.Usage = D3D11_USAGE_DEFAULT; desc.Usage = D3D11_USAGE_DEFAULT;
desc.BindFlags = D3D11_BIND_RENDER_TARGET; desc.BindFlags = D3D11_BIND_RENDER_TARGET;
...@@ -8473,7 +8471,7 @@ static void test_getdc(void) ...@@ -8473,7 +8471,7 @@ static void test_getdc(void)
if (testdata[i].getdc_supported) if (testdata[i].getdc_supported)
ok(SUCCEEDED(hr), "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name); ok(SUCCEEDED(hr), "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
else else
todo_wine ok(FAILED(hr), "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name); ok(FAILED(hr), "Got unexpected hr %#x for format %s.\n", hr, testdata[i].name);
if (FAILED(hr)) if (FAILED(hr))
continue; continue;
......
...@@ -443,11 +443,25 @@ static const struct wined3d_parent_ops d3d_texture2d_wined3d_parent_ops = ...@@ -443,11 +443,25 @@ static const struct wined3d_parent_ops d3d_texture2d_wined3d_parent_ops =
d3d_texture2d_wined3d_object_released, d3d_texture2d_wined3d_object_released,
}; };
static BOOL is_gdi_compatible_texture(const D3D11_TEXTURE2D_DESC *desc)
{
if (!(desc->Format == DXGI_FORMAT_B8G8R8A8_UNORM
|| desc->Format == DXGI_FORMAT_B8G8R8A8_TYPELESS
|| desc->Format == DXGI_FORMAT_B8G8R8A8_UNORM_SRGB))
return FALSE;
if (desc->Usage != D3D11_USAGE_DEFAULT)
return FALSE;
return TRUE;
}
static HRESULT d3d_texture2d_init(struct d3d_texture2d *texture, struct d3d_device *device, static HRESULT d3d_texture2d_init(struct d3d_texture2d *texture, struct d3d_device *device,
const D3D11_TEXTURE2D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data) const D3D11_TEXTURE2D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data)
{ {
struct wined3d_resource_desc wined3d_desc; struct wined3d_resource_desc wined3d_desc;
unsigned int levels; unsigned int levels;
DWORD flags = 0;
HRESULT hr; HRESULT hr;
texture->ID3D11Texture2D_iface.lpVtbl = &d3d11_texture2d_vtbl; texture->ID3D11Texture2D_iface.lpVtbl = &d3d11_texture2d_vtbl;
...@@ -473,8 +487,21 @@ static HRESULT d3d_texture2d_init(struct d3d_texture2d *texture, struct d3d_devi ...@@ -473,8 +487,21 @@ static HRESULT d3d_texture2d_init(struct d3d_texture2d *texture, struct d3d_devi
levels = desc->MipLevels ? desc->MipLevels : wined3d_log2i(max(desc->Width, desc->Height)) + 1; levels = desc->MipLevels ? desc->MipLevels : wined3d_log2i(max(desc->Width, desc->Height)) + 1;
if (desc->MiscFlags & D3D11_RESOURCE_MISC_GDI_COMPATIBLE)
{
if (is_gdi_compatible_texture(desc))
flags |= WINED3D_TEXTURE_CREATE_GET_DC;
else
{
WARN("Incompatible description used to create GDI compatible texture.\n");
wined3d_private_store_cleanup(&texture->private_store);
wined3d_mutex_unlock();
return E_INVALIDARG;
}
}
if (FAILED(hr = wined3d_texture_create(device->wined3d_device, &wined3d_desc, if (FAILED(hr = wined3d_texture_create(device->wined3d_device, &wined3d_desc,
desc->ArraySize, levels, 0, (struct wined3d_sub_resource_data *)data, desc->ArraySize, levels, flags, (struct wined3d_sub_resource_data *)data,
texture, &d3d_texture2d_wined3d_parent_ops, &texture->wined3d_texture))) texture, &d3d_texture2d_wined3d_parent_ops, &texture->wined3d_texture)))
{ {
WARN("Failed to create wined3d texture, hr %#x.\n", hr); WARN("Failed to create wined3d texture, hr %#x.\n", hr);
......
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