2007-07-09 14:06:40 +02:00
|
|
|
/*
|
|
|
|
* Direct3D 10
|
|
|
|
*
|
|
|
|
* Copyright 2007 Andras Kovacs
|
2009-02-27 09:29:48 +01:00
|
|
|
* Copyright 2009 Henri Verbeet for CodeWeavers
|
2007-07-09 14:06:40 +02:00
|
|
|
*
|
|
|
|
* 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"
|
2008-10-20 15:28:08 +02:00
|
|
|
#include "wine/port.h"
|
2007-07-09 14:06:40 +02:00
|
|
|
|
2008-10-20 15:28:08 +02:00
|
|
|
#include "d3d10_private.h"
|
2007-07-09 14:06:40 +02:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
|
|
|
|
|
2008-10-21 15:06:58 +02:00
|
|
|
HRESULT WINAPI D3D10CreateDevice(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type,
|
|
|
|
HMODULE swrast, UINT flags, UINT sdk_version, ID3D10Device **device)
|
|
|
|
{
|
2008-11-14 13:57:06 +01:00
|
|
|
IDXGIFactory *factory;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2017-05-05 11:59:23 +02:00
|
|
|
TRACE("adapter %p, driver_type %s, swrast %p, flags %#x, sdk_version %#x, device %p.\n",
|
2008-10-21 15:06:58 +02:00
|
|
|
adapter, debug_d3d10_driver_type(driver_type), swrast, flags, sdk_version, device);
|
|
|
|
|
2017-05-05 11:59:23 +02:00
|
|
|
if (sdk_version != D3D10_SDK_VERSION)
|
|
|
|
{
|
|
|
|
WARN("Invalid SDK version %#x.\n", sdk_version);
|
|
|
|
return E_INVALIDARG;
|
|
|
|
}
|
|
|
|
|
2008-11-14 13:57:06 +01:00
|
|
|
if (adapter)
|
|
|
|
{
|
|
|
|
IDXGIAdapter_AddRef(adapter);
|
|
|
|
hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2017-05-05 11:59:23 +02:00
|
|
|
WARN("Failed to get dxgi factory, returning %#x.\n", hr);
|
2008-11-14 13:57:06 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hr = CreateDXGIFactory(&IID_IDXGIFactory, (void **)&factory);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2017-05-05 11:59:23 +02:00
|
|
|
WARN("Failed to create dxgi factory, returning %#x.\n", hr);
|
2008-11-14 13:57:06 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2017-05-05 11:59:23 +02:00
|
|
|
switch (driver_type)
|
2008-11-14 13:57:06 +01:00
|
|
|
{
|
|
|
|
case D3D10_DRIVER_TYPE_HARDWARE:
|
|
|
|
{
|
|
|
|
hr = IDXGIFactory_EnumAdapters(factory, 0, &adapter);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2017-05-05 11:59:23 +02:00
|
|
|
WARN("No adapters found, returning %#x.\n", hr);
|
2008-11-14 13:57:06 +01:00
|
|
|
IDXGIFactory_Release(factory);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case D3D10_DRIVER_TYPE_NULL:
|
2017-05-05 11:59:23 +02:00
|
|
|
FIXME("NULL device not implemented, falling back to refrast.\n");
|
2011-09-24 17:28:32 +02:00
|
|
|
/* fall through, for now */
|
2008-11-14 13:57:06 +01:00
|
|
|
case D3D10_DRIVER_TYPE_REFERENCE:
|
|
|
|
{
|
|
|
|
HMODULE refrast = LoadLibraryA("d3d10ref.dll");
|
|
|
|
if (!refrast)
|
|
|
|
{
|
2017-05-05 11:59:23 +02:00
|
|
|
WARN("Failed to load refrast, returning E_FAIL.\n");
|
2008-11-14 13:57:06 +01:00
|
|
|
IDXGIFactory_Release(factory);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
hr = IDXGIFactory_CreateSoftwareAdapter(factory, refrast, &adapter);
|
|
|
|
FreeLibrary(refrast);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2017-05-05 11:59:23 +02:00
|
|
|
WARN("Failed to create a software adapter, returning %#x.\n", hr);
|
2008-11-14 13:57:06 +01:00
|
|
|
IDXGIFactory_Release(factory);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case D3D10_DRIVER_TYPE_SOFTWARE:
|
|
|
|
{
|
|
|
|
if (!swrast)
|
|
|
|
{
|
2017-05-05 11:59:23 +02:00
|
|
|
WARN("Software device requested, but NULL swrast passed, returning E_FAIL.\n");
|
2008-11-14 13:57:06 +01:00
|
|
|
IDXGIFactory_Release(factory);
|
|
|
|
return E_FAIL;
|
|
|
|
}
|
|
|
|
hr = IDXGIFactory_CreateSoftwareAdapter(factory, swrast, &adapter);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2017-05-05 11:59:23 +02:00
|
|
|
WARN("Failed to create a software adapter, returning %#x.\n", hr);
|
2008-11-14 13:57:06 +01:00
|
|
|
IDXGIFactory_Release(factory);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-01-27 10:07:53 +01:00
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled driver type %#x.\n", driver_type);
|
|
|
|
IDXGIFactory_Release(factory);
|
|
|
|
return E_FAIL;
|
2008-11-14 13:57:06 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-16 00:24:10 +01:00
|
|
|
hr = D3D10CoreCreateDevice(factory, adapter, flags, D3D_FEATURE_LEVEL_10_0, device);
|
2008-11-14 13:57:06 +01:00
|
|
|
IDXGIAdapter_Release(adapter);
|
|
|
|
IDXGIFactory_Release(factory);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2017-05-05 11:59:23 +02:00
|
|
|
WARN("Failed to create a device, returning %#x.\n", hr);
|
2008-11-14 13:57:06 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2017-05-05 11:59:23 +02:00
|
|
|
TRACE("Created ID3D10Device %p.\n", *device);
|
2008-11-14 13:57:06 +01:00
|
|
|
|
|
|
|
return hr;
|
2008-10-21 15:06:58 +02:00
|
|
|
}
|
2008-10-23 16:37:09 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
2008-11-14 13:57:07 +01:00
|
|
|
IDXGIDevice *dxgi_device;
|
2008-10-23 16:37:09 +02:00
|
|
|
IDXGIFactory *factory;
|
|
|
|
HRESULT hr;
|
|
|
|
|
2015-08-18 00:53:24 +02:00
|
|
|
TRACE("adapter %p, driver_type %s, swrast %p, flags %#x, sdk_version %d, "
|
|
|
|
"swapchain_desc %p, swapchain %p, device %p\n",
|
2008-10-23 16:37:09 +02:00
|
|
|
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);
|
2008-11-14 13:57:07 +01:00
|
|
|
*device = NULL;
|
2008-10-23 16:37:09 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Created ID3D10Device %p\n", *device);
|
|
|
|
|
2008-11-14 13:57:07 +01:00
|
|
|
hr = ID3D10Device_QueryInterface(*device, &IID_IDXGIDevice, (void **)&dxgi_device);
|
2008-10-23 16:37:09 +02:00
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
2008-11-14 13:57:07 +01:00
|
|
|
ERR("Failed to get a dxgi device from the d3d10 device, returning %#x\n", hr);
|
2008-10-23 16:37:09 +02:00
|
|
|
ID3D10Device_Release(*device);
|
|
|
|
*device = NULL;
|
2008-11-14 13:57:07 +01:00
|
|
|
return hr;
|
|
|
|
}
|
2008-10-23 16:37:09 +02:00
|
|
|
|
2008-11-14 13:57:07 +01:00
|
|
|
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;
|
2008-10-23 16:37:09 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2008-11-14 13:57:07 +01:00
|
|
|
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;
|
|
|
|
}
|
2008-10-23 16:37:09 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2009-02-26 09:00:01 +01:00
|
|
|
|
2016-05-25 20:04:05 +02:00
|
|
|
static int d3d10_effect_type_compare(const void *key, const struct wine_rb_entry *entry)
|
|
|
|
{
|
|
|
|
const struct d3d10_effect_type *t = WINE_RB_ENTRY_VALUE(entry, const struct d3d10_effect_type, entry);
|
|
|
|
const DWORD *id = key;
|
|
|
|
|
|
|
|
return *id - t->id;
|
|
|
|
}
|
|
|
|
|
2009-02-26 09:00:01 +01:00
|
|
|
HRESULT WINAPI D3D10CreateEffectFromMemory(void *data, SIZE_T data_size, UINT flags,
|
|
|
|
ID3D10Device *device, ID3D10EffectPool *effect_pool, ID3D10Effect **effect)
|
|
|
|
{
|
|
|
|
struct d3d10_effect *object;
|
2009-02-27 09:29:48 +01:00
|
|
|
HRESULT hr;
|
2009-02-26 09:00:01 +01:00
|
|
|
|
|
|
|
FIXME("data %p, data_size %lu, flags %#x, device %p, effect_pool %p, effect %p stub!\n",
|
|
|
|
data, data_size, flags, device, effect_pool, effect);
|
|
|
|
|
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate D3D10 effect object memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2016-09-01 10:55:49 +02:00
|
|
|
wine_rb_init(&object->types, d3d10_effect_type_compare);
|
2011-06-03 11:15:47 +02:00
|
|
|
object->ID3D10Effect_iface.lpVtbl = &d3d10_effect_vtbl;
|
2009-02-26 09:00:01 +01:00
|
|
|
object->refcount = 1;
|
2009-03-06 08:43:48 +01:00
|
|
|
ID3D10Device_AddRef(device);
|
|
|
|
object->device = device;
|
2009-02-26 09:00:01 +01:00
|
|
|
|
2009-02-27 09:29:48 +01:00
|
|
|
hr = d3d10_effect_parse(object, data, data_size);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
ERR("Failed to parse effect\n");
|
2011-06-03 11:15:47 +02:00
|
|
|
IUnknown_Release(&object->ID3D10Effect_iface);
|
2009-02-27 09:29:48 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2011-06-03 11:15:47 +02:00
|
|
|
*effect = &object->ID3D10Effect_iface;
|
2009-02-26 09:00:01 +01:00
|
|
|
|
|
|
|
TRACE("Created ID3D10Effect %p\n", object);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2009-11-04 10:37:14 +01:00
|
|
|
|
2012-01-03 23:06:51 +01:00
|
|
|
HRESULT WINAPI D3D10CompileEffectFromMemory(void *data, SIZE_T data_size, const char *filename,
|
|
|
|
const D3D10_SHADER_MACRO *defines, ID3D10Include *include, UINT hlsl_flags, UINT fx_flags,
|
|
|
|
ID3D10Blob **effect, ID3D10Blob **errors)
|
|
|
|
{
|
|
|
|
FIXME("data %p, data_size %lu, filename %s, defines %p, include %p,"
|
|
|
|
" hlsl_flags %#x, fx_flags %#x, effect %p, errors %p stub!\n",
|
|
|
|
data, data_size, wine_dbgstr_a(filename), defines, include,
|
|
|
|
hlsl_flags, fx_flags, effect, errors);
|
|
|
|
|
|
|
|
if (effect)
|
|
|
|
*effect = NULL;
|
|
|
|
if (errors)
|
|
|
|
*errors = NULL;
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2016-04-01 08:44:53 +02:00
|
|
|
HRESULT WINAPI D3D10CreateEffectPoolFromMemory(void *data, SIZE_T data_size, UINT fx_flags,
|
|
|
|
ID3D10Device *device, ID3D10EffectPool **effect_pool)
|
|
|
|
{
|
|
|
|
FIXME("data %p, data_size %lu, fx_flags %#x, device %p, effect_pool %p stub.\n",
|
|
|
|
data, data_size, fx_flags, device, effect_pool);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
2012-01-03 23:06:51 +01:00
|
|
|
|
2013-09-18 10:57:12 +02:00
|
|
|
const char * WINAPI D3D10GetVertexShaderProfile(ID3D10Device *device)
|
2009-11-04 10:37:14 +01:00
|
|
|
{
|
|
|
|
FIXME("device %p stub!\n", device);
|
|
|
|
|
|
|
|
return "vs_4_0";
|
|
|
|
}
|
2009-11-04 10:37:15 +01:00
|
|
|
|
2013-09-18 10:57:12 +02:00
|
|
|
const char * WINAPI D3D10GetGeometryShaderProfile(ID3D10Device *device)
|
2009-11-04 10:37:15 +01:00
|
|
|
{
|
|
|
|
FIXME("device %p stub!\n", device);
|
|
|
|
|
|
|
|
return "gs_4_0";
|
|
|
|
}
|
2009-11-04 10:37:16 +01:00
|
|
|
|
2013-09-18 10:57:12 +02:00
|
|
|
const char * WINAPI D3D10GetPixelShaderProfile(ID3D10Device *device)
|
2009-11-04 10:37:16 +01:00
|
|
|
{
|
|
|
|
FIXME("device %p stub!\n", device);
|
|
|
|
|
|
|
|
return "ps_4_0";
|
|
|
|
}
|
2010-07-21 20:44:59 +02:00
|
|
|
|
|
|
|
HRESULT WINAPI D3D10ReflectShader(const void *data, SIZE_T data_size, ID3D10ShaderReflection **reflector)
|
|
|
|
{
|
|
|
|
struct d3d10_shader_reflection *object;
|
|
|
|
|
|
|
|
FIXME("data %p, data_size %lu, reflector %p stub!\n", data, data_size, reflector);
|
|
|
|
|
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate D3D10 shader reflection object memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2011-06-03 11:18:36 +02:00
|
|
|
object->ID3D10ShaderReflection_iface.lpVtbl = &d3d10_shader_reflection_vtbl;
|
2010-07-21 20:44:59 +02:00
|
|
|
object->refcount = 1;
|
|
|
|
|
2011-06-03 11:18:36 +02:00
|
|
|
*reflector = &object->ID3D10ShaderReflection_iface;
|
2010-07-21 20:44:59 +02:00
|
|
|
|
|
|
|
TRACE("Created ID3D10ShaderReflection %p\n", object);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|