2008-11-12 12:04:24 +01:00
|
|
|
/*
|
|
|
|
* Copyright 2008 Henri Verbeet for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "wine/port.h"
|
|
|
|
|
2009-01-16 10:14:24 +01:00
|
|
|
#define D3D10CORE_INIT_GUID
|
2008-11-12 12:04:24 +01:00
|
|
|
#include "d3d10core_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d10core);
|
|
|
|
|
2013-09-17 09:22:40 +02:00
|
|
|
BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, void *reserved)
|
2008-11-12 12:04:24 +01:00
|
|
|
{
|
2013-09-17 09:22:40 +02:00
|
|
|
switch (reason)
|
2008-11-12 12:04:24 +01:00
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2013-09-17 09:22:40 +02:00
|
|
|
DisableThreadLibraryCalls(inst);
|
2008-11-12 12:04:24 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2008-11-12 15:43:46 +01:00
|
|
|
|
|
|
|
static HRESULT WINAPI layer_init(enum dxgi_device_layer_id id, DWORD *count, DWORD *values)
|
|
|
|
{
|
|
|
|
TRACE("id %#x, count %p, values %p\n", id, count, values);
|
|
|
|
|
|
|
|
if (id != DXGI_DEVICE_LAYER_D3D10_DEVICE)
|
|
|
|
{
|
|
|
|
WARN("Unknown layer id %#x\n", id);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static UINT WINAPI layer_get_size(enum dxgi_device_layer_id id, struct layer_get_size_args *args, DWORD unknown0)
|
|
|
|
{
|
|
|
|
TRACE("id %#x, args %p, unknown0 %#x\n", id, args, unknown0);
|
|
|
|
|
|
|
|
if (id != DXGI_DEVICE_LAYER_D3D10_DEVICE)
|
|
|
|
{
|
|
|
|
WARN("Unknown layer id %#x\n", id);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return sizeof(struct d3d10_device);
|
|
|
|
}
|
|
|
|
|
|
|
|
static HRESULT WINAPI layer_create(enum dxgi_device_layer_id id, void **layer_base, DWORD unknown0,
|
|
|
|
void *device_object, REFIID riid, void **device_layer)
|
|
|
|
{
|
|
|
|
struct d3d10_device *object;
|
2012-12-11 22:27:31 +01:00
|
|
|
HRESULT hr;
|
2008-11-12 15:43:46 +01:00
|
|
|
|
|
|
|
TRACE("id %#x, layer_base %p, unknown0 %#x, device_object %p, riid %s, device_layer %p\n",
|
|
|
|
id, layer_base, unknown0, device_object, debugstr_guid(riid), device_layer);
|
|
|
|
|
|
|
|
if (id != DXGI_DEVICE_LAYER_D3D10_DEVICE)
|
|
|
|
{
|
|
|
|
WARN("Unknown layer id %#x\n", id);
|
|
|
|
*device_layer = NULL;
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2009-01-20 10:00:20 +01:00
|
|
|
object = *layer_base;
|
2012-12-11 22:27:31 +01:00
|
|
|
if (FAILED(hr = d3d10_device_init(object, device_object)))
|
|
|
|
{
|
|
|
|
WARN("Failed to initialize device, hr %#x.\n", hr);
|
|
|
|
*device_layer = NULL;
|
|
|
|
return hr;
|
|
|
|
}
|
2012-03-22 17:18:47 +01:00
|
|
|
*device_layer = &object->IUnknown_inner;
|
2008-11-12 15:43:46 +01:00
|
|
|
|
|
|
|
TRACE("Created d3d10 device at %p\n", object);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
HRESULT WINAPI D3D10CoreRegisterLayers(void)
|
|
|
|
{
|
|
|
|
const struct dxgi_device_layer layers[] =
|
|
|
|
{
|
|
|
|
{DXGI_DEVICE_LAYER_D3D10_DEVICE, layer_init, layer_get_size, layer_create},
|
|
|
|
};
|
|
|
|
|
|
|
|
DXGID3D10RegisterLayers(layers, sizeof(layers)/sizeof(*layers));
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2008-11-14 13:57:06 +01:00
|
|
|
|
|
|
|
HRESULT WINAPI D3D10CoreCreateDevice(IDXGIFactory *factory, IDXGIAdapter *adapter,
|
2009-12-07 20:20:03 +01:00
|
|
|
UINT flags, void *unknown0, ID3D10Device **device)
|
2008-11-14 13:57:06 +01:00
|
|
|
{
|
|
|
|
IUnknown *dxgi_device;
|
|
|
|
HMODULE d3d10core;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2009-12-07 20:20:03 +01:00
|
|
|
TRACE("factory %p, adapter %p, flags %#x, unknown0 %p, device %p.\n",
|
2008-11-17 12:16:03 +01:00
|
|
|
factory, adapter, flags, unknown0, device);
|
|
|
|
|
2008-11-14 13:57:06 +01:00
|
|
|
d3d10core = GetModuleHandleA("d3d10core.dll");
|
|
|
|
hr = DXGID3D10CreateDevice(d3d10core, factory, adapter, flags, unknown0, (void **)&dxgi_device);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to create device, returning %#x\n", hr);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = IUnknown_QueryInterface(dxgi_device, &IID_ID3D10Device, (void **)device);
|
|
|
|
IUnknown_Release(dxgi_device);
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|