static BOOL validate_texture2d_desc(const D3D11_TEXTURE2D_DESC *desc) { if (desc->MiscFlags & D3D11_RESOURCE_MISC_TEXTURECUBE && desc->ArraySize < 6) { WARN("Invalid array size %u for cube texture.\n", desc->ArraySize); return FALSE; } if (desc->MiscFlags & D3D11_RESOURCE_MISC_GDI_COMPATIBLE && !is_gdi_compatible_texture(desc)) { WARN("Incompatible description used to create GDI compatible texture.\n"); return FALSE; } return TRUE; }
static HRESULT d3d_texture2d_init(struct d3d_texture2d *texture, struct d3d_device *device, const D3D11_TEXTURE2D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data) { struct wined3d_resource_desc wined3d_desc; unsigned int levels; DWORD flags = 0; HRESULT hr; texture->ID3D11Texture2D_iface.lpVtbl = &d3d11_texture2d_vtbl; texture->ID3D10Texture2D_iface.lpVtbl = &d3d10_texture2d_vtbl; texture->refcount = 1; wined3d_mutex_lock(); wined3d_private_store_init(&texture->private_store); texture->desc = *desc; if (desc->SampleDesc.Count > 1) FIXME("Multisampled textures not implemented.\n"); wined3d_desc.resource_type = WINED3D_RTYPE_TEXTURE_2D; wined3d_desc.format = wined3dformat_from_dxgi_format(desc->Format); wined3d_desc.multisample_type = desc->SampleDesc.Count > 1 ? desc->SampleDesc.Count : WINED3D_MULTISAMPLE_NONE; wined3d_desc.multisample_quality = desc->SampleDesc.Quality; wined3d_desc.usage = wined3d_usage_from_d3d11(desc->BindFlags, desc->Usage); wined3d_desc.pool = WINED3D_POOL_DEFAULT; wined3d_desc.width = desc->Width; wined3d_desc.height = desc->Height; wined3d_desc.depth = 1; wined3d_desc.size = 0; 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, desc->ArraySize, levels, flags, (struct wined3d_sub_resource_data *)data, texture, &d3d_texture2d_wined3d_parent_ops, &texture->wined3d_texture))) { WARN("Failed to create wined3d texture, hr %#x.\n", hr); wined3d_private_store_cleanup(&texture->private_store); wined3d_mutex_unlock(); if (hr == WINED3DERR_NOTAVAILABLE || hr == WINED3DERR_INVALIDCALL) hr = E_INVALIDARG; return hr; } texture->desc.MipLevels = levels; if (desc->MipLevels == 1 && desc->ArraySize == 1) { IWineDXGIDevice *wine_device; if (FAILED(hr = ID3D10Device1_QueryInterface(&device->ID3D10Device1_iface, &IID_IWineDXGIDevice, (void **)&wine_device))) { ERR("Device should implement IWineDXGIDevice.\n"); wined3d_texture_decref(texture->wined3d_texture); wined3d_mutex_unlock(); return E_FAIL; } hr = IWineDXGIDevice_create_surface(wine_device, texture->wined3d_texture, 0, NULL, (IUnknown *)&texture->ID3D10Texture2D_iface, (void **)&texture->dxgi_surface); IWineDXGIDevice_Release(wine_device); if (FAILED(hr)) { ERR("Failed to create DXGI surface, returning %#x\n", hr); texture->dxgi_surface = NULL; wined3d_texture_decref(texture->wined3d_texture); wined3d_mutex_unlock(); return hr; } } wined3d_mutex_unlock(); texture->device = &device->ID3D11Device_iface; ID3D11Device_AddRef(texture->device); return S_OK; }