HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d10_device *device, const D3D10_TEXTURE2D_DESC *desc) { struct wined3d_resource_desc wined3d_desc; HRESULT hr; texture->ID3D10Texture2D_iface.lpVtbl = &d3d10_texture2d_vtbl; texture->refcount = 1; texture->desc = *desc; if (desc->MipLevels == 1 && desc->ArraySize == 1) { IWineDXGIDevice *wine_device; hr = ID3D10Device_QueryInterface(&device->ID3D10Device_iface, &IID_IWineDXGIDevice, (void **)&wine_device); if (FAILED(hr)) { ERR("Device should implement IWineDXGIDevice\n"); return E_FAIL; } hr = IWineDXGIDevice_create_surface(wine_device, NULL, 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); return hr; } } if (desc->ArraySize != 1) FIXME("Array textures not implemented.\n"); if (desc->SampleDesc.Count > 1) FIXME("Multisampled textures not implemented.\n"); wined3d_desc.resource_type = WINED3D_RTYPE_TEXTURE; 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_d3d10core(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; if (FAILED(hr = wined3d_texture_create(device->wined3d_device, &wined3d_desc, desc->MipLevels, 0, texture, &d3d10_texture2d_wined3d_parent_ops, &texture->wined3d_texture))) { WARN("Failed to create wined3d texture, hr %#x.\n", hr); if (texture->dxgi_surface) IUnknown_Release(texture->dxgi_surface); return hr; } texture->desc.MipLevels = wined3d_texture_get_level_count(texture->wined3d_texture); return S_OK; }
static void test_device_interfaces(ID3D10Device *device) { IUnknown *obj; HRESULT hr; if (SUCCEEDED(hr = ID3D10Device_QueryInterface(device, &IID_IUnknown, (void **)&obj))) IUnknown_Release(obj); ok(SUCCEEDED(hr), "ID3D10Device does not implement IUnknown\n"); if (SUCCEEDED(hr = ID3D10Device_QueryInterface(device, &IID_IDXGIObject, (void **)&obj))) IUnknown_Release(obj); ok(SUCCEEDED(hr), "ID3D10Device does not implement IDXGIObject\n"); if (SUCCEEDED(hr = ID3D10Device_QueryInterface(device, &IID_IDXGIDevice, (void **)&obj))) IUnknown_Release(obj); ok(SUCCEEDED(hr), "ID3D10Device does not implement IDXGIDevice\n"); if (SUCCEEDED(hr = ID3D10Device_QueryInterface(device, &IID_ID3D10Device, (void **)&obj))) IUnknown_Release(obj); ok(SUCCEEDED(hr), "ID3D10Device does not implement ID3D10Device\n"); }
HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d10_device *device, const D3D10_TEXTURE2D_DESC *desc) { HRESULT hr; texture->ID3D10Texture2D_iface.lpVtbl = &d3d10_texture2d_vtbl; texture->refcount = 1; texture->desc = *desc; if (desc->MipLevels == 1 && desc->ArraySize == 1) { IWineDXGIDevice *wine_device; hr = ID3D10Device_QueryInterface(&device->ID3D10Device_iface, &IID_IWineDXGIDevice, (void **)&wine_device); if (FAILED(hr)) { ERR("Device should implement IWineDXGIDevice\n"); return E_FAIL; } hr = IWineDXGIDevice_create_surface(wine_device, NULL, 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); return hr; } } 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_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 S_OK; }
HRESULT d3d10_texture2d_init(struct d3d10_texture2d *texture, struct d3d10_device *device, const D3D10_TEXTURE2D_DESC *desc) { HRESULT hr; texture->ID3D10Texture2D_iface.lpVtbl = &d3d10_texture2d_vtbl; texture->refcount = 1; texture->desc = *desc; if (desc->MipLevels == 1 && desc->ArraySize == 1) { IWineDXGIDevice *wine_device; hr = ID3D10Device_QueryInterface(&device->ID3D10Device_iface, &IID_IWineDXGIDevice, (void **)&wine_device); if (FAILED(hr)) { ERR("Device should implement IWineDXGIDevice\n"); return E_FAIL; } hr = IWineDXGIDevice_create_surface(wine_device, NULL, 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); return hr; } FIXME("Implement DXGI<->wined3d usage conversion\n"); hr = wined3d_surface_create(device->wined3d_device, desc->Width, desc->Height, wined3dformat_from_dxgi_format(desc->Format), 0, desc->Usage, WINED3DPOOL_DEFAULT, desc->SampleDesc.Count > 1 ? desc->SampleDesc.Count : WINED3DMULTISAMPLE_NONE, desc->SampleDesc.Quality, SURFACE_OPENGL, 0, texture, &d3d10_texture2d_wined3d_parent_ops, &texture->wined3d_surface); if (FAILED(hr)) { ERR("CreateSurface failed, returning %#x\n", hr); IDXGISurface_Release(texture->dxgi_surface); return hr; } } return S_OK; }
static IDXGIDevice *create_device(void) { IDXGIDevice *dxgi_device; ID3D10Device *device; HRESULT hr; if (SUCCEEDED(D3D10CreateDevice(NULL, D3D10_DRIVER_TYPE_HARDWARE, NULL, 0, D3D10_SDK_VERSION, &device))) goto success; if (SUCCEEDED(D3D10CreateDevice(NULL, D3D10_DRIVER_TYPE_WARP, NULL, 0, D3D10_SDK_VERSION, &device))) goto success; if (SUCCEEDED(D3D10CreateDevice(NULL, D3D10_DRIVER_TYPE_REFERENCE, NULL, 0, D3D10_SDK_VERSION, &device))) goto success; return NULL; success: hr = ID3D10Device_QueryInterface(device, &IID_IDXGIDevice, (void **)&dxgi_device); ok(SUCCEEDED(hr), "Created device does not implement IDXGIDevice\n"); ID3D10Device_Release(device); return dxgi_device; }
HRESULT WINAPI D3DX10GetFeatureLevel1(ID3D10Device *device, ID3D10Device1 **device1) { TRACE("device %p, device1 %p.\n", device, device1); return ID3D10Device_QueryInterface(device, &IID_ID3D10Device1, (void **)device1); }
HRESULT WINAPI D3D10CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type, HMODULE swrast, UINT flags, UINT sdk_version, DXGI_SWAP_CHAIN_DESC *swapchain_desc, IDXGISwapChain **swapchain, ID3D10Device **device) { IDXGIDevice *dxgi_device; IDXGIFactory *factory; HRESULT hr; TRACE("adapter %p, driver_type %s, swrast %p, flags %#x, sdk_version %d,\n" "\tswapchain_desc %p, swapchain %p, device %p\n", adapter, debug_d3d10_driver_type(driver_type), swrast, flags, sdk_version, swapchain_desc, swapchain, device); hr = D3D10CreateDevice(adapter, driver_type, swrast, flags, sdk_version, device); if (FAILED(hr)) { WARN("Failed to create a device, returning %#x\n", hr); *device = NULL; return hr; } TRACE("Created ID3D10Device %p\n", *device); hr = ID3D10Device_QueryInterface(*device, &IID_IDXGIDevice, (void **)&dxgi_device); if (FAILED(hr)) { ERR("Failed to get a dxgi device from the d3d10 device, returning %#x\n", hr); ID3D10Device_Release(*device); *device = NULL; return hr; } hr = IDXGIDevice_GetAdapter(dxgi_device, &adapter); IDXGIDevice_Release(dxgi_device); if (FAILED(hr)) { ERR("Failed to get the device adapter, returning %#x\n", hr); ID3D10Device_Release(*device); *device = NULL; return hr; } hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory); IDXGIAdapter_Release(adapter); if (FAILED(hr)) { ERR("Failed to get the adapter factory, returning %#x\n", hr); ID3D10Device_Release(*device); *device = NULL; return hr; } hr = IDXGIFactory_CreateSwapChain(factory, (IUnknown *)*device, swapchain_desc, swapchain); IDXGIFactory_Release(factory); if (FAILED(hr)) { ID3D10Device_Release(*device); *device = NULL; WARN("Failed to create a swapchain, returning %#x\n", hr); return hr; } TRACE("Created IDXGISwapChain %p\n", *swapchain); return S_OK; }