From 3c7ece7bdb571a6742574e4587dc289557a19a62 Mon Sep 17 00:00:00 2001 From: Justin Miller Date: Mon, 11 Sep 2023 18:37:07 -0700 Subject: [PATCH] d3d10 and d3d10core d3d10_1 now compile --- dll/directx/wine/CMakeLists.txt | 12 +- dll/directx/wine/d3d10/CMakeLists.txt | 2 +- dll/directx/wine/d3d10/d3d10_main.c | 41 +- dll/directx/wine/d3d10/d3d10_private.h | 2 +- dll/directx/wine/d3d10/effect.c | 43 +- dll/directx/wine/d3d10/shader.c | 6 +- dll/directx/wine/d3d10/stateblock.c | 6 +- dll/directx/wine/d3d10/utils.c | 3 - dll/directx/wine/d3d10_1/d3d10_1_main.c | 23 +- dll/directx/wine/d3d10core/Makefile.in | 8 - dll/directx/wine/d3d11/Makefile.in | 17 - dll/directx/wine/d3d11/async.c | 16 +- dll/directx/wine/d3d11/buffer.c | 20 +- dll/directx/wine/d3d11/d3d11.spec | 8 +- dll/directx/wine/d3d11/d3d11_main.c | 54 +- dll/directx/wine/d3d11/d3d11_private.h | 139 +- dll/directx/wine/d3d11/device.c | 1919 ++++++++++++--------- dll/directx/wine/d3d11/inputlayout.c | 40 +- dll/directx/wine/d3d11/shader.c | 580 ++----- dll/directx/wine/d3d11/state.c | 85 +- dll/directx/wine/d3d11/texture.c | 528 +++++- dll/directx/wine/d3d11/utils.c | 123 +- dll/directx/wine/d3d11/view.c | 282 ++- dll/directx/wine/d3d12/d3d12.spec | 13 +- dll/directx/wine/d3d12/d3d12_main.c | 392 ++++- dll/directx/wine/d3d12core/CMakeLists.txt | 21 - dll/directx/wine/d3d12core/Makefile.in | 1 - dll/directx/wine/d3d12core/d3d12core.spec | 2 - sdk/lib/dxguid/dxguid-mingw.c | 4 + 29 files changed, 2520 insertions(+), 1870 deletions(-) delete mode 100644 dll/directx/wine/d3d10core/Makefile.in delete mode 100644 dll/directx/wine/d3d11/Makefile.in delete mode 100644 dll/directx/wine/d3d12core/CMakeLists.txt delete mode 100644 dll/directx/wine/d3d12core/Makefile.in delete mode 100644 dll/directx/wine/d3d12core/d3d12core.spec diff --git a/dll/directx/wine/CMakeLists.txt b/dll/directx/wine/CMakeLists.txt index 56b8e04902801..1f0a211523cea 100644 --- a/dll/directx/wine/CMakeLists.txt +++ b/dll/directx/wine/CMakeLists.txt @@ -6,10 +6,10 @@ if (MSVC) endif() add_subdirectory(amstream) -add_subdirectory(d3d8) -add_subdirectory(d3d9) +#add_subdirectory(d3d8) +#add_subdirectory(d3d9) add_subdirectory(d3dcompiler_43) -add_subdirectory(d3drm) +#add_subdirectory(d3drm) add_subdirectory(d3dx9_24) add_subdirectory(d3dx9_25) add_subdirectory(d3dx9_26) @@ -31,7 +31,7 @@ add_subdirectory(d3dx9_41) add_subdirectory(d3dx9_42) add_subdirectory(d3dx9_43) add_subdirectory(d3dxof) -add_subdirectory(ddraw) +#add_subdirectory(ddraw) add_subdirectory(devenum) add_subdirectory(dinput) add_subdirectory(dinput8) @@ -54,8 +54,8 @@ add_subdirectory(wined3d) add_subdirectory(d3d10_1) add_subdirectory(d3d10core) add_subdirectory(d3d11) - add_subdirectory(d3d12) - add_subdirectory(d3d12core) + #add_subdirectory(d3d12) + #add_subdirectory(d3d12core) #add_subdirectory(dwrite) add_subdirectory(dxgi) #endif() \ No newline at end of file diff --git a/dll/directx/wine/d3d10/CMakeLists.txt b/dll/directx/wine/d3d10/CMakeLists.txt index 0b2a1549fabba..0431e25336c3c 100644 --- a/dll/directx/wine/d3d10/CMakeLists.txt +++ b/dll/directx/wine/d3d10/CMakeLists.txt @@ -27,7 +27,7 @@ if(CMAKE_C_COMPILER_ID STREQUAL "GNU") endif() set_module_type(d3d10 win32dll) -target_link_libraries(d3d10 wine uuid) +target_link_libraries(d3d10 wine dxguid uuid) add_importlibs(d3d10 d3d11 d3dwine msvcrt d3dcompiler_43 d3d10core dxgi kernel32 ntdll) add_pch(d3d10 d3d10_private.h SOURCE) add_dependencies(d3d10 wineheaders d3d_idl_headers) diff --git a/dll/directx/wine/d3d10/d3d10_main.c b/dll/directx/wine/d3d10/d3d10_main.c index 4ce0df78c795f..e3d1c57e44825 100644 --- a/dll/directx/wine/d3d10/d3d10_main.c +++ b/dll/directx/wine/d3d10/d3d10_main.c @@ -20,17 +20,13 @@ * */ -#include "config.h" -#include "wine/port.h" - #include "d3d10_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d10); -HRESULT WINAPI D3D10CreateDevice(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type, +static HRESULT d3d10_create_device(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type, HMODULE swrast, UINT flags, UINT sdk_version, ID3D10Device **device) { - GUID Factory = {0x7b7166ec,0x21c7,0x44ae,0xb2,0x1a,0xc9,0xae,0x32,0x1a,0xe3,0x69}; IDXGIFactory *factory; HRESULT hr; @@ -46,7 +42,7 @@ HRESULT WINAPI D3D10CreateDevice(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver if (adapter) { IDXGIAdapter_AddRef(adapter); - hr = IDXGIAdapter_GetParent(adapter, &Factory, (void **)&factory); + hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory); if (FAILED(hr)) { WARN("Failed to get dxgi factory, returning %#x.\n", hr); @@ -55,7 +51,7 @@ HRESULT WINAPI D3D10CreateDevice(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver } else { - hr = CreateDXGIFactory(&Factory, (void **)&factory); + hr = CreateDXGIFactory(&IID_IDXGIFactory, (void **)&factory); if (FAILED(hr)) { WARN("Failed to create dxgi factory, returning %#x.\n", hr); @@ -64,6 +60,8 @@ HRESULT WINAPI D3D10CreateDevice(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver switch (driver_type) { + case D3D10_DRIVER_TYPE_WARP: + FIXME("WARP driver not implemented, falling back to hardware.\n"); case D3D10_DRIVER_TYPE_HARDWARE: { hr = IDXGIFactory_EnumAdapters(factory, 0, &adapter); @@ -138,12 +136,16 @@ HRESULT WINAPI D3D10CreateDevice(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver return hr; } +HRESULT WINAPI D3D10CreateDevice(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type, + HMODULE swrast, UINT flags, UINT sdk_version, ID3D10Device **device) +{ + return d3d10_create_device(adapter, driver_type, swrast, flags, sdk_version, device); +} + 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) { - GUID Factory = {0x7b7166ec,0x21c7,0x44ae,0xb2,0x1a,0xc9,0xae,0x32,0x1a,0xe3,0x69}; - GUID Device = {0x54ec77fa,0x1377,0x44e6,0x8c,0x32,0x88,0xfd,0x5f,0x44,0xc8,0x4c}; IDXGIDevice *dxgi_device; IDXGIFactory *factory; HRESULT hr; @@ -153,8 +155,9 @@ HRESULT WINAPI D3D10CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D10_DRIVER 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)) + /* Avoid forwarding to D3D10CreateDevice(), since it breaks applications + * hooking these entry-points. */ + if (FAILED(hr = d3d10_create_device(adapter, driver_type, swrast, flags, sdk_version, device))) { WARN("Failed to create a device, returning %#x\n", hr); *device = NULL; @@ -163,7 +166,7 @@ HRESULT WINAPI D3D10CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D10_DRIVER TRACE("Created ID3D10Device %p\n", *device); - hr = ID3D10Device_QueryInterface(*device, &Device, (void **)&dxgi_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); @@ -182,7 +185,7 @@ HRESULT WINAPI D3D10CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D10_DRIVER return hr; } - hr = IDXGIAdapter_GetParent(adapter, &Factory, (void **)&factory); + hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory); IDXGIAdapter_Release(adapter); if (FAILED(hr)) { @@ -256,17 +259,13 @@ HRESULT WINAPI D3D10CompileEffectFromMemory(void *data, SIZE_T data_size, const 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", + TRACE("data %p, data_size %lu, filename %s, defines %p, include %p, " + "hlsl_flags %#x, fx_flags %#x, effect %p, errors %p.\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; + return D3DCompile(data, data_size, filename, defines, include, + NULL, "fx_4_0", hlsl_flags, fx_flags, effect, errors); } HRESULT WINAPI D3D10CreateEffectPoolFromMemory(void *data, SIZE_T data_size, UINT fx_flags, diff --git a/dll/directx/wine/d3d10/d3d10_private.h b/dll/directx/wine/d3d10/d3d10_private.h index 0f0f95553c605..e785b8b8698e4 100644 --- a/dll/directx/wine/d3d10/d3d10_private.h +++ b/dll/directx/wine/d3d10/d3d10_private.h @@ -43,7 +43,7 @@ const char *debug_d3d10_driver_type(D3D10_DRIVER_TYPE driver_type) DECLSPEC_HIDD const char *debug_d3d10_shader_variable_class(D3D10_SHADER_VARIABLE_CLASS c) DECLSPEC_HIDDEN; const char *debug_d3d10_shader_variable_type(D3D10_SHADER_VARIABLE_TYPE t) DECLSPEC_HIDDEN; const char *debug_d3d10_device_state_types(D3D10_DEVICE_STATE_TYPES t) DECLSPEC_HIDDEN; -//GUID IID_IDXGIFactory = {0x7b7166ec,0x21c7,0x44ae,0xb2,0x1a,0xc9,0xae,0x32,0x1a,0xe3,0x69}; + enum d3d10_effect_object_type { D3D10_EOT_RASTERIZER_STATE = 0x0, diff --git a/dll/directx/wine/d3d10/effect.c b/dll/directx/wine/d3d10/effect.c index 5e5dd8f390c3e..fafd5b6722fe7 100644 --- a/dll/directx/wine/d3d10/effect.c +++ b/dll/directx/wine/d3d10/effect.c @@ -18,9 +18,6 @@ * */ -#include "config.h" -#include "wine/port.h" - #include "d3d10_private.h" #include @@ -373,8 +370,13 @@ static HRESULT shader_parse_signature(const char *data, DWORD data_size, struct return E_INVALIDARG; } read_dword(&ptr, &e[i].SemanticIndex); +#ifdef __REACTOS__ read_dword(&ptr, (DWORD *)&e[i].SystemValueType); read_dword(&ptr, (DWORD *)&e[i].ComponentType); +#else + read_dword(&ptr, &e[i].SystemValueType); + read_dword(&ptr, &e[i].ComponentType); +#endif read_dword(&ptr, &e[i].Register); read_dword(&ptr, &mask); @@ -1139,7 +1141,7 @@ static const struct d3d10_effect_state_property_info *get_property_info(UINT id) { unsigned int i; - for (i = 0; i < sizeof(property_info) / sizeof(*property_info); ++i) + for (i = 0; i < ARRAY_SIZE(property_info); ++i) { if (property_info[i].id == id) return &property_info[i]; @@ -1152,7 +1154,7 @@ static const struct d3d10_effect_state_storage_info *get_storage_info(D3D_SHADER { unsigned int i; - for (i = 0; i < sizeof(d3d10_effect_state_storage_info) / sizeof(*d3d10_effect_state_storage_info); ++i) + for (i = 0; i < ARRAY_SIZE(d3d10_effect_state_storage_info); ++i) { if (d3d10_effect_state_storage_info[i].id == id) return &d3d10_effect_state_storage_info[i]; @@ -1350,14 +1352,20 @@ static HRESULT parse_fx10_object(const char *data, size_t data_size, WARN("Invalid offset %#lx (data size %#lx).\n", (long)(*ptr - data), (long)data_size); return E_FAIL; } - - read_dword(ptr, (DWORD *)&o->type); +#ifdef __REACTOS__ + read_dword(ptr, (DWORD*)&o->type); +#else + read_dword(ptr, &o->type); +#endif TRACE("Effect object is of type %#x.\n", o->type); read_dword(ptr, &tmp); TRACE("Effect object index %#x.\n", tmp); - +#ifdef __REACTOS__ read_dword(ptr, (DWORD *)&operation); +#else + read_dword(ptr, &operation); +#endif TRACE("Effect object operation %#x.\n", operation); read_dword(ptr, &offset); @@ -1945,7 +1953,11 @@ static HRESULT parse_fx10_local_buffer(const char *data, size_t data_size, read_dword(ptr, &l->data_size); TRACE("Local buffer data size: %#x.\n", l->data_size); - read_dword(ptr, (DWORD *)&d3d10_cbuffer_type); +#ifdef __REACTOS__ + read_dword(ptr, (DWORD*)&d3d10_cbuffer_type); +#else + read_dword(ptr, &d3d10_cbuffer_type); +#endif TRACE("Local buffer type: %#x.\n", d3d10_cbuffer_type); switch(d3d10_cbuffer_type) @@ -2588,10 +2600,9 @@ static inline struct d3d10_effect *impl_from_ID3D10Effect(ID3D10Effect *iface) static HRESULT STDMETHODCALLTYPE d3d10_effect_QueryInterface(ID3D10Effect *iface, REFIID riid, void **object) { - GUID effect = {0x51b0ca8b, 0xec0b, 0x4519, 0x87, 0x0d, 0x8e, 0xe1, 0xcb, 0x50, 0x17, 0xc7}; TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object); - if (IsEqualGUID(riid, &effect) + if (IsEqualGUID(riid, &IID_ID3D10Effect) || IsEqualGUID(riid, &IID_IUnknown)) { IUnknown_AddRef(iface); @@ -2720,14 +2731,14 @@ static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_GetCon if (index >= This->local_buffer_count) { WARN("Invalid index specified\n"); - return (ID3D10EffectConstantBuffer *)&null_local_buffer; + return (ID3D10EffectConstantBuffer *)&null_local_buffer.ID3D10EffectVariable_iface; } l = &This->local_buffers[index]; TRACE("Returning buffer %p, %s.\n", l, debugstr_a(l->name)); - return (ID3D10EffectConstantBuffer *)l; + return (ID3D10EffectConstantBuffer *)&l->ID3D10EffectVariable_iface; } static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_GetConstantBufferByName(ID3D10Effect *iface, @@ -2745,13 +2756,13 @@ static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_GetCon if (l->name && !strcmp(l->name, name)) { TRACE("Returning buffer %p.\n", l); - return (ID3D10EffectConstantBuffer *)l; + return (ID3D10EffectConstantBuffer *)&l->ID3D10EffectVariable_iface; } } WARN("Invalid name specified\n"); - return (ID3D10EffectConstantBuffer *)&null_local_buffer; + return (ID3D10EffectConstantBuffer *)&null_local_buffer.ID3D10EffectVariable_iface; } static struct ID3D10EffectVariable * STDMETHODCALLTYPE d3d10_effect_GetVariableByIndex(ID3D10Effect *iface, UINT index) @@ -3533,7 +3544,7 @@ static struct ID3D10EffectConstantBuffer * STDMETHODCALLTYPE d3d10_effect_variab TRACE("iface %p\n", iface); - return (ID3D10EffectConstantBuffer *)This->buffer; + return (ID3D10EffectConstantBuffer *)&This->buffer->ID3D10EffectVariable_iface; } static struct ID3D10EffectScalarVariable * STDMETHODCALLTYPE d3d10_effect_variable_AsScalar( diff --git a/dll/directx/wine/d3d10/shader.c b/dll/directx/wine/d3d10/shader.c index 8050a04fd0a0f..52e3cc06bf48e 100644 --- a/dll/directx/wine/d3d10/shader.c +++ b/dll/directx/wine/d3d10/shader.c @@ -18,9 +18,6 @@ * */ -#include "config.h" -#include "wine/port.h" - #include "d3d10_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d10); @@ -34,10 +31,9 @@ static inline struct d3d10_shader_reflection *impl_from_ID3D10ShaderReflection(I static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_QueryInterface(ID3D10ShaderReflection *iface, REFIID riid, void **object) { - GUID Reflection = {0xd40e20b6, 0xf8f7, 0x42ad, 0xab, 0x20, 0x4b, 0xaf, 0x8f, 0x15, 0xdf, 0xaa}; TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object); - if (IsEqualGUID(riid, &Reflection) + if (IsEqualGUID(riid, &IID_ID3D10ShaderReflection) || IsEqualGUID(riid, &IID_IUnknown)) { IUnknown_AddRef(iface); diff --git a/dll/directx/wine/d3d10/stateblock.c b/dll/directx/wine/d3d10/stateblock.c index 19003e3d326e0..e20a4e31f3c77 100644 --- a/dll/directx/wine/d3d10/stateblock.c +++ b/dll/directx/wine/d3d10/stateblock.c @@ -17,9 +17,6 @@ * */ -#include "config.h" -#include "wine/port.h" - #include "d3d10_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d10); @@ -234,14 +231,13 @@ static void stateblock_cleanup(struct d3d10_stateblock *stateblock) static HRESULT STDMETHODCALLTYPE d3d10_stateblock_QueryInterface(ID3D10StateBlock *iface, REFIID iid, void **object) { - GUID State = {0x0803425a, 0x57f5, 0x4dd6, 0x94, 0x65, 0xa8, 0x75, 0x70, 0x83, 0x4a, 0x08}; struct d3d10_stateblock *stateblock; TRACE("iface %p, iid %s, object %p.\n", iface, debugstr_guid(iid), object); stateblock = impl_from_ID3D10StateBlock(iface); - if (IsEqualGUID(iid, &State) + if (IsEqualGUID(iid, &IID_ID3D10StateBlock) || IsEqualGUID(iid, &IID_IUnknown)) { IUnknown_AddRef(&stateblock->ID3D10StateBlock_iface); diff --git a/dll/directx/wine/d3d10/utils.c b/dll/directx/wine/d3d10/utils.c index 223b33a801719..3b5186848840b 100644 --- a/dll/directx/wine/d3d10/utils.c +++ b/dll/directx/wine/d3d10/utils.c @@ -17,9 +17,6 @@ * */ -#include "config.h" -#include "wine/port.h" - #include "d3d10_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d10); diff --git a/dll/directx/wine/d3d10_1/d3d10_1_main.c b/dll/directx/wine/d3d10_1/d3d10_1_main.c index 23ccc2320e1ed..8ee5aa71f799c 100644 --- a/dll/directx/wine/d3d10_1/d3d10_1_main.c +++ b/dll/directx/wine/d3d10_1/d3d10_1_main.c @@ -63,10 +63,9 @@ static const char *debug_d3d10_feature_level(D3D10_FEATURE_LEVEL1 feature_level) #undef WINE_D3D10_TO_STR -HRESULT WINAPI D3D10CreateDevice1(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type, HMODULE swrast, +static HRESULT d3d10_create_device1(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type, HMODULE swrast, UINT flags, D3D10_FEATURE_LEVEL1 hw_level, UINT sdk_version, ID3D10Device1 **device) { - GUID DeviceGUID = {0x7b7166ec,0x21c7,0x44ae,0xb2,0x1a,0xc9,0xae,0x32,0x1a,0xe3,0x69}; IDXGIFactory *factory; HRESULT hr; @@ -85,7 +84,7 @@ HRESULT WINAPI D3D10CreateDevice1(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE drive if (adapter) { IDXGIAdapter_AddRef(adapter); - if (FAILED(hr = IDXGIAdapter_GetParent(adapter, &DeviceGUID, (void **)&factory))) + if (FAILED(hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory))) { WARN("Failed to get dxgi factory, hr %#x.\n", hr); return hr; @@ -93,7 +92,7 @@ HRESULT WINAPI D3D10CreateDevice1(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE drive } else { - if (FAILED(hr = CreateDXGIFactory(&DeviceGUID, (void **)&factory))) + if (FAILED(hr = CreateDXGIFactory(&IID_IDXGIFactory, (void **)&factory))) { WARN("Failed to create dxgi factory, hr %#x.\n", hr); return hr; @@ -176,12 +175,16 @@ HRESULT WINAPI D3D10CreateDevice1(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE drive return hr; } +HRESULT WINAPI D3D10CreateDevice1(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type, HMODULE swrast, + UINT flags, D3D10_FEATURE_LEVEL1 hw_level, UINT sdk_version, ID3D10Device1 **device) +{ + return d3d10_create_device1(adapter, driver_type, swrast, flags, hw_level, sdk_version, device); +} + HRESULT WINAPI D3D10CreateDeviceAndSwapChain1(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type, HMODULE swrast, UINT flags, D3D10_FEATURE_LEVEL1 feature_level, UINT sdk_version, DXGI_SWAP_CHAIN_DESC *swapchain_desc, IDXGISwapChain **swapchain, ID3D10Device1 **device) { - GUID DeviceGUID = {0x7b7166ec,0x21c7,0x44ae,0xb2,0x1a,0xc9,0xae,0x32,0x1a,0xe3,0x69}; - GUID dxgiGUID = {0x54ec77fa,0x1377,0x44e6,0x8c,0x32,0x88,0xfd,0x5f,0x44,0xc8,0x4c}; IDXGIDevice *dxgi_device; IDXGIFactory *factory; HRESULT hr; @@ -197,7 +200,9 @@ HRESULT WINAPI D3D10CreateDeviceAndSwapChain1(IDXGIAdapter *adapter, D3D10_DRIVE if (!device) return E_INVALIDARG; - if (FAILED(hr = D3D10CreateDevice1(adapter, driver_type, swrast, flags, feature_level, sdk_version, device))) + /* Avoid forwarding to D3D10CreateDevice1(), since it breaks applications + * hooking these entry-points. */ + if (FAILED(hr = d3d10_create_device1(adapter, driver_type, swrast, flags, feature_level, sdk_version, device))) { WARN("Failed to create a device, returning %#x.\n", hr); *device = NULL; @@ -206,7 +211,7 @@ HRESULT WINAPI D3D10CreateDeviceAndSwapChain1(IDXGIAdapter *adapter, D3D10_DRIVE if (swapchain) { - if (FAILED(hr = ID3D10Device1_QueryInterface(*device, &dxgiGUID, (void **)&dxgi_device))) + if (FAILED(hr = ID3D10Device1_QueryInterface(*device, &IID_IDXGIDevice, (void **)&dxgi_device))) { ERR("Failed to get a dxgi device from the d3d10 device, returning %#x.\n", hr); goto cleanup; @@ -220,7 +225,7 @@ HRESULT WINAPI D3D10CreateDeviceAndSwapChain1(IDXGIAdapter *adapter, D3D10_DRIVE goto cleanup; } - hr = IDXGIAdapter_GetParent(adapter, &DeviceGUID, (void **)&factory); + hr = IDXGIAdapter_GetParent(adapter, &IID_IDXGIFactory, (void **)&factory); IDXGIAdapter_Release(adapter); if (FAILED(hr)) { diff --git a/dll/directx/wine/d3d10core/Makefile.in b/dll/directx/wine/d3d10core/Makefile.in deleted file mode 100644 index bfa0a81dd78a3..0000000000000 --- a/dll/directx/wine/d3d10core/Makefile.in +++ /dev/null @@ -1,8 +0,0 @@ -MODULE = d3d10core.dll -IMPORTLIB = d3d10core -IMPORTS = d3d11 - -C_SRCS = \ - d3d10core_main.c - -RC_SRCS = version.rc diff --git a/dll/directx/wine/d3d11/Makefile.in b/dll/directx/wine/d3d11/Makefile.in deleted file mode 100644 index 5a56faec523e4..0000000000000 --- a/dll/directx/wine/d3d11/Makefile.in +++ /dev/null @@ -1,17 +0,0 @@ -MODULE = d3d11.dll -IMPORTLIB = d3d11 -IMPORTS = dxguid uuid dxgi wined3d - -C_SRCS = \ - async.c \ - buffer.c \ - d3d11_main.c \ - device.c \ - inputlayout.c \ - shader.c \ - state.c \ - texture.c \ - utils.c \ - view.c - -RC_SRCS = version.rc diff --git a/dll/directx/wine/d3d11/async.c b/dll/directx/wine/d3d11/async.c index 41238aca3cea8..fd83871220d51 100644 --- a/dll/directx/wine/d3d11/async.c +++ b/dll/directx/wine/d3d11/async.c @@ -18,9 +18,6 @@ * */ -#include "config.h" -#include "wine/port.h" - #include "d3d11_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d11); @@ -74,7 +71,7 @@ static ULONG STDMETHODCALLTYPE d3d11_query_AddRef(ID3D11Query *iface) if (refcount == 1) { - ID3D11Device_AddRef(query->device); + ID3D11Device2_AddRef(query->device); wined3d_mutex_lock(); wined3d_query_incref(query->wined3d_query); wined3d_mutex_unlock(); @@ -92,13 +89,13 @@ static ULONG STDMETHODCALLTYPE d3d11_query_Release(ID3D11Query *iface) if (!refcount) { - ID3D11Device *device = query->device; + ID3D11Device2 *device = query->device; wined3d_mutex_lock(); wined3d_query_decref(query->wined3d_query); wined3d_mutex_unlock(); - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -110,7 +107,7 @@ static void STDMETHODCALLTYPE d3d11_query_GetDevice(ID3D11Query *iface, ID3D11De TRACE("iface %p, device %p.\n", iface, device); - *device = query->device; + *device = (ID3D11Device *)query->device; ID3D11Device_AddRef(*device); } @@ -254,7 +251,7 @@ static void STDMETHODCALLTYPE d3d10_query_GetDevice(ID3D10Query *iface, ID3D10De TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_QueryInterface(query->device, &IID_ID3D10Device, (void **)device); + ID3D11Device2_QueryInterface(query->device, &IID_ID3D10Device, (void **)device); } static HRESULT STDMETHODCALLTYPE d3d10_query_GetPrivateData(ID3D10Query *iface, @@ -470,8 +467,7 @@ static HRESULT d3d_query_init(struct d3d_query *query, struct d3d_device *device wined3d_mutex_unlock(); query->predicate = predicate; - query->device = &device->ID3D11Device_iface; - ID3D11Device_AddRef(query->device); + ID3D11Device2_AddRef(query->device = &device->ID3D11Device2_iface); return S_OK; } diff --git a/dll/directx/wine/d3d11/buffer.c b/dll/directx/wine/d3d11/buffer.c index 09778e20ad19e..ed9ee133118ae 100644 --- a/dll/directx/wine/d3d11/buffer.c +++ b/dll/directx/wine/d3d11/buffer.c @@ -17,9 +17,6 @@ * */ -#include "config.h" -#include "wine/port.h" - #include "d3d11_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d11); @@ -71,7 +68,7 @@ static ULONG STDMETHODCALLTYPE d3d11_buffer_AddRef(ID3D11Buffer *iface) if (refcount == 1) { - ID3D11Device_AddRef(buffer->device); + ID3D11Device2_AddRef(buffer->device); wined3d_mutex_lock(); wined3d_buffer_incref(buffer->wined3d_buffer); wined3d_mutex_unlock(); @@ -89,14 +86,14 @@ static ULONG STDMETHODCALLTYPE d3d11_buffer_Release(ID3D11Buffer *iface) if (!refcount) { - ID3D11Device *device = buffer->device; + ID3D11Device2 *device = buffer->device; wined3d_mutex_lock(); wined3d_buffer_decref(buffer->wined3d_buffer); wined3d_mutex_unlock(); /* Release the device last, it may cause the wined3d device to be * destroyed. */ - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -108,7 +105,7 @@ static void STDMETHODCALLTYPE d3d11_buffer_GetDevice(ID3D11Buffer *iface, ID3D11 TRACE("iface %p, device %p.\n", iface, device); - *device = buffer->device; + *device = (ID3D11Device *)buffer->device; ID3D11Device_AddRef(*device); } @@ -242,7 +239,7 @@ static void STDMETHODCALLTYPE d3d10_buffer_GetDevice(ID3D10Buffer *iface, ID3D10 TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_QueryInterface(buffer->device, &IID_ID3D10Device, (void **)device); + ID3D11Device2_QueryInterface(buffer->device, &IID_ID3D10Device, (void **)device); } static HRESULT STDMETHODCALLTYPE d3d10_buffer_GetPrivateData(ID3D10Buffer *iface, @@ -450,8 +447,8 @@ static HRESULT d3d_buffer_init(struct d3d_buffer *buffer, struct d3d_device *dev return E_INVALIDARG; wined3d_desc.byte_width = buffer->desc.ByteWidth; - wined3d_desc.usage = wined3d_usage_from_d3d11(0, buffer->desc.Usage); - wined3d_desc.bind_flags = buffer->desc.BindFlags; + wined3d_desc.usage = wined3d_usage_from_d3d11(buffer->desc.Usage); + wined3d_desc.bind_flags = wined3d_bind_flags_from_d3d11(buffer->desc.BindFlags); wined3d_desc.access = wined3d_access_from_d3d11(buffer->desc.Usage, buffer->desc.CPUAccessFlags); wined3d_desc.misc_flags = buffer->desc.MiscFlags; wined3d_desc.structure_byte_stride = buffer->desc.StructureByteStride; @@ -470,8 +467,7 @@ static HRESULT d3d_buffer_init(struct d3d_buffer *buffer, struct d3d_device *dev } wined3d_mutex_unlock(); - buffer->device = &device->ID3D11Device_iface; - ID3D11Device_AddRef(buffer->device); + ID3D11Device2_AddRef(buffer->device = &device->ID3D11Device2_iface); return S_OK; } diff --git a/dll/directx/wine/d3d11/d3d11.spec b/dll/directx/wine/d3d11/d3d11.spec index 60c77f9d30972..08a597f6f7da2 100644 --- a/dll/directx/wine/d3d11/d3d11.spec +++ b/dll/directx/wine/d3d11/d3d11.spec @@ -4,14 +4,15 @@ @ stdcall D3D11CoreRegisterLayers() @ stdcall D3D11CreateDevice(ptr long ptr long ptr long long ptr ptr ptr) @ stdcall D3D11CreateDeviceAndSwapChain(ptr long ptr long ptr long long ptr ptr ptr ptr ptr) -@ stub D3DKMTCloseAdapter +@ stdcall D3D11On12CreateDevice(ptr long ptr long ptr long long ptr ptr ptr) +@ stdcall -stub D3DKMTCloseAdapter(ptr) ;gdi32.D3DKMTCloseAdapter @ stub D3DKMTCreateAllocation @ stub D3DKMTCreateContext -@ stub D3DKMTCreateDevice +@ stdcall -stub D3DKMTCreateDevice(ptr) ;gdi32.D3DKMTCreateDevice @ stub D3DKMTCreateSynchronizationObject @ stub D3DKMTDestroyAllocation @ stub D3DKMTDestroyContext -@ stub D3DKMTDestroyDevice +@ stdcall -stub D3DKMTDestroyDevice(ptr) ;gdi32.D3DKMTDestroyDevice @ stub D3DKMTDestroySynchronizationObject @ stub D3DKMTEscape @ stub D3DKMTGetContextSchedulingPriority @@ -21,6 +22,7 @@ @ stub D3DKMTGetRuntimeData @ stub D3DKMTGetSharedPrimaryHandle @ stub D3DKMTLock +@ stdcall -stub D3DKMTOpenAdapterFromGdiDisplayName(ptr); gdi32.D3DKMTOpenAdapterFromGdiDisplayName @ stub D3DKMTOpenAdapterFromHdc @ stub D3DKMTOpenResource @ stub D3DKMTPresent diff --git a/dll/directx/wine/d3d11/d3d11_main.c b/dll/directx/wine/d3d11/d3d11_main.c index 154a376b7848f..a5854a93cc319 100644 --- a/dll/directx/wine/d3d11/d3d11_main.c +++ b/dll/directx/wine/d3d11/d3d11_main.c @@ -20,9 +20,6 @@ * */ -#include "config.h" -#include "wine/port.h" - #define D3D11_INIT_GUID #include "d3d11_private.h" @@ -95,27 +92,11 @@ static HRESULT WINAPI layer_create(enum dxgi_device_layer_id id, void **layer_ba return S_OK; } -static void WINAPI layer_set_feature_level(enum dxgi_device_layer_id id, void *device, - D3D_FEATURE_LEVEL feature_level) -{ - struct d3d_device *d3d_device = device; - - TRACE("id %#x, device %p, feature_level %#x.\n", id, device, feature_level); - - if (id != DXGI_DEVICE_LAYER_D3D10_DEVICE) - { - WARN("Unknown layer id %#x.\n", id); - return; - } - - d3d_device->feature_level = feature_level; -} - HRESULT WINAPI D3D11CoreRegisterLayers(void) { static const struct dxgi_device_layer layers[] = { - {DXGI_DEVICE_LAYER_D3D10_DEVICE, layer_init, layer_get_size, layer_create, layer_set_feature_level}, + {DXGI_DEVICE_LAYER_D3D10_DEVICE, layer_init, layer_get_size, layer_create}, }; DXGID3D10RegisterLayers(layers, ARRAY_SIZE(layers)); @@ -152,7 +133,7 @@ HRESULT WINAPI D3D11CoreCreateDevice(IDXGIFactory *factory, IDXGIAdapter *adapte return S_OK; } -HRESULT WINAPI D3D11CreateDevice(IDXGIAdapter *adapter, D3D_DRIVER_TYPE driver_type, HMODULE swrast, UINT flags, +static HRESULT d3d11_create_device(IDXGIAdapter *adapter, D3D_DRIVER_TYPE driver_type, HMODULE swrast, UINT flags, const D3D_FEATURE_LEVEL *feature_levels, UINT levels, UINT sdk_version, ID3D11Device **device_out, D3D_FEATURE_LEVEL *obtained_feature_level, ID3D11DeviceContext **immediate_context) { @@ -202,6 +183,8 @@ HRESULT WINAPI D3D11CreateDevice(IDXGIAdapter *adapter, D3D_DRIVER_TYPE driver_t switch(driver_type) { + case D3D_DRIVER_TYPE_WARP: + FIXME("WARP driver not implemented, falling back to hardware.\n"); case D3D_DRIVER_TYPE_HARDWARE: { hr = IDXGIFactory_EnumAdapters(factory, 0, &adapter); @@ -292,6 +275,14 @@ HRESULT WINAPI D3D11CreateDevice(IDXGIAdapter *adapter, D3D_DRIVER_TYPE driver_t return (device_out || immediate_context) ? S_OK : S_FALSE; } +HRESULT WINAPI D3D11CreateDevice(IDXGIAdapter *adapter, D3D_DRIVER_TYPE driver_type, HMODULE swrast, UINT flags, + const D3D_FEATURE_LEVEL *feature_levels, UINT levels, UINT sdk_version, ID3D11Device **device_out, + D3D_FEATURE_LEVEL *obtained_feature_level, ID3D11DeviceContext **immediate_context) +{ + return d3d11_create_device(adapter, driver_type, swrast, flags, feature_levels, + levels, sdk_version, device_out, obtained_feature_level, immediate_context); +} + HRESULT WINAPI D3D11CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D_DRIVER_TYPE driver_type, HMODULE swrast, UINT flags, const D3D_FEATURE_LEVEL *feature_levels, UINT levels, UINT sdk_version, const DXGI_SWAP_CHAIN_DESC *swapchain_desc, IDXGISwapChain **swapchain, @@ -313,8 +304,10 @@ HRESULT WINAPI D3D11CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D_DRIVER_T if (device_out) *device_out = NULL; - if (FAILED(hr = D3D11CreateDevice(adapter, driver_type, swrast, flags, feature_levels, levels, sdk_version, - &device, obtained_feature_level, immediate_context))) + /* Avoid forwarding to D3D11CreateDevice(), since it breaks applications + * hooking these entry-points. */ + if (FAILED(hr = d3d11_create_device(adapter, driver_type, swrast, flags, feature_levels, + levels, sdk_version, &device, obtained_feature_level, immediate_context))) { WARN("Failed to create a device, returning %#x.\n", hr); return hr; @@ -375,3 +368,18 @@ HRESULT WINAPI D3D11CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D_DRIVER_T return hr; } + +HRESULT WINAPI D3D11On12CreateDevice(IUnknown *device, UINT flags, + const D3D_FEATURE_LEVEL *feature_levels, UINT feature_level_count, + IUnknown * const *queues, UINT queue_count, UINT node_mask, + ID3D11Device **d3d11_device, ID3D11DeviceContext **d3d11_immediate_context, + D3D_FEATURE_LEVEL *obtained_feature_level) +{ + FIXME("device %p, flags %#x, feature_levels %p, feature_level_count %u, " + "queues %p, queue_count %u, node_mask 0x%08x, " + "d3d11_device %p, d3d11_immediate_context %p, obtained_feature_level %p stub!\n", + device, flags, feature_levels, feature_level_count, queues, queue_count, + node_mask, d3d11_device, d3d11_immediate_context, obtained_feature_level); + + return E_NOTIMPL; +} diff --git a/dll/directx/wine/d3d11/d3d11_private.h b/dll/directx/wine/d3d11/d3d11_private.h index b71347e9eb262..2f57841dbc070 100644 --- a/dll/directx/wine/d3d11/d3d11_private.h +++ b/dll/directx/wine/d3d11/d3d11_private.h @@ -38,35 +38,6 @@ #include "wine/winedxgi.h" #include "wine/rbtree.h" -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0])) -#endif - -#define MAKE_TAG(ch0, ch1, ch2, ch3) \ - ((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \ - ((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 )) -#define TAG_DXBC MAKE_TAG('D', 'X', 'B', 'C') -#define TAG_ISGN MAKE_TAG('I', 'S', 'G', 'N') -#define TAG_OSGN MAKE_TAG('O', 'S', 'G', 'N') -#define TAG_OSG5 MAKE_TAG('O', 'S', 'G', '5') -#define TAG_PCSG MAKE_TAG('P', 'C', 'S', 'G') -#define TAG_SHDR MAKE_TAG('S', 'H', 'D', 'R') -#define TAG_SHEX MAKE_TAG('S', 'H', 'E', 'X') -#define TAG_AON9 MAKE_TAG('A', 'o', 'n', '9') - -struct d3d_device; - -//TODO: The guids still suck - - - - - - - - - - @@ -112,6 +83,11 @@ DEFINE_GUID(IID_ID3D11InputLayout, 0xe4819ddc, 0x4cf0, 0x4025, 0xbd,0x26, 0x5d,0 DEFINE_GUID(IID_ID3D11HullShader, 0x8e5c6061, 0x628a, 0x4c8e, 0x82,0x64, 0xbb,0xe4,0x5c,0xb3,0xd5,0xdd); DEFINE_GUID(IID_ID3D10Multithread, 0x9b7e4e00, 0x342c, 0x4106, 0xa1,0x9f, 0x4f,0x27,0x04,0xf6,0x89,0xf0); +DEFINE_GUID(IID_ID3D11DeviceContext1, 0xbb2c6faa, 0xb5fb, 0x4082, 0x8e,0x6b, 0x38,0x8b,0x8c,0xfa,0x90,0xe1); +DEFINE_GUID(IID_ID3D11Device1, 0xa04bfb29, 0x08ef, 0x43d6, 0xa4,0x9c, 0xa9,0xbd,0xbd,0xcb,0xe6,0x86); +DEFINE_GUID(IID_ID3D11Device2, 0x9d06dffa, 0xd1e5, 0x4d07, 0x83,0xa8, 0x1b,0xb1,0x23,0xf2,0xf8,0x41); +DEFINE_GUID(IID_ID3D11Multithread, 0x9b7e4e00, 0x342c, 0x4106, 0xa1,0x9f, 0x4f,0x27,0x04,0xf6,0x89,0xf0); +DEFINE_GUID(IID_ID3D10Texture1D,0x9B7E4C03,0x342C,0x4106,0xA1,0x9F,0x4F,0x27,0x04,0xF6,0x89,0xF0); DEFINE_GUID(IID_ID3D11Device, 0xdb6f6ddb, 0xac77, 0x4e88, 0x82,0x53, 0x81,0x9d,0xf9,0xbb,0xf1,0x40); DEFINE_GUID(IID_IDXGIDevice, 0x54ec77fa, 0x1377, 0x44e6, 0x8c,0x32, 0x88,0xfd,0x5f,0x44,0xc8,0x4c); @@ -140,6 +116,21 @@ DEFINE_GUID(IID_ID3D11DeviceChild, 0x1841e5c8, 0x16b0, 0x489b, 0xbc,0xc8, 0x44,0 DEFINE_GUID(IID_ID3D10Device1, 0x9b7e4c8f, 0x342c, 0x4106, 0xa1,0x9f, 0x4f,0x27,0x04,0xf6,0x89,0xf0); DEFINE_GUID(IID_ID3D10DeviceChild, 0x9b7e4c00, 0x342c, 0x4106, 0xa1,0x9f, 0x4f,0x27,0x04,0xf6,0x89,0xf0); DEFINE_GUID(IID_ID3D10Device, 0x9b7e4c0f, 0x342c, 0x4106, 0xa1,0x9f, 0x4f,0x27,0x04,0xf6,0x89,0xf0); + +#define MAKE_TAG(ch0, ch1, ch2, ch3) \ + ((DWORD)(ch0) | ((DWORD)(ch1) << 8) | \ + ((DWORD)(ch2) << 16) | ((DWORD)(ch3) << 24 )) +#define TAG_AON9 MAKE_TAG('A', 'o', 'n', '9') +#define TAG_DXBC MAKE_TAG('D', 'X', 'B', 'C') +#define TAG_ISGN MAKE_TAG('I', 'S', 'G', 'N') +#define TAG_OSG5 MAKE_TAG('O', 'S', 'G', '5') +#define TAG_OSGN MAKE_TAG('O', 'S', 'G', 'N') +#define TAG_PCSG MAKE_TAG('P', 'C', 'S', 'G') +#define TAG_SHDR MAKE_TAG('S', 'H', 'D', 'R') +#define TAG_SHEX MAKE_TAG('S', 'H', 'E', 'X') + +struct d3d_device; + /* TRACE helper functions */ const char *debug_d3d10_primitive_topology(D3D10_PRIMITIVE_TOPOLOGY topology) DECLSPEC_HIDDEN; const char *debug_dxgi_format(DXGI_FORMAT format) DECLSPEC_HIDDEN; @@ -152,8 +143,7 @@ void d3d11_primitive_topology_from_wined3d_primitive_type(enum wined3d_primitive void wined3d_primitive_type_from_d3d11_primitive_topology(D3D11_PRIMITIVE_TOPOLOGY topology, enum wined3d_primitive_type *type, unsigned int *patch_vertex_count) DECLSPEC_HIDDEN; unsigned int wined3d_getdata_flags_from_d3d11_async_getdata_flags(unsigned int d3d11_flags) DECLSPEC_HIDDEN; -UINT d3d11_bind_flags_from_wined3d_usage(DWORD wined3d_usage) DECLSPEC_HIDDEN; -DWORD wined3d_usage_from_d3d11(UINT bind_flags, enum D3D11_USAGE usage) DECLSPEC_HIDDEN; +DWORD wined3d_usage_from_d3d11(enum D3D11_USAGE usage) DECLSPEC_HIDDEN; struct wined3d_resource *wined3d_resource_from_d3d11_resource(ID3D11Resource *resource) DECLSPEC_HIDDEN; struct wined3d_resource *wined3d_resource_from_d3d10_resource(ID3D10Resource *resource) DECLSPEC_HIDDEN; DWORD wined3d_map_flags_from_d3d11_map_type(D3D11_MAP map_type) DECLSPEC_HIDDEN; @@ -180,21 +170,34 @@ HRESULT d3d_set_private_data(struct wined3d_private_store *store, HRESULT d3d_set_private_data_interface(struct wined3d_private_store *store, REFGUID guid, const IUnknown *object) DECLSPEC_HIDDEN; -static inline void read_dword(const char **ptr, DWORD *d) +static inline unsigned int wined3d_bind_flags_from_d3d11(UINT bind_flags) { - memcpy(d, *ptr, sizeof(*d)); - *ptr += sizeof(*d); + return bind_flags; } -static inline BOOL require_space(size_t offset, size_t count, size_t size, size_t data_size) +static inline UINT d3d11_bind_flags_from_wined3d(unsigned int bind_flags) { - return !count || (data_size - offset) / count >= size; + return bind_flags; } -void skip_dword_unknown(const char **ptr, unsigned int count) DECLSPEC_HIDDEN; +/* ID3D11Texture1D, ID3D10Texture1D */ +struct d3d_texture1d +{ + ID3D11Texture1D ID3D11Texture1D_iface; + ID3D10Texture1D ID3D10Texture1D_iface; + LONG refcount; + + struct wined3d_private_store private_store; + IUnknown *dxgi_surface; + struct wined3d_texture *wined3d_texture; + D3D11_TEXTURE1D_DESC desc; + ID3D11Device2 *device; +}; -HRESULT parse_dxbc(const char *data, SIZE_T data_size, - HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx) DECLSPEC_HIDDEN; +HRESULT d3d_texture1d_create(struct d3d_device *device, const D3D11_TEXTURE1D_DESC *desc, + const D3D11_SUBRESOURCE_DATA *data, struct d3d_texture1d **texture) DECLSPEC_HIDDEN; +struct d3d_texture1d *unsafe_impl_from_ID3D11Texture1D(ID3D11Texture1D *iface) DECLSPEC_HIDDEN; +struct d3d_texture1d *unsafe_impl_from_ID3D10Texture1D(ID3D10Texture1D *iface) DECLSPEC_HIDDEN; /* ID3D11Texture2D, ID3D10Texture2D */ struct d3d_texture2d @@ -207,7 +210,7 @@ struct d3d_texture2d IUnknown *dxgi_surface; struct wined3d_texture *wined3d_texture; D3D11_TEXTURE2D_DESC desc; - ID3D11Device *device; + ID3D11Device2 *device; }; static inline struct d3d_texture2d *impl_from_ID3D11Texture2D(ID3D11Texture2D *iface) @@ -230,7 +233,7 @@ struct d3d_texture3d struct wined3d_private_store private_store; struct wined3d_texture *wined3d_texture; D3D11_TEXTURE3D_DESC desc; - ID3D11Device *device; + ID3D11Device2 *device; }; HRESULT d3d_texture3d_create(struct d3d_device *device, const D3D11_TEXTURE3D_DESC *desc, @@ -248,7 +251,7 @@ struct d3d_buffer struct wined3d_private_store private_store; struct wined3d_buffer *wined3d_buffer; D3D11_BUFFER_DESC desc; - ID3D11Device *device; + ID3D11Device2 *device; }; HRESULT d3d_buffer_create(struct d3d_device *device, const D3D11_BUFFER_DESC *desc, @@ -267,7 +270,7 @@ struct d3d_depthstencil_view struct wined3d_rendertarget_view *wined3d_view; D3D11_DEPTH_STENCIL_VIEW_DESC desc; ID3D11Resource *resource; - ID3D11Device *device; + ID3D11Device2 *device; }; HRESULT d3d_depthstencil_view_create(struct d3d_device *device, ID3D11Resource *resource, @@ -286,7 +289,7 @@ struct d3d_rendertarget_view struct wined3d_rendertarget_view *wined3d_view; D3D11_RENDER_TARGET_VIEW_DESC desc; ID3D11Resource *resource; - ID3D11Device *device; + ID3D11Device2 *device; }; HRESULT d3d_rendertarget_view_create(struct d3d_device *device, ID3D11Resource *resource, @@ -305,7 +308,7 @@ struct d3d_shader_resource_view struct wined3d_shader_resource_view *wined3d_view; D3D11_SHADER_RESOURCE_VIEW_DESC desc; ID3D11Resource *resource; - ID3D11Device *device; + ID3D11Device2 *device; }; HRESULT d3d_shader_resource_view_create(struct d3d_device *device, ID3D11Resource *resource, @@ -325,7 +328,7 @@ struct d3d11_unordered_access_view struct wined3d_unordered_access_view *wined3d_view; D3D11_UNORDERED_ACCESS_VIEW_DESC desc; ID3D11Resource *resource; - ID3D11Device *device; + ID3D11Device2 *device; }; HRESULT d3d11_unordered_access_view_create(struct d3d_device *device, ID3D11Resource *resource, @@ -342,7 +345,7 @@ struct d3d_input_layout struct wined3d_private_store private_store; struct wined3d_vertex_declaration *wined3d_decl; - ID3D11Device *device; + ID3D11Device2 *device; }; HRESULT d3d_input_layout_create(struct d3d_device *device, @@ -361,7 +364,7 @@ struct d3d_vertex_shader struct wined3d_private_store private_store; struct wined3d_shader *wined3d_shader; - ID3D11Device *device; + ID3D11Device2 *device; }; HRESULT d3d_vertex_shader_create(struct d3d_device *device, const void *byte_code, SIZE_T byte_code_length, @@ -377,7 +380,7 @@ struct d3d11_hull_shader struct wined3d_private_store private_store; struct wined3d_shader *wined3d_shader; - ID3D11Device *device; + ID3D11Device2 *device; }; HRESULT d3d11_hull_shader_create(struct d3d_device *device, const void *byte_code, SIZE_T byte_code_length, @@ -392,7 +395,7 @@ struct d3d11_domain_shader struct wined3d_private_store private_store; struct wined3d_shader *wined3d_shader; - ID3D11Device *device; + ID3D11Device2 *device; }; HRESULT d3d11_domain_shader_create(struct d3d_device *device, const void *byte_code, SIZE_T byte_code_length, @@ -408,7 +411,7 @@ struct d3d_geometry_shader struct wined3d_private_store private_store; struct wined3d_shader *wined3d_shader; - ID3D11Device *device; + ID3D11Device2 *device; }; HRESULT d3d_geometry_shader_create(struct d3d_device *device, const void *byte_code, SIZE_T byte_code_length, @@ -427,7 +430,7 @@ struct d3d_pixel_shader struct wined3d_private_store private_store; struct wined3d_shader *wined3d_shader; - ID3D11Device *device; + ID3D11Device2 *device; }; HRESULT d3d_pixel_shader_create(struct d3d_device *device, const void *byte_code, SIZE_T byte_code_length, @@ -443,19 +446,13 @@ struct d3d11_compute_shader struct wined3d_private_store private_store; struct wined3d_shader *wined3d_shader; - ID3D11Device *device; + ID3D11Device2 *device; }; HRESULT d3d11_compute_shader_create(struct d3d_device *device, const void *byte_code, SIZE_T byte_code_length, struct d3d11_compute_shader **shader) DECLSPEC_HIDDEN; struct d3d11_compute_shader *unsafe_impl_from_ID3D11ComputeShader(ID3D11ComputeShader *iface) DECLSPEC_HIDDEN; -HRESULT shader_parse_signature(DWORD tag, const char *data, DWORD data_size, - struct wined3d_shader_signature *s) DECLSPEC_HIDDEN; -struct wined3d_shader_signature_element *shader_find_signature_element(const struct wined3d_shader_signature *s, - const char *semantic_name, unsigned int semantic_idx, unsigned int stream_idx) DECLSPEC_HIDDEN; -void shader_free_signature(struct wined3d_shader_signature *s) DECLSPEC_HIDDEN; - /* ID3D11ClassLinkage */ struct d3d11_class_linkage { @@ -463,7 +460,7 @@ struct d3d11_class_linkage LONG refcount; struct wined3d_private_store private_store; - ID3D11Device *device; + ID3D11Device2 *device; }; HRESULT d3d11_class_linkage_create(struct d3d_device *device, @@ -480,7 +477,7 @@ struct d3d_blend_state struct wined3d_blend_state *wined3d_state; D3D11_BLEND_DESC desc; struct wine_rb_entry entry; - ID3D11Device *device; + ID3D11Device2 *device; }; static inline struct d3d_blend_state *impl_from_ID3D11BlendState(ID3D11BlendState *iface) @@ -503,7 +500,7 @@ struct d3d_depthstencil_state struct wined3d_private_store private_store; D3D11_DEPTH_STENCIL_DESC desc; struct wine_rb_entry entry; - ID3D11Device *device; + ID3D11Device2 *device; }; static inline struct d3d_depthstencil_state *impl_from_ID3D11DepthStencilState(ID3D11DepthStencilState *iface) @@ -529,7 +526,7 @@ struct d3d_rasterizer_state struct wined3d_rasterizer_state *wined3d_state; D3D11_RASTERIZER_DESC desc; struct wine_rb_entry entry; - ID3D11Device *device; + ID3D11Device2 *device; }; HRESULT d3d_rasterizer_state_create(struct d3d_device *device, const D3D11_RASTERIZER_DESC *desc, @@ -548,7 +545,7 @@ struct d3d_sampler_state struct wined3d_sampler *wined3d_sampler; D3D11_SAMPLER_DESC desc; struct wine_rb_entry entry; - ID3D11Device *device; + ID3D11Device2 *device; }; HRESULT d3d_sampler_state_create(struct d3d_device *device, const D3D11_SAMPLER_DESC *desc, @@ -567,7 +564,7 @@ struct d3d_query struct wined3d_query *wined3d_query; BOOL predicate; D3D11_QUERY_DESC desc; - ID3D11Device *device; + ID3D11Device2 *device; }; HRESULT d3d_query_create(struct d3d_device *device, const D3D11_QUERY_DESC *desc, BOOL predicate, @@ -579,7 +576,8 @@ struct d3d_query *unsafe_impl_from_ID3D11Asynchronous(ID3D11Asynchronous *iface) /* ID3D11DeviceContext - immediate context */ struct d3d11_immediate_context { - ID3D11DeviceContext ID3D11DeviceContext_iface; + ID3D11DeviceContext1 ID3D11DeviceContext1_iface; + ID3D11Multithread ID3D11Multithread_iface; LONG refcount; struct wined3d_private_store private_store; @@ -589,7 +587,7 @@ struct d3d11_immediate_context struct d3d_device { IUnknown IUnknown_inner; - ID3D11Device ID3D11Device_iface; + ID3D11Device2 ID3D11Device2_iface; ID3D10Device1 ID3D10Device1_iface; ID3D10Multithread ID3D10Multithread_iface; IWineDXGIDeviceParent IWineDXGIDeviceParent_iface; @@ -608,14 +606,13 @@ struct d3d_device struct wine_rb_tree rasterizer_states; struct wine_rb_tree sampler_states; - float blend_factor[4]; struct d3d_depthstencil_state *depth_stencil_state; UINT stencil_ref; }; -static inline struct d3d_device *impl_from_ID3D11Device(ID3D11Device *iface) +static inline struct d3d_device *impl_from_ID3D11Device2(ID3D11Device2 *iface) { - return CONTAINING_RECORD(iface, struct d3d_device, ID3D11Device_iface); + return CONTAINING_RECORD(iface, struct d3d_device, ID3D11Device2_iface); } static inline struct d3d_device *impl_from_ID3D10Device(ID3D10Device1 *iface) @@ -655,8 +652,6 @@ struct dxgi_device_layer UINT (WINAPI *get_size)(enum dxgi_device_layer_id id, struct layer_get_size_args *args, DWORD unknown0); HRESULT (WINAPI *create)(enum dxgi_device_layer_id id, void **layer_base, DWORD unknown0, void *device_object, REFIID riid, void **device_layer); - void (WINAPI *set_feature_level)(enum dxgi_device_layer_id id, void *device, - D3D_FEATURE_LEVEL feature_level); }; HRESULT WINAPI DXGID3D10CreateDevice(HMODULE d3d10core, IDXGIFactory *factory, IDXGIAdapter *adapter, diff --git a/dll/directx/wine/d3d11/device.c b/dll/directx/wine/d3d11/device.c index 25308c298011b..212881a9b71da 100644 --- a/dll/directx/wine/d3d11/device.c +++ b/dll/directx/wine/d3d11/device.c @@ -17,9 +17,6 @@ * */ -#include "config.h" -#include "wine/port.h" - #define NONAMELESSUNION #include "d3d11_private.h" @@ -34,132 +31,175 @@ static const struct wined3d_parent_ops d3d_null_wined3d_parent_ops = /* ID3D11DeviceContext - immediate context methods */ -static inline struct d3d11_immediate_context *impl_from_ID3D11DeviceContext(ID3D11DeviceContext *iface) +static inline struct d3d11_immediate_context *impl_from_ID3D11DeviceContext1(ID3D11DeviceContext1 *iface) { - return CONTAINING_RECORD(iface, struct d3d11_immediate_context, ID3D11DeviceContext_iface); + return CONTAINING_RECORD(iface, struct d3d11_immediate_context, ID3D11DeviceContext1_iface); } -static inline struct d3d_device *device_from_immediate_ID3D11DeviceContext(ID3D11DeviceContext *iface) +static inline struct d3d_device *device_from_immediate_ID3D11DeviceContext1(ID3D11DeviceContext1 *iface) { - struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext(iface); + struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext1(iface); return CONTAINING_RECORD(context, struct d3d_device, immediate_context); } -static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_QueryInterface(ID3D11DeviceContext *iface, - REFIID riid, void **out) +static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_QueryInterface(ID3D11DeviceContext1 *iface, + REFIID iid, void **out) { - TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out); + struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext1(iface); - if (IsEqualGUID(riid, &IID_ID3D11DeviceContext) - || IsEqualGUID(riid, &IID_ID3D11DeviceChild) - || IsEqualGUID(riid, &IID_IUnknown)) + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_ID3D11DeviceContext1) + || IsEqualGUID(iid, &IID_ID3D11DeviceContext) + || IsEqualGUID(iid, &IID_ID3D11DeviceChild) + || IsEqualGUID(iid, &IID_IUnknown)) { - ID3D11DeviceContext_AddRef(iface); - *out = iface; - return S_OK; + *out = &context->ID3D11DeviceContext1_iface; + } + else if (IsEqualGUID(iid, &IID_ID3D11Multithread)) + { + *out = &context->ID3D11Multithread_iface; + } + else + { + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + *out = NULL; + return E_NOINTERFACE; } - WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid)); - *out = NULL; - return E_NOINTERFACE; + ID3D11DeviceContext1_AddRef(iface); + return S_OK; } -static ULONG STDMETHODCALLTYPE d3d11_immediate_context_AddRef(ID3D11DeviceContext *iface) +static ULONG STDMETHODCALLTYPE d3d11_immediate_context_AddRef(ID3D11DeviceContext1 *iface) { - struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext(iface); - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext1(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); ULONG refcount = InterlockedIncrement(&context->refcount); TRACE("%p increasing refcount to %u.\n", context, refcount); if (refcount == 1) { - ID3D11Device_AddRef(&device->ID3D11Device_iface); + ID3D11Device2_AddRef(&device->ID3D11Device2_iface); } return refcount; } -static ULONG STDMETHODCALLTYPE d3d11_immediate_context_Release(ID3D11DeviceContext *iface) +static ULONG STDMETHODCALLTYPE d3d11_immediate_context_Release(ID3D11DeviceContext1 *iface) { - struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext(iface); - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext1(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); ULONG refcount = InterlockedDecrement(&context->refcount); TRACE("%p decreasing refcount to %u.\n", context, refcount); if (!refcount) { - ID3D11Device_Release(&device->ID3D11Device_iface); + ID3D11Device2_Release(&device->ID3D11Device2_iface); } return refcount; } -static void STDMETHODCALLTYPE d3d11_immediate_context_GetDevice(ID3D11DeviceContext *iface, ID3D11Device **device) +static void d3d11_immediate_context_get_constant_buffers(ID3D11DeviceContext1 *iface, + enum wined3d_shader_type type, UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers) { - struct d3d_device *device_object = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + unsigned int i; + + wined3d_mutex_lock(); + for (i = 0; i < buffer_count; ++i) + { + struct wined3d_buffer *wined3d_buffer; + struct d3d_buffer *buffer_impl; + + if (!(wined3d_buffer = wined3d_device_get_constant_buffer(device->wined3d_device, + type, start_slot + i))) + { + buffers[i] = NULL; + continue; + } + + buffer_impl = wined3d_buffer_get_parent(wined3d_buffer); + buffers[i] = &buffer_impl->ID3D11Buffer_iface; + ID3D11Buffer_AddRef(buffers[i]); + } + wined3d_mutex_unlock(); +} + +static void d3d11_immediate_context_set_constant_buffers(ID3D11DeviceContext1 *iface, + enum wined3d_shader_type type, UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers) +{ + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + unsigned int i; + + wined3d_mutex_lock(); + for (i = 0; i < buffer_count; ++i) + { + struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]); + + wined3d_device_set_constant_buffer(device->wined3d_device, type, start_slot + i, + buffer ? buffer->wined3d_buffer : NULL); + } + wined3d_mutex_unlock(); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_GetDevice(ID3D11DeviceContext1 *iface, ID3D11Device **device) +{ + struct d3d_device *device_object = device_from_immediate_ID3D11DeviceContext1(iface); TRACE("iface %p, device %p.\n", iface, device); - *device = &device_object->ID3D11Device_iface; + *device = (ID3D11Device *)&device_object->ID3D11Device2_iface; ID3D11Device_AddRef(*device); } -static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_GetPrivateData(ID3D11DeviceContext *iface, REFGUID guid, +static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_GetPrivateData(ID3D11DeviceContext1 *iface, REFGUID guid, UINT *data_size, void *data) { - struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext(iface); + struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext1(iface); TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data); return d3d_get_private_data(&context->private_store, guid, data_size, data); } -static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_SetPrivateData(ID3D11DeviceContext *iface, REFGUID guid, +static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_SetPrivateData(ID3D11DeviceContext1 *iface, REFGUID guid, UINT data_size, const void *data) { - struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext(iface); + struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext1(iface); TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data); return d3d_set_private_data(&context->private_store, guid, data_size, data); } -static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_SetPrivateDataInterface(ID3D11DeviceContext *iface, +static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_SetPrivateDataInterface(ID3D11DeviceContext1 *iface, REFGUID guid, const IUnknown *data) { - struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext(iface); + struct d3d11_immediate_context *context = impl_from_ID3D11DeviceContext1(iface); TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data); return d3d_set_private_data_interface(&context->private_store, guid, data); } -static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetConstantBuffers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetConstantBuffers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", iface, start_slot, buffer_count, buffers); - wined3d_mutex_lock(); - for (i = 0; i < buffer_count; ++i) - { - struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]); - - wined3d_device_set_vs_cb(device->wined3d_device, start_slot + i, - buffer ? buffer->wined3d_buffer : NULL); - } - wined3d_mutex_unlock(); + d3d11_immediate_context_set_constant_buffers(iface, WINED3D_SHADER_TYPE_VERTEX, start_slot, + buffer_count, buffers); } -static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetShaderResources(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", @@ -176,10 +216,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetShaderResources(ID3D1 wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetShader(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetShader(ID3D11DeviceContext1 *iface, ID3D11PixelShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d_pixel_shader *ps = unsafe_impl_from_ID3D11PixelShader(shader); TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n", @@ -193,10 +233,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetShader(ID3D11DeviceCo wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetSamplers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetSamplers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n", @@ -213,10 +253,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetSamplers(ID3D11Device wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetShader(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetShader(ID3D11DeviceContext1 *iface, ID3D11VertexShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d_vertex_shader *vs = unsafe_impl_from_ID3D11VertexShader(shader); TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n", @@ -230,10 +270,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetShader(ID3D11DeviceCo wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexed(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexed(ID3D11DeviceContext1 *iface, UINT index_count, UINT start_index_location, INT base_vertex_location) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); TRACE("iface %p, index_count %u, start_index_location %u, base_vertex_location %d.\n", iface, index_count, start_index_location, base_vertex_location); @@ -244,10 +284,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexed(ID3D11DeviceCo wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_Draw(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_Draw(ID3D11DeviceContext1 *iface, UINT vertex_count, UINT start_vertex_location) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); TRACE("iface %p, vertex_count %u, start_vertex_location %u.\n", iface, vertex_count, start_vertex_location); @@ -257,7 +297,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_Draw(ID3D11DeviceContext * wined3d_mutex_unlock(); } -static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_Map(ID3D11DeviceContext *iface, ID3D11Resource *resource, +static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_Map(ID3D11DeviceContext1 *iface, ID3D11Resource *resource, UINT subresource_idx, D3D11_MAP map_type, UINT map_flags, D3D11_MAPPED_SUBRESOURCE *mapped_subresource) { struct wined3d_resource *wined3d_resource; @@ -284,7 +324,7 @@ static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_Map(ID3D11DeviceContext return hr; } -static void STDMETHODCALLTYPE d3d11_immediate_context_Unmap(ID3D11DeviceContext *iface, ID3D11Resource *resource, +static void STDMETHODCALLTYPE d3d11_immediate_context_Unmap(ID3D11DeviceContext1 *iface, ID3D11Resource *resource, UINT subresource_idx) { struct wined3d_resource *wined3d_resource; @@ -298,30 +338,20 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_Unmap(ID3D11DeviceContext wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetConstantBuffers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetConstantBuffers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", iface, start_slot, buffer_count, buffers); - wined3d_mutex_lock(); - for (i = 0; i < buffer_count; ++i) - { - struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]); - - wined3d_device_set_ps_cb(device->wined3d_device, start_slot + i, - buffer ? buffer->wined3d_buffer : NULL); - } - wined3d_mutex_unlock(); + d3d11_immediate_context_set_constant_buffers(iface, WINED3D_SHADER_TYPE_PIXEL, start_slot, + buffer_count, buffers); } -static void STDMETHODCALLTYPE d3d11_immediate_context_IASetInputLayout(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_IASetInputLayout(ID3D11DeviceContext1 *iface, ID3D11InputLayout *input_layout) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d_input_layout *layout = unsafe_impl_from_ID3D11InputLayout(input_layout); TRACE("iface %p, input_layout %p.\n", iface, input_layout); @@ -331,10 +361,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_IASetInputLayout(ID3D11Dev wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_IASetVertexBuffers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_IASetVertexBuffers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers, const UINT *strides, const UINT *offsets) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n", @@ -351,10 +381,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_IASetVertexBuffers(ID3D11D wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_IASetIndexBuffer(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_IASetIndexBuffer(ID3D11DeviceContext1 *iface, ID3D11Buffer *buffer, DXGI_FORMAT format, UINT offset) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d_buffer *buffer_impl = unsafe_impl_from_ID3D11Buffer(buffer); TRACE("iface %p, buffer %p, format %s, offset %u.\n", @@ -367,11 +397,11 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_IASetIndexBuffer(ID3D11Dev wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexedInstanced(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexedInstanced(ID3D11DeviceContext1 *iface, UINT instance_index_count, UINT instance_count, UINT start_index_location, INT base_vertex_location, UINT start_instance_location) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); TRACE("iface %p, instance_index_count %u, instance_count %u, start_index_location %u, " "base_vertex_location %d, start_instance_location %u.\n", @@ -385,10 +415,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexedInstanced(ID3D1 wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_DrawInstanced(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_DrawInstanced(ID3D11DeviceContext1 *iface, UINT instance_vertex_count, UINT instance_count, UINT start_vertex_location, UINT start_instance_location) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); TRACE("iface %p, instance_vertex_count %u, instance_count %u, start_vertex_location %u, " "start_instance_location %u.\n", @@ -401,30 +431,20 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_DrawInstanced(ID3D11Device wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetConstantBuffers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetConstantBuffers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", iface, start_slot, buffer_count, buffers); - wined3d_mutex_lock(); - for (i = 0; i < buffer_count; ++i) - { - struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]); - - wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i, - buffer ? buffer->wined3d_buffer : NULL); - } - wined3d_mutex_unlock(); + d3d11_immediate_context_set_constant_buffers(iface, WINED3D_SHADER_TYPE_GEOMETRY, start_slot, + buffer_count, buffers); } -static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetShader(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetShader(ID3D11DeviceContext1 *iface, ID3D11GeometryShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d_geometry_shader *gs = unsafe_impl_from_ID3D11GeometryShader(shader); TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n", @@ -438,10 +458,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetShader(ID3D11DeviceCo wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_IASetPrimitiveTopology(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_IASetPrimitiveTopology(ID3D11DeviceContext1 *iface, D3D11_PRIMITIVE_TOPOLOGY topology) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); enum wined3d_primitive_type primitive_type; unsigned int patch_vertex_count; @@ -454,10 +474,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_IASetPrimitiveTopology(ID3 wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetShaderResources(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views); @@ -473,10 +493,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetShaderResources(ID3D1 wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetSamplers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetSamplers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n", @@ -493,7 +513,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetSamplers(ID3D11Device wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_Begin(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_Begin(ID3D11DeviceContext1 *iface, ID3D11Asynchronous *asynchronous) { struct d3d_query *query = unsafe_impl_from_ID3D11Asynchronous(asynchronous); @@ -507,7 +527,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_Begin(ID3D11DeviceContext wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_End(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_End(ID3D11DeviceContext1 *iface, ID3D11Asynchronous *asynchronous) { struct d3d_query *query = unsafe_impl_from_ID3D11Asynchronous(asynchronous); @@ -521,7 +541,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_End(ID3D11DeviceContext *i wined3d_mutex_unlock(); } -static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_GetData(ID3D11DeviceContext *iface, +static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_GetData(ID3D11DeviceContext1 *iface, ID3D11Asynchronous *asynchronous, void *data, UINT data_size, UINT data_flags) { struct d3d_query *query = unsafe_impl_from_ID3D11Asynchronous(asynchronous); @@ -553,10 +573,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_GetData(ID3D11DeviceCon return hr; } -static void STDMETHODCALLTYPE d3d11_immediate_context_SetPredication(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_SetPredication(ID3D11DeviceContext1 *iface, ID3D11Predicate *predicate, BOOL value) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d_query *query; TRACE("iface %p, predicate %p, value %#x.\n", iface, predicate, value); @@ -568,10 +588,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_SetPredication(ID3D11Devic wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetShaderResources(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views); @@ -587,10 +607,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetShaderResources(ID3D1 wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetSamplers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetSamplers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n", @@ -607,11 +627,11 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetSamplers(ID3D11Device wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetRenderTargets(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetRenderTargets(ID3D11DeviceContext1 *iface, UINT render_target_view_count, ID3D11RenderTargetView *const *render_target_views, ID3D11DepthStencilView *depth_stencil_view) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d_depthstencil_view *dsv; unsigned int i; @@ -635,12 +655,12 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetRenderTargets(ID3D11D } static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetRenderTargetsAndUnorderedAccessViews( - ID3D11DeviceContext *iface, UINT render_target_view_count, + ID3D11DeviceContext1 *iface, UINT render_target_view_count, ID3D11RenderTargetView *const *render_target_views, ID3D11DepthStencilView *depth_stencil_view, UINT unordered_access_view_start_slot, UINT unordered_access_view_count, ID3D11UnorderedAccessView *const *unordered_access_views, const UINT *initial_counts) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p, " @@ -681,10 +701,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetRenderTargetsAndUnord } } -static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11DeviceContext1 *iface, ID3D11BlendState *blend_state, const float blend_factor[4], UINT sample_mask) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); static const float default_blend_factor[] = {1.0f, 1.0f, 1.0f, 1.0f}; struct d3d_blend_state *blend_state_impl; const D3D11_BLEND_DESC *desc; @@ -696,11 +716,11 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11Devi blend_factor = default_blend_factor; wined3d_mutex_lock(); - memcpy(device->blend_factor, blend_factor, 4 * sizeof(*blend_factor)); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEMASK, sample_mask); if (!(blend_state_impl = unsafe_impl_from_ID3D11BlendState(blend_state))) { - wined3d_device_set_blend_state(device->wined3d_device, NULL); + wined3d_device_set_blend_state(device->wined3d_device, NULL, + (const struct wined3d_color *)blend_factor); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ALPHABLENDENABLE, FALSE); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_COLORWRITEENABLE, D3D11_COLOR_WRITE_ENABLE_ALL); @@ -714,7 +734,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11Devi return; } - wined3d_device_set_blend_state(device->wined3d_device, blend_state_impl->wined3d_state); + wined3d_device_set_blend_state(device->wined3d_device, blend_state_impl->wined3d_state, + (const struct wined3d_color *)blend_factor); desc = &blend_state_impl->desc; wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_ALPHABLENDENABLE, desc->RenderTarget[0].BlendEnable); @@ -729,13 +750,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetBlendState(ID3D11Devi wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SRCBLENDALPHA, d->SrcBlendAlpha); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DESTBLENDALPHA, d->DestBlendAlpha); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_BLENDOPALPHA, d->BlendOpAlpha); - - if (memcmp(blend_factor, default_blend_factor, sizeof(default_blend_factor)) - && (d->SrcBlend == D3D11_BLEND_BLEND_FACTOR || d->SrcBlend == D3D11_BLEND_INV_BLEND_FACTOR - || d->DestBlend == D3D11_BLEND_BLEND_FACTOR || d->DestBlend == D3D11_BLEND_INV_BLEND_FACTOR - || d->SrcBlendAlpha == D3D11_BLEND_BLEND_FACTOR || d->SrcBlendAlpha == D3D11_BLEND_INV_BLEND_FACTOR - || d->DestBlendAlpha == D3D11_BLEND_BLEND_FACTOR || d->DestBlendAlpha == D3D11_BLEND_INV_BLEND_FACTOR)) - FIXME("Ignoring blend factor %s.\n", debug_float4(blend_factor)); } wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_COLORWRITEENABLE, desc->RenderTarget[0].RenderTargetWriteMask); @@ -756,10 +770,10 @@ static void set_default_depth_stencil_state(struct wined3d_device *wined3d_devic wined3d_device_set_render_state(wined3d_device, WINED3D_RS_STENCILENABLE, FALSE); } -static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetDepthStencilState(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetDepthStencilState(ID3D11DeviceContext1 *iface, ID3D11DepthStencilState *depth_stencil_state, UINT stencil_ref) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); const D3D11_DEPTH_STENCILOP_DESC *front, *back; const D3D11_DEPTH_STENCIL_DESC *desc; @@ -818,10 +832,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMSetDepthStencilState(ID3 wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_SOSetTargets(ID3D11DeviceContext *iface, UINT buffer_count, +static void STDMETHODCALLTYPE d3d11_immediate_context_SOSetTargets(ID3D11DeviceContext1 *iface, UINT buffer_count, ID3D11Buffer *const *buffers, const UINT *offsets) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int count, i; TRACE("iface %p, buffer_count %u, buffers %p, offsets %p.\n", iface, buffer_count, buffers, offsets); @@ -842,15 +856,15 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_SOSetTargets(ID3D11DeviceC wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_DrawAuto(ID3D11DeviceContext *iface) +static void STDMETHODCALLTYPE d3d11_immediate_context_DrawAuto(ID3D11DeviceContext1 *iface) { FIXME("iface %p stub!\n", iface); } -static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexedInstancedIndirect(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexedInstancedIndirect(ID3D11DeviceContext1 *iface, ID3D11Buffer *buffer, UINT offset) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d_buffer *d3d_buffer; TRACE("iface %p, buffer %p, offset %u.\n", iface, buffer, offset); @@ -863,10 +877,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_DrawIndexedInstancedIndire wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_DrawInstancedIndirect(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_DrawInstancedIndirect(ID3D11DeviceContext1 *iface, ID3D11Buffer *buffer, UINT offset) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d_buffer *d3d_buffer; TRACE("iface %p, buffer %p, offset %u.\n", iface, buffer, offset); @@ -879,10 +893,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_DrawInstancedIndirect(ID3D wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_Dispatch(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_Dispatch(ID3D11DeviceContext1 *iface, UINT thread_group_count_x, UINT thread_group_count_y, UINT thread_group_count_z) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); TRACE("iface %p, thread_group_count_x %u, thread_group_count_y %u, thread_group_count_z %u.\n", iface, thread_group_count_x, thread_group_count_y, thread_group_count_z); @@ -893,10 +907,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_Dispatch(ID3D11DeviceConte wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_DispatchIndirect(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_DispatchIndirect(ID3D11DeviceContext1 *iface, ID3D11Buffer *buffer, UINT offset) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d_buffer *buffer_impl; TRACE("iface %p, buffer %p, offset %u.\n", iface, buffer, offset); @@ -909,10 +923,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_DispatchIndirect(ID3D11Dev wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceContext1 *iface, ID3D11RasterizerState *rasterizer_state) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d_rasterizer_state *rasterizer_state_impl; const D3D11_RASTERIZER_DESC *desc; union @@ -947,9 +961,6 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon const_bias.f = desc->DepthBias; wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SLOPESCALEDEPTHBIAS, scale_bias.d); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_DEPTHBIAS, const_bias.d); - /* GL_DEPTH_CLAMP */ - if (!desc->DepthClipEnable) - FIXME("Ignoring DepthClipEnable %#x.\n", desc->DepthClipEnable); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_SCISSORTESTENABLE, desc->ScissorEnable); wined3d_device_set_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEANTIALIAS, desc->MultisampleEnable); wined3d_device_set_render_state(device->wined3d_device, @@ -957,55 +968,53 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetState(ID3D11DeviceCon wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetViewports(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetViewports(ID3D11DeviceContext1 *iface, UINT viewport_count, const D3D11_VIEWPORT *viewports) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); - struct wined3d_viewport wined3d_vp; + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + struct wined3d_viewport wined3d_vp[WINED3D_MAX_VIEWPORTS]; + unsigned int i; TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports); - if (viewport_count > 1) - FIXME("Multiple viewports not implemented.\n"); - - if (!viewport_count) + if (viewport_count > ARRAY_SIZE(wined3d_vp)) return; - wined3d_vp.x = viewports[0].TopLeftX; - wined3d_vp.y = viewports[0].TopLeftY; - wined3d_vp.width = viewports[0].Width; - wined3d_vp.height = viewports[0].Height; - wined3d_vp.min_z = viewports[0].MinDepth; - wined3d_vp.max_z = viewports[0].MaxDepth; + for (i = 0; i < viewport_count; ++i) + { + wined3d_vp[i].x = viewports[i].TopLeftX; + wined3d_vp[i].y = viewports[i].TopLeftY; + wined3d_vp[i].width = viewports[i].Width; + wined3d_vp[i].height = viewports[i].Height; + wined3d_vp[i].min_z = viewports[i].MinDepth; + wined3d_vp[i].max_z = viewports[i].MaxDepth; + } wined3d_mutex_lock(); - wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp); + wined3d_device_set_viewports(device->wined3d_device, viewport_count, wined3d_vp); wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetScissorRects(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_RSSetScissorRects(ID3D11DeviceContext1 *iface, UINT rect_count, const D3D11_RECT *rects) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects); - if (rect_count > 1) - FIXME("Multiple scissor rects not implemented.\n"); - - if (!rect_count) + if (rect_count > WINED3D_MAX_VIEWPORTS) return; wined3d_mutex_lock(); - wined3d_device_set_scissor_rect(device->wined3d_device, rects); + wined3d_device_set_scissor_rects(device->wined3d_device, rect_count, rects); wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_CopySubresourceRegion(ID3D11DeviceContext1 *iface, ID3D11Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z, ID3D11Resource *src_resource, UINT src_subresource_idx, const D3D11_BOX *src_box) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource; struct wined3d_box wined3d_src_box; @@ -1022,14 +1031,14 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CopySubresourceRegion(ID3D wined3d_src_resource = wined3d_resource_from_d3d11_resource(src_resource); wined3d_mutex_lock(); wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_dst_resource, dst_subresource_idx, - dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL); + dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL, 0); wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_CopyResource(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_CopyResource(ID3D11DeviceContext1 *iface, ID3D11Resource *dst_resource, ID3D11Resource *src_resource) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource; TRACE("iface %p, dst_resource %p, src_resource %p.\n", iface, dst_resource, src_resource); @@ -1041,11 +1050,11 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CopyResource(ID3D11DeviceC wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_UpdateSubresource(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_UpdateSubresource(ID3D11DeviceContext1 *iface, ID3D11Resource *resource, UINT subresource_idx, const D3D11_BOX *box, const void *data, UINT row_pitch, UINT depth_pitch) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct wined3d_resource *wined3d_resource; struct wined3d_box wined3d_box; @@ -1058,14 +1067,14 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_UpdateSubresource(ID3D11De wined3d_resource = wined3d_resource_from_d3d11_resource(resource); wined3d_mutex_lock(); wined3d_device_update_sub_resource(device->wined3d_device, wined3d_resource, - subresource_idx, box ? &wined3d_box : NULL, data, row_pitch, depth_pitch); + subresource_idx, box ? &wined3d_box : NULL, data, row_pitch, depth_pitch, 0); wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_CopyStructureCount(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_CopyStructureCount(ID3D11DeviceContext1 *iface, ID3D11Buffer *dst_buffer, UINT dst_offset, ID3D11UnorderedAccessView *src_view) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d11_unordered_access_view *uav; struct d3d_buffer *buffer_impl; @@ -1081,10 +1090,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CopyStructureCount(ID3D11D wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_ClearRenderTargetView(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_ClearRenderTargetView(ID3D11DeviceContext1 *iface, ID3D11RenderTargetView *render_target_view, const float color_rgba[4]) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d_rendertarget_view *view = unsafe_impl_from_ID3D11RenderTargetView(render_target_view); const struct wined3d_color color = {color_rgba[0], color_rgba[1], color_rgba[2], color_rgba[3]}; HRESULT hr; @@ -1102,10 +1111,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_ClearRenderTargetView(ID3D wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_ClearUnorderedAccessViewUint(ID3D11DeviceContext1 *iface, ID3D11UnorderedAccessView *unordered_access_view, const UINT values[4]) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d11_unordered_access_view *view; TRACE("iface %p, unordered_access_view %p, values {%u, %u, %u, %u}.\n", @@ -1118,17 +1127,17 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_ClearUnorderedAccessViewUi wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_ClearUnorderedAccessViewFloat(ID3D11DeviceContext1 *iface, ID3D11UnorderedAccessView *unordered_access_view, const float values[4]) { FIXME("iface %p, unordered_access_view %p, values %s stub!\n", iface, unordered_access_view, debug_float4(values)); } -static void STDMETHODCALLTYPE d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_ClearDepthStencilView(ID3D11DeviceContext1 *iface, ID3D11DepthStencilView *depth_stencil_view, UINT flags, FLOAT depth, UINT8 stencil) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d_depthstencil_view *view = unsafe_impl_from_ID3D11DepthStencilView(depth_stencil_view); DWORD wined3d_flags; HRESULT hr; @@ -1148,7 +1157,7 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_ClearDepthStencilView(ID3D wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_GenerateMips(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_GenerateMips(ID3D11DeviceContext1 *iface, ID3D11ShaderResourceView *view) { struct d3d_shader_resource_view *srv = unsafe_impl_from_ID3D11ShaderResourceView(view); @@ -1160,13 +1169,13 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_GenerateMips(ID3D11DeviceC wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_SetResourceMinLOD(ID3D11DeviceContext1 *iface, ID3D11Resource *resource, FLOAT min_lod) { FIXME("iface %p, resource %p, min_lod %f stub!\n", iface, resource, min_lod); } -static FLOAT STDMETHODCALLTYPE d3d11_immediate_context_GetResourceMinLOD(ID3D11DeviceContext *iface, +static FLOAT STDMETHODCALLTYPE d3d11_immediate_context_GetResourceMinLOD(ID3D11DeviceContext1 *iface, ID3D11Resource *resource) { FIXME("iface %p, resource %p stub!\n", iface, resource); @@ -1174,12 +1183,12 @@ static FLOAT STDMETHODCALLTYPE d3d11_immediate_context_GetResourceMinLOD(ID3D11D return 0.0f; } -static void STDMETHODCALLTYPE d3d11_immediate_context_ResolveSubresource(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_ResolveSubresource(ID3D11DeviceContext1 *iface, ID3D11Resource *dst_resource, UINT dst_subresource_idx, ID3D11Resource *src_resource, UINT src_subresource_idx, DXGI_FORMAT format) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource; enum wined3d_format_id wined3d_format; @@ -1198,16 +1207,16 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_ResolveSubresource(ID3D11D wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_ExecuteCommandList(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_ExecuteCommandList(ID3D11DeviceContext1 *iface, ID3D11CommandList *command_list, BOOL restore_state) { FIXME("iface %p, command_list %p, restore_state %#x stub!\n", iface, command_list, restore_state); } -static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetShaderResources(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", @@ -1224,10 +1233,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetShaderResources(ID3D1 wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetShader(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetShader(ID3D11DeviceContext1 *iface, ID3D11HullShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d11_hull_shader *hs = unsafe_impl_from_ID3D11HullShader(shader); TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n", @@ -1241,10 +1250,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetShader(ID3D11DeviceCo wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetSamplers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetSamplers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n", @@ -1261,30 +1270,20 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetSamplers(ID3D11Device wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetConstantBuffers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetConstantBuffers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", iface, start_slot, buffer_count, buffers); - wined3d_mutex_lock(); - for (i = 0; i < buffer_count; ++i) - { - struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]); - - wined3d_device_set_hs_cb(device->wined3d_device, start_slot + i, - buffer ? buffer->wined3d_buffer : NULL); - } - wined3d_mutex_unlock(); + d3d11_immediate_context_set_constant_buffers(iface, WINED3D_SHADER_TYPE_HULL, start_slot, + buffer_count, buffers); } -static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetShaderResources(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", @@ -1301,10 +1300,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetShaderResources(ID3D1 wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetShader(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetShader(ID3D11DeviceContext1 *iface, ID3D11DomainShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d11_domain_shader *ds = unsafe_impl_from_ID3D11DomainShader(shader); TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n", @@ -1318,10 +1317,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetShader(ID3D11DeviceCo wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetSamplers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetSamplers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n", @@ -1338,30 +1337,20 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetSamplers(ID3D11Device wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetConstantBuffers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetConstantBuffers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", iface, start_slot, buffer_count, buffers); - wined3d_mutex_lock(); - for (i = 0; i < buffer_count; ++i) - { - struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]); - - wined3d_device_set_ds_cb(device->wined3d_device, start_slot + i, - buffer ? buffer->wined3d_buffer : NULL); - } - wined3d_mutex_unlock(); + d3d11_immediate_context_set_constant_buffers(iface, WINED3D_SHADER_TYPE_DOMAIN, start_slot, + buffer_count, buffers); } -static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetShaderResources(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView *const *views) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", @@ -1378,10 +1367,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetShaderResources(ID3D1 wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetUnorderedAccessViews(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11UnorderedAccessView *const *views, const UINT *initial_counts) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, view_count %u, views %p, initial_counts %p.\n", @@ -1398,10 +1387,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetUnorderedAccessViews( wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetShader(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetShader(ID3D11DeviceContext1 *iface, ID3D11ComputeShader *shader, ID3D11ClassInstance *const *class_instances, UINT class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d11_compute_shader *cs = unsafe_impl_from_ID3D11ComputeShader(shader); TRACE("iface %p, shader %p, class_instances %p, class_instance_count %u.\n", @@ -1415,10 +1404,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetShader(ID3D11DeviceCo wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetSamplers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetSamplers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT sampler_count, ID3D11SamplerState *const *samplers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n", @@ -1435,58 +1424,30 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetSamplers(ID3D11Device wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetConstantBuffers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetConstantBuffers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT buffer_count, ID3D11Buffer *const *buffers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", iface, start_slot, buffer_count, buffers); - wined3d_mutex_lock(); - for (i = 0; i < buffer_count; ++i) - { - struct d3d_buffer *buffer = unsafe_impl_from_ID3D11Buffer(buffers[i]); - - wined3d_device_set_cs_cb(device->wined3d_device, start_slot + i, - buffer ? buffer->wined3d_buffer : NULL); - } - wined3d_mutex_unlock(); + d3d11_immediate_context_set_constant_buffers(iface, WINED3D_SHADER_TYPE_COMPUTE, start_slot, + buffer_count, buffers); } -static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetConstantBuffers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetConstantBuffers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", iface, start_slot, buffer_count, buffers); - wined3d_mutex_lock(); - for (i = 0; i < buffer_count; ++i) - { - struct wined3d_buffer *wined3d_buffer; - struct d3d_buffer *buffer_impl; - - if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i))) - { - buffers[i] = NULL; - continue; - } - - buffer_impl = wined3d_buffer_get_parent(wined3d_buffer); - buffers[i] = &buffer_impl->ID3D11Buffer_iface; - ID3D11Buffer_AddRef(buffers[i]); - } - wined3d_mutex_unlock(); + d3d11_immediate_context_get_constant_buffers(iface, WINED3D_SHADER_TYPE_VERTEX, start_slot, + buffer_count, buffers); } -static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetShaderResources(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", @@ -1511,10 +1472,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetShaderResources(ID3D1 wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetShader(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetShader(ID3D11DeviceContext1 *iface, ID3D11PixelShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct wined3d_shader *wined3d_shader; struct d3d_pixel_shader *shader_impl; @@ -1523,6 +1484,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetShader(ID3D11DeviceCo if (class_instances || class_instance_count) FIXME("Dynamic linking not implemented yet.\n"); + if (class_instance_count) + *class_instance_count = 0; wined3d_mutex_lock(); if (!(wined3d_shader = wined3d_device_get_pixel_shader(device->wined3d_device))) @@ -1538,10 +1501,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetShader(ID3D11DeviceCo ID3D11PixelShader_AddRef(*shader); } -static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetSamplers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetSamplers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n", @@ -1566,10 +1529,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetSamplers(ID3D11Device wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetShader(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetShader(ID3D11DeviceContext1 *iface, ID3D11VertexShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d_vertex_shader *shader_impl; struct wined3d_shader *wined3d_shader; @@ -1578,6 +1541,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetShader(ID3D11DeviceCo if (class_instances || class_instance_count) FIXME("Dynamic linking not implemented yet.\n"); + if (class_instance_count) + *class_instance_count = 0; wined3d_mutex_lock(); if (!(wined3d_shader = wined3d_device_get_vertex_shader(device->wined3d_device))) @@ -1593,38 +1558,20 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetShader(ID3D11DeviceCo ID3D11VertexShader_AddRef(*shader); } -static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetConstantBuffers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetConstantBuffers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", iface, start_slot, buffer_count, buffers); - wined3d_mutex_lock(); - for (i = 0; i < buffer_count; ++i) - { - struct wined3d_buffer *wined3d_buffer; - struct d3d_buffer *buffer_impl; - - if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i))) - { - buffers[i] = NULL; - continue; - } - - buffer_impl = wined3d_buffer_get_parent(wined3d_buffer); - buffers[i] = &buffer_impl->ID3D11Buffer_iface; - ID3D11Buffer_AddRef(buffers[i]); - } - wined3d_mutex_unlock(); + d3d11_immediate_context_get_constant_buffers(iface, WINED3D_SHADER_TYPE_PIXEL, start_slot, + buffer_count, buffers); } -static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetInputLayout(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetInputLayout(ID3D11DeviceContext1 *iface, ID3D11InputLayout **input_layout) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct wined3d_vertex_declaration *wined3d_declaration; struct d3d_input_layout *input_layout_impl; @@ -1644,10 +1591,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetInputLayout(ID3D11Dev ID3D11InputLayout_AddRef(*input_layout); } -static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetVertexBuffers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetVertexBuffers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers, UINT *strides, UINT *offsets) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p, strides %p, offsets %p.\n", @@ -1681,10 +1628,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetVertexBuffers(ID3D11D wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetIndexBuffer(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetIndexBuffer(ID3D11DeviceContext1 *iface, ID3D11Buffer **buffer, DXGI_FORMAT *format, UINT *offset) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); enum wined3d_format_id wined3d_format; struct wined3d_buffer *wined3d_buffer; struct d3d_buffer *buffer_impl; @@ -1706,38 +1653,20 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetIndexBuffer(ID3D11Dev ID3D11Buffer_AddRef(*buffer = &buffer_impl->ID3D11Buffer_iface); } -static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetConstantBuffers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetConstantBuffers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", iface, start_slot, buffer_count, buffers); - wined3d_mutex_lock(); - for (i = 0; i < buffer_count; ++i) - { - struct wined3d_buffer *wined3d_buffer; - struct d3d_buffer *buffer_impl; - - if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i))) - { - buffers[i] = NULL; - continue; - } - - buffer_impl = wined3d_buffer_get_parent(wined3d_buffer); - buffers[i] = &buffer_impl->ID3D11Buffer_iface; - ID3D11Buffer_AddRef(buffers[i]); - } - wined3d_mutex_unlock(); + d3d11_immediate_context_get_constant_buffers(iface, WINED3D_SHADER_TYPE_GEOMETRY, start_slot, + buffer_count, buffers); } -static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetShader(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetShader(ID3D11DeviceContext1 *iface, ID3D11GeometryShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d_geometry_shader *shader_impl; struct wined3d_shader *wined3d_shader; @@ -1746,6 +1675,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetShader(ID3D11DeviceCo if (class_instances || class_instance_count) FIXME("Dynamic linking not implemented yet.\n"); + if (class_instance_count) + *class_instance_count = 0; wined3d_mutex_lock(); if (!(wined3d_shader = wined3d_device_get_geometry_shader(device->wined3d_device))) @@ -1761,10 +1692,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetShader(ID3D11DeviceCo ID3D11GeometryShader_AddRef(*shader); } -static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetPrimitiveTopology(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetPrimitiveTopology(ID3D11DeviceContext1 *iface, D3D11_PRIMITIVE_TOPOLOGY *topology) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); enum wined3d_primitive_type primitive_type; unsigned int patch_vertex_count; @@ -1777,10 +1708,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_IAGetPrimitiveTopology(ID3 d3d11_primitive_topology_from_wined3d_primitive_type(primitive_type, patch_vertex_count, topology); } -static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetShaderResources(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views); @@ -1804,10 +1735,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetShaderResources(ID3D1 wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetSamplers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetSamplers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n", @@ -1832,10 +1763,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetSamplers(ID3D11Device wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_GetPredication(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_GetPredication(ID3D11DeviceContext1 *iface, ID3D11Predicate **predicate, BOOL *value) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct wined3d_query *wined3d_predicate; struct d3d_query *predicate_impl; @@ -1855,10 +1786,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_GetPredication(ID3D11Devic ID3D11Predicate_AddRef(*predicate); } -static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetShaderResources(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views); @@ -1882,10 +1813,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetShaderResources(ID3D1 wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetSamplers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetSamplers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n", @@ -1910,11 +1841,11 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetSamplers(ID3D11Device wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetRenderTargets(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetRenderTargets(ID3D11DeviceContext1 *iface, UINT render_target_view_count, ID3D11RenderTargetView **render_target_views, ID3D11DepthStencilView **depth_stencil_view) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct wined3d_rendertarget_view *wined3d_view; TRACE("iface %p, render_target_view_count %u, render_target_views %p, depth_stencil_view %p.\n", @@ -1959,13 +1890,13 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetRenderTargets(ID3D11D } static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetRenderTargetsAndUnorderedAccessViews( - ID3D11DeviceContext *iface, + ID3D11DeviceContext1 *iface, UINT render_target_view_count, ID3D11RenderTargetView **render_target_views, ID3D11DepthStencilView **depth_stencil_view, UINT unordered_access_view_start_slot, UINT unordered_access_view_count, ID3D11UnorderedAccessView **unordered_access_views) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct wined3d_unordered_access_view *wined3d_view; struct d3d11_unordered_access_view *view_impl; unsigned int i; @@ -2000,10 +1931,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetRenderTargetsAndUnord } } -static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetBlendState(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetBlendState(ID3D11DeviceContext1 *iface, ID3D11BlendState **blend_state, FLOAT blend_factor[4], UINT *sample_mask) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct wined3d_blend_state *wined3d_state; struct d3d_blend_state *blend_state_impl; @@ -2011,7 +1942,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetBlendState(ID3D11Devi iface, blend_state, blend_factor, sample_mask); wined3d_mutex_lock(); - if ((wined3d_state = wined3d_device_get_blend_state(device->wined3d_device))) + if ((wined3d_state = wined3d_device_get_blend_state(device->wined3d_device, + (struct wined3d_color *)blend_factor))) { blend_state_impl = wined3d_blend_state_get_parent(wined3d_state); ID3D11BlendState_AddRef(*blend_state = &blend_state_impl->ID3D11BlendState_iface); @@ -2020,15 +1952,14 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetBlendState(ID3D11Devi { *blend_state = NULL; } - memcpy(blend_factor, device->blend_factor, 4 * sizeof(*blend_factor)); *sample_mask = wined3d_device_get_render_state(device->wined3d_device, WINED3D_RS_MULTISAMPLEMASK); wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetDepthStencilState(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetDepthStencilState(ID3D11DeviceContext1 *iface, ID3D11DepthStencilState **depth_stencil_state, UINT *stencil_ref) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n", iface, depth_stencil_state, stencil_ref); @@ -2039,10 +1970,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_OMGetDepthStencilState(ID3 *stencil_ref = device->stencil_ref; } -static void STDMETHODCALLTYPE d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_SOGetTargets(ID3D11DeviceContext1 *iface, UINT buffer_count, ID3D11Buffer **buffers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, buffer_count %u, buffers %p.\n", iface, buffer_count, buffers); @@ -2066,10 +1997,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_SOGetTargets(ID3D11DeviceC wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetState(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetState(ID3D11DeviceContext1 *iface, ID3D11RasterizerState **rasterizer_state) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d_rasterizer_state *rasterizer_state_impl; struct wined3d_rasterizer_state *wined3d_state; @@ -2088,65 +2019,74 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetState(ID3D11DeviceCon wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetViewports(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetViewports(ID3D11DeviceContext1 *iface, UINT *viewport_count, D3D11_VIEWPORT *viewports) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); - struct wined3d_viewport wined3d_vp; + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + struct wined3d_viewport wined3d_vp[WINED3D_MAX_VIEWPORTS]; + unsigned int actual_count = ARRAY_SIZE(wined3d_vp), i; TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports); - if (!viewports) - { - *viewport_count = 1; - return; - } - - if (!*viewport_count) + if (!viewport_count) return; wined3d_mutex_lock(); - wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp); + wined3d_device_get_viewports(device->wined3d_device, &actual_count, viewports ? wined3d_vp : NULL); wined3d_mutex_unlock(); - viewports[0].TopLeftX = wined3d_vp.x; - viewports[0].TopLeftY = wined3d_vp.y; - viewports[0].Width = wined3d_vp.width; - viewports[0].Height = wined3d_vp.height; - viewports[0].MinDepth = wined3d_vp.min_z; - viewports[0].MaxDepth = wined3d_vp.max_z; + if (!viewports) + { + *viewport_count = actual_count; + return; + } + + if (*viewport_count > actual_count) + memset(&viewports[actual_count], 0, (*viewport_count - actual_count) * sizeof(*viewports)); - if (*viewport_count > 1) - memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports)); + *viewport_count = min(actual_count, *viewport_count); + for (i = 0; i < *viewport_count; ++i) + { + viewports[i].TopLeftX = wined3d_vp[i].x; + viewports[i].TopLeftY = wined3d_vp[i].y; + viewports[i].Width = wined3d_vp[i].width; + viewports[i].Height = wined3d_vp[i].height; + viewports[i].MinDepth = wined3d_vp[i].min_z; + viewports[i].MaxDepth = wined3d_vp[i].max_z; + } } -static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_RSGetScissorRects(ID3D11DeviceContext1 *iface, UINT *rect_count, D3D11_RECT *rects) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + unsigned int actual_count; TRACE("iface %p, rect_count %p, rects %p.\n", iface, rect_count, rects); - if (!rects) - { - *rect_count = 1; + if (!rect_count) return; - } - if (!*rect_count) - return; + actual_count = *rect_count; wined3d_mutex_lock(); - wined3d_device_get_scissor_rect(device->wined3d_device, rects); + wined3d_device_get_scissor_rects(device->wined3d_device, &actual_count, rects); wined3d_mutex_unlock(); - if (*rect_count > 1) - memset(&rects[1], 0, (*rect_count - 1) * sizeof(*rects)); + + if (!rects) + { + *rect_count = actual_count; + return; + } + + if (*rect_count > actual_count) + memset(&rects[actual_count], 0, (*rect_count - actual_count) * sizeof(*rects)); } -static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views); @@ -2169,10 +2109,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShaderResources(ID3D1 wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShader(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShader(ID3D11DeviceContext1 *iface, ID3D11HullShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d11_hull_shader *shader_impl; struct wined3d_shader *wined3d_shader; @@ -2181,6 +2121,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShader(ID3D11DeviceCo if (class_instances || class_instance_count) FIXME("Dynamic linking not implemented yet.\n"); + if (class_instance_count) + *class_instance_count = 0; wined3d_mutex_lock(); if (!(wined3d_shader = wined3d_device_get_hull_shader(device->wined3d_device))) @@ -2195,10 +2137,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetShader(ID3D11DeviceCo ID3D11HullShader_AddRef(*shader = &shader_impl->ID3D11HullShader_iface); } -static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetSamplers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetSamplers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n", @@ -2222,37 +2164,20 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetSamplers(ID3D11Device wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetConstantBuffers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetConstantBuffers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", iface, start_slot, buffer_count, buffers); - wined3d_mutex_lock(); - for (i = 0; i < buffer_count; ++i) - { - struct wined3d_buffer *wined3d_buffer; - struct d3d_buffer *buffer_impl; - - if (!(wined3d_buffer = wined3d_device_get_hs_cb(device->wined3d_device, start_slot + i))) - { - buffers[i] = NULL; - continue; - } - - buffer_impl = wined3d_buffer_get_parent(wined3d_buffer); - ID3D11Buffer_AddRef(buffers[i] = &buffer_impl->ID3D11Buffer_iface); - } - wined3d_mutex_unlock(); + d3d11_immediate_context_get_constant_buffers(iface, WINED3D_SHADER_TYPE_HULL, start_slot, + buffer_count, buffers); } -static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetShaderResources(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", @@ -2276,10 +2201,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetShaderResources(ID3D1 wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetShader(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetShader(ID3D11DeviceContext1 *iface, ID3D11DomainShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d11_domain_shader *shader_impl; struct wined3d_shader *wined3d_shader; @@ -2288,6 +2213,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetShader(ID3D11DeviceCo if (class_instances || class_instance_count) FIXME("Dynamic linking not implemented yet.\n"); + if (class_instance_count) + *class_instance_count = 0; wined3d_mutex_lock(); if (!(wined3d_shader = wined3d_device_get_domain_shader(device->wined3d_device))) @@ -2302,10 +2229,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetShader(ID3D11DeviceCo ID3D11DomainShader_AddRef(*shader = &shader_impl->ID3D11DomainShader_iface); } -static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetSamplers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetSamplers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n", @@ -2329,37 +2256,20 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetSamplers(ID3D11Device wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetConstantBuffers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetConstantBuffers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", iface, start_slot, buffer_count, buffers); - wined3d_mutex_lock(); - for (i = 0; i < buffer_count; ++i) - { - struct wined3d_buffer *wined3d_buffer; - struct d3d_buffer *buffer_impl; - - if (!(wined3d_buffer = wined3d_device_get_ds_cb(device->wined3d_device, start_slot + i))) - { - buffers[i] = NULL; - continue; - } - - buffer_impl = wined3d_buffer_get_parent(wined3d_buffer); - ID3D11Buffer_AddRef(buffers[i] = &buffer_impl->ID3D11Buffer_iface); - } - wined3d_mutex_unlock(); + d3d11_immediate_context_get_constant_buffers(iface, WINED3D_SHADER_TYPE_DOMAIN, start_slot, + buffer_count, buffers); } -static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetShaderResources(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetShaderResources(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11ShaderResourceView **views) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views); @@ -2382,10 +2292,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetShaderResources(ID3D1 wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetUnorderedAccessViews(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetUnorderedAccessViews(ID3D11DeviceContext1 *iface, UINT start_slot, UINT view_count, ID3D11UnorderedAccessView **views) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, view_count %u, views %p.\n", iface, start_slot, view_count, views); @@ -2408,10 +2318,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetUnorderedAccessViews( wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetShader(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetShader(ID3D11DeviceContext1 *iface, ID3D11ComputeShader **shader, ID3D11ClassInstance **class_instances, UINT *class_instance_count) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); struct d3d11_compute_shader *shader_impl; struct wined3d_shader *wined3d_shader; @@ -2420,6 +2330,8 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetShader(ID3D11DeviceCo if (class_instances || class_instance_count) FIXME("Dynamic linking not implemented yet.\n"); + if (class_instance_count) + *class_instance_count = 0; wined3d_mutex_lock(); if (!(wined3d_shader = wined3d_device_get_compute_shader(device->wined3d_device))) @@ -2434,10 +2346,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetShader(ID3D11DeviceCo ID3D11ComputeShader_AddRef(*shader = &shader_impl->ID3D11ComputeShader_iface); } -static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetSamplers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetSamplers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT sampler_count, ID3D11SamplerState **samplers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); unsigned int i; TRACE("iface %p, start_slot %u, sampler_count %u, samplers %p.\n", @@ -2461,38 +2373,21 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetSamplers(ID3D11Device wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetConstantBuffers(ID3D11DeviceContext *iface, +static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetConstantBuffers(ID3D11DeviceContext1 *iface, UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", iface, start_slot, buffer_count, buffers); - wined3d_mutex_lock(); - for (i = 0; i < buffer_count; ++i) - { - struct wined3d_buffer *wined3d_buffer; - struct d3d_buffer *buffer_impl; - - if (!(wined3d_buffer = wined3d_device_get_cs_cb(device->wined3d_device, start_slot + i))) - { - buffers[i] = NULL; - continue; - } - - buffer_impl = wined3d_buffer_get_parent(wined3d_buffer); - ID3D11Buffer_AddRef(buffers[i] = &buffer_impl->ID3D11Buffer_iface); - } - wined3d_mutex_unlock(); + d3d11_immediate_context_get_constant_buffers(iface, WINED3D_SHADER_TYPE_COMPUTE, start_slot, + buffer_count, buffers); } -static void STDMETHODCALLTYPE d3d11_immediate_context_ClearState(ID3D11DeviceContext *iface) +static void STDMETHODCALLTYPE d3d11_immediate_context_ClearState(ID3D11DeviceContext1 *iface) { - struct d3d_device *device = device_from_immediate_ID3D11DeviceContext(iface); + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); static const float blend_factor[] = {1.0f, 1.0f, 1.0f, 1.0f}; - unsigned int i; + unsigned int i, j; TRACE("iface %p.\n", iface); @@ -2521,14 +2416,10 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_ClearState(ID3D11DeviceCon wined3d_device_set_ps_resource_view(device->wined3d_device, i, NULL); wined3d_device_set_cs_resource_view(device->wined3d_device, i, NULL); } - for (i = 0; i < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++i) + for (i = 0; i < WINED3D_SHADER_TYPE_COUNT; ++i) { - wined3d_device_set_vs_cb(device->wined3d_device, i, NULL); - wined3d_device_set_hs_cb(device->wined3d_device, i, NULL); - wined3d_device_set_ds_cb(device->wined3d_device, i, NULL); - wined3d_device_set_gs_cb(device->wined3d_device, i, NULL); - wined3d_device_set_ps_cb(device->wined3d_device, i, NULL); - wined3d_device_set_cs_cb(device->wined3d_device, i, NULL); + for (j = 0; j < D3D11_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT; ++j) + wined3d_device_set_constant_buffer(device->wined3d_device, i, j, NULL); } for (i = 0; i < D3D11_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT; ++i) { @@ -2547,11 +2438,11 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_ClearState(ID3D11DeviceCon wined3d_device_set_unordered_access_view(device->wined3d_device, i, NULL, ~0u); wined3d_device_set_cs_uav(device->wined3d_device, i, NULL, ~0u); } - ID3D11DeviceContext_OMSetDepthStencilState(iface, NULL, 0); - ID3D11DeviceContext_OMSetBlendState(iface, NULL, blend_factor, D3D11_DEFAULT_SAMPLE_MASK); - ID3D11DeviceContext_RSSetViewports(iface, 0, NULL); - ID3D11DeviceContext_RSSetScissorRects(iface, 0, NULL); - ID3D11DeviceContext_RSSetState(iface, NULL); + ID3D11DeviceContext1_OMSetDepthStencilState(iface, NULL, 0); + ID3D11DeviceContext1_OMSetBlendState(iface, NULL, blend_factor, D3D11_DEFAULT_SAMPLE_MASK); + ID3D11DeviceContext1_RSSetViewports(iface, 0, NULL); + ID3D11DeviceContext1_RSSetScissorRects(iface, 0, NULL); + ID3D11DeviceContext1_RSSetState(iface, NULL); for (i = 0; i < D3D11_SO_BUFFER_SLOT_COUNT; ++i) { wined3d_device_set_stream_output(device->wined3d_device, i, NULL, 0); @@ -2560,26 +2451,26 @@ static void STDMETHODCALLTYPE d3d11_immediate_context_ClearState(ID3D11DeviceCon wined3d_mutex_unlock(); } -static void STDMETHODCALLTYPE d3d11_immediate_context_Flush(ID3D11DeviceContext *iface) +static void STDMETHODCALLTYPE d3d11_immediate_context_Flush(ID3D11DeviceContext1 *iface) { FIXME("iface %p stub!\n", iface); } -static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE d3d11_immediate_context_GetType(ID3D11DeviceContext *iface) +static D3D11_DEVICE_CONTEXT_TYPE STDMETHODCALLTYPE d3d11_immediate_context_GetType(ID3D11DeviceContext1 *iface) { TRACE("iface %p.\n", iface); return D3D11_DEVICE_CONTEXT_IMMEDIATE; } -static UINT STDMETHODCALLTYPE d3d11_immediate_context_GetContextFlags(ID3D11DeviceContext *iface) +static UINT STDMETHODCALLTYPE d3d11_immediate_context_GetContextFlags(ID3D11DeviceContext1 *iface) { FIXME("iface %p stub!\n", iface); return 0; } -static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_FinishCommandList(ID3D11DeviceContext *iface, +static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_FinishCommandList(ID3D11DeviceContext1 *iface, BOOL restore, ID3D11CommandList **command_list) { FIXME("iface %p, restore %#x, command_list %p stub!\n", iface, restore, command_list); @@ -2587,7 +2478,173 @@ static HRESULT STDMETHODCALLTYPE d3d11_immediate_context_FinishCommandList(ID3D1 return E_NOTIMPL; } -static const struct ID3D11DeviceContextVtbl d3d11_immediate_context_vtbl = +static void STDMETHODCALLTYPE d3d11_immediate_context_CopySubresourceRegion1(ID3D11DeviceContext1 *iface, + ID3D11Resource *dst_resource, UINT dst_subresource_idx, UINT dst_x, UINT dst_y, UINT dst_z, + ID3D11Resource *src_resource, UINT src_subresource_idx, const D3D11_BOX *src_box, UINT flags) +{ + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + struct wined3d_resource *wined3d_dst_resource, *wined3d_src_resource; + struct wined3d_box wined3d_src_box; + + TRACE("iface %p, dst_resource %p, dst_subresource_idx %u, dst_x %u, dst_y %u, dst_z %u, " + "src_resource %p, src_subresource_idx %u, src_box %p, flags %#x.\n", + iface, dst_resource, dst_subresource_idx, dst_x, dst_y, dst_z, + src_resource, src_subresource_idx, src_box, flags); + + if (src_box) + wined3d_box_set(&wined3d_src_box, src_box->left, src_box->top, + src_box->right, src_box->bottom, src_box->front, src_box->back); + + wined3d_dst_resource = wined3d_resource_from_d3d11_resource(dst_resource); + wined3d_src_resource = wined3d_resource_from_d3d11_resource(src_resource); + wined3d_mutex_lock(); + wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_dst_resource, dst_subresource_idx, + dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL, flags); + wined3d_mutex_unlock(); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_UpdateSubresource1(ID3D11DeviceContext1 *iface, + ID3D11Resource *resource, UINT subresource_idx, const D3D11_BOX *box, const void *data, + UINT row_pitch, UINT depth_pitch, UINT flags) +{ + struct d3d_device *device = device_from_immediate_ID3D11DeviceContext1(iface); + struct wined3d_resource *wined3d_resource; + struct wined3d_box wined3d_box; + + TRACE("iface %p, resource %p, subresource_idx %u, box %p, data %p, row_pitch %u, depth_pitch %u, flags %#x.\n", + iface, resource, subresource_idx, box, data, row_pitch, depth_pitch, flags); + + if (box) + wined3d_box_set(&wined3d_box, box->left, box->top, box->right, box->bottom, + box->front, box->back); + + wined3d_resource = wined3d_resource_from_d3d11_resource(resource); + wined3d_mutex_lock(); + wined3d_device_update_sub_resource(device->wined3d_device, wined3d_resource, subresource_idx, + box ? &wined3d_box : NULL, data, row_pitch, depth_pitch, flags); + wined3d_mutex_unlock(); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_DiscardResource(ID3D11DeviceContext1 *iface, + ID3D11Resource *resource) +{ + FIXME("iface %p, resource %p stub!\n", iface, resource); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_DiscardView(ID3D11DeviceContext1 *iface, ID3D11View *view) +{ + FIXME("iface %p, view %p stub!\n", iface, view); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_VSSetConstantBuffers1(ID3D11DeviceContext1 *iface, + UINT start_slot, UINT buffer_count, ID3D11Buffer * const *buffers, const UINT *first_constant, + const UINT *num_constants) +{ + FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n", + iface, start_slot, buffer_count, buffers, first_constant, num_constants); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_HSSetConstantBuffers1(ID3D11DeviceContext1 *iface, + UINT start_slot, UINT buffer_count, ID3D11Buffer * const *buffers, const UINT *first_constant, + const UINT *num_constants) +{ + FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n", + iface, start_slot, buffer_count, buffers, first_constant, num_constants); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_DSSetConstantBuffers1(ID3D11DeviceContext1 *iface, + UINT start_slot, UINT buffer_count, ID3D11Buffer * const *buffers, const UINT *first_constant, + const UINT *num_constants) +{ + FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n", + iface, start_slot, buffer_count, buffers, first_constant, num_constants); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_GSSetConstantBuffers1(ID3D11DeviceContext1 *iface, + UINT start_slot, UINT buffer_count, ID3D11Buffer * const *buffers, const UINT *first_constant, + const UINT *num_constants) +{ + FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n", + iface, start_slot, buffer_count, buffers, first_constant, num_constants); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_PSSetConstantBuffers1(ID3D11DeviceContext1 *iface, + UINT start_slot, UINT buffer_count, ID3D11Buffer * const *buffers, const UINT *first_constant, + const UINT *num_constants) +{ + FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n", + iface, start_slot, buffer_count, buffers, first_constant, num_constants); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_CSSetConstantBuffers1(ID3D11DeviceContext1 *iface, + UINT start_slot, UINT buffer_count, ID3D11Buffer * const *buffers, const UINT *first_constant, + const UINT *num_constants) +{ + FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n", + iface, start_slot, buffer_count, buffers, first_constant, num_constants); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_VSGetConstantBuffers1(ID3D11DeviceContext1 *iface, + UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers, UINT *first_constant, UINT *num_constants) +{ + FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n", + iface, start_slot, buffer_count, buffers, first_constant, num_constants); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_HSGetConstantBuffers1(ID3D11DeviceContext1 *iface, + UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers, UINT *first_constant, UINT *num_constants) +{ + FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n", + iface, start_slot, buffer_count, buffers, first_constant, num_constants); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_DSGetConstantBuffers1(ID3D11DeviceContext1 *iface, + UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers, UINT *first_constant, UINT *num_constants) +{ + FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n", + iface, start_slot, buffer_count, buffers, first_constant, num_constants); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_GSGetConstantBuffers1(ID3D11DeviceContext1 *iface, + UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers, UINT *first_constant, UINT *num_constants) +{ + FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n", + iface, start_slot, buffer_count, buffers, first_constant, num_constants); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_PSGetConstantBuffers1(ID3D11DeviceContext1 *iface, + UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers, UINT *first_constant, UINT *num_constants) +{ + FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n", + iface, start_slot, buffer_count, buffers, first_constant, num_constants); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_CSGetConstantBuffers1(ID3D11DeviceContext1 *iface, + UINT start_slot, UINT buffer_count, ID3D11Buffer **buffers, UINT *first_constant, UINT *num_constants) +{ + FIXME("iface %p, start_slot %u, buffer_count %u, buffers %p, first_constant %p, num_constants %p stub!\n", + iface, start_slot, buffer_count, buffers, first_constant, num_constants); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_SwapDeviceContextState(ID3D11DeviceContext1 *iface, + ID3DDeviceContextState *state, ID3DDeviceContextState **prev_state) +{ + FIXME("iface %p, state %p, prev_state %p stub!\n", iface, state, prev_state); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_ClearView(ID3D11DeviceContext1 *iface, ID3D11View *view, + const FLOAT color[4], const D3D11_RECT *rect, UINT num_rects) +{ + FIXME("iface %p, view %p, color %p, rect %p, num_rects %u stub!\n", iface, view, color, rect, num_rects); +} + +static void STDMETHODCALLTYPE d3d11_immediate_context_DiscardView1(ID3D11DeviceContext1 *iface, ID3D11View *view, + const D3D11_RECT *rects, UINT num_rects) +{ + FIXME("iface %p, view %p, rects %p, num_rects %u stub!\n", iface, view, rects, num_rects); +} + +static const struct ID3D11DeviceContext1Vtbl d3d11_immediate_context_vtbl = { /* IUnknown methods */ d3d11_immediate_context_QueryInterface, @@ -2707,14 +2764,110 @@ static const struct ID3D11DeviceContextVtbl d3d11_immediate_context_vtbl = d3d11_immediate_context_GetType, d3d11_immediate_context_GetContextFlags, d3d11_immediate_context_FinishCommandList, + /* ID3D11DeviceContext1 methods */ + d3d11_immediate_context_CopySubresourceRegion1, + d3d11_immediate_context_UpdateSubresource1, + d3d11_immediate_context_DiscardResource, + d3d11_immediate_context_DiscardView, + d3d11_immediate_context_VSSetConstantBuffers1, + d3d11_immediate_context_HSSetConstantBuffers1, + d3d11_immediate_context_DSSetConstantBuffers1, + d3d11_immediate_context_GSSetConstantBuffers1, + d3d11_immediate_context_PSSetConstantBuffers1, + d3d11_immediate_context_CSSetConstantBuffers1, + d3d11_immediate_context_VSGetConstantBuffers1, + d3d11_immediate_context_HSGetConstantBuffers1, + d3d11_immediate_context_DSGetConstantBuffers1, + d3d11_immediate_context_GSGetConstantBuffers1, + d3d11_immediate_context_PSGetConstantBuffers1, + d3d11_immediate_context_CSGetConstantBuffers1, + d3d11_immediate_context_SwapDeviceContextState, + d3d11_immediate_context_ClearView, + d3d11_immediate_context_DiscardView1, +}; + +/* ID3D11Multithread methods */ + +static inline struct d3d11_immediate_context *impl_from_ID3D11Multithread(ID3D11Multithread *iface) +{ + return CONTAINING_RECORD(iface, struct d3d11_immediate_context, ID3D11Multithread_iface); +} + +static HRESULT STDMETHODCALLTYPE d3d11_multithread_QueryInterface(ID3D11Multithread *iface, + REFIID iid, void **out) +{ + struct d3d11_immediate_context *context = impl_from_ID3D11Multithread(iface); + + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + return d3d11_immediate_context_QueryInterface(&context->ID3D11DeviceContext1_iface, iid, out); +} + +static ULONG STDMETHODCALLTYPE d3d11_multithread_AddRef(ID3D11Multithread *iface) +{ + struct d3d11_immediate_context *context = impl_from_ID3D11Multithread(iface); + + TRACE("iface %p.\n", iface); + + return d3d11_immediate_context_AddRef(&context->ID3D11DeviceContext1_iface); +} + +static ULONG STDMETHODCALLTYPE d3d11_multithread_Release(ID3D11Multithread *iface) +{ + struct d3d11_immediate_context *context = impl_from_ID3D11Multithread(iface); + + TRACE("iface %p.\n", iface); + + return d3d11_immediate_context_Release(&context->ID3D11DeviceContext1_iface); +} + +static void STDMETHODCALLTYPE d3d11_multithread_Enter(ID3D11Multithread *iface) +{ + TRACE("iface %p.\n", iface); + + wined3d_mutex_lock(); +} + +static void STDMETHODCALLTYPE d3d11_multithread_Leave(ID3D11Multithread *iface) +{ + TRACE("iface %p.\n", iface); + + wined3d_mutex_unlock(); +} + +static BOOL STDMETHODCALLTYPE d3d11_multithread_SetMultithreadProtected( + ID3D11Multithread *iface, BOOL enable) +{ + FIXME("iface %p, enable %#x stub!\n", iface, enable); + + return TRUE; +} + +static BOOL STDMETHODCALLTYPE d3d11_multithread_GetMultithreadProtected(ID3D11Multithread *iface) +{ + FIXME("iface %p stub!\n", iface); + + return TRUE; +} + +static const struct ID3D11MultithreadVtbl d3d11_multithread_vtbl = +{ + d3d11_multithread_QueryInterface, + d3d11_multithread_AddRef, + d3d11_multithread_Release, + d3d11_multithread_Enter, + d3d11_multithread_Leave, + d3d11_multithread_SetMultithreadProtected, + d3d11_multithread_GetMultithreadProtected, }; static void d3d11_immediate_context_init(struct d3d11_immediate_context *context, struct d3d_device *device) { - context->ID3D11DeviceContext_iface.lpVtbl = &d3d11_immediate_context_vtbl; + context->ID3D11DeviceContext1_iface.lpVtbl = &d3d11_immediate_context_vtbl; + context->ID3D11Multithread_iface.lpVtbl = &d3d11_multithread_vtbl; context->refcount = 1; - ID3D11Device_AddRef(&device->ID3D11Device_iface); + ID3D11Device2_AddRef(&device->ID3D11Device2_iface); wined3d_private_store_init(&context->private_store); } @@ -2726,28 +2879,28 @@ static void d3d11_immediate_context_destroy(struct d3d11_immediate_context *cont /* ID3D11Device methods */ -static HRESULT STDMETHODCALLTYPE d3d11_device_QueryInterface(ID3D11Device *iface, REFIID riid, void **out) +static HRESULT STDMETHODCALLTYPE d3d11_device_QueryInterface(ID3D11Device2 *iface, REFIID iid, void **out) { - struct d3d_device *device = impl_from_ID3D11Device(iface); - return IUnknown_QueryInterface(device->outer_unk, riid, out); + struct d3d_device *device = impl_from_ID3D11Device2(iface); + return IUnknown_QueryInterface(device->outer_unk, iid, out); } -static ULONG STDMETHODCALLTYPE d3d11_device_AddRef(ID3D11Device *iface) +static ULONG STDMETHODCALLTYPE d3d11_device_AddRef(ID3D11Device2 *iface) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); return IUnknown_AddRef(device->outer_unk); } -static ULONG STDMETHODCALLTYPE d3d11_device_Release(ID3D11Device *iface) +static ULONG STDMETHODCALLTYPE d3d11_device_Release(ID3D11Device2 *iface) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); return IUnknown_Release(device->outer_unk); } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBuffer(ID3D11Device *iface, const D3D11_BUFFER_DESC *desc, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBuffer(ID3D11Device2 *iface, const D3D11_BUFFER_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Buffer **buffer) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_buffer *object; HRESULT hr; @@ -2761,18 +2914,27 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBuffer(ID3D11Device *iface, return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture1D(ID3D11Device *iface, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture1D(ID3D11Device2 *iface, const D3D11_TEXTURE1D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture1D **texture) { - FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture); + struct d3d_device *device = impl_from_ID3D11Device2(iface); + struct d3d_texture1d *object; + HRESULT hr; - return E_NOTIMPL; + TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture); + + if (FAILED(hr = d3d_texture1d_create(device, desc, data, &object))) + return hr; + + *texture = &object->ID3D11Texture1D_iface; + + return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture2D(ID3D11Device *iface, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture2D(ID3D11Device2 *iface, const D3D11_TEXTURE2D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture2D **texture) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_texture2d *object; HRESULT hr; @@ -2786,10 +2948,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture2D(ID3D11Device *ifac return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture3D(ID3D11Device *iface, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture3D(ID3D11Device2 *iface, const D3D11_TEXTURE3D_DESC *desc, const D3D11_SUBRESOURCE_DATA *data, ID3D11Texture3D **texture) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_texture3d *object; HRESULT hr; @@ -2803,10 +2965,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateTexture3D(ID3D11Device *ifac return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateShaderResourceView(ID3D11Device *iface, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateShaderResourceView(ID3D11Device2 *iface, ID3D11Resource *resource, const D3D11_SHADER_RESOURCE_VIEW_DESC *desc, ID3D11ShaderResourceView **view) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_shader_resource_view *object; HRESULT hr; @@ -2823,10 +2985,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateShaderResourceView(ID3D11Dev return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateUnorderedAccessView(ID3D11Device *iface, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateUnorderedAccessView(ID3D11Device2 *iface, ID3D11Resource *resource, const D3D11_UNORDERED_ACCESS_VIEW_DESC *desc, ID3D11UnorderedAccessView **view) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d11_unordered_access_view *object; HRESULT hr; @@ -2840,10 +3002,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateUnorderedAccessView(ID3D11De return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRenderTargetView(ID3D11Device *iface, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRenderTargetView(ID3D11Device2 *iface, ID3D11Resource *resource, const D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3D11RenderTargetView **view) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_rendertarget_view *object; HRESULT hr; @@ -2860,10 +3022,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRenderTargetView(ID3D11Devic return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilView(ID3D11Device *iface, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilView(ID3D11Device2 *iface, ID3D11Resource *resource, const D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3D11DepthStencilView **view) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_depthstencil_view *object; HRESULT hr; @@ -2877,11 +3039,11 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilView(ID3D11Devic return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateInputLayout(ID3D11Device *iface, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateInputLayout(ID3D11Device2 *iface, const D3D11_INPUT_ELEMENT_DESC *element_descs, UINT element_count, const void *shader_byte_code, SIZE_T shader_byte_code_length, ID3D11InputLayout **input_layout) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_input_layout *object; HRESULT hr; @@ -2898,10 +3060,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateInputLayout(ID3D11Device *if return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateVertexShader(ID3D11Device *iface, const void *byte_code, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateVertexShader(ID3D11Device2 *iface, const void *byte_code, SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11VertexShader **shader) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_vertex_shader *object; HRESULT hr; @@ -2919,10 +3081,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateVertexShader(ID3D11Device *i return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateGeometryShader(ID3D11Device *iface, const void *byte_code, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateGeometryShader(ID3D11Device2 *iface, const void *byte_code, SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11GeometryShader **shader) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_geometry_shader *object; HRESULT hr; @@ -2941,12 +3103,12 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateGeometryShader(ID3D11Device return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device *iface, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateGeometryShaderWithStreamOutput(ID3D11Device2 *iface, const void *byte_code, SIZE_T byte_code_length, const D3D11_SO_DECLARATION_ENTRY *so_entries, UINT entry_count, const UINT *buffer_strides, UINT strides_count, UINT rasterizer_stream, ID3D11ClassLinkage *class_linkage, ID3D11GeometryShader **shader) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_geometry_shader *object; HRESULT hr; @@ -2970,10 +3132,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateGeometryShaderWithStreamOutp return hr; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePixelShader(ID3D11Device *iface, const void *byte_code, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePixelShader(ID3D11Device2 *iface, const void *byte_code, SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11PixelShader **shader) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_pixel_shader *object; HRESULT hr; @@ -2991,10 +3153,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePixelShader(ID3D11Device *if return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateHullShader(ID3D11Device *iface, const void *byte_code, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateHullShader(ID3D11Device2 *iface, const void *byte_code, SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11HullShader **shader) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d11_hull_shader *object; HRESULT hr; @@ -3012,10 +3174,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateHullShader(ID3D11Device *ifa return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDomainShader(ID3D11Device *iface, const void *byte_code, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDomainShader(ID3D11Device2 *iface, const void *byte_code, SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11DomainShader **shader) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d11_domain_shader *object; HRESULT hr; @@ -3033,10 +3195,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDomainShader(ID3D11Device *i return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateComputeShader(ID3D11Device *iface, const void *byte_code, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateComputeShader(ID3D11Device2 *iface, const void *byte_code, SIZE_T byte_code_length, ID3D11ClassLinkage *class_linkage, ID3D11ComputeShader **shader) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d11_compute_shader *object; HRESULT hr; @@ -3054,10 +3216,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateComputeShader(ID3D11Device * return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateClassLinkage(ID3D11Device *iface, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateClassLinkage(ID3D11Device2 *iface, ID3D11ClassLinkage **class_linkage) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d11_class_linkage *object; HRESULT hr; @@ -3071,10 +3233,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateClassLinkage(ID3D11Device *i return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBlendState(ID3D11Device *iface, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBlendState(ID3D11Device2 *iface, const D3D11_BLEND_DESC *desc, ID3D11BlendState **blend_state) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_blend_state *object; HRESULT hr; @@ -3088,10 +3250,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBlendState(ID3D11Device *ifa return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilState(ID3D11Device *iface, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilState(ID3D11Device2 *iface, const D3D11_DEPTH_STENCIL_DESC *desc, ID3D11DepthStencilState **depth_stencil_state) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_depthstencil_state *object; HRESULT hr; @@ -3105,10 +3267,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDepthStencilState(ID3D11Devi return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRasterizerState(ID3D11Device *iface, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRasterizerState(ID3D11Device2 *iface, const D3D11_RASTERIZER_DESC *desc, ID3D11RasterizerState **rasterizer_state) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_rasterizer_state *object; HRESULT hr; @@ -3122,10 +3284,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRasterizerState(ID3D11Device return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateSamplerState(ID3D11Device *iface, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateSamplerState(ID3D11Device2 *iface, const D3D11_SAMPLER_DESC *desc, ID3D11SamplerState **sampler_state) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_sampler_state *object; HRESULT hr; @@ -3139,10 +3301,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateSamplerState(ID3D11Device *i return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateQuery(ID3D11Device *iface, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateQuery(ID3D11Device2 *iface, const D3D11_QUERY_DESC *desc, ID3D11Query **query) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_query *object; HRESULT hr; @@ -3161,10 +3323,10 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateQuery(ID3D11Device *iface, return S_FALSE; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePredicate(ID3D11Device *iface, const D3D11_QUERY_DESC *desc, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePredicate(ID3D11Device2 *iface, const D3D11_QUERY_DESC *desc, ID3D11Predicate **predicate) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct d3d_query *object; HRESULT hr; @@ -3183,7 +3345,7 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreatePredicate(ID3D11Device *ifac return S_FALSE; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateCounter(ID3D11Device *iface, const D3D11_COUNTER_DESC *desc, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateCounter(ID3D11Device2 *iface, const D3D11_COUNTER_DESC *desc, ID3D11Counter **counter) { FIXME("iface %p, desc %p, counter %p stub!\n", iface, desc, counter); @@ -3191,43 +3353,46 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CreateCounter(ID3D11Device *iface, return E_NOTIMPL; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDeferredContext(ID3D11Device *iface, UINT flags, +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDeferredContext(ID3D11Device2 *iface, UINT flags, ID3D11DeviceContext **context) { FIXME("iface %p, flags %#x, context %p stub!\n", iface, flags, context); + *context = NULL; return E_NOTIMPL; } -static HRESULT STDMETHODCALLTYPE d3d11_device_OpenSharedResource(ID3D11Device *iface, HANDLE resource, REFIID riid, +static HRESULT STDMETHODCALLTYPE d3d11_device_OpenSharedResource(ID3D11Device2 *iface, HANDLE resource, REFIID iid, void **out) { - FIXME("iface %p, resource %p, riid %s, out %p stub!\n", iface, resource, debugstr_guid(riid), out); + FIXME("iface %p, resource %p, iid %s, out %p stub!\n", iface, resource, debugstr_guid(iid), out); return E_NOTIMPL; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFormatSupport(ID3D11Device *iface, DXGI_FORMAT format, +static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFormatSupport(ID3D11Device2 *iface, DXGI_FORMAT format, UINT *format_support) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct wined3d_device_creation_parameters params; enum wined3d_format_id wined3d_format; + D3D_FEATURE_LEVEL feature_level; struct wined3d *wined3d; unsigned int i; static const struct { enum wined3d_resource_type rtype; - unsigned int usage; + unsigned int bind_flags; D3D11_FORMAT_SUPPORT flag; } flag_mapping[] = { - {WINED3D_RTYPE_TEXTURE_2D, WINED3DUSAGE_TEXTURE, D3D11_FORMAT_SUPPORT_TEXTURE2D}, - {WINED3D_RTYPE_TEXTURE_3D, WINED3DUSAGE_TEXTURE, D3D11_FORMAT_SUPPORT_TEXTURE3D}, - {WINED3D_RTYPE_NONE, WINED3DUSAGE_RENDERTARGET, D3D11_FORMAT_SUPPORT_RENDER_TARGET}, - {WINED3D_RTYPE_NONE, WINED3DUSAGE_DEPTHSTENCIL, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL}, + {WINED3D_RTYPE_TEXTURE_1D, WINED3D_BIND_SHADER_RESOURCE, D3D11_FORMAT_SUPPORT_TEXTURE1D}, + {WINED3D_RTYPE_TEXTURE_2D, WINED3D_BIND_SHADER_RESOURCE, D3D11_FORMAT_SUPPORT_TEXTURE2D}, + {WINED3D_RTYPE_TEXTURE_3D, WINED3D_BIND_SHADER_RESOURCE, D3D11_FORMAT_SUPPORT_TEXTURE3D}, + {WINED3D_RTYPE_NONE, WINED3D_BIND_RENDER_TARGET, D3D11_FORMAT_SUPPORT_RENDER_TARGET}, + {WINED3D_RTYPE_NONE, WINED3D_BIND_DEPTH_STENCIL, D3D11_FORMAT_SUPPORT_DEPTH_STENCIL}, }; HRESULT hr; @@ -3244,12 +3409,13 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFormatSupport(ID3D11Device *i *format_support = 0; wined3d_mutex_lock(); + feature_level = device->feature_level; wined3d = wined3d_device_get_wined3d(device->wined3d_device); wined3d_device_get_creation_parameters(device->wined3d_device, ¶ms); for (i = 0; i < ARRAY_SIZE(flag_mapping); ++i) { hr = wined3d_check_device_format(wined3d, params.adapter_idx, params.device_type, - WINED3DFMT_UNKNOWN, flag_mapping[i].usage, flag_mapping[i].rtype, wined3d_format); + WINED3DFMT_UNKNOWN, 0, flag_mapping[i].bind_flags, flag_mapping[i].rtype, wined3d_format); if (hr == WINED3DERR_NOTAVAILABLE || hr == WINED3DOK_NOMIPGEN) continue; if (hr != WINED3D_OK) @@ -3263,13 +3429,32 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFormatSupport(ID3D11Device *i } wined3d_mutex_unlock(); + if (*format_support & (D3D11_FORMAT_SUPPORT_TEXTURE1D + | D3D11_FORMAT_SUPPORT_TEXTURE2D | D3D11_FORMAT_SUPPORT_TEXTURE3D)) + { + *format_support |= D3D11_FORMAT_SUPPORT_SHADER_LOAD; + *format_support |= D3D11_FORMAT_SUPPORT_SHADER_SAMPLE; + + if (feature_level >= D3D_FEATURE_LEVEL_10_1) + *format_support |= D3D11_FORMAT_SUPPORT_SHADER_GATHER; + + if (*format_support & D3D11_FORMAT_SUPPORT_DEPTH_STENCIL) + { + if (feature_level >= D3D_FEATURE_LEVEL_10_0) + *format_support |= D3D11_FORMAT_SUPPORT_SHADER_SAMPLE_COMPARISON; + + if (feature_level >= D3D_FEATURE_LEVEL_10_1) + *format_support |= D3D11_FORMAT_SUPPORT_SHADER_GATHER_COMPARISON; + } + } + return S_OK; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CheckMultisampleQualityLevels(ID3D11Device *iface, +static HRESULT STDMETHODCALLTYPE d3d11_device_CheckMultisampleQualityLevels(ID3D11Device2 *iface, DXGI_FORMAT format, UINT sample_count, UINT *quality_level_count) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); struct wined3d_device_creation_parameters params; struct wined3d *wined3d; HRESULT hr; @@ -3306,12 +3491,12 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CheckMultisampleQualityLevels(ID3D return hr; } -static void STDMETHODCALLTYPE d3d11_device_CheckCounterInfo(ID3D11Device *iface, D3D11_COUNTER_INFO *info) +static void STDMETHODCALLTYPE d3d11_device_CheckCounterInfo(ID3D11Device2 *iface, D3D11_COUNTER_INFO *info) { FIXME("iface %p, info %p stub!\n", iface, info); } -static HRESULT STDMETHODCALLTYPE d3d11_device_CheckCounter(ID3D11Device *iface, const D3D11_COUNTER_DESC *desc, +static HRESULT STDMETHODCALLTYPE d3d11_device_CheckCounter(ID3D11Device2 *iface, const D3D11_COUNTER_DESC *desc, D3D11_COUNTER_TYPE *type, UINT *active_counter_count, char *name, UINT *name_length, char *units, UINT *units_length, char *description, UINT *description_length) { @@ -3323,11 +3508,11 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CheckCounter(ID3D11Device *iface, return E_NOTIMPL; } -static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFeatureSupport(ID3D11Device *iface, D3D11_FEATURE feature, +static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFeatureSupport(ID3D11Device2 *iface, D3D11_FEATURE feature, void *feature_support_data, UINT feature_support_data_size) { - struct d3d_device *device = impl_from_ID3D11Device(iface); - WINED3DCAPS wined3d_caps; + struct d3d_device *device = impl_from_ID3D11Device2(iface); + struct wined3d_caps wined3d_caps; HRESULT hr; TRACE("iface %p, feature %u, feature_support_data %p, feature_support_data_size %u.\n", @@ -3337,25 +3522,104 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFeatureSupport(ID3D11Device * { case D3D11_FEATURE_THREADING: { - D3D11_FEATURE_DATA_THREADING *threading_data = feature_support_data; - if (feature_support_data_size != sizeof(*threading_data)) + D3D11_FEATURE_DATA_THREADING *threading_data = feature_support_data; + if (feature_support_data_size != sizeof(*threading_data)) + { + WARN("Invalid data size.\n"); + return E_INVALIDARG; + } + + /* We lie about the threading support to make Tomb Raider 2013 and + * Deus Ex: Human Revolution happy. */ + FIXME("Returning fake threading support data.\n"); + threading_data->DriverConcurrentCreates = TRUE; + threading_data->DriverCommandLists = TRUE; + return S_OK; + } + + case D3D11_FEATURE_DOUBLES: + { + D3D11_FEATURE_DATA_DOUBLES *doubles_data = feature_support_data; + if (feature_support_data_size != sizeof(*doubles_data)) + { + WARN("Invalid data size.\n"); + return E_INVALIDARG; + } + + wined3d_mutex_lock(); + hr = wined3d_device_get_device_caps(device->wined3d_device, &wined3d_caps); + wined3d_mutex_unlock(); + if (FAILED(hr)) + { + WARN("Failed to get device caps, hr %#x.\n", hr); + return hr; + } + + doubles_data->DoublePrecisionFloatShaderOps = wined3d_caps.shader_double_precision; + return S_OK; + } + + case D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS: + { + D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS *options = feature_support_data; + if (feature_support_data_size != sizeof(*options)) + { + WARN("Invalid data size.\n"); + return E_INVALIDARG; + } + + options->ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x = FALSE; + return S_OK; + } + + case D3D11_FEATURE_D3D11_OPTIONS: + { + D3D11_FEATURE_DATA_D3D11_OPTIONS *options = feature_support_data; + if (feature_support_data_size != sizeof(*options)) + { + WARN("Invalid data size.\n"); + return E_INVALIDARG; + } + + FIXME("Returning fake Options support data.\n"); + options->OutputMergerLogicOp = FALSE; + options->UAVOnlyRenderingForcedSampleCount = FALSE; + options->DiscardAPIsSeenByDriver = FALSE; + options->FlagsForUpdateAndCopySeenByDriver = FALSE; + options->ClearView = FALSE; + options->CopyWithOverlap = FALSE; + options->ConstantBufferPartialUpdate = FALSE; + options->ConstantBufferOffsetting = FALSE; + options->MapNoOverwriteOnDynamicConstantBuffer = FALSE; + options->MapNoOverwriteOnDynamicBufferSRV = FALSE; + options->MultisampleRTVWithForcedSampleCountOne = FALSE; + options->SAD4ShaderInstructions = FALSE; + options->ExtendedDoublesShaderInstructions = FALSE; + options->ExtendedResourceSharing = FALSE; + return S_OK; + } + + case D3D11_FEATURE_D3D11_OPTIONS1: + { + D3D11_FEATURE_DATA_D3D11_OPTIONS1 *options = feature_support_data; + if (feature_support_data_size != sizeof(*options)) { WARN("Invalid data size.\n"); return E_INVALIDARG; } - /* We lie about the threading support to make Tomb Raider 2013 and - * Deus Ex: Human Revolution happy. */ - FIXME("Returning fake threading support data.\n"); - threading_data->DriverConcurrentCreates = TRUE; - threading_data->DriverCommandLists = TRUE; + FIXME("Returning fake Options1 support data.\n"); + options->TiledResourcesTier = D3D11_TILED_RESOURCES_NOT_SUPPORTED; + options->MinMaxFiltering = FALSE; + options->ClearViewAlsoSupportsDepthOnlyFormats = FALSE; + options->MapOnDefaultBuffers = FALSE; return S_OK; } - case D3D11_FEATURE_DOUBLES: + case D3D11_FEATURE_D3D11_OPTIONS3: { - D3D11_FEATURE_DATA_DOUBLES *doubles_data = feature_support_data; - if (feature_support_data_size != sizeof(*doubles_data)) + D3D11_FEATURE_DATA_D3D11_OPTIONS3 *options = feature_support_data; + if (feature_support_data_size != sizeof(*options)) { WARN("Invalid data size.\n"); return E_INVALIDARG; @@ -3370,20 +3634,22 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFeatureSupport(ID3D11Device * return hr; } - doubles_data->DoublePrecisionFloatShaderOps = wined3d_caps.shader_double_precision; + options->VPAndRTArrayIndexFromAnyShaderFeedingRasterizer + = wined3d_caps.viewport_array_index_any_shader; return S_OK; } - case D3D11_FEATURE_D3D10_X_HARDWARE_OPTIONS: + case D3D11_FEATURE_ARCHITECTURE_INFO: { - D3D11_FEATURE_DATA_D3D10_X_HARDWARE_OPTIONS *options = feature_support_data; + D3D11_FEATURE_DATA_ARCHITECTURE_INFO *options = feature_support_data; if (feature_support_data_size != sizeof(*options)) { WARN("Invalid data size.\n"); return E_INVALIDARG; } - options->ComputeShaders_Plus_RawAndStructuredBuffers_Via_Shader_4_x = FALSE; + FIXME("Returning fake data architecture info.\n"); + options->TileBasedDeferredRenderer = FALSE; return S_OK; } @@ -3393,7 +3659,7 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_CheckFeatureSupport(ID3D11Device * } } -static HRESULT STDMETHODCALLTYPE d3d11_device_GetPrivateData(ID3D11Device *iface, REFGUID guid, +static HRESULT STDMETHODCALLTYPE d3d11_device_GetPrivateData(ID3D11Device2 *iface, REFGUID guid, UINT *data_size, void *data) { IDXGIDevice *dxgi_device; @@ -3401,7 +3667,7 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_GetPrivateData(ID3D11Device *iface TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data); - if (FAILED(hr = ID3D11Device_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device))) + if (FAILED(hr = ID3D11Device2_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device))) return hr; hr = IDXGIDevice_GetPrivateData(dxgi_device, guid, data_size, data); IDXGIDevice_Release(dxgi_device); @@ -3409,7 +3675,7 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_GetPrivateData(ID3D11Device *iface return hr; } -static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateData(ID3D11Device *iface, REFGUID guid, +static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateData(ID3D11Device2 *iface, REFGUID guid, UINT data_size, const void *data) { IDXGIDevice *dxgi_device; @@ -3417,7 +3683,7 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateData(ID3D11Device *iface TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data); - if (FAILED(hr = ID3D11Device_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device))) + if (FAILED(hr = ID3D11Device2_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device))) return hr; hr = IDXGIDevice_SetPrivateData(dxgi_device, guid, data_size, data); IDXGIDevice_Release(dxgi_device); @@ -3425,7 +3691,7 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateData(ID3D11Device *iface return hr; } -static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateDataInterface(ID3D11Device *iface, REFGUID guid, +static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateDataInterface(ID3D11Device2 *iface, REFGUID guid, const IUnknown *data) { IDXGIDevice *dxgi_device; @@ -3433,7 +3699,7 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateDataInterface(ID3D11Devi TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data); - if (FAILED(hr = ID3D11Device_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device))) + if (FAILED(hr = ID3D11Device2_QueryInterface(iface, &IID_IDXGIDevice, (void **)&dxgi_device))) return hr; hr = IDXGIDevice_SetPrivateDataInterface(dxgi_device, guid, data); IDXGIDevice_Release(dxgi_device); @@ -3441,55 +3707,152 @@ static HRESULT STDMETHODCALLTYPE d3d11_device_SetPrivateDataInterface(ID3D11Devi return hr; } -static D3D_FEATURE_LEVEL STDMETHODCALLTYPE d3d11_device_GetFeatureLevel(ID3D11Device *iface) +static D3D_FEATURE_LEVEL STDMETHODCALLTYPE d3d11_device_GetFeatureLevel(ID3D11Device2 *iface) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); TRACE("iface %p.\n", iface); return device->feature_level; } -static UINT STDMETHODCALLTYPE d3d11_device_GetCreationFlags(ID3D11Device *iface) +static UINT STDMETHODCALLTYPE d3d11_device_GetCreationFlags(ID3D11Device2 *iface) { FIXME("iface %p stub!\n", iface); return 0; } -static HRESULT STDMETHODCALLTYPE d3d11_device_GetDeviceRemovedReason(ID3D11Device *iface) +static HRESULT STDMETHODCALLTYPE d3d11_device_GetDeviceRemovedReason(ID3D11Device2 *iface) { - FIXME("iface %p stub!\n", iface); + WARN("iface %p stub!\n", iface); return S_OK; } -static void STDMETHODCALLTYPE d3d11_device_GetImmediateContext(ID3D11Device *iface, +static void STDMETHODCALLTYPE d3d11_device_GetImmediateContext(ID3D11Device2 *iface, ID3D11DeviceContext **immediate_context) { - struct d3d_device *device = impl_from_ID3D11Device(iface); + struct d3d_device *device = impl_from_ID3D11Device2(iface); TRACE("iface %p, immediate_context %p.\n", iface, immediate_context); - *immediate_context = &device->immediate_context.ID3D11DeviceContext_iface; + *immediate_context = (ID3D11DeviceContext *)&device->immediate_context.ID3D11DeviceContext1_iface; ID3D11DeviceContext_AddRef(*immediate_context); } -static HRESULT STDMETHODCALLTYPE d3d11_device_SetExceptionMode(ID3D11Device *iface, UINT flags) +static HRESULT STDMETHODCALLTYPE d3d11_device_SetExceptionMode(ID3D11Device2 *iface, UINT flags) { FIXME("iface %p, flags %#x stub!\n", iface, flags); return E_NOTIMPL; } -static UINT STDMETHODCALLTYPE d3d11_device_GetExceptionMode(ID3D11Device *iface) +static UINT STDMETHODCALLTYPE d3d11_device_GetExceptionMode(ID3D11Device2 *iface) { FIXME("iface %p stub!\n", iface); return 0; } -static const struct ID3D11DeviceVtbl d3d11_device_vtbl = +static void STDMETHODCALLTYPE d3d11_device_GetImmediateContext1(ID3D11Device2 *iface, + ID3D11DeviceContext1 **immediate_context) +{ + struct d3d_device *device = impl_from_ID3D11Device2(iface); + + TRACE("iface %p, immediate_context %p.\n", iface, immediate_context); + + *immediate_context = &device->immediate_context.ID3D11DeviceContext1_iface; + ID3D11DeviceContext1_AddRef(*immediate_context); +} + +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDeferredContext1(ID3D11Device2 *iface, UINT flags, + ID3D11DeviceContext1 **context) +{ + FIXME("iface %p, flags %#x, context %p stub!\n", iface, flags, context); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateBlendState1(ID3D11Device2 *iface, + const D3D11_BLEND_DESC1 *desc, ID3D11BlendState1 **state) +{ + FIXME("iface %p, desc %p, state %p stub!\n", iface, desc, state); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateRasterizerState1(ID3D11Device2 *iface, + const D3D11_RASTERIZER_DESC1 *desc, ID3D11RasterizerState1 **state) +{ + FIXME("iface %p, desc %p, state %p stub!\n", iface, desc, state); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDeviceContextState(ID3D11Device2 *iface, UINT flags, + const D3D_FEATURE_LEVEL *feature_levels, UINT feature_levels_count, UINT sdk_version, + REFIID emulated_interface, D3D_FEATURE_LEVEL *chosen_feature_level, ID3DDeviceContextState **state) +{ + FIXME("iface %p, flags %#x, feature_levels %p, feature_level_count %u, sdk_version %u, " + "emulated_interface %s, chosen_feature_level %p, state %p stub!\n", iface, flags, feature_levels, + feature_levels_count, sdk_version, debugstr_guid(emulated_interface), chosen_feature_level, state); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d11_device_OpenSharedResource1(ID3D11Device2 *iface, HANDLE handle, + REFIID iid, void **resource) +{ + FIXME("iface %p, handle %p, iid %s, resource %p stub!\n", iface, handle, debugstr_guid(iid), resource); + + return E_NOTIMPL; +} + +static HRESULT STDMETHODCALLTYPE d3d11_device_OpenSharedResourceByName(ID3D11Device2 *iface, const WCHAR *name, + DWORD access, REFIID iid, void **resource) +{ + FIXME("iface %p, name %s, access %#x, iid %s, resource %p stub!\n", iface, debugstr_w(name), access, + debugstr_guid(iid), resource); + + return E_NOTIMPL; +} + +static void STDMETHODCALLTYPE d3d11_device_GetImmediateContext2(ID3D11Device2 *iface, + ID3D11DeviceContext2 **context) +{ + FIXME("iface %p, context %p stub!\n", iface, context); +} + +static HRESULT STDMETHODCALLTYPE d3d11_device_CreateDeferredContext2(ID3D11Device2 *iface, + UINT flags, ID3D11DeviceContext2 **context) +{ + FIXME("iface %p, flags %#x, context %p stub!\n", iface, flags, context); + + return E_NOTIMPL; +} + +static void STDMETHODCALLTYPE d3d11_device_GetResourceTiling(ID3D11Device2 *iface, + ID3D11Resource *resource, UINT *tile_count, D3D11_PACKED_MIP_DESC *mip_desc, + D3D11_TILE_SHAPE *tile_shape, UINT *subresource_tiling_count, UINT first_subresource_tiling, + D3D11_SUBRESOURCE_TILING *subresource_tiling) +{ + FIXME("iface %p, resource %p, tile_count %p, mip_desc %p, tile_shape %p, " + "subresource_tiling_count %p, first_subresource_tiling %u, subresource_tiling %p stub!\n", + iface, resource, tile_count, mip_desc, tile_shape, + subresource_tiling_count, first_subresource_tiling, subresource_tiling); +} + +static HRESULT STDMETHODCALLTYPE d3d11_device_CheckMultisampleQualityLevels1(ID3D11Device2 *iface, + DXGI_FORMAT format, UINT sample_count, UINT flags, UINT *quality_level_count) +{ + FIXME("iface %p, format %#x, sample_count %u, flags %#x, quality_level_count %p stub!\n", + iface, format, sample_count, flags, quality_level_count); + + return E_NOTIMPL; +} + +static const struct ID3D11Device2Vtbl d3d11_device_vtbl = { /* IUnknown methods */ d3d11_device_QueryInterface, @@ -3536,6 +3899,19 @@ static const struct ID3D11DeviceVtbl d3d11_device_vtbl = d3d11_device_GetImmediateContext, d3d11_device_SetExceptionMode, d3d11_device_GetExceptionMode, + /* ID3D11Device1 methods */ + d3d11_device_GetImmediateContext1, + d3d11_device_CreateDeferredContext1, + d3d11_device_CreateBlendState1, + d3d11_device_CreateRasterizerState1, + d3d11_device_CreateDeviceContextState, + d3d11_device_OpenSharedResource1, + d3d11_device_OpenSharedResourceByName, + /* ID3D11Device2 methods */ + d3d11_device_GetImmediateContext2, + d3d11_device_CreateDeferredContext2, + d3d11_device_GetResourceTiling, + d3d11_device_CheckMultisampleQualityLevels1, }; /* Inner IUnknown methods */ @@ -3551,10 +3927,12 @@ static HRESULT STDMETHODCALLTYPE d3d_device_inner_QueryInterface(IUnknown *iface TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out); - if (IsEqualGUID(riid, &IID_ID3D11Device) + if (IsEqualGUID(riid, &IID_ID3D11Device2) + || IsEqualGUID(riid, &IID_ID3D11Device1) + || IsEqualGUID(riid, &IID_ID3D11Device) || IsEqualGUID(riid, &IID_IUnknown)) { - *out = &device->ID3D11Device_iface; + *out = &device->ID3D11Device2_iface; } else if (IsEqualGUID(riid, &IID_ID3D10Device1) || IsEqualGUID(riid, &IID_ID3D10Device)) @@ -3617,11 +3995,11 @@ static ULONG STDMETHODCALLTYPE d3d_device_inner_Release(IUnknown *iface) /* IUnknown methods */ -static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device1 *iface, REFIID riid, - void **ppv) +static HRESULT STDMETHODCALLTYPE d3d10_device_QueryInterface(ID3D10Device1 *iface, REFIID iid, + void **out) { struct d3d_device *device = impl_from_ID3D10Device(iface); - return IUnknown_QueryInterface(device->outer_unk, riid, ppv); + return IUnknown_QueryInterface(device->outer_unk, iid, out); } static ULONG STDMETHODCALLTYPE d3d10_device_AddRef(ID3D10Device1 *iface) @@ -3638,26 +4016,59 @@ static ULONG STDMETHODCALLTYPE d3d10_device_Release(ID3D10Device1 *iface) /* ID3D10Device methods */ -static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device1 *iface, - UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers) +static void d3d10_device_get_constant_buffers(ID3D10Device1 *iface, + enum wined3d_shader_type type, UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers) { struct d3d_device *device = impl_from_ID3D10Device(iface); unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", - iface, start_slot, buffer_count, buffers); + wined3d_mutex_lock(); + for (i = 0; i < buffer_count; ++i) + { + struct wined3d_buffer *wined3d_buffer; + struct d3d_buffer *buffer_impl; + + if (!(wined3d_buffer = wined3d_device_get_constant_buffer(device->wined3d_device, + type, start_slot + i))) + { + buffers[i] = NULL; + continue; + } + + buffer_impl = wined3d_buffer_get_parent(wined3d_buffer); + buffers[i] = &buffer_impl->ID3D10Buffer_iface; + ID3D10Buffer_AddRef(buffers[i]); + } + wined3d_mutex_unlock(); +} + +static void d3d10_device_set_constant_buffers(ID3D10Device1 *iface, + enum wined3d_shader_type type, UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers) +{ + struct d3d_device *device = impl_from_ID3D10Device(iface); + unsigned int i; wined3d_mutex_lock(); for (i = 0; i < buffer_count; ++i) { struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]); - wined3d_device_set_vs_cb(device->wined3d_device, start_slot + i, + wined3d_device_set_constant_buffer(device->wined3d_device, type, start_slot + i, buffer ? buffer->wined3d_buffer : NULL); } wined3d_mutex_unlock(); } +static void STDMETHODCALLTYPE d3d10_device_VSSetConstantBuffers(ID3D10Device1 *iface, + UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers) +{ + TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", + iface, start_slot, buffer_count, buffers); + + d3d10_device_set_constant_buffers(iface, WINED3D_SHADER_TYPE_VERTEX, start_slot, + buffer_count, buffers); +} + static void STDMETHODCALLTYPE d3d10_device_PSSetShaderResources(ID3D10Device1 *iface, UINT start_slot, UINT view_count, ID3D10ShaderResourceView *const *views) { @@ -3754,21 +4165,11 @@ static void STDMETHODCALLTYPE d3d10_device_Draw(ID3D10Device1 *iface, UINT verte static void STDMETHODCALLTYPE d3d10_device_PSSetConstantBuffers(ID3D10Device1 *iface, UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers) { - struct d3d_device *device = impl_from_ID3D10Device(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", iface, start_slot, buffer_count, buffers); - wined3d_mutex_lock(); - for (i = 0; i < buffer_count; ++i) - { - struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]); - - wined3d_device_set_ps_cb(device->wined3d_device, start_slot + i, - buffer ? buffer->wined3d_buffer : NULL); - } - wined3d_mutex_unlock(); + d3d10_device_set_constant_buffers(iface, WINED3D_SHADER_TYPE_PIXEL, start_slot, + buffer_count, buffers); } static void STDMETHODCALLTYPE d3d10_device_IASetInputLayout(ID3D10Device1 *iface, @@ -3858,21 +4259,11 @@ static void STDMETHODCALLTYPE d3d10_device_DrawInstanced(ID3D10Device1 *iface, static void STDMETHODCALLTYPE d3d10_device_GSSetConstantBuffers(ID3D10Device1 *iface, UINT start_slot, UINT buffer_count, ID3D10Buffer *const *buffers) { - struct d3d_device *device = impl_from_ID3D10Device(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", iface, start_slot, buffer_count, buffers); - wined3d_mutex_lock(); - for (i = 0; i < buffer_count; ++i) - { - struct d3d_buffer *buffer = unsafe_impl_from_ID3D10Buffer(buffers[i]); - - wined3d_device_set_gs_cb(device->wined3d_device, start_slot + i, - buffer ? buffer->wined3d_buffer : NULL); - } - wined3d_mutex_unlock(); + d3d10_device_set_constant_buffers(iface, WINED3D_SHADER_TYPE_GEOMETRY, start_slot, + buffer_count, buffers); } static void STDMETHODCALLTYPE d3d10_device_GSSetShader(ID3D10Device1 *iface, ID3D10GeometryShader *shader) @@ -4032,7 +4423,7 @@ static void STDMETHODCALLTYPE d3d10_device_OMSetBlendState(ID3D10Device1 *iface, iface, blend_state, debug_float4(blend_factor), sample_mask); blend_state_object = unsafe_impl_from_ID3D10BlendState(blend_state); - d3d11_immediate_context_OMSetBlendState(&device->immediate_context.ID3D11DeviceContext_iface, + d3d11_immediate_context_OMSetBlendState(&device->immediate_context.ID3D11DeviceContext1_iface, blend_state_object ? &blend_state_object->ID3D11BlendState_iface : NULL, blend_factor, sample_mask); } @@ -4046,7 +4437,7 @@ static void STDMETHODCALLTYPE d3d10_device_OMSetDepthStencilState(ID3D10Device1 iface, depth_stencil_state, stencil_ref); ds_state_object = unsafe_impl_from_ID3D10DepthStencilState(depth_stencil_state); - d3d11_immediate_context_OMSetDepthStencilState(&device->immediate_context.ID3D11DeviceContext_iface, + d3d11_immediate_context_OMSetDepthStencilState(&device->immediate_context.ID3D11DeviceContext1_iface, ds_state_object ? &ds_state_object->ID3D11DepthStencilState_iface : NULL, stencil_ref); } @@ -4088,7 +4479,7 @@ static void STDMETHODCALLTYPE d3d10_device_RSSetState(ID3D10Device1 *iface, ID3D TRACE("iface %p, rasterizer_state %p.\n", iface, rasterizer_state); rasterizer_state_object = unsafe_impl_from_ID3D10RasterizerState(rasterizer_state); - d3d11_immediate_context_RSSetState(&device->immediate_context.ID3D11DeviceContext_iface, + d3d11_immediate_context_RSSetState(&device->immediate_context.ID3D11DeviceContext1_iface, rasterizer_state_object ? &rasterizer_state_object->ID3D11RasterizerState_iface : NULL); } @@ -4096,25 +4487,26 @@ static void STDMETHODCALLTYPE d3d10_device_RSSetViewports(ID3D10Device1 *iface, UINT viewport_count, const D3D10_VIEWPORT *viewports) { struct d3d_device *device = impl_from_ID3D10Device(iface); - struct wined3d_viewport wined3d_vp; + struct wined3d_viewport wined3d_vp[WINED3D_MAX_VIEWPORTS]; + unsigned int i; TRACE("iface %p, viewport_count %u, viewports %p.\n", iface, viewport_count, viewports); - if (viewport_count > 1) - FIXME("Multiple viewports not implemented.\n"); - - if (!viewport_count) + if (viewport_count > ARRAY_SIZE(wined3d_vp)) return; - wined3d_vp.x = viewports[0].TopLeftX; - wined3d_vp.y = viewports[0].TopLeftY; - wined3d_vp.width = viewports[0].Width; - wined3d_vp.height = viewports[0].Height; - wined3d_vp.min_z = viewports[0].MinDepth; - wined3d_vp.max_z = viewports[0].MaxDepth; + for (i = 0; i < viewport_count; ++i) + { + wined3d_vp[i].x = viewports[i].TopLeftX; + wined3d_vp[i].y = viewports[i].TopLeftY; + wined3d_vp[i].width = viewports[i].Width; + wined3d_vp[i].height = viewports[i].Height; + wined3d_vp[i].min_z = viewports[i].MinDepth; + wined3d_vp[i].max_z = viewports[i].MaxDepth; + } wined3d_mutex_lock(); - wined3d_device_set_viewport(device->wined3d_device, &wined3d_vp); + wined3d_device_set_viewports(device->wined3d_device, viewport_count, wined3d_vp); wined3d_mutex_unlock(); } @@ -4125,14 +4517,11 @@ static void STDMETHODCALLTYPE d3d10_device_RSSetScissorRects(ID3D10Device1 *ifac TRACE("iface %p, rect_count %u, rects %p.\n", iface, rect_count, rects); - if (rect_count > 1) - FIXME("Multiple scissor rects not implemented.\n"); - - if (!rect_count) + if (rect_count > WINED3D_MAX_VIEWPORTS) return; wined3d_mutex_lock(); - wined3d_device_set_scissor_rect(device->wined3d_device, rects); + wined3d_device_set_scissor_rects(device->wined3d_device, rect_count, rects); wined3d_mutex_unlock(); } @@ -4157,7 +4546,7 @@ static void STDMETHODCALLTYPE d3d10_device_CopySubresourceRegion(ID3D10Device1 * wined3d_src_resource = wined3d_resource_from_d3d10_resource(src_resource); wined3d_mutex_lock(); wined3d_device_copy_sub_resource_region(device->wined3d_device, wined3d_dst_resource, dst_subresource_idx, - dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL); + dst_x, dst_y, dst_z, wined3d_src_resource, src_subresource_idx, src_box ? &wined3d_src_box : NULL, 0); wined3d_mutex_unlock(); } @@ -4187,7 +4576,7 @@ static void STDMETHODCALLTYPE d3d10_device_UpdateSubresource(ID3D10Device1 *ifac iface, resource, subresource_idx, box, data, row_pitch, depth_pitch); ID3D10Resource_QueryInterface(resource, &IID_ID3D11Resource, (void **)&d3d11_resource); - d3d11_immediate_context_UpdateSubresource(&device->immediate_context.ID3D11DeviceContext_iface, + d3d11_immediate_context_UpdateSubresource(&device->immediate_context.ID3D11DeviceContext1_iface, d3d11_resource, subresource_idx, (const D3D11_BOX *)box, data, row_pitch, depth_pitch); ID3D11Resource_Release(d3d11_resource); } @@ -4274,29 +4663,11 @@ static void STDMETHODCALLTYPE d3d10_device_ResolveSubresource(ID3D10Device1 *ifa static void STDMETHODCALLTYPE d3d10_device_VSGetConstantBuffers(ID3D10Device1 *iface, UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers) { - struct d3d_device *device = impl_from_ID3D10Device(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", iface, start_slot, buffer_count, buffers); - wined3d_mutex_lock(); - for (i = 0; i < buffer_count; ++i) - { - struct wined3d_buffer *wined3d_buffer; - struct d3d_buffer *buffer_impl; - - if (!(wined3d_buffer = wined3d_device_get_vs_cb(device->wined3d_device, start_slot + i))) - { - buffers[i] = NULL; - continue; - } - - buffer_impl = wined3d_buffer_get_parent(wined3d_buffer); - buffers[i] = &buffer_impl->ID3D10Buffer_iface; - ID3D10Buffer_AddRef(buffers[i]); - } - wined3d_mutex_unlock(); + d3d10_device_get_constant_buffers(iface, WINED3D_SHADER_TYPE_VERTEX, start_slot, buffer_count, + buffers); } static void STDMETHODCALLTYPE d3d10_device_PSGetShaderResources(ID3D10Device1 *iface, @@ -4402,29 +4773,11 @@ static void STDMETHODCALLTYPE d3d10_device_VSGetShader(ID3D10Device1 *iface, ID3 static void STDMETHODCALLTYPE d3d10_device_PSGetConstantBuffers(ID3D10Device1 *iface, UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers) { - struct d3d_device *device = impl_from_ID3D10Device(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", iface, start_slot, buffer_count, buffers); - wined3d_mutex_lock(); - for (i = 0; i < buffer_count; ++i) - { - struct wined3d_buffer *wined3d_buffer; - struct d3d_buffer *buffer_impl; - - if (!(wined3d_buffer = wined3d_device_get_ps_cb(device->wined3d_device, start_slot + i))) - { - buffers[i] = NULL; - continue; - } - - buffer_impl = wined3d_buffer_get_parent(wined3d_buffer); - buffers[i] = &buffer_impl->ID3D10Buffer_iface; - ID3D10Buffer_AddRef(buffers[i]); - } - wined3d_mutex_unlock(); + d3d10_device_get_constant_buffers(iface, WINED3D_SHADER_TYPE_PIXEL, start_slot, buffer_count, + buffers); } static void STDMETHODCALLTYPE d3d10_device_IAGetInputLayout(ID3D10Device1 *iface, ID3D10InputLayout **input_layout) @@ -4510,29 +4863,11 @@ static void STDMETHODCALLTYPE d3d10_device_IAGetIndexBuffer(ID3D10Device1 *iface static void STDMETHODCALLTYPE d3d10_device_GSGetConstantBuffers(ID3D10Device1 *iface, UINT start_slot, UINT buffer_count, ID3D10Buffer **buffers) { - struct d3d_device *device = impl_from_ID3D10Device(iface); - unsigned int i; - TRACE("iface %p, start_slot %u, buffer_count %u, buffers %p.\n", iface, start_slot, buffer_count, buffers); - wined3d_mutex_lock(); - for (i = 0; i < buffer_count; ++i) - { - struct wined3d_buffer *wined3d_buffer; - struct d3d_buffer *buffer_impl; - - if (!(wined3d_buffer = wined3d_device_get_gs_cb(device->wined3d_device, start_slot + i))) - { - buffers[i] = NULL; - continue; - } - - buffer_impl = wined3d_buffer_get_parent(wined3d_buffer); - buffers[i] = &buffer_impl->ID3D10Buffer_iface; - ID3D10Buffer_AddRef(buffers[i]); - } - wined3d_mutex_unlock(); + d3d10_device_get_constant_buffers(iface, WINED3D_SHADER_TYPE_GEOMETRY, start_slot, buffer_count, + buffers); } static void STDMETHODCALLTYPE d3d10_device_GSGetShader(ID3D10Device1 *iface, ID3D10GeometryShader **shader) @@ -4760,7 +5095,7 @@ static void STDMETHODCALLTYPE d3d10_device_OMGetBlendState(ID3D10Device1 *iface, TRACE("iface %p, blend_state %p, blend_factor %p, sample_mask %p.\n", iface, blend_state, blend_factor, sample_mask); - d3d11_immediate_context_OMGetBlendState(&device->immediate_context.ID3D11DeviceContext_iface, + d3d11_immediate_context_OMGetBlendState(&device->immediate_context.ID3D11DeviceContext1_iface, &d3d11_blend_state, blend_factor, sample_mask); if (d3d11_blend_state) @@ -4778,7 +5113,7 @@ static void STDMETHODCALLTYPE d3d10_device_OMGetDepthStencilState(ID3D10Device1 TRACE("iface %p, depth_stencil_state %p, stencil_ref %p.\n", iface, depth_stencil_state, stencil_ref); - d3d11_immediate_context_OMGetDepthStencilState(&device->immediate_context.ID3D11DeviceContext_iface, + d3d11_immediate_context_OMGetDepthStencilState(&device->immediate_context.ID3D11DeviceContext1_iface, &d3d11_iface, stencil_ref); if (d3d11_iface) @@ -4840,54 +5175,63 @@ static void STDMETHODCALLTYPE d3d10_device_RSGetViewports(ID3D10Device1 *iface, UINT *viewport_count, D3D10_VIEWPORT *viewports) { struct d3d_device *device = impl_from_ID3D10Device(iface); - struct wined3d_viewport wined3d_vp; + struct wined3d_viewport wined3d_vp[WINED3D_MAX_VIEWPORTS]; + unsigned int actual_count = ARRAY_SIZE(wined3d_vp), i; TRACE("iface %p, viewport_count %p, viewports %p.\n", iface, viewport_count, viewports); - if (!viewports) - { - *viewport_count = 1; - return; - } - - if (!*viewport_count) + if (!viewport_count) return; wined3d_mutex_lock(); - wined3d_device_get_viewport(device->wined3d_device, &wined3d_vp); + wined3d_device_get_viewports(device->wined3d_device, &actual_count, viewports ? wined3d_vp : NULL); wined3d_mutex_unlock(); - viewports[0].TopLeftX = wined3d_vp.x; - viewports[0].TopLeftY = wined3d_vp.y; - viewports[0].Width = wined3d_vp.width; - viewports[0].Height = wined3d_vp.height; - viewports[0].MinDepth = wined3d_vp.min_z; - viewports[0].MaxDepth = wined3d_vp.max_z; + if (!viewports) + { + *viewport_count = actual_count; + return; + } - if (*viewport_count > 1) - memset(&viewports[1], 0, (*viewport_count - 1) * sizeof(*viewports)); + if (*viewport_count > actual_count) + memset(&viewports[actual_count], 0, (*viewport_count - actual_count) * sizeof(*viewports)); + + *viewport_count = min(actual_count, *viewport_count); + for (i = 0; i < *viewport_count; ++i) + { + viewports[i].TopLeftX = wined3d_vp[i].x; + viewports[i].TopLeftY = wined3d_vp[i].y; + viewports[i].Width = wined3d_vp[i].width; + viewports[i].Height = wined3d_vp[i].height; + viewports[i].MinDepth = wined3d_vp[i].min_z; + viewports[i].MaxDepth = wined3d_vp[i].max_z; + } } static void STDMETHODCALLTYPE d3d10_device_RSGetScissorRects(ID3D10Device1 *iface, UINT *rect_count, D3D10_RECT *rects) { struct d3d_device *device = impl_from_ID3D10Device(iface); + unsigned int actual_count; TRACE("iface %p, rect_count %p, rects %p.\n", iface, rect_count, rects); - if (!rects) - { - *rect_count = 1; + if (!rect_count) return; - } - if (!*rect_count) - return; + actual_count = *rect_count; wined3d_mutex_lock(); - wined3d_device_get_scissor_rect(device->wined3d_device, rects); + wined3d_device_get_scissor_rects(device->wined3d_device, &actual_count, rects); wined3d_mutex_unlock(); - if (*rect_count > 1) - memset(&rects[1], 0, (*rect_count - 1) * sizeof(*rects)); + + if (!rects) + { + *rect_count = actual_count; + return; + } + + if (*rect_count > actual_count) + memset(&rects[actual_count], 0, (*rect_count - actual_count) * sizeof(*rects)); } static HRESULT STDMETHODCALLTYPE d3d10_device_GetDeviceRemovedReason(ID3D10Device1 *iface) @@ -4921,7 +5265,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_GetPrivateData(ID3D10Device1 *ifac TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data); - return d3d11_device_GetPrivateData(&device->ID3D11Device_iface, guid, data_size, data); + return d3d11_device_GetPrivateData(&device->ID3D11Device2_iface, guid, data_size, data); } static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device1 *iface, @@ -4931,7 +5275,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateData(ID3D10Device1 *ifac TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data); - return d3d11_device_SetPrivateData(&device->ID3D11Device_iface, guid, data_size, data); + return d3d11_device_SetPrivateData(&device->ID3D11Device2_iface, guid, data_size, data); } static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Device1 *iface, @@ -4941,7 +5285,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_SetPrivateDataInterface(ID3D10Devi TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data); - return d3d11_device_SetPrivateDataInterface(&device->ID3D11Device_iface, guid, data); + return d3d11_device_SetPrivateDataInterface(&device->ID3D11Device2_iface, guid, data); } static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device1 *iface) @@ -4950,7 +5294,7 @@ static void STDMETHODCALLTYPE d3d10_device_ClearState(ID3D10Device1 *iface) TRACE("iface %p.\n", iface); - d3d11_immediate_context_ClearState(&device->immediate_context.ID3D11DeviceContext_iface); + d3d11_immediate_context_ClearState(&device->immediate_context.ID3D11DeviceContext1_iface); } static void STDMETHODCALLTYPE d3d10_device_Flush(ID3D10Device1 *iface) @@ -4986,9 +5330,28 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CreateBuffer(ID3D10Device1 *iface, static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture1D(ID3D10Device1 *iface, const D3D10_TEXTURE1D_DESC *desc, const D3D10_SUBRESOURCE_DATA *data, ID3D10Texture1D **texture) { - FIXME("iface %p, desc %p, data %p, texture %p stub!\n", iface, desc, data, texture); + struct d3d_device *device = impl_from_ID3D10Device(iface); + D3D11_TEXTURE1D_DESC d3d11_desc; + struct d3d_texture1d *object; + HRESULT hr; - return E_NOTIMPL; + TRACE("iface %p, desc %p, data %p, texture %p.\n", iface, desc, data, texture); + + d3d11_desc.Width = desc->Width; + d3d11_desc.MipLevels = desc->MipLevels; + d3d11_desc.ArraySize = desc->ArraySize; + d3d11_desc.Format = desc->Format; + d3d11_desc.Usage = d3d11_usage_from_d3d10_usage(desc->Usage); + d3d11_desc.BindFlags = d3d11_bind_flags_from_d3d10_bind_flags(desc->BindFlags); + d3d11_desc.CPUAccessFlags = d3d11_cpu_access_flags_from_d3d10_cpu_access_flags(desc->CPUAccessFlags); + d3d11_desc.MiscFlags = d3d11_resource_misc_flags_from_d3d10_resource_misc_flags(desc->MiscFlags); + + if (FAILED(hr = d3d_texture1d_create(device, &d3d11_desc, (const D3D11_SUBRESOURCE_DATA *)data, &object))) + return hr; + + *texture = &object->ID3D10Texture1D_iface; + + return S_OK; } static HRESULT STDMETHODCALLTYPE d3d10_device_CreateTexture2D(ID3D10Device1 *iface, @@ -5460,7 +5823,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CheckFormatSupport(ID3D10Device1 * TRACE("iface %p, format %s, format_support %p.\n", iface, debug_dxgi_format(format), format_support); - return d3d11_device_CheckFormatSupport(&device->ID3D11Device_iface, format, format_support); + return d3d11_device_CheckFormatSupport(&device->ID3D11Device2_iface, format, format_support); } static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D10Device1 *iface, @@ -5471,7 +5834,7 @@ static HRESULT STDMETHODCALLTYPE d3d10_device_CheckMultisampleQualityLevels(ID3D TRACE("iface %p, format %s, sample_count %u, quality_level_count %p.\n", iface, debug_dxgi_format(format), sample_count, quality_level_count); - return d3d11_device_CheckMultisampleQualityLevels(&device->ID3D11Device_iface, format, + return d3d11_device_CheckMultisampleQualityLevels(&device->ID3D11Device2_iface, format, sample_count, quality_level_count); } @@ -5690,9 +6053,9 @@ static void STDMETHODCALLTYPE d3d10_multithread_Leave(ID3D10Multithread *iface) wined3d_mutex_unlock(); } -static BOOL STDMETHODCALLTYPE d3d10_multithread_SetMultithreadProtected(ID3D10Multithread *iface, BOOL protect) +static BOOL STDMETHODCALLTYPE d3d10_multithread_SetMultithreadProtected(ID3D10Multithread *iface, BOOL enable) { - FIXME("iface %p, protect %#x stub!\n", iface, protect); + FIXME("iface %p, enable %#x stub!\n", iface, enable); return TRUE; } @@ -5723,10 +6086,10 @@ static inline struct d3d_device *device_from_dxgi_device_parent(IWineDXGIDeviceP } static HRESULT STDMETHODCALLTYPE dxgi_device_parent_QueryInterface(IWineDXGIDeviceParent *iface, - REFIID riid, void **ppv) + REFIID iid, void **out) { struct d3d_device *device = device_from_dxgi_device_parent(iface); - return IUnknown_QueryInterface(device->outer_unk, riid, ppv); + return IUnknown_QueryInterface(device->outer_unk, iid, out); } static ULONG STDMETHODCALLTYPE dxgi_device_parent_AddRef(IWineDXGIDeviceParent *iface) @@ -5773,6 +6136,8 @@ static void CDECL device_parent_wined3d_device_created(struct wined3d_device_par wined3d_device_incref(wined3d_device); device->wined3d_device = wined3d_device; + device->feature_level = wined3d_device_get_feature_level(wined3d_device); + set_default_depth_stencil_state(wined3d_device); } @@ -5786,12 +6151,12 @@ static void CDECL device_parent_activate(struct wined3d_device_parent *device_pa TRACE("device_parent %p, activate %#x.\n", device_parent, activate); } -static HRESULT CDECL device_parent_sub_resource_created(struct wined3d_device_parent *device_parent, - struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, void **parent, - const struct wined3d_parent_ops **parent_ops) +static HRESULT CDECL device_parent_texture_sub_resource_created(struct wined3d_device_parent *device_parent, + enum wined3d_resource_type type, struct wined3d_texture *wined3d_texture, unsigned int sub_resource_idx, + void **parent, const struct wined3d_parent_ops **parent_ops) { - TRACE("device_parent %p, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n", - device_parent, wined3d_texture, sub_resource_idx, parent, parent_ops); + TRACE("device_parent %p, type %#x, wined3d_texture %p, sub_resource_idx %u, parent %p, parent_ops %p.\n", + device_parent, type, wined3d_texture, sub_resource_idx, parent, parent_ops); *parent = NULL; *parent_ops = &d3d_null_wined3d_parent_ops; @@ -5820,7 +6185,7 @@ static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_devic desc.SampleDesc.Count = wined3d_desc->multisample_type ? wined3d_desc->multisample_type : 1; desc.SampleDesc.Quality = wined3d_desc->multisample_quality; desc.Usage = D3D11_USAGE_DEFAULT; - desc.BindFlags = d3d11_bind_flags_from_wined3d_usage(wined3d_desc->usage); + desc.BindFlags = d3d11_bind_flags_from_wined3d(wined3d_desc->bind_flags); desc.CPUAccessFlags = 0; desc.MiscFlags = 0; @@ -5833,7 +6198,7 @@ static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_devic if (texture_flags) FIXME("Unhandled flags %#x.\n", texture_flags); - if (FAILED(hr = d3d11_device_CreateTexture2D(&device->ID3D11Device_iface, + if (FAILED(hr = d3d11_device_CreateTexture2D(&device->ID3D11Device2_iface, &desc, NULL, &texture_iface))) { WARN("Failed to create 2D texture, hr %#x.\n", hr); @@ -5849,42 +6214,13 @@ static HRESULT CDECL device_parent_create_swapchain_texture(struct wined3d_devic return S_OK; } -static HRESULT CDECL device_parent_create_swapchain(struct wined3d_device_parent *device_parent, - struct wined3d_swapchain_desc *desc, struct wined3d_swapchain **swapchain) -{ - struct d3d_device *device = device_from_wined3d_device_parent(device_parent); - IWineDXGIDevice *wine_device; - HRESULT hr; - - TRACE("device_parent %p, desc %p, swapchain %p.\n", device_parent, desc, swapchain); - - if (FAILED(hr = d3d11_device_QueryInterface(&device->ID3D11Device_iface, - &IID_IWineDXGIDevice, (void **)&wine_device))) - { - ERR("Device should implement IWineDXGIDevice.\n"); - return E_FAIL; - } - - hr = IWineDXGIDevice_create_swapchain(wine_device, desc, TRUE, swapchain); - IWineDXGIDevice_Release(wine_device); - if (FAILED(hr)) - { - ERR("Failed to create DXGI swapchain, returning %#x\n", hr); - return hr; - } - - return S_OK; -} - static const struct wined3d_device_parent_ops d3d_wined3d_device_parent_ops = { device_parent_wined3d_device_created, device_parent_mode_changed, device_parent_activate, - device_parent_sub_resource_created, - device_parent_sub_resource_created, + device_parent_texture_sub_resource_created, device_parent_create_swapchain_texture, - device_parent_create_swapchain, }; static int d3d_sampler_state_compare(const void *key, const struct wine_rb_entry *entry) @@ -5923,7 +6259,7 @@ static int d3d_rasterizer_state_compare(const void *key, const struct wine_rb_en void d3d_device_init(struct d3d_device *device, void *outer_unknown) { device->IUnknown_inner.lpVtbl = &d3d_device_inner_unknown_vtbl; - device->ID3D11Device_iface.lpVtbl = &d3d11_device_vtbl; + device->ID3D11Device2_iface.lpVtbl = &d3d11_device_vtbl; device->ID3D10Device1_iface.lpVtbl = &d3d10_device1_vtbl; device->ID3D10Multithread_iface.lpVtbl = &d3d10_multithread_vtbl; device->IWineDXGIDeviceParent_iface.lpVtbl = &d3d_dxgi_device_parent_vtbl; @@ -5933,12 +6269,7 @@ void d3d_device_init(struct d3d_device *device, void *outer_unknown) device->outer_unk = outer_unknown; d3d11_immediate_context_init(&device->immediate_context, device); - ID3D11DeviceContext_Release(&device->immediate_context.ID3D11DeviceContext_iface); - - device->blend_factor[0] = 1.0f; - device->blend_factor[1] = 1.0f; - device->blend_factor[2] = 1.0f; - device->blend_factor[3] = 1.0f; + ID3D11DeviceContext1_Release(&device->immediate_context.ID3D11DeviceContext1_iface); wine_rb_init(&device->blend_states, d3d_blend_state_compare); wine_rb_init(&device->depthstencil_states, d3d_depthstencil_state_compare); diff --git a/dll/directx/wine/d3d11/inputlayout.c b/dll/directx/wine/d3d11/inputlayout.c index ef1d2e687d5e2..293407358400a 100644 --- a/dll/directx/wine/d3d11/inputlayout.c +++ b/dll/directx/wine/d3d11/inputlayout.c @@ -24,19 +24,20 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d11); -static HRESULT isgn_handler(const char *data, DWORD data_size, DWORD tag, void *ctx) +static struct wined3d_shader_signature_element *shader_find_signature_element(const struct wined3d_shader_signature *s, + const char *semantic_name, unsigned int semantic_idx, unsigned int stream_idx) { - struct wined3d_shader_signature *is = ctx; - - if (tag != TAG_ISGN) - return S_OK; + struct wined3d_shader_signature_element *e = s->elements; + unsigned int i; - if (is->elements) + for (i = 0; i < s->element_count; ++i) { - FIXME("Multiple input signatures.\n"); - shader_free_signature(is); + if (!_strnicmp(e[i].semantic_name, semantic_name, -1) && e[i].semantic_idx == semantic_idx + && e[i].stream_idx == stream_idx) + return &e[i]; } - return shader_parse_signature(tag, data, data_size, is); + + return NULL; } static HRESULT d3d11_input_layout_to_wined3d_declaration(const D3D11_INPUT_ELEMENT_DESC *element_descs, @@ -47,17 +48,16 @@ static HRESULT d3d11_input_layout_to_wined3d_declaration(const D3D11_INPUT_ELEME unsigned int i; HRESULT hr; - memset(&is, 0, sizeof(is)); - if (FAILED(hr = parse_dxbc(shader_byte_code, shader_byte_code_length, isgn_handler, &is))) + if (FAILED(hr = wined3d_extract_shader_input_signature_from_dxbc(&is, shader_byte_code, shader_byte_code_length))) { - ERR("Failed to parse input signature.\n"); + ERR("Failed to extract input signature.\n"); return E_FAIL; } if (!(*wined3d_elements = heap_calloc(element_count, sizeof(**wined3d_elements)))) { ERR("Failed to allocate wined3d vertex element array memory.\n"); - shader_free_signature(&is); + heap_free(is.elements); return E_OUTOFMEMORY; } @@ -83,7 +83,7 @@ static HRESULT d3d11_input_layout_to_wined3d_declaration(const D3D11_INPUT_ELEME WARN("Unused input element %u.\n", i); } - shader_free_signature(&is); + heap_free(is.elements); return S_OK; } @@ -134,7 +134,7 @@ static ULONG STDMETHODCALLTYPE d3d11_input_layout_AddRef(ID3D11InputLayout *ifac if (refcount == 1) { - ID3D11Device_AddRef(layout->device); + ID3D11Device2_AddRef(layout->device); wined3d_mutex_lock(); wined3d_vertex_declaration_incref(layout->wined3d_decl); wined3d_mutex_unlock(); @@ -152,13 +152,13 @@ static ULONG STDMETHODCALLTYPE d3d11_input_layout_Release(ID3D11InputLayout *ifa if (!refcount) { - ID3D11Device *device = layout->device; + ID3D11Device2 *device = layout->device; wined3d_mutex_lock(); wined3d_vertex_declaration_decref(layout->wined3d_decl); wined3d_mutex_unlock(); - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -171,7 +171,7 @@ static void STDMETHODCALLTYPE d3d11_input_layout_GetDevice(ID3D11InputLayout *if TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_AddRef(*device = layout->device); + ID3D11Device_AddRef(*device = (ID3D11Device *)layout->device); } static HRESULT STDMETHODCALLTYPE d3d11_input_layout_GetPrivateData(ID3D11InputLayout *iface, @@ -262,7 +262,7 @@ static void STDMETHODCALLTYPE d3d10_input_layout_GetDevice(ID3D10InputLayout *if TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_QueryInterface(layout->device, &IID_ID3D10Device, (void **)device); + ID3D11Device2_QueryInterface(layout->device, &IID_ID3D10Device, (void **)device); } static HRESULT STDMETHODCALLTYPE d3d10_input_layout_GetPrivateData(ID3D10InputLayout *iface, @@ -357,7 +357,7 @@ static HRESULT d3d_input_layout_init(struct d3d_input_layout *layout, struct d3d } wined3d_mutex_unlock(); - ID3D11Device_AddRef(layout->device = &device->ID3D11Device_iface); + ID3D11Device2_AddRef(layout->device = &device->ID3D11Device2_iface); return S_OK; } diff --git a/dll/directx/wine/d3d11/shader.c b/dll/directx/wine/d3d11/shader.c index d7b71b0624dce..2667e9a883f81 100644 --- a/dll/directx/wine/d3d11/shader.c +++ b/dll/directx/wine/d3d11/shader.c @@ -24,262 +24,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d11); -struct aon9_header -{ - DWORD chunk_size; - DWORD shader_version; - DWORD unknown; - DWORD byte_code_offset; -}; - -struct shader_handler_context -{ - D3D_FEATURE_LEVEL feature_level; - struct wined3d_shader_desc *desc; -}; - -static HRESULT shdr_handler(const char *data, DWORD data_size, DWORD tag, void *context) -{ - const struct shader_handler_context *ctx = context; - struct wined3d_shader_desc *desc = ctx->desc; - HRESULT hr; - - switch (tag) - { - case TAG_ISGN: - if (ctx->feature_level <= D3D_FEATURE_LEVEL_9_3) - { - TRACE("Skipping shader input signature on feature level %#x.\n", ctx->feature_level); - break; - } - if (desc->input_signature.elements) - { - FIXME("Multiple input signatures.\n"); - break; - } - if (FAILED(hr = shader_parse_signature(tag, data, data_size, &desc->input_signature))) - return hr; - break; - - case TAG_OSGN: - case TAG_OSG5: - if (ctx->feature_level <= D3D_FEATURE_LEVEL_9_3) - { - TRACE("Skipping shader output signature on feature level %#x.\n", ctx->feature_level); - break; - } - if (desc->output_signature.elements) - { - FIXME("Multiple output signatures.\n"); - break; - } - if (FAILED(hr = shader_parse_signature(tag, data, data_size, &desc->output_signature))) - return hr; - break; - - case TAG_PCSG: - if (desc->patch_constant_signature.elements) - { - FIXME("Multiple patch constant signatures.\n"); - break; - } - if (FAILED(hr = shader_parse_signature(tag, data, data_size, &desc->patch_constant_signature))) - return hr; - break; - - case TAG_SHDR: - case TAG_SHEX: - if (ctx->feature_level <= D3D_FEATURE_LEVEL_9_3) - { - TRACE("Skipping SM4+ shader code on feature level %#x.\n", ctx->feature_level); - break; - } - if (desc->byte_code) - FIXME("Multiple shader code chunks.\n"); - desc->byte_code = (const DWORD *)data; - desc->byte_code_size = data_size; - desc->format = WINED3D_SHADER_BYTE_CODE_FORMAT_SM4; - break; - - case TAG_AON9: - if (ctx->feature_level <= D3D_FEATURE_LEVEL_9_3) - { - const struct aon9_header *header = (const struct aon9_header *)data; - unsigned int unknown_dword_count; - const char *byte_code; - - if (data_size < sizeof(*header)) - { - WARN("Invalid Aon9 data size %#x.\n", data_size); - return E_FAIL; - } - byte_code = data + header->byte_code_offset; - unknown_dword_count = (header->byte_code_offset - sizeof(*header)) / sizeof(DWORD); - - if (data_size - 2 * sizeof(DWORD) < header->byte_code_offset) - { - WARN("Invalid byte code offset %#x (size %#x).\n", header->byte_code_offset, data_size); - return E_FAIL; - } - FIXME("Skipping %u unknown DWORDs.\n", unknown_dword_count); - - if (desc->byte_code) - FIXME("Multiple shader code chunks.\n"); - desc->byte_code = (const DWORD *)byte_code; - desc->byte_code_size = data_size - header->byte_code_offset; - desc->format = WINED3D_SHADER_BYTE_CODE_FORMAT_SM1; - TRACE("Feature level 9 shader version 0%08x, 0%08x.\n", header->shader_version, *desc->byte_code); - } - else - { - TRACE("Skipping feature level 9 shader code on feature level %#x.\n", ctx->feature_level); - } - break; - - default: - FIXME("Unhandled chunk %s.\n", debugstr_an((const char *)&tag, 4)); - break; - } - - return S_OK; -} - -static void free_shader_desc(struct wined3d_shader_desc *desc) -{ - shader_free_signature(&desc->input_signature); - shader_free_signature(&desc->output_signature); - shader_free_signature(&desc->patch_constant_signature); -} - -static HRESULT shader_extract_from_dxbc(const void *dxbc, SIZE_T dxbc_length, - struct wined3d_shader_desc *desc, D3D_FEATURE_LEVEL feature_level) -{ - struct shader_handler_context ctx = {feature_level, desc}; - HRESULT hr; - - desc->byte_code = NULL; - desc->byte_code_size = 0; - memset(&desc->input_signature, 0, sizeof(desc->input_signature)); - memset(&desc->output_signature, 0, sizeof(desc->output_signature)); - memset(&desc->patch_constant_signature, 0, sizeof(desc->patch_constant_signature)); - - hr = parse_dxbc(dxbc, dxbc_length, shdr_handler, &ctx); - if (!desc->byte_code) - hr = E_INVALIDARG; - - if (FAILED(hr)) - { - FIXME("Failed to parse shader, hr %#x.\n", hr); - free_shader_desc(desc); - } - - return hr; -} - -static const char *shader_get_string(const char *data, size_t data_size, DWORD offset) -{ - size_t len, max_len; - - if (offset >= data_size) - { - WARN("Invalid offset %#x (data size %#lx).\n", offset, (long)data_size); - return NULL; - } - - max_len = data_size - offset; - len = strnlen(data + offset, max_len); - - if (len == max_len) - return NULL; - - return data + offset; -} - -HRESULT shader_parse_signature(DWORD tag, const char *data, DWORD data_size, - struct wined3d_shader_signature *s) -{ - struct wined3d_shader_signature_element *e; - const char *ptr = data; - unsigned int i; - DWORD count; - - if (!require_space(0, 2, sizeof(DWORD), data_size)) - { - WARN("Invalid data size %#x.\n", data_size); - return E_INVALIDARG; - } - - read_dword(&ptr, &count); - TRACE("%u elements.\n", count); - - skip_dword_unknown(&ptr, 1); /* It seems to always be 0x00000008. */ - - if (!require_space(ptr - data, count, 6 * sizeof(DWORD), data_size)) - { - WARN("Invalid count %#x (data size %#x).\n", count, data_size); - return E_INVALIDARG; - } - - if (!(e = heap_calloc(count, sizeof(*e)))) - { - ERR("Failed to allocate input signature memory.\n"); - return E_OUTOFMEMORY; - } - - for (i = 0; i < count; ++i) - { - DWORD name_offset; - - if (tag == TAG_OSG5) - read_dword(&ptr, &e[i].stream_idx); - else - e[i].stream_idx = 0; - read_dword(&ptr, &name_offset); - if (!(e[i].semantic_name = shader_get_string(data, data_size, name_offset))) - { - WARN("Invalid name offset %#x (data size %#x).\n", name_offset, data_size); - heap_free(e); - return E_INVALIDARG; - } - read_dword(&ptr, &e[i].semantic_idx); - read_dword(&ptr, (DWORD *)&e[i].sysval_semantic); - read_dword(&ptr, (DWORD *)&e[i].component_type); - read_dword(&ptr, &e[i].register_idx); - read_dword(&ptr, &e[i].mask); - - TRACE("Stream: %u, semantic: %s, semantic idx: %u, sysval_semantic %#x, " - "type %u, register idx: %u, use_mask %#x, input_mask %#x.\n", - e[i].stream_idx, debugstr_a(e[i].semantic_name), e[i].semantic_idx, e[i].sysval_semantic, - e[i].component_type, e[i].register_idx, (e[i].mask >> 8) & 0xff, e[i].mask & 0xff); - } - - s->elements = e; - s->element_count = count; - - return S_OK; -} - -struct wined3d_shader_signature_element *shader_find_signature_element(const struct wined3d_shader_signature *s, - const char *semantic_name, unsigned int semantic_idx, unsigned int stream_idx) -{ - struct wined3d_shader_signature_element *e = s->elements; - unsigned int i; - - for (i = 0; i < s->element_count; ++i) - { - if (!strcasecmp(e[i].semantic_name, semantic_name) && e[i].semantic_idx == semantic_idx - && e[i].stream_idx == stream_idx) - return &e[i]; - } - - return NULL; -} - -void shader_free_signature(struct wined3d_shader_signature *s) -{ - heap_free(s->elements); -} - /* ID3D11VertexShader methods */ static inline struct d3d_vertex_shader *impl_from_ID3D11VertexShader(ID3D11VertexShader *iface) @@ -326,7 +70,7 @@ static ULONG STDMETHODCALLTYPE d3d11_vertex_shader_AddRef(ID3D11VertexShader *if if (refcount == 1) { - ID3D11Device_AddRef(shader->device); + ID3D11Device2_AddRef(shader->device); wined3d_mutex_lock(); wined3d_shader_incref(shader->wined3d_shader); wined3d_mutex_unlock(); @@ -344,14 +88,14 @@ static ULONG STDMETHODCALLTYPE d3d11_vertex_shader_Release(ID3D11VertexShader *i if (!refcount) { - ID3D11Device *device = shader->device; + ID3D11Device2 *device = shader->device; wined3d_mutex_lock(); wined3d_shader_decref(shader->wined3d_shader); wined3d_mutex_unlock(); /* Release the device last, it may cause the wined3d device to be * destroyed. */ - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -364,7 +108,7 @@ static void STDMETHODCALLTYPE d3d11_vertex_shader_GetDevice(ID3D11VertexShader * TRACE("iface %p, device %p.\n", iface, device); - *device = shader->device; + *device = (ID3D11Device *)shader->device; ID3D11Device_AddRef(*device); } @@ -456,7 +200,7 @@ static void STDMETHODCALLTYPE d3d10_vertex_shader_GetDevice(ID3D10VertexShader * TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_QueryInterface(shader->device, &IID_ID3D10Device, (void **)device); + ID3D11Device2_QueryInterface(shader->device, &IID_ID3D10Device, (void **)device); } static HRESULT STDMETHODCALLTYPE d3d10_vertex_shader_GetPrivateData(ID3D10VertexShader *iface, @@ -517,27 +261,6 @@ static const struct wined3d_parent_ops d3d_vertex_shader_wined3d_parent_ops = d3d_vertex_shader_wined3d_object_destroyed, }; -static unsigned int d3d_sm_from_feature_level(D3D_FEATURE_LEVEL feature_level) -{ - switch (feature_level) - { - case D3D_FEATURE_LEVEL_11_1: - case D3D_FEATURE_LEVEL_11_0: - return 5; - case D3D_FEATURE_LEVEL_10_1: - case D3D_FEATURE_LEVEL_10_0: - return 4; - case D3D_FEATURE_LEVEL_9_3: - return 3; - case D3D_FEATURE_LEVEL_9_2: - case D3D_FEATURE_LEVEL_9_1: - return 2; - default: - ERR("Unexpected feature_level %#x.\n", feature_level); - } - return 0; -} - static HRESULT d3d_vertex_shader_init(struct d3d_vertex_shader *shader, struct d3d_device *device, const void *byte_code, SIZE_T byte_code_length) { @@ -550,19 +273,10 @@ static HRESULT d3d_vertex_shader_init(struct d3d_vertex_shader *shader, struct d wined3d_mutex_lock(); wined3d_private_store_init(&shader->private_store); - if (FAILED(hr = shader_extract_from_dxbc(byte_code, byte_code_length, &desc, device->feature_level))) - { - WARN("Failed to extract shader, hr %#x.\n", hr); - wined3d_private_store_cleanup(&shader->private_store); - wined3d_mutex_unlock(); - return hr; - } - desc.max_version = d3d_sm_from_feature_level(device->feature_level); - - hr = wined3d_shader_create_vs(device->wined3d_device, &desc, shader, - &d3d_vertex_shader_wined3d_parent_ops, &shader->wined3d_shader); - free_shader_desc(&desc); - if (FAILED(hr)) + desc.byte_code = byte_code; + desc.byte_code_size = byte_code_length; + if (FAILED(hr = wined3d_shader_create_vs(device->wined3d_device, &desc, shader, + &d3d_vertex_shader_wined3d_parent_ops, &shader->wined3d_shader))) { WARN("Failed to create wined3d vertex shader, hr %#x.\n", hr); wined3d_private_store_cleanup(&shader->private_store); @@ -571,8 +285,7 @@ static HRESULT d3d_vertex_shader_init(struct d3d_vertex_shader *shader, struct d } wined3d_mutex_unlock(); - shader->device = &device->ID3D11Device_iface; - ID3D11Device_AddRef(shader->device); + ID3D11Device2_AddRef(shader->device = &device->ID3D11Device2_iface); return S_OK; } @@ -653,7 +366,7 @@ static ULONG STDMETHODCALLTYPE d3d11_hull_shader_AddRef(ID3D11HullShader *iface) if (refcount == 1) { - ID3D11Device_AddRef(shader->device); + ID3D11Device2_AddRef(shader->device); wined3d_mutex_lock(); wined3d_shader_incref(shader->wined3d_shader); wined3d_mutex_unlock(); @@ -671,7 +384,7 @@ static ULONG STDMETHODCALLTYPE d3d11_hull_shader_Release(ID3D11HullShader *iface if (!refcount) { - ID3D11Device *device = shader->device; + ID3D11Device2 *device = shader->device; wined3d_mutex_lock(); wined3d_shader_decref(shader->wined3d_shader); @@ -679,7 +392,7 @@ static ULONG STDMETHODCALLTYPE d3d11_hull_shader_Release(ID3D11HullShader *iface /* Release the device last, it may cause the wined3d device to be * destroyed. */ - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -692,7 +405,7 @@ static void STDMETHODCALLTYPE d3d11_hull_shader_GetDevice(ID3D11HullShader *ifac TRACE("iface %p, device %p.\n", iface, device); - *device = shader->device; + *device = (ID3D11Device *)shader->device; ID3D11Device_AddRef(*device); } @@ -763,19 +476,10 @@ static HRESULT d3d11_hull_shader_init(struct d3d11_hull_shader *shader, struct d wined3d_mutex_lock(); wined3d_private_store_init(&shader->private_store); - if (FAILED(hr = shader_extract_from_dxbc(byte_code, byte_code_length, &desc, device->feature_level))) - { - WARN("Failed to extract shader, hr %#x.\n", hr); - wined3d_private_store_cleanup(&shader->private_store); - wined3d_mutex_unlock(); - return hr; - } - desc.max_version = d3d_sm_from_feature_level(device->feature_level); - - hr = wined3d_shader_create_hs(device->wined3d_device, &desc, shader, - &d3d11_hull_shader_wined3d_parent_ops, &shader->wined3d_shader); - free_shader_desc(&desc); - if (FAILED(hr)) + desc.byte_code = byte_code; + desc.byte_code_size = byte_code_length; + if (FAILED(hr = wined3d_shader_create_hs(device->wined3d_device, &desc, shader, + &d3d11_hull_shader_wined3d_parent_ops, &shader->wined3d_shader))) { WARN("Failed to create wined3d hull shader, hr %#x.\n", hr); wined3d_private_store_cleanup(&shader->private_store); @@ -784,8 +488,7 @@ static HRESULT d3d11_hull_shader_init(struct d3d11_hull_shader *shader, struct d } wined3d_mutex_unlock(); - shader->device = &device->ID3D11Device_iface; - ID3D11Device_AddRef(shader->device); + ID3D11Device2_AddRef(shader->device = &device->ID3D11Device2_iface); return S_OK; } @@ -856,7 +559,7 @@ static ULONG STDMETHODCALLTYPE d3d11_domain_shader_AddRef(ID3D11DomainShader *if if (refcount == 1) { - ID3D11Device_AddRef(shader->device); + ID3D11Device2_AddRef(shader->device); wined3d_mutex_lock(); wined3d_shader_incref(shader->wined3d_shader); wined3d_mutex_unlock(); @@ -874,7 +577,7 @@ static ULONG STDMETHODCALLTYPE d3d11_domain_shader_Release(ID3D11DomainShader *i if (!refcount) { - ID3D11Device *device = shader->device; + ID3D11Device2 *device = shader->device; wined3d_mutex_lock(); wined3d_shader_decref(shader->wined3d_shader); @@ -882,7 +585,7 @@ static ULONG STDMETHODCALLTYPE d3d11_domain_shader_Release(ID3D11DomainShader *i /* Release the device last, it may cause the wined3d device to be * destroyed. */ - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -895,7 +598,7 @@ static void STDMETHODCALLTYPE d3d11_domain_shader_GetDevice(ID3D11DomainShader * TRACE("iface %p, device %p.\n", iface, device); - *device = shader->device; + *device = (ID3D11Device *)shader->device; ID3D11Device_AddRef(*device); } @@ -966,19 +669,10 @@ static HRESULT d3d11_domain_shader_init(struct d3d11_domain_shader *shader, stru wined3d_mutex_lock(); wined3d_private_store_init(&shader->private_store); - if (FAILED(hr = shader_extract_from_dxbc(byte_code, byte_code_length, &desc, device->feature_level))) - { - WARN("Failed to extract shader, hr %#x.\n", hr); - wined3d_private_store_cleanup(&shader->private_store); - wined3d_mutex_unlock(); - return hr; - } - desc.max_version = d3d_sm_from_feature_level(device->feature_level); - - hr = wined3d_shader_create_ds(device->wined3d_device, &desc, shader, - &d3d11_domain_shader_wined3d_parent_ops, &shader->wined3d_shader); - free_shader_desc(&desc); - if (FAILED(hr)) + desc.byte_code = byte_code; + desc.byte_code_size = byte_code_length; + if (FAILED(hr = wined3d_shader_create_ds(device->wined3d_device, &desc, shader, + &d3d11_domain_shader_wined3d_parent_ops, &shader->wined3d_shader))) { WARN("Failed to create wined3d domain shader, hr %#x.\n", hr); wined3d_private_store_cleanup(&shader->private_store); @@ -987,8 +681,7 @@ static HRESULT d3d11_domain_shader_init(struct d3d11_domain_shader *shader, stru } wined3d_mutex_unlock(); - shader->device = &device->ID3D11Device_iface; - ID3D11Device_AddRef(shader->device); + ID3D11Device2_AddRef(shader->device = &device->ID3D11Device2_iface); return S_OK; } @@ -1069,7 +762,7 @@ static ULONG STDMETHODCALLTYPE d3d11_geometry_shader_AddRef(ID3D11GeometryShader if (refcount == 1) { - ID3D11Device_AddRef(shader->device); + ID3D11Device2_AddRef(shader->device); wined3d_mutex_lock(); wined3d_shader_incref(shader->wined3d_shader); wined3d_mutex_unlock(); @@ -1087,7 +780,7 @@ static ULONG STDMETHODCALLTYPE d3d11_geometry_shader_Release(ID3D11GeometryShade if (!refcount) { - ID3D11Device *device = shader->device; + ID3D11Device2 *device = shader->device; wined3d_mutex_lock(); wined3d_shader_decref(shader->wined3d_shader); @@ -1095,7 +788,7 @@ static ULONG STDMETHODCALLTYPE d3d11_geometry_shader_Release(ID3D11GeometryShade /* Release the device last, it may cause the wined3d device to be * destroyed. */ - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -1108,7 +801,7 @@ static void STDMETHODCALLTYPE d3d11_geometry_shader_GetDevice(ID3D11GeometryShad TRACE("iface %p, device %p.\n", iface, device); - *device = shader->device; + *device = (ID3D11Device *)shader->device; ID3D11Device_AddRef(*device); } @@ -1200,7 +893,7 @@ static void STDMETHODCALLTYPE d3d10_geometry_shader_GetDevice(ID3D10GeometryShad TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_QueryInterface(shader->device, &IID_ID3D10Device, (void **)device); + ID3D11Device2_QueryInterface(shader->device, &IID_ID3D10Device, (void **)device); } static HRESULT STDMETHODCALLTYPE d3d10_geometry_shader_GetPrivateData(ID3D10GeometryShader *iface, @@ -1261,112 +954,82 @@ static const struct wined3d_parent_ops d3d_geometry_shader_wined3d_parent_ops = d3d_geometry_shader_wined3d_object_destroyed, }; -static HRESULT wined3d_so_elements_from_d3d11_so_entries(struct wined3d_stream_output_element *elements, - const D3D11_SO_DECLARATION_ENTRY *entries, unsigned int entry_count, - const unsigned int *buffer_strides, unsigned int buffer_stride_count, - const struct wined3d_shader_signature *os, D3D_FEATURE_LEVEL feature_level) +static HRESULT validate_stream_output_entries(const D3D11_SO_DECLARATION_ENTRY *entries, unsigned int entry_count, + const unsigned int *buffer_strides, unsigned int buffer_stride_count, D3D_FEATURE_LEVEL feature_level) { - unsigned int i, j, mask; + unsigned int i, j; for (i = 0; i < entry_count; ++i) { - struct wined3d_stream_output_element *e = &elements[i]; - const D3D11_SO_DECLARATION_ENTRY *f = &entries[i]; - struct wined3d_shader_signature_element *output; + const D3D11_SO_DECLARATION_ENTRY *e = &entries[i]; TRACE("Stream: %u, semantic: %s, semantic idx: %u, start component: %u, " "component count %u, output slot %u.\n", - f->Stream, debugstr_a(f->SemanticName), f->SemanticIndex, - f->StartComponent, f->ComponentCount, f->OutputSlot); + e->Stream, debugstr_a(e->SemanticName), e->SemanticIndex, + e->StartComponent, e->ComponentCount, e->OutputSlot); - if (f->Stream >= D3D11_SO_STREAM_COUNT) + if (e->Stream >= D3D11_SO_STREAM_COUNT) { - WARN("Invalid stream %u.\n", f->Stream); + WARN("Invalid stream %u.\n", e->Stream); return E_INVALIDARG; } - if (f->Stream && feature_level < D3D_FEATURE_LEVEL_11_0) + if (e->Stream && feature_level < D3D_FEATURE_LEVEL_11_0) { - WARN("Invalid stream %u for feature level %#x.\n", f->Stream, feature_level); + WARN("Invalid stream %u for feature level %#x.\n", e->Stream, feature_level); return E_INVALIDARG; } - if (f->Stream) + if (e->Stream) { FIXME("Streams not implemented yet.\n"); return E_INVALIDARG; } - if (f->OutputSlot >= D3D11_SO_BUFFER_SLOT_COUNT) + if (e->OutputSlot >= D3D11_SO_BUFFER_SLOT_COUNT) { - WARN("Invalid output slot %u.\n", f->OutputSlot); + WARN("Invalid output slot %u.\n", e->OutputSlot); return E_INVALIDARG; } - e->stream_idx = f->Stream; - e->component_idx = f->StartComponent; - e->component_count = f->ComponentCount; - e->output_slot = f->OutputSlot; - - if (!f->SemanticName) + if (!e->SemanticName) { - if (f->SemanticIndex) + if (e->SemanticIndex) { - WARN("Invalid semantic idx %u for stream output gap.\n", f->SemanticIndex); + WARN("Invalid semantic idx %u for stream output gap.\n", e->SemanticIndex); return E_INVALIDARG; } - if (e->component_idx || !e->component_count) + if (e->StartComponent || !e->ComponentCount) { - WARN("Invalid stream output gap %u-%u.\n", e->component_idx, e->component_count); + WARN("Invalid stream output gap %u-%u.\n", e->StartComponent, e->ComponentCount); return E_INVALIDARG; } - - e->register_idx = WINED3D_STREAM_OUTPUT_GAP; } - else if ((output = shader_find_signature_element(os, f->SemanticName, f->SemanticIndex, f->Stream))) + else { - if (e->component_idx > 3 || e->component_count > 4 || !e->component_count - || e->component_idx + e->component_count > 4) + if (e->StartComponent > 3 || e->ComponentCount > 4 || !e->ComponentCount + || e->StartComponent + e->ComponentCount > 4) { - WARN("Invalid component range %u-%u.\n", e->component_idx, e->component_count); + WARN("Invalid component range %u-%u.\n", e->StartComponent, e->ComponentCount); return E_INVALIDARG; } - - for (j = 0; j < 4; ++j) - { - if ((1u << j) & output->mask) - break; - } - e->component_idx += j; - mask = ((1u << e->component_count) - 1) << e->component_idx; - if ((output->mask & 0xff & mask) != mask) - { - WARN("Invalid component range %u-%u (mask %#x), output mask %#x.\n", - e->component_idx, e->component_count, mask, output->mask & 0xff); - return E_INVALIDARG; - } - - e->register_idx = output->register_idx; - TRACE("Register idx: %u, register component idx %u, register mask %#x.\n", - e->register_idx, e->component_idx, mask); - } - else - { - WARN("Failed to find output signature element for stream output entry.\n"); - return E_INVALIDARG; } } for (i = 0; i < entry_count; ++i) { - const struct wined3d_stream_output_element *e1 = &elements[i]; - if (e1->register_idx == WINED3D_STREAM_OUTPUT_GAP) + const D3D11_SO_DECLARATION_ENTRY *e1 = &entries[i]; + if (!e1->SemanticName) /* gap */ continue; for (j = i + 1; j < entry_count; ++j) { - const struct wined3d_stream_output_element *e2 = &elements[j]; + const D3D11_SO_DECLARATION_ENTRY *e2 = &entries[j]; + if (!e2->SemanticName) /* gap */ + continue; - if (e1->register_idx == e2->register_idx - && e1->component_idx < e2->component_idx + e2->component_count - && e1->component_idx + e1->component_count > e2->component_idx) + if (e1->Stream == e2->Stream + && !_strnicmp(e1->SemanticName, e2->SemanticName, -1) + && e1->SemanticIndex == e2->SemanticIndex + && e1->StartComponent < e2->StartComponent + e2->ComponentCount + && e1->StartComponent + e1->ComponentCount > e2->StartComponent) { WARN("Stream output elements %u and %u overlap.\n", i, j); return E_INVALIDARG; @@ -1382,14 +1045,14 @@ static HRESULT wined3d_so_elements_from_d3d11_so_entries(struct wined3d_stream_o for (j = 0; j < entry_count; ++j) { - const struct wined3d_stream_output_element *e = &elements[j]; + const D3D11_SO_DECLARATION_ENTRY *e = &entries[j]; - if (e->stream_idx != i) + if (e->Stream != i) continue; - current_stride[e->output_slot] += 4 * e->component_count; - ++element_count[e->output_slot]; - if (e->register_idx == WINED3D_STREAM_OUTPUT_GAP) - ++gap_count[e->output_slot]; + current_stride[e->OutputSlot] += 4 * e->ComponentCount; + ++element_count[e->OutputSlot]; + if (!e->SemanticName) + ++gap_count[e->OutputSlot]; } for (j = 0; j < D3D11_SO_BUFFER_SLOT_COUNT; ++j) @@ -1475,36 +1138,22 @@ static HRESULT d3d_geometry_shader_init(struct d3d_geometry_shader *shader, } } - if (FAILED(hr = shader_extract_from_dxbc(byte_code, byte_code_length, &desc, device->feature_level))) - { - WARN("Failed to extract shader, hr %#x.\n", hr); + if (FAILED(hr = validate_stream_output_entries(so_entries, so_entry_count, + buffer_strides, buffer_stride_count, device->feature_level))) return hr; - } - desc.max_version = d3d_sm_from_feature_level(device->feature_level); + + desc.byte_code = byte_code; + desc.byte_code_size = byte_code_length; memset(&so_desc, 0, sizeof(so_desc)); if (so_entries) { + so_desc.elements = (const struct wined3d_stream_output_element *)so_entries; so_desc.element_count = so_entry_count; for (i = 0; i < min(buffer_stride_count, ARRAY_SIZE(so_desc.buffer_strides)); ++i) so_desc.buffer_strides[i] = buffer_strides[i]; so_desc.buffer_stride_count = buffer_stride_count; so_desc.rasterizer_stream_idx = rasterizer_stream; - - if (!(so_desc.elements = heap_calloc(so_entry_count, sizeof(*so_desc.elements)))) - { - ERR("Failed to allocate wined3d stream output element array memory.\n"); - free_shader_desc(&desc); - return E_OUTOFMEMORY; - } - if (FAILED(hr = wined3d_so_elements_from_d3d11_so_entries(so_desc.elements, - so_entries, so_entry_count, buffer_strides, buffer_stride_count, - &desc.output_signature, device->feature_level))) - { - heap_free(so_desc.elements); - free_shader_desc(&desc); - return hr; - } } shader->ID3D11GeometryShader_iface.lpVtbl = &d3d11_geometry_shader_vtbl; @@ -1513,11 +1162,8 @@ static HRESULT d3d_geometry_shader_init(struct d3d_geometry_shader *shader, wined3d_mutex_lock(); wined3d_private_store_init(&shader->private_store); - hr = wined3d_shader_create_gs(device->wined3d_device, &desc, so_entries ? &so_desc : NULL, - shader, &d3d_geometry_shader_wined3d_parent_ops, &shader->wined3d_shader); - heap_free(so_desc.elements); - free_shader_desc(&desc); - if (FAILED(hr)) + if (FAILED(hr = wined3d_shader_create_gs(device->wined3d_device, &desc, so_entries ? &so_desc : NULL, + shader, &d3d_geometry_shader_wined3d_parent_ops, &shader->wined3d_shader))) { WARN("Failed to create wined3d geometry shader, hr %#x.\n", hr); wined3d_private_store_cleanup(&shader->private_store); @@ -1526,8 +1172,7 @@ static HRESULT d3d_geometry_shader_init(struct d3d_geometry_shader *shader, } wined3d_mutex_unlock(); - shader->device = &device->ID3D11Device_iface; - ID3D11Device_AddRef(shader->device); + ID3D11Device2_AddRef(shader->device = &device->ID3D11Device2_iface); return S_OK; } @@ -1621,7 +1266,7 @@ static ULONG STDMETHODCALLTYPE d3d11_pixel_shader_AddRef(ID3D11PixelShader *ifac if (refcount == 1) { - ID3D11Device_AddRef(shader->device); + ID3D11Device2_AddRef(shader->device); wined3d_mutex_lock(); wined3d_shader_incref(shader->wined3d_shader); wined3d_mutex_unlock(); @@ -1639,14 +1284,14 @@ static ULONG STDMETHODCALLTYPE d3d11_pixel_shader_Release(ID3D11PixelShader *ifa if (!refcount) { - ID3D11Device *device = shader->device; + ID3D11Device2 *device = shader->device; wined3d_mutex_lock(); wined3d_shader_decref(shader->wined3d_shader); wined3d_mutex_unlock(); /* Release the device last, it may cause the wined3d device to be * destroyed. */ - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -1659,7 +1304,7 @@ static void STDMETHODCALLTYPE d3d11_pixel_shader_GetDevice(ID3D11PixelShader *if TRACE("iface %p, device %p.\n", iface, device); - *device = shader->device; + *device = (ID3D11Device *)shader->device; ID3D11Device_AddRef(*device); } @@ -1751,7 +1396,7 @@ static void STDMETHODCALLTYPE d3d10_pixel_shader_GetDevice(ID3D10PixelShader *if TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_QueryInterface(shader->device, &IID_ID3D10Device, (void **)device); + ID3D11Device2_QueryInterface(shader->device, &IID_ID3D10Device, (void **)device); } static HRESULT STDMETHODCALLTYPE d3d10_pixel_shader_GetPrivateData(ID3D10PixelShader *iface, @@ -1824,19 +1469,10 @@ static HRESULT d3d_pixel_shader_init(struct d3d_pixel_shader *shader, struct d3d wined3d_mutex_lock(); wined3d_private_store_init(&shader->private_store); - if (FAILED(hr = shader_extract_from_dxbc(byte_code, byte_code_length, &desc, device->feature_level))) - { - WARN("Failed to extract shader, hr %#x.\n", hr); - wined3d_private_store_cleanup(&shader->private_store); - wined3d_mutex_unlock(); - return hr; - } - desc.max_version = d3d_sm_from_feature_level(device->feature_level); - - hr = wined3d_shader_create_ps(device->wined3d_device, &desc, shader, - &d3d_pixel_shader_wined3d_parent_ops, &shader->wined3d_shader); - free_shader_desc(&desc); - if (FAILED(hr)) + desc.byte_code = byte_code; + desc.byte_code_size = byte_code_length; + if (FAILED(hr = wined3d_shader_create_ps(device->wined3d_device, &desc, shader, + &d3d_pixel_shader_wined3d_parent_ops, &shader->wined3d_shader))) { WARN("Failed to create wined3d pixel shader, hr %#x.\n", hr); wined3d_private_store_cleanup(&shader->private_store); @@ -1845,8 +1481,7 @@ static HRESULT d3d_pixel_shader_init(struct d3d_pixel_shader *shader, struct d3d } wined3d_mutex_unlock(); - shader->device = &device->ID3D11Device_iface; - ID3D11Device_AddRef(shader->device); + ID3D11Device2_AddRef(shader->device = &device->ID3D11Device2_iface); return S_OK; } @@ -1926,7 +1561,7 @@ static ULONG STDMETHODCALLTYPE d3d11_compute_shader_AddRef(ID3D11ComputeShader * if (refcount == 1) { - ID3D11Device_AddRef(shader->device); + ID3D11Device2_AddRef(shader->device); wined3d_mutex_lock(); wined3d_shader_incref(shader->wined3d_shader); wined3d_mutex_unlock(); @@ -1944,7 +1579,7 @@ static ULONG STDMETHODCALLTYPE d3d11_compute_shader_Release(ID3D11ComputeShader if (!refcount) { - ID3D11Device *device = shader->device; + ID3D11Device2 *device = shader->device; wined3d_mutex_lock(); wined3d_shader_decref(shader->wined3d_shader); @@ -1952,7 +1587,7 @@ static ULONG STDMETHODCALLTYPE d3d11_compute_shader_Release(ID3D11ComputeShader /* Release the device last, it may cause the wined3d device to be * destroyed. */ - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -1965,7 +1600,7 @@ static void STDMETHODCALLTYPE d3d11_compute_shader_GetDevice(ID3D11ComputeShader TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_AddRef(*device = shader->device); + ID3D11Device_AddRef(*device = (ID3D11Device *)shader->device); } static HRESULT STDMETHODCALLTYPE d3d11_compute_shader_GetPrivateData(ID3D11ComputeShader *iface, @@ -2035,19 +1670,10 @@ static HRESULT d3d11_compute_shader_init(struct d3d11_compute_shader *shader, st wined3d_mutex_lock(); wined3d_private_store_init(&shader->private_store); - if (FAILED(hr = shader_extract_from_dxbc(byte_code, byte_code_length, &desc, device->feature_level))) - { - WARN("Failed to extract shader, hr %#x.\n", hr); - wined3d_private_store_cleanup(&shader->private_store); - wined3d_mutex_unlock(); - return hr; - } - desc.max_version = d3d_sm_from_feature_level(device->feature_level); - - hr = wined3d_shader_create_cs(device->wined3d_device, &desc, shader, - &d3d11_compute_shader_wined3d_parent_ops, &shader->wined3d_shader); - free_shader_desc(&desc); - if (FAILED(hr)) + desc.byte_code = byte_code; + desc.byte_code_size = byte_code_length; + if (FAILED(hr = wined3d_shader_create_cs(device->wined3d_device, &desc, shader, + &d3d11_compute_shader_wined3d_parent_ops, &shader->wined3d_shader))) { WARN("Failed to create wined3d compute shader, hr %#x.\n", hr); wined3d_private_store_cleanup(&shader->private_store); @@ -2056,7 +1682,7 @@ static HRESULT d3d11_compute_shader_init(struct d3d11_compute_shader *shader, st } wined3d_mutex_unlock(); - ID3D11Device_AddRef(shader->device = &device->ID3D11Device_iface); + ID3D11Device2_AddRef(shader->device = &device->ID3D11Device2_iface); return S_OK; } @@ -2136,12 +1762,12 @@ static ULONG STDMETHODCALLTYPE d3d11_class_linkage_Release(ID3D11ClassLinkage *i if (!refcount) { - ID3D11Device *device = class_linkage->device; + ID3D11Device2 *device = class_linkage->device; wined3d_private_store_cleanup(&class_linkage->private_store); heap_free(class_linkage); - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -2154,7 +1780,7 @@ static void STDMETHODCALLTYPE d3d11_class_linkage_GetDevice(ID3D11ClassLinkage * TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_AddRef(*device = class_linkage->device); + ID3D11Device_AddRef(*device = (ID3D11Device *)class_linkage->device); } static HRESULT STDMETHODCALLTYPE d3d11_class_linkage_GetPrivateData(ID3D11ClassLinkage *iface, @@ -2235,7 +1861,7 @@ HRESULT d3d11_class_linkage_create(struct d3d_device *device, struct d3d11_class object->refcount = 1; wined3d_private_store_init(&object->private_store); - ID3D11Device_AddRef(object->device = &device->ID3D11Device_iface); + ID3D11Device2_AddRef(object->device = &device->ID3D11Device2_iface); TRACE("Created class linkage %p.\n", object); *class_linkage = object; diff --git a/dll/directx/wine/d3d11/state.c b/dll/directx/wine/d3d11/state.c index a14c9d3cb40de..92b75f8e1fb4d 100644 --- a/dll/directx/wine/d3d11/state.c +++ b/dll/directx/wine/d3d11/state.c @@ -17,9 +17,6 @@ * */ -#include "config.h" -#include "wine/port.h" - #include "d3d11_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d11); @@ -66,7 +63,7 @@ static ULONG STDMETHODCALLTYPE d3d11_blend_state_AddRef(ID3D11BlendState *iface) if (refcount == 1) { - ID3D11Device_AddRef(state->device); + ID3D11Device2_AddRef(state->device); wined3d_mutex_lock(); wined3d_blend_state_incref(state->wined3d_state); wined3d_mutex_unlock(); @@ -84,13 +81,13 @@ static ULONG STDMETHODCALLTYPE d3d11_blend_state_Release(ID3D11BlendState *iface if (!refcount) { - ID3D11Device *device = state->device; + ID3D11Device2 *device = state->device; wined3d_mutex_lock(); wined3d_blend_state_decref(state->wined3d_state); wined3d_mutex_unlock(); - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -103,7 +100,7 @@ static void STDMETHODCALLTYPE d3d11_blend_state_GetDevice(ID3D11BlendState *ifac TRACE("iface %p, device %p.\n", iface, device); - *device = state->device; + *device = (ID3D11Device *)state->device; ID3D11Device_AddRef(*device); } @@ -206,7 +203,7 @@ static void STDMETHODCALLTYPE d3d10_blend_state_GetDevice(ID3D10BlendState1 *ifa TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_QueryInterface(state->device, &IID_ID3D10Device, (void **)device); + ID3D11Device2_QueryInterface(state->device, &IID_ID3D10Device, (void **)device); } static HRESULT STDMETHODCALLTYPE d3d10_blend_state_GetPrivateData(ID3D10BlendState1 *iface, @@ -294,7 +291,7 @@ static const struct ID3D10BlendState1Vtbl d3d10_blend_state_vtbl = static void STDMETHODCALLTYPE d3d_blend_state_wined3d_object_destroyed(void *parent) { struct d3d_blend_state *state = parent; - struct d3d_device *device = impl_from_ID3D11Device(state->device); + struct d3d_device *device = impl_from_ID3D11Device2(state->device); wine_rb_remove(&device->blend_states, &state->entry); wined3d_private_store_cleanup(&state->private_store); @@ -328,12 +325,24 @@ HRESULT d3d_blend_state_create(struct d3d_device *device, const D3D11_BLEND_DESC { j = desc->IndependentBlendEnable ? i : 0; tmp_desc.RenderTarget[i].BlendEnable = desc->RenderTarget[j].BlendEnable; - tmp_desc.RenderTarget[i].SrcBlend = desc->RenderTarget[j].SrcBlend; - tmp_desc.RenderTarget[i].DestBlend = desc->RenderTarget[j].DestBlend; - tmp_desc.RenderTarget[i].BlendOp = desc->RenderTarget[j].BlendOp; - tmp_desc.RenderTarget[i].SrcBlendAlpha = desc->RenderTarget[j].SrcBlendAlpha; - tmp_desc.RenderTarget[i].DestBlendAlpha = desc->RenderTarget[j].DestBlendAlpha; - tmp_desc.RenderTarget[i].BlendOpAlpha = desc->RenderTarget[j].BlendOpAlpha; + if (tmp_desc.RenderTarget[i].BlendEnable) + { + tmp_desc.RenderTarget[i].SrcBlend = desc->RenderTarget[j].SrcBlend; + tmp_desc.RenderTarget[i].DestBlend = desc->RenderTarget[j].DestBlend; + tmp_desc.RenderTarget[i].BlendOp = desc->RenderTarget[j].BlendOp; + tmp_desc.RenderTarget[i].SrcBlendAlpha = desc->RenderTarget[j].SrcBlendAlpha; + tmp_desc.RenderTarget[i].DestBlendAlpha = desc->RenderTarget[j].DestBlendAlpha; + tmp_desc.RenderTarget[i].BlendOpAlpha = desc->RenderTarget[j].BlendOpAlpha; + } + else + { + tmp_desc.RenderTarget[i].SrcBlend = D3D11_BLEND_ONE; + tmp_desc.RenderTarget[i].DestBlend = D3D11_BLEND_ZERO; + tmp_desc.RenderTarget[i].BlendOp = D3D11_BLEND_OP_ADD; + tmp_desc.RenderTarget[i].SrcBlendAlpha = D3D11_BLEND_ONE; + tmp_desc.RenderTarget[i].DestBlendAlpha = D3D11_BLEND_ZERO; + tmp_desc.RenderTarget[i].BlendOpAlpha = D3D11_BLEND_OP_ADD; + } tmp_desc.RenderTarget[i].RenderTargetWriteMask = desc->RenderTarget[j].RenderTargetWriteMask; if (i > 3 && tmp_desc.RenderTarget[i].RenderTargetWriteMask != D3D11_COLOR_WRITE_ENABLE_ALL) @@ -395,7 +404,7 @@ HRESULT d3d_blend_state_create(struct d3d_device *device, const D3D11_BLEND_DESC } wined3d_mutex_unlock(); - ID3D11Device_AddRef(object->device = &device->ID3D11Device_iface); + ID3D11Device2_AddRef(object->device = &device->ID3D11Device2_iface); TRACE("Created blend state %p.\n", object); *state = object; @@ -466,7 +475,7 @@ static ULONG STDMETHODCALLTYPE d3d11_depthstencil_state_AddRef(ID3D11DepthStenci static void d3d_depthstencil_state_cleanup(struct d3d_depthstencil_state *state) { wined3d_private_store_cleanup(&state->private_store); - ID3D11Device_Release(state->device); + ID3D11Device2_Release(state->device); } static ULONG STDMETHODCALLTYPE d3d11_depthstencil_state_Release(ID3D11DepthStencilState *iface) @@ -478,7 +487,7 @@ static ULONG STDMETHODCALLTYPE d3d11_depthstencil_state_Release(ID3D11DepthStenc if (!refcount) { - struct d3d_device *device = impl_from_ID3D11Device(state->device); + struct d3d_device *device = impl_from_ID3D11Device2(state->device); wined3d_mutex_lock(); wine_rb_remove(&device->depthstencil_states, &state->entry); d3d_depthstencil_state_cleanup(state); @@ -496,7 +505,7 @@ static void STDMETHODCALLTYPE d3d11_depthstencil_state_GetDevice(ID3D11DepthSten TRACE("iface %p, device %p.\n", iface, device); - *device = state->device; + *device = (ID3D11Device *)state->device; ID3D11Device_AddRef(*device); } @@ -600,7 +609,7 @@ static void STDMETHODCALLTYPE d3d10_depthstencil_state_GetDevice(ID3D10DepthSten TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_QueryInterface(state->device, &IID_ID3D10Device, (void **)device); + ID3D11Device2_QueryInterface(state->device, &IID_ID3D10Device, (void **)device); } static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_state_GetPrivateData(ID3D10DepthStencilState *iface, @@ -671,8 +680,7 @@ static HRESULT d3d_depthstencil_state_init(struct d3d_depthstencil_state *state, wined3d_private_store_init(&state->private_store); state->desc = *desc; - state->device = &device->ID3D11Device_iface; - ID3D11Device_AddRef(state->device); + ID3D11Device2_AddRef(state->device = &device->ID3D11Device2_iface); return S_OK; } @@ -751,7 +759,7 @@ HRESULT d3d_depthstencil_state_create(struct d3d_device *device, const D3D11_DEP return hr; } - if (wine_rb_put(&device->depthstencil_states, desc, &object->entry) == -1) + if (wine_rb_put(&device->depthstencil_states, &tmp_desc, &object->entry) == -1) { ERR("Failed to insert depthstencil state entry.\n"); d3d_depthstencil_state_cleanup(object); @@ -831,7 +839,7 @@ static ULONG STDMETHODCALLTYPE d3d11_rasterizer_state_AddRef(ID3D11RasterizerSta if (refcount == 1) { - ID3D11Device_AddRef(state->device); + ID3D11Device2_AddRef(state->device); wined3d_mutex_lock(); wined3d_rasterizer_state_incref(state->wined3d_state); wined3d_mutex_unlock(); @@ -849,13 +857,13 @@ static ULONG STDMETHODCALLTYPE d3d11_rasterizer_state_Release(ID3D11RasterizerSt if (!refcount) { - ID3D11Device *device = state->device; + ID3D11Device2 *device = state->device; wined3d_mutex_lock(); wined3d_rasterizer_state_decref(state->wined3d_state); wined3d_mutex_unlock(); - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -868,7 +876,7 @@ static void STDMETHODCALLTYPE d3d11_rasterizer_state_GetDevice(ID3D11RasterizerS TRACE("iface %p, device %p.\n", iface, device); - *device = state->device; + *device = (ID3D11Device *)state->device; ID3D11Device_AddRef(*device); } @@ -972,7 +980,7 @@ static void STDMETHODCALLTYPE d3d10_rasterizer_state_GetDevice(ID3D10RasterizerS TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_QueryInterface(state->device, &IID_ID3D10Device, (void **)device); + ID3D11Device2_QueryInterface(state->device, &IID_ID3D10Device, (void **)device); } static HRESULT STDMETHODCALLTYPE d3d10_rasterizer_state_GetPrivateData(ID3D10RasterizerState *iface, @@ -1037,7 +1045,7 @@ static const struct ID3D10RasterizerStateVtbl d3d10_rasterizer_state_vtbl = static void STDMETHODCALLTYPE d3d_rasterizer_state_wined3d_object_destroyed(void *parent) { struct d3d_rasterizer_state *state = parent; - struct d3d_device *device = impl_from_ID3D11Device(state->device); + struct d3d_device *device = impl_from_ID3D11Device2(state->device); wine_rb_remove(&device->rasterizer_states, &state->entry); wined3d_private_store_cleanup(&state->private_store); @@ -1069,6 +1077,8 @@ static HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, str } wined3d_desc.front_ccw = desc->FrontCounterClockwise; + wined3d_desc.depth_clip = desc->DepthClipEnable; + wined3d_desc.depth_bias_clamp = desc->DepthBiasClamp; /* We cannot fail after creating a wined3d_rasterizer_state object. It * would lead to double free. */ @@ -1081,7 +1091,7 @@ static HRESULT d3d_rasterizer_state_init(struct d3d_rasterizer_state *state, str return hr; } - ID3D11Device_AddRef(state->device = &device->ID3D11Device_iface); + ID3D11Device2_AddRef(state->device = &device->ID3D11Device2_iface); return S_OK; } @@ -1194,7 +1204,7 @@ static ULONG STDMETHODCALLTYPE d3d11_sampler_state_AddRef(ID3D11SamplerState *if if (refcount == 1) { - ID3D11Device_AddRef(state->device); + ID3D11Device2_AddRef(state->device); wined3d_mutex_lock(); wined3d_sampler_incref(state->wined3d_sampler); wined3d_mutex_unlock(); @@ -1212,13 +1222,13 @@ static ULONG STDMETHODCALLTYPE d3d11_sampler_state_Release(ID3D11SamplerState *i if (!refcount) { - ID3D11Device *device = state->device; + ID3D11Device2 *device = state->device; wined3d_mutex_lock(); wined3d_sampler_decref(state->wined3d_sampler); wined3d_mutex_unlock(); - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -1231,7 +1241,7 @@ static void STDMETHODCALLTYPE d3d11_sampler_state_GetDevice(ID3D11SamplerState * TRACE("iface %p, device %p.\n", iface, device); - *device = state->device; + *device = (ID3D11Device *)state->device; ID3D11Device_AddRef(*device); } @@ -1335,7 +1345,7 @@ static void STDMETHODCALLTYPE d3d10_sampler_state_GetDevice(ID3D10SamplerState * TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_QueryInterface(state->device, &IID_ID3D10Device, (void **)device); + ID3D11Device2_QueryInterface(state->device, &IID_ID3D10Device, (void **)device); } static HRESULT STDMETHODCALLTYPE d3d10_sampler_state_GetPrivateData(ID3D10SamplerState *iface, @@ -1400,7 +1410,7 @@ static const struct ID3D10SamplerStateVtbl d3d10_sampler_state_vtbl = static void STDMETHODCALLTYPE d3d_sampler_wined3d_object_destroyed(void *parent) { struct d3d_sampler_state *state = parent; - struct d3d_device *device = impl_from_ID3D11Device(state->device); + struct d3d_device *device = impl_from_ID3D11Device2(state->device); wine_rb_remove(&device->sampler_states, &state->entry); wined3d_private_store_cleanup(&state->private_store); @@ -1494,8 +1504,7 @@ static HRESULT d3d_sampler_state_init(struct d3d_sampler_state *state, struct d3 return hr; } - state->device = &device->ID3D11Device_iface; - ID3D11Device_AddRef(state->device); + ID3D11Device2_AddRef(state->device = &device->ID3D11Device2_iface); return S_OK; } diff --git a/dll/directx/wine/d3d11/texture.c b/dll/directx/wine/d3d11/texture.c index 2bcbe964b9b28..d54f22f35c952 100644 --- a/dll/directx/wine/d3d11/texture.c +++ b/dll/directx/wine/d3d11/texture.c @@ -18,13 +18,504 @@ * */ -#include "config.h" -#include "wine/port.h" - #include "d3d11_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d11); +/* ID3D11Texture1D methods */ + +static inline struct d3d_texture1d *impl_from_ID3D11Texture1D(ID3D11Texture1D *iface) +{ + return CONTAINING_RECORD(iface, struct d3d_texture1d, ID3D11Texture1D_iface); +} + +static HRESULT STDMETHODCALLTYPE d3d11_texture1d_QueryInterface(ID3D11Texture1D *iface, REFIID iid, void **out) +{ + struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface); + + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + if (IsEqualGUID(iid, &IID_ID3D11Texture1D) + || IsEqualGUID(iid, &IID_ID3D11Resource) + || IsEqualGUID(iid, &IID_ID3D11DeviceChild) + || IsEqualGUID(iid, &IID_IUnknown)) + { + *out = iface; + IUnknown_AddRef(iface); + return S_OK; + } + + if (IsEqualGUID(iid, &IID_ID3D10Texture1D) + || IsEqualGUID(iid, &IID_ID3D10Resource) + || IsEqualGUID(iid, &IID_ID3D10DeviceChild)) + { + *out = &texture->ID3D10Texture1D_iface; + IUnknown_AddRef((IUnknown *)*out); + return S_OK; + } + + if (texture->dxgi_surface) + { + TRACE("Forwarding to dxgi surface.\n"); + return IUnknown_QueryInterface(texture->dxgi_surface, iid, out); + } + + WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(iid)); + + *out = NULL; + return E_NOINTERFACE; +} + +static ULONG STDMETHODCALLTYPE d3d11_texture1d_AddRef(ID3D11Texture1D *iface) +{ + struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface); + ULONG refcount = InterlockedIncrement(&texture->refcount); + + TRACE("%p increasing refcount to %u.\n", texture, refcount); + + if (refcount == 1) + { + ID3D11Device2_AddRef(texture->device); + wined3d_mutex_lock(); + wined3d_texture_incref(texture->wined3d_texture); + wined3d_mutex_unlock(); + } + + return refcount; +} + +static ULONG STDMETHODCALLTYPE d3d11_texture1d_Release(ID3D11Texture1D *iface) +{ + struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface); + ULONG refcount = InterlockedDecrement(&texture->refcount); + + TRACE("%p decreasing refcount to %u.\n", texture, refcount); + + if (!refcount) + { + ID3D11Device2 *device = texture->device; + + wined3d_mutex_lock(); + wined3d_texture_decref(texture->wined3d_texture); + wined3d_mutex_unlock(); + /* Release the device last, it may cause the wined3d device to be + * destroyed. */ + ID3D11Device2_Release(device); + } + + return refcount; +} + +static void STDMETHODCALLTYPE d3d11_texture1d_GetDevice(ID3D11Texture1D *iface, ID3D11Device **device) +{ + struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface); + + TRACE("iface %p, device %p.\n", iface, device); + + *device = (ID3D11Device *)texture->device; + ID3D11Device_AddRef(*device); +} + +static HRESULT STDMETHODCALLTYPE d3d11_texture1d_GetPrivateData(ID3D11Texture1D *iface, + REFGUID guid, UINT *data_size, void *data) +{ + struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface); + IDXGISurface *dxgi_surface; + HRESULT hr; + + TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data); + + if (texture->dxgi_surface + && SUCCEEDED(IUnknown_QueryInterface(texture->dxgi_surface, &IID_IDXGISurface, (void **)&dxgi_surface))) + { + hr = IDXGISurface_GetPrivateData(dxgi_surface, guid, data_size, data); + IDXGISurface_Release(dxgi_surface); + return hr; + } + + return d3d_get_private_data(&texture->private_store, guid, data_size, data); +} + +static HRESULT STDMETHODCALLTYPE d3d11_texture1d_SetPrivateData(ID3D11Texture1D *iface, + REFGUID guid, UINT data_size, const void *data) +{ + struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface); + IDXGISurface *dxgi_surface; + HRESULT hr; + + TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data); + + if (texture->dxgi_surface + && SUCCEEDED(IUnknown_QueryInterface(texture->dxgi_surface, &IID_IDXGISurface, (void **)&dxgi_surface))) + { + hr = IDXGISurface_SetPrivateData(dxgi_surface, guid, data_size, data); + IDXGISurface_Release(dxgi_surface); + return hr; + } + + return d3d_set_private_data(&texture->private_store, guid, data_size, data); +} + +static HRESULT STDMETHODCALLTYPE d3d11_texture1d_SetPrivateDataInterface(ID3D11Texture1D *iface, + REFGUID guid, const IUnknown *data) +{ + struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface); + IDXGISurface *dxgi_surface; + HRESULT hr; + + TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data); + + if (texture->dxgi_surface + && SUCCEEDED(IUnknown_QueryInterface(texture->dxgi_surface, &IID_IDXGISurface, (void **)&dxgi_surface))) + { + hr = IDXGISurface_SetPrivateDataInterface(dxgi_surface, guid, data); + IDXGISurface_Release(dxgi_surface); + return hr; + } + + return d3d_set_private_data_interface(&texture->private_store, guid, data); +} + +static void STDMETHODCALLTYPE d3d11_texture1d_GetType(ID3D11Texture1D *iface, + D3D11_RESOURCE_DIMENSION *resource_dimension) +{ + TRACE("iface %p, resource_dimension %p.\n", iface, resource_dimension); + + *resource_dimension = D3D11_RESOURCE_DIMENSION_TEXTURE1D; +} + +static void STDMETHODCALLTYPE d3d11_texture1d_SetEvictionPriority(ID3D11Texture1D *iface, UINT eviction_priority) +{ + FIXME("iface %p, eviction_priority %#x stub!\n", iface, eviction_priority); +} + +static UINT STDMETHODCALLTYPE d3d11_texture1d_GetEvictionPriority(ID3D11Texture1D *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0; +} + +static void STDMETHODCALLTYPE d3d11_texture1d_GetDesc(ID3D11Texture1D *iface, D3D11_TEXTURE1D_DESC *desc) +{ + struct d3d_texture1d *texture = impl_from_ID3D11Texture1D(iface); + + TRACE("iface %p, desc %p.\n", iface, desc); + + *desc = texture->desc; +} + +static const struct ID3D11Texture1DVtbl d3d11_texture1d_vtbl = +{ + /* IUnknown methods */ + d3d11_texture1d_QueryInterface, + d3d11_texture1d_AddRef, + d3d11_texture1d_Release, + /* ID3D11DeviceChild methods */ + d3d11_texture1d_GetDevice, + d3d11_texture1d_GetPrivateData, + d3d11_texture1d_SetPrivateData, + d3d11_texture1d_SetPrivateDataInterface, + /* ID3D11Resource methods */ + d3d11_texture1d_GetType, + d3d11_texture1d_SetEvictionPriority, + d3d11_texture1d_GetEvictionPriority, + /* ID3D11Texture1D methods */ + d3d11_texture1d_GetDesc, +}; + +struct d3d_texture1d *unsafe_impl_from_ID3D11Texture1D(ID3D11Texture1D *iface) +{ + if (!iface) + return NULL; + assert(iface->lpVtbl == &d3d11_texture1d_vtbl); + return CONTAINING_RECORD(iface, struct d3d_texture1d, ID3D11Texture1D_iface); +} + +static inline struct d3d_texture1d *impl_from_ID3D10Texture1D(ID3D10Texture1D *iface) +{ + return CONTAINING_RECORD(iface, struct d3d_texture1d, ID3D10Texture1D_iface); +} + +/* IUnknown methods */ + +static HRESULT STDMETHODCALLTYPE d3d10_texture1d_QueryInterface(ID3D10Texture1D *iface, REFIID iid, void **out) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + + TRACE("iface %p, iid %s, out %p.\n", iface, debugstr_guid(iid), out); + + return d3d11_texture1d_QueryInterface(&texture->ID3D11Texture1D_iface, iid, out); +} + +static ULONG STDMETHODCALLTYPE d3d10_texture1d_AddRef(ID3D10Texture1D *iface) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + + TRACE("iface %p.\n", iface); + + return d3d11_texture1d_AddRef(&texture->ID3D11Texture1D_iface); +} + +static void STDMETHODCALLTYPE d3d_texture1d_wined3d_object_released(void *parent) +{ + struct d3d_texture1d *texture = parent; + + if (texture->dxgi_surface) + IUnknown_Release(texture->dxgi_surface); + wined3d_private_store_cleanup(&texture->private_store); + heap_free(texture); +} + +static ULONG STDMETHODCALLTYPE d3d10_texture1d_Release(ID3D10Texture1D *iface) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + + TRACE("iface %p.\n", iface); + + return d3d11_texture1d_Release(&texture->ID3D11Texture1D_iface); +} + +/* ID3D10DeviceChild methods */ + +static void STDMETHODCALLTYPE d3d10_texture1d_GetDevice(ID3D10Texture1D *iface, ID3D10Device **device) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + + TRACE("iface %p, device %p.\n", iface, device); + + ID3D11Device2_QueryInterface(texture->device, &IID_ID3D10Device, (void **)device); +} + +static HRESULT STDMETHODCALLTYPE d3d10_texture1d_GetPrivateData(ID3D10Texture1D *iface, + REFGUID guid, UINT *data_size, void *data) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + + TRACE("iface %p, guid %s, data_size %p, data %p.\n", iface, debugstr_guid(guid), data_size, data); + + return d3d11_texture1d_GetPrivateData(&texture->ID3D11Texture1D_iface, guid, data_size, data); +} + +static HRESULT STDMETHODCALLTYPE d3d10_texture1d_SetPrivateData(ID3D10Texture1D *iface, + REFGUID guid, UINT data_size, const void *data) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + + TRACE("iface %p, guid %s, data_size %u, data %p.\n", iface, debugstr_guid(guid), data_size, data); + + return d3d11_texture1d_SetPrivateData(&texture->ID3D11Texture1D_iface, guid, data_size, data); +} + +static HRESULT STDMETHODCALLTYPE d3d10_texture1d_SetPrivateDataInterface(ID3D10Texture1D *iface, + REFGUID guid, const IUnknown *data) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + + TRACE("iface %p, guid %s, data %p.\n", iface, debugstr_guid(guid), data); + + return d3d11_texture1d_SetPrivateDataInterface(&texture->ID3D11Texture1D_iface, guid, data); +} + +/* ID3D10Resource methods */ + +static void STDMETHODCALLTYPE d3d10_texture1d_GetType(ID3D10Texture1D *iface, + D3D10_RESOURCE_DIMENSION *resource_dimension) +{ + TRACE("iface %p, resource_dimension %p\n", iface, resource_dimension); + + *resource_dimension = D3D10_RESOURCE_DIMENSION_TEXTURE1D; +} + +static void STDMETHODCALLTYPE d3d10_texture1d_SetEvictionPriority(ID3D10Texture1D *iface, UINT eviction_priority) +{ + FIXME("iface %p, eviction_priority %u stub!\n", iface, eviction_priority); +} + +static UINT STDMETHODCALLTYPE d3d10_texture1d_GetEvictionPriority(ID3D10Texture1D *iface) +{ + FIXME("iface %p stub!\n", iface); + + return 0; +} + +/* ID3D10Texture1D methods */ + +static HRESULT STDMETHODCALLTYPE d3d10_texture1d_Map(ID3D10Texture1D *iface, UINT sub_resource_idx, + D3D10_MAP map_type, UINT map_flags, void **data) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + struct wined3d_map_desc wined3d_map_desc; + HRESULT hr; + + TRACE("iface %p, sub_resource_idx %u, map_type %u, map_flags %#x, data %p.\n", + iface, sub_resource_idx, map_type, map_flags, data); + + if (map_flags) + FIXME("Ignoring map_flags %#x.\n", map_flags); + + wined3d_mutex_lock(); + if (SUCCEEDED(hr = wined3d_resource_map(wined3d_texture_get_resource(texture->wined3d_texture), sub_resource_idx, + &wined3d_map_desc, NULL, wined3d_map_flags_from_d3d11_map_type(map_type)))) + { + *data = wined3d_map_desc.data; + } + wined3d_mutex_unlock(); + + return hr; +} + +static void STDMETHODCALLTYPE d3d10_texture1d_Unmap(ID3D10Texture1D *iface, UINT sub_resource_idx) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + + TRACE("iface %p, sub_resource_idx %u.\n", iface, sub_resource_idx); + + wined3d_mutex_lock(); + wined3d_resource_unmap(wined3d_texture_get_resource(texture->wined3d_texture), sub_resource_idx); + wined3d_mutex_unlock(); +} + +static void STDMETHODCALLTYPE d3d10_texture1d_GetDesc(ID3D10Texture1D *iface, D3D10_TEXTURE1D_DESC *desc) +{ + struct d3d_texture1d *texture = impl_from_ID3D10Texture1D(iface); + D3D11_TEXTURE1D_DESC d3d11_desc; + + TRACE("iface %p, desc %p.\n", iface, desc); + + d3d11_texture1d_GetDesc(&texture->ID3D11Texture1D_iface, &d3d11_desc); + + desc->Width = d3d11_desc.Width; + desc->MipLevels = d3d11_desc.MipLevels; + desc->ArraySize = d3d11_desc.ArraySize; + desc->Format = d3d11_desc.Format; + desc->Usage = d3d10_usage_from_d3d11_usage(d3d11_desc.Usage); + desc->BindFlags = d3d10_bind_flags_from_d3d11_bind_flags(d3d11_desc.BindFlags); + desc->CPUAccessFlags = d3d10_cpu_access_flags_from_d3d11_cpu_access_flags(d3d11_desc.CPUAccessFlags); + desc->MiscFlags = d3d10_resource_misc_flags_from_d3d11_resource_misc_flags(d3d11_desc.MiscFlags); +} + +static const struct ID3D10Texture1DVtbl d3d10_texture1d_vtbl = +{ + /* IUnknown methods */ + d3d10_texture1d_QueryInterface, + d3d10_texture1d_AddRef, + d3d10_texture1d_Release, + /* ID3D10DeviceChild methods */ + d3d10_texture1d_GetDevice, + d3d10_texture1d_GetPrivateData, + d3d10_texture1d_SetPrivateData, + d3d10_texture1d_SetPrivateDataInterface, + /* ID3D10Resource methods */ + d3d10_texture1d_GetType, + d3d10_texture1d_SetEvictionPriority, + d3d10_texture1d_GetEvictionPriority, + /* ID3D10Texture1D methods */ + d3d10_texture1d_Map, + d3d10_texture1d_Unmap, + d3d10_texture1d_GetDesc, +}; + +struct d3d_texture1d *unsafe_impl_from_ID3D10Texture1D(ID3D10Texture1D *iface) +{ + if (!iface) + return NULL; + assert(iface->lpVtbl == &d3d10_texture1d_vtbl); + return CONTAINING_RECORD(iface, struct d3d_texture1d, ID3D10Texture1D_iface); +} + +static const struct wined3d_parent_ops d3d_texture1d_wined3d_parent_ops = +{ + d3d_texture1d_wined3d_object_released, +}; + +HRESULT d3d_texture1d_create(struct d3d_device *device, const D3D11_TEXTURE1D_DESC *desc, + const D3D11_SUBRESOURCE_DATA *data, struct d3d_texture1d **out) +{ + struct wined3d_resource_desc wined3d_desc; + struct d3d_texture1d *texture; + unsigned int levels; + DWORD flags = 0; + HRESULT hr; + + if (!(texture = heap_alloc_zero(sizeof(*texture)))) + return E_OUTOFMEMORY; + + texture->ID3D11Texture1D_iface.lpVtbl = &d3d11_texture1d_vtbl; + texture->ID3D10Texture1D_iface.lpVtbl = &d3d10_texture1d_vtbl; + texture->refcount = 1; + wined3d_private_store_init(&texture->private_store); + texture->desc = *desc; + levels = desc->MipLevels ? desc->MipLevels : wined3d_log2i(desc->Width) + 1; + texture->desc.MipLevels = levels; + + wined3d_desc.resource_type = WINED3D_RTYPE_TEXTURE_1D; + wined3d_desc.format = wined3dformat_from_dxgi_format(desc->Format); + wined3d_desc.multisample_type = WINED3D_MULTISAMPLE_NONE; + wined3d_desc.multisample_quality = 0; + wined3d_desc.usage = wined3d_usage_from_d3d11(desc->Usage); + wined3d_desc.bind_flags = wined3d_bind_flags_from_d3d11(desc->BindFlags); + wined3d_desc.access = wined3d_access_from_d3d11(desc->Usage, + desc->Usage == D3D11_USAGE_DEFAULT ? 0 : desc->CPUAccessFlags); + wined3d_desc.width = desc->Width; + wined3d_desc.height = 1; + wined3d_desc.depth = 1; + wined3d_desc.size = 0; + + if (desc->MiscFlags & D3D11_RESOURCE_MISC_GDI_COMPATIBLE) + flags |= WINED3D_TEXTURE_CREATE_GET_DC; + if (desc->MiscFlags & D3D11_RESOURCE_MISC_GENERATE_MIPS) + flags |= WINED3D_TEXTURE_CREATE_GENERATE_MIPMAPS; + + wined3d_mutex_lock(); + if (FAILED(hr = wined3d_texture_create(device->wined3d_device, &wined3d_desc, + desc->ArraySize, levels, flags, (struct wined3d_sub_resource_data *)data, + texture, &d3d_texture1d_wined3d_parent_ops, &texture->wined3d_texture))) + { + WARN("Failed to create wined3d texture, hr %#x.\n", hr); + wined3d_private_store_cleanup(&texture->private_store); + heap_free(texture); + wined3d_mutex_unlock(); + if (hr == WINED3DERR_NOTAVAILABLE || hr == WINED3DERR_INVALIDCALL) + hr = E_INVALIDARG; + return hr; + } + + 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->ID3D10Texture1D_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(); + + ID3D11Device2_AddRef(texture->device = &device->ID3D11Device2_iface); + + TRACE("Created texture %p.\n", texture); + *out = texture; + + return S_OK; +} + /* ID3D11Texture2D methods */ static HRESULT STDMETHODCALLTYPE d3d11_texture2d_QueryInterface(ID3D11Texture2D *iface, REFIID riid, void **object) @@ -72,7 +563,7 @@ static ULONG STDMETHODCALLTYPE d3d11_texture2d_AddRef(ID3D11Texture2D *iface) if (refcount == 1) { - ID3D11Device_AddRef(texture->device); + ID3D11Device2_AddRef(texture->device); wined3d_mutex_lock(); wined3d_texture_incref(texture->wined3d_texture); wined3d_mutex_unlock(); @@ -90,14 +581,14 @@ static ULONG STDMETHODCALLTYPE d3d11_texture2d_Release(ID3D11Texture2D *iface) if (!refcount) { - ID3D11Device *device = texture->device; + ID3D11Device2 *device = texture->device; wined3d_mutex_lock(); wined3d_texture_decref(texture->wined3d_texture); wined3d_mutex_unlock(); /* Release the device last, it may cause the wined3d device to be * destroyed. */ - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -109,7 +600,7 @@ static void STDMETHODCALLTYPE d3d11_texture2d_GetDevice(ID3D11Texture2D *iface, TRACE("iface %p, device %p.\n", iface, device); - *device = texture->device; + *device = (ID3D11Device *)texture->device; ID3D11Device_AddRef(*device); } @@ -295,7 +786,7 @@ static void STDMETHODCALLTYPE d3d10_texture2d_GetDevice(ID3D10Texture2D *iface, TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_QueryInterface(texture->device, &IID_ID3D10Device, (void **)device); + ID3D11Device2_QueryInterface(texture->device, &IID_ID3D10Device, (void **)device); } static HRESULT STDMETHODCALLTYPE d3d10_texture2d_GetPrivateData(ID3D10Texture2D *iface, @@ -516,7 +1007,8 @@ HRESULT d3d_texture2d_create(struct d3d_device *device, const D3D11_TEXTURE2D_DE 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.usage = wined3d_usage_from_d3d11(desc->Usage); + wined3d_desc.bind_flags = wined3d_bind_flags_from_d3d11(desc->BindFlags); wined3d_desc.access = wined3d_access_from_d3d11(desc->Usage, desc->Usage == D3D11_USAGE_DEFAULT ? 0 : desc->CPUAccessFlags); wined3d_desc.width = desc->Width; @@ -572,7 +1064,7 @@ HRESULT d3d_texture2d_create(struct d3d_device *device, const D3D11_TEXTURE2D_DE } wined3d_mutex_unlock(); - ID3D11Device_AddRef(texture->device = &device->ID3D11Device_iface); + ID3D11Device2_AddRef(texture->device = &device->ID3D11Device2_iface); TRACE("Created texture %p.\n", texture); *out = texture; @@ -626,7 +1118,7 @@ static ULONG STDMETHODCALLTYPE d3d11_texture3d_AddRef(ID3D11Texture3D *iface) if (refcount == 1) { - ID3D11Device_AddRef(texture->device); + ID3D11Device2_AddRef(texture->device); wined3d_mutex_lock(); wined3d_texture_incref(texture->wined3d_texture); wined3d_mutex_unlock(); @@ -652,14 +1144,14 @@ static ULONG STDMETHODCALLTYPE d3d11_texture3d_Release(ID3D11Texture3D *iface) if (!refcount) { - ID3D11Device *device = texture->device; + ID3D11Device2 *device = texture->device; wined3d_mutex_lock(); wined3d_texture_decref(texture->wined3d_texture); wined3d_mutex_unlock(); /* Release the device last, it may cause the wined3d device to be * destroyed. */ - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -671,7 +1163,7 @@ static void STDMETHODCALLTYPE d3d11_texture3d_GetDevice(ID3D11Texture3D *iface, TRACE("iface %p, device %p.\n", iface, device); - *device = texture->device; + *device = (ID3D11Device *)texture->device; ID3D11Device_AddRef(*device); } @@ -793,7 +1285,7 @@ static void STDMETHODCALLTYPE d3d10_texture3d_GetDevice(ID3D10Texture3D *iface, TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_QueryInterface(texture->device, &IID_ID3D10Device, (void **)device); + ID3D11Device2_QueryInterface(texture->device, &IID_ID3D10Device, (void **)device); } static HRESULT STDMETHODCALLTYPE d3d10_texture3d_GetPrivateData(ID3D10Texture3D *iface, @@ -974,7 +1466,8 @@ static HRESULT d3d_texture3d_init(struct d3d_texture3d *texture, struct d3d_devi wined3d_desc.format = wined3dformat_from_dxgi_format(desc->Format); wined3d_desc.multisample_type = WINED3D_MULTISAMPLE_NONE; wined3d_desc.multisample_quality = 0; - wined3d_desc.usage = wined3d_usage_from_d3d11(desc->BindFlags, desc->Usage); + wined3d_desc.usage = wined3d_usage_from_d3d11(desc->Usage); + wined3d_desc.bind_flags = wined3d_bind_flags_from_d3d11(desc->BindFlags); wined3d_desc.access = wined3d_access_from_d3d11(desc->Usage, desc->Usage == D3D11_USAGE_DEFAULT ? 0 : desc->CPUAccessFlags); wined3d_desc.width = desc->Width; @@ -1001,8 +1494,7 @@ static HRESULT d3d_texture3d_init(struct d3d_texture3d *texture, struct d3d_devi wined3d_mutex_unlock(); texture->desc.MipLevels = levels; - texture->device = &device->ID3D11Device_iface; - ID3D11Device_AddRef(texture->device); + ID3D11Device2_AddRef(texture->device = &device->ID3D11Device2_iface); return S_OK; } diff --git a/dll/directx/wine/d3d11/utils.c b/dll/directx/wine/d3d11/utils.c index cd226b21fb8cf..065436cb4f5d8 100644 --- a/dll/directx/wine/d3d11/utils.c +++ b/dll/directx/wine/d3d11/utils.c @@ -17,9 +17,6 @@ * */ -#include "config.h" -#include "wine/port.h" - #include "d3d11_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d11); @@ -441,37 +438,10 @@ unsigned int wined3d_getdata_flags_from_d3d11_async_getdata_flags(unsigned int d return WINED3DGETDATA_FLUSH; } -UINT d3d11_bind_flags_from_wined3d_usage(DWORD wined3d_usage) -{ - UINT bind_flags = 0; - - if (wined3d_usage & WINED3DUSAGE_TEXTURE) - bind_flags |= D3D11_BIND_SHADER_RESOURCE; - if (wined3d_usage & WINED3DUSAGE_RENDERTARGET) - bind_flags |= D3D11_BIND_RENDER_TARGET; - - wined3d_usage &= ~(WINED3DUSAGE_TEXTURE | WINED3DUSAGE_RENDERTARGET); - if (wined3d_usage) - FIXME("Unhandled wined3d usage %#x.\n", wined3d_usage); - return bind_flags; -} - -DWORD wined3d_usage_from_d3d11(UINT bind_flags, enum D3D11_USAGE usage) +DWORD wined3d_usage_from_d3d11(enum D3D11_USAGE usage) { - static const DWORD handled = D3D11_BIND_SHADER_RESOURCE - | D3D11_BIND_RENDER_TARGET - | D3D11_BIND_DEPTH_STENCIL; DWORD wined3d_usage = 0; - if (bind_flags & D3D11_BIND_SHADER_RESOURCE) - wined3d_usage |= WINED3DUSAGE_TEXTURE; - if (bind_flags & D3D11_BIND_RENDER_TARGET) - wined3d_usage |= WINED3DUSAGE_RENDERTARGET; - if (bind_flags & D3D11_BIND_DEPTH_STENCIL) - wined3d_usage |= WINED3DUSAGE_DEPTHSTENCIL; - if (bind_flags & ~handled) - FIXME("Unhandled bind flags %#x.\n", bind_flags & ~handled); - if (usage == D3D11_USAGE_DYNAMIC) wined3d_usage |= WINED3DUSAGE_DYNAMIC; @@ -713,6 +683,10 @@ struct wined3d_resource *wined3d_resource_from_d3d11_resource(ID3D11Resource *re return wined3d_buffer_get_resource(unsafe_impl_from_ID3D11Buffer( (ID3D11Buffer *)resource)->wined3d_buffer); + case D3D11_RESOURCE_DIMENSION_TEXTURE1D: + return wined3d_texture_get_resource(unsafe_impl_from_ID3D11Texture1D( + (ID3D11Texture1D *)resource)->wined3d_texture); + case D3D11_RESOURCE_DIMENSION_TEXTURE2D: return wined3d_texture_get_resource(unsafe_impl_from_ID3D11Texture2D( (ID3D11Texture2D *)resource)->wined3d_texture); @@ -739,6 +713,10 @@ struct wined3d_resource *wined3d_resource_from_d3d10_resource(ID3D10Resource *re return wined3d_buffer_get_resource(unsafe_impl_from_ID3D10Buffer( (ID3D10Buffer *)resource)->wined3d_buffer); + case D3D10_RESOURCE_DIMENSION_TEXTURE1D: + return wined3d_texture_get_resource(unsafe_impl_from_ID3D10Texture1D( + (ID3D10Texture1D *)resource)->wined3d_texture); + case D3D10_RESOURCE_DIMENSION_TEXTURE2D: return wined3d_texture_get_resource(unsafe_impl_from_ID3D10Texture2D( (ID3D10Texture2D *)resource)->wined3d_texture); @@ -890,86 +868,3 @@ HRESULT d3d_set_private_data_interface(struct wined3d_private_store *store, return hr; } - -void skip_dword_unknown(const char **ptr, unsigned int count) -{ - unsigned int i; - DWORD d; - - WARN("Skipping %u unknown DWORDs:\n", count); - for (i = 0; i < count; ++i) - { - read_dword(ptr, &d); - WARN("\t0x%08x\n", d); - } -} - -HRESULT parse_dxbc(const char *data, SIZE_T data_size, - HRESULT (*chunk_handler)(const char *data, DWORD data_size, DWORD tag, void *ctx), void *ctx) -{ - const char *ptr = data; - HRESULT hr = S_OK; - DWORD chunk_count; - DWORD total_size; - unsigned int i; - DWORD version; - DWORD tag; - - read_dword(&ptr, &tag); - TRACE("tag: %s.\n", debugstr_an((const char *)&tag, 4)); - - if (tag != TAG_DXBC) - { - WARN("Wrong tag.\n"); - return E_INVALIDARG; - } - - WARN("Ignoring DXBC checksum.\n"); - skip_dword_unknown(&ptr, 4); - - read_dword(&ptr, &version); - TRACE("version: %#x.\n", version); - if (version != 0x00000001) - { - WARN("Got unexpected DXBC version %#x.\n", version); - return E_INVALIDARG; - } - - read_dword(&ptr, &total_size); - TRACE("total size: %#x\n", total_size); - - read_dword(&ptr, &chunk_count); - TRACE("chunk count: %#x\n", chunk_count); - - for (i = 0; i < chunk_count; ++i) - { - DWORD chunk_tag, chunk_size; - const char *chunk_ptr; - DWORD chunk_offset; - - read_dword(&ptr, &chunk_offset); - TRACE("chunk %u at offset %#x\n", i, chunk_offset); - - if (chunk_offset >= data_size || !require_space(chunk_offset, 2, sizeof(DWORD), data_size)) - { - WARN("Invalid chunk offset %#x (data size %#lx).\n", chunk_offset, data_size); - return E_FAIL; - } - - chunk_ptr = data + chunk_offset; - - read_dword(&chunk_ptr, &chunk_tag); - read_dword(&chunk_ptr, &chunk_size); - - if (!require_space(chunk_ptr - data, 1, chunk_size, data_size)) - { - WARN("Invalid chunk size %#x (data size %#lx, chunk offset %#x).\n", chunk_size, data_size, chunk_offset); - return E_FAIL; - } - - hr = chunk_handler(chunk_ptr, chunk_size, chunk_tag, ctx); - if (FAILED(hr)) break; - } - - return hr; -} diff --git a/dll/directx/wine/d3d11/view.c b/dll/directx/wine/d3d11/view.c index 2787c08ce0ed5..a6eddf59ce312 100644 --- a/dll/directx/wine/d3d11/view.c +++ b/dll/directx/wine/d3d11/view.c @@ -17,14 +17,79 @@ * */ -#include "config.h" -#include "wine/port.h" - #define NONAMELESSUNION #include "d3d11_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d11); +static HRESULT get_resource_properties(ID3D11Resource *resource, D3D11_RESOURCE_DIMENSION *dimension, + DXGI_FORMAT *format, unsigned int *miplevel_count, unsigned int *layer_count) +{ + ID3D11Resource_GetType(resource, dimension); + switch (*dimension) + { + case D3D11_RESOURCE_DIMENSION_BUFFER: + return S_OK; + + case D3D11_RESOURCE_DIMENSION_TEXTURE1D: + { + const struct d3d_texture1d *texture; + + if (!(texture = unsafe_impl_from_ID3D11Texture1D((ID3D11Texture1D *)resource))) + { + ERR("Cannot get implementation from ID3D11Texture1D.\n"); + return E_FAIL; + } + + *format = texture->desc.Format; + if (miplevel_count) + *miplevel_count = texture->desc.MipLevels; + *layer_count = texture->desc.ArraySize; + break; + } + + case D3D11_RESOURCE_DIMENSION_TEXTURE2D: + { + const struct d3d_texture2d *texture; + + if (!(texture = unsafe_impl_from_ID3D11Texture2D((ID3D11Texture2D *)resource))) + { + ERR("Cannot get implementation from ID3D11Texture2D.\n"); + return E_FAIL; + } + + *format = texture->desc.Format; + if (miplevel_count) + *miplevel_count = texture->desc.MipLevels; + *layer_count = texture->desc.ArraySize; + break; + } + + case D3D11_RESOURCE_DIMENSION_TEXTURE3D: + { + const struct d3d_texture3d *texture; + + if (!(texture = unsafe_impl_from_ID3D11Texture3D((ID3D11Texture3D *)resource))) + { + ERR("Cannot get implementation from ID3D11Texture3D.\n"); + return E_FAIL; + } + + *format = texture->desc.Format; + if (miplevel_count) + *miplevel_count = texture->desc.MipLevels; + *layer_count = texture->desc.Depth; + break; + } + + default: + WARN("Invalid resource dimension %#x.\n", *dimension); + return E_INVALIDARG; + } + + return S_OK; +} + static HRESULT set_dsv_desc_from_resource(D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3D11Resource *resource) { D3D11_RESOURCE_DIMENSION dimension; @@ -113,10 +178,10 @@ static HRESULT set_dsv_desc_from_resource(D3D11_DEPTH_STENCIL_VIEW_DESC *desc, I return S_OK; } - default: - ERR("Unhandled resource dimension %#x.\n", dimension); case D3D11_RESOURCE_DIMENSION_BUFFER: case D3D11_RESOURCE_DIMENSION_TEXTURE3D: + default: + WARN("Invalid resource dimension %#x.\n", dimension); return E_INVALIDARG; } } @@ -126,27 +191,22 @@ static HRESULT normalize_dsv_desc(D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3D11Res D3D11_RESOURCE_DIMENSION dimension; unsigned int layer_count; DXGI_FORMAT format; + HRESULT hr; - ID3D11Resource_GetType(resource, &dimension); + if (FAILED(hr = get_resource_properties(resource, &dimension, &format, NULL, &layer_count))) + return hr; switch (dimension) { case D3D11_RESOURCE_DIMENSION_TEXTURE1D: - { if (desc->ViewDimension != D3D11_DSV_DIMENSION_TEXTURE1D && desc->ViewDimension != D3D11_DSV_DIMENSION_TEXTURE1DARRAY) { WARN("Incompatible dimensions %#x, %#x.\n", dimension, desc->ViewDimension); return E_INVALIDARG; } - - FIXME("Unhandled 1D texture resource.\n"); - return S_OK; - } + break; case D3D11_RESOURCE_DIMENSION_TEXTURE2D: - { - const struct d3d_texture2d *texture; - if (desc->ViewDimension != D3D11_DSV_DIMENSION_TEXTURE2D && desc->ViewDimension != D3D11_DSV_DIMENSION_TEXTURE2DARRAY && desc->ViewDimension != D3D11_DSV_DIMENSION_TEXTURE2DMS @@ -155,26 +215,13 @@ static HRESULT normalize_dsv_desc(D3D11_DEPTH_STENCIL_VIEW_DESC *desc, ID3D11Res WARN("Incompatible dimensions %#x, %#x.\n", dimension, desc->ViewDimension); return E_INVALIDARG; } - - if (!(texture = unsafe_impl_from_ID3D11Texture2D((ID3D11Texture2D *)resource))) - { - ERR("Cannot get implementation from ID3D11Texture2D.\n"); - return E_FAIL; - } - - format = texture->desc.Format; - layer_count = texture->desc.ArraySize; break; - } case D3D11_RESOURCE_DIMENSION_BUFFER: case D3D11_RESOURCE_DIMENSION_TEXTURE3D: + default: WARN("Invalid resource dimension %#x.\n", dimension); return E_INVALIDARG; - - default: - ERR("Unhandled resource dimension %#x.\n", dimension); - return E_FAIL; } if (desc->Format == DXGI_FORMAT_UNKNOWN) @@ -328,37 +375,30 @@ static HRESULT normalize_rtv_desc(D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3D11Res D3D11_RESOURCE_DIMENSION dimension; unsigned int layer_count; DXGI_FORMAT format; + HRESULT hr; - ID3D11Resource_GetType(resource, &dimension); + if (FAILED(hr = get_resource_properties(resource, &dimension, &format, NULL, &layer_count))) + return hr; switch (dimension) { case D3D11_RESOURCE_DIMENSION_BUFFER: - { if (desc->ViewDimension != D3D11_RTV_DIMENSION_BUFFER) { WARN("Incompatible dimensions %#x, %#x.\n", dimension, desc->ViewDimension); return E_INVALIDARG; } return S_OK; - } case D3D11_RESOURCE_DIMENSION_TEXTURE1D: - { if (desc->ViewDimension != D3D11_RTV_DIMENSION_TEXTURE1D && desc->ViewDimension != D3D11_RTV_DIMENSION_TEXTURE1DARRAY) { WARN("Incompatible dimensions %#x, %#x.\n", dimension, desc->ViewDimension); return E_INVALIDARG; } - - FIXME("Unhandled 1D texture resource.\n"); - return S_OK; - } + break; case D3D11_RESOURCE_DIMENSION_TEXTURE2D: - { - const struct d3d_texture2d *texture; - if (desc->ViewDimension != D3D11_RTV_DIMENSION_TEXTURE2D && desc->ViewDimension != D3D11_RTV_DIMENSION_TEXTURE2DARRAY && desc->ViewDimension != D3D11_RTV_DIMENSION_TEXTURE2DMS @@ -367,42 +407,19 @@ static HRESULT normalize_rtv_desc(D3D11_RENDER_TARGET_VIEW_DESC *desc, ID3D11Res WARN("Incompatible dimensions %#x, %#x.\n", dimension, desc->ViewDimension); return E_INVALIDARG; } - - if (!(texture = unsafe_impl_from_ID3D11Texture2D((ID3D11Texture2D *)resource))) - { - ERR("Cannot get implementation from ID3D11Texture2D.\n"); - return E_FAIL; - } - - format = texture->desc.Format; - layer_count = texture->desc.ArraySize; break; - } case D3D11_RESOURCE_DIMENSION_TEXTURE3D: - { - const struct d3d_texture3d *texture; - if (desc->ViewDimension != D3D11_RTV_DIMENSION_TEXTURE3D) { WARN("Incompatible dimensions %#x, %#x.\n", dimension, desc->ViewDimension); return E_INVALIDARG; } - - if (!(texture = unsafe_impl_from_ID3D11Texture3D((ID3D11Texture3D *)resource))) - { - ERR("Cannot get implementation from ID3D11Texture3D.\n"); - return E_FAIL; - } - - format = texture->desc.Format; - layer_count = texture->desc.Depth; break; - } default: - ERR("Unhandled resource dimension %#x.\n", dimension); - return E_FAIL; + WARN("Invalid resource dimension %#x.\n", dimension); + return E_INVALIDARG; } if (desc->Format == DXGI_FORMAT_UNKNOWN) @@ -594,7 +611,7 @@ static HRESULT set_srv_desc_from_resource(D3D11_SHADER_RESOURCE_VIEW_DESC *desc, } default: - ERR("Unhandled resource dimension %#x.\n", dimension); + WARN("Invalid resource dimension %#x.\n", dimension); return E_INVALIDARG; } } @@ -604,12 +621,13 @@ static HRESULT normalize_srv_desc(D3D11_SHADER_RESOURCE_VIEW_DESC *desc, ID3D11R unsigned int miplevel_count, layer_count; D3D11_RESOURCE_DIMENSION dimension; DXGI_FORMAT format; + HRESULT hr; - ID3D11Resource_GetType(resource, &dimension); + if (FAILED(hr = get_resource_properties(resource, &dimension, &format, &miplevel_count, &layer_count))) + return hr; switch (dimension) { case D3D11_RESOURCE_DIMENSION_BUFFER: - { if (desc->ViewDimension != D3D11_SRV_DIMENSION_BUFFER && desc->ViewDimension != D3D11_SRV_DIMENSION_BUFFEREX) { @@ -622,25 +640,17 @@ static HRESULT normalize_srv_desc(D3D11_SHADER_RESOURCE_VIEW_DESC *desc, ID3D11R return E_INVALIDARG; } return S_OK; - } case D3D11_RESOURCE_DIMENSION_TEXTURE1D: - { if (desc->ViewDimension != D3D11_SRV_DIMENSION_TEXTURE1D && desc->ViewDimension != D3D11_SRV_DIMENSION_TEXTURE1DARRAY) { WARN("Incompatible dimensions %#x, %#x.\n", dimension, desc->ViewDimension); return E_INVALIDARG; } - - FIXME("Unhandled 1D texture resource.\n"); - return S_OK; - } + break; case D3D11_RESOURCE_DIMENSION_TEXTURE2D: - { - const struct d3d_texture2d *texture; - if (desc->ViewDimension != D3D11_SRV_DIMENSION_TEXTURE2D && desc->ViewDimension != D3D11_SRV_DIMENSION_TEXTURE2DARRAY && desc->ViewDimension != D3D11_SRV_DIMENSION_TEXTURE2DMS @@ -651,44 +661,19 @@ static HRESULT normalize_srv_desc(D3D11_SHADER_RESOURCE_VIEW_DESC *desc, ID3D11R WARN("Incompatible dimensions %#x, %#x.\n", dimension, desc->ViewDimension); return E_INVALIDARG; } - - if (!(texture = unsafe_impl_from_ID3D11Texture2D((ID3D11Texture2D *)resource))) - { - ERR("Cannot get implementation from ID3D11Texture2D.\n"); - return E_FAIL; - } - - format = texture->desc.Format; - miplevel_count = texture->desc.MipLevels; - layer_count = texture->desc.ArraySize; break; - } case D3D11_RESOURCE_DIMENSION_TEXTURE3D: - { - const struct d3d_texture3d *texture; - if (desc->ViewDimension != D3D11_SRV_DIMENSION_TEXTURE3D) { WARN("Incompatible dimensions %#x, %#x.\n", dimension, desc->ViewDimension); return E_INVALIDARG; } - - if (!(texture = unsafe_impl_from_ID3D11Texture3D((ID3D11Texture3D *)resource))) - { - ERR("Cannot get implementation from ID3D11Texture3D.\n"); - return E_FAIL; - } - - format = texture->desc.Format; - miplevel_count = texture->desc.MipLevels; - layer_count = 1; break; - } default: - ERR("Unhandled resource dimension %#x.\n", dimension); - return E_FAIL; + WARN("Invalid resource dimension %#x.\n", dimension); + return E_INVALIDARG; } if (desc->Format == DXGI_FORMAT_UNKNOWN) @@ -855,79 +840,49 @@ static HRESULT normalize_uav_desc(D3D11_UNORDERED_ACCESS_VIEW_DESC *desc, ID3D11 D3D11_RESOURCE_DIMENSION dimension; unsigned int layer_count; DXGI_FORMAT format; + HRESULT hr; - ID3D11Resource_GetType(resource, &dimension); + if (FAILED(hr = get_resource_properties(resource, &dimension, &format, NULL, &layer_count))) + return hr; switch (dimension) { case D3D11_RESOURCE_DIMENSION_BUFFER: - { if (desc->ViewDimension != D3D11_UAV_DIMENSION_BUFFER) { WARN("Incompatible dimensions %#x, %#x.\n", dimension, desc->ViewDimension); return E_INVALIDARG; } return S_OK; - } case D3D11_RESOURCE_DIMENSION_TEXTURE1D: - { if (desc->ViewDimension != D3D11_UAV_DIMENSION_TEXTURE1D && desc->ViewDimension != D3D11_UAV_DIMENSION_TEXTURE1DARRAY) { WARN("Incompatible dimensions %#x, %#x.\n", dimension, desc->ViewDimension); return E_INVALIDARG; } - - FIXME("Unhandled 1D texture resource.\n"); - return S_OK; - } + break; case D3D11_RESOURCE_DIMENSION_TEXTURE2D: - { - const struct d3d_texture2d *texture; - if (desc->ViewDimension != D3D11_UAV_DIMENSION_TEXTURE2D && desc->ViewDimension != D3D11_UAV_DIMENSION_TEXTURE2DARRAY) { WARN("Incompatible dimensions %#x, %#x.\n", dimension, desc->ViewDimension); return E_INVALIDARG; } - - if (!(texture = unsafe_impl_from_ID3D11Texture2D((ID3D11Texture2D *)resource))) - { - ERR("Cannot get implementation from ID3D11Texture2D.\n"); - return E_FAIL; - } - - format = texture->desc.Format; - layer_count = texture->desc.ArraySize; break; - } case D3D11_RESOURCE_DIMENSION_TEXTURE3D: - { - const struct d3d_texture3d *texture; - if (desc->ViewDimension != D3D11_UAV_DIMENSION_TEXTURE3D) { WARN("Incompatible dimensions %#x, %#x.\n", dimension, desc->ViewDimension); return E_INVALIDARG; } - - if (!(texture = unsafe_impl_from_ID3D11Texture3D((ID3D11Texture3D *)resource))) - { - ERR("Cannot get implementation from ID3D11Texture3D.\n"); - return E_FAIL; - } - - format = texture->desc.Format; - layer_count = texture->desc.Depth; break; - } default: - ERR("Unhandled resource dimension %#x.\n", dimension); - return E_FAIL; + WARN("Invalid resource dimension %#x.\n", dimension); + return E_INVALIDARG; } if (desc->Format == DXGI_FORMAT_UNKNOWN) @@ -1006,7 +961,7 @@ static ULONG STDMETHODCALLTYPE d3d11_depthstencil_view_AddRef(ID3D11DepthStencil if (refcount == 1) { - ID3D11Device_AddRef(view->device); + ID3D11Device2_AddRef(view->device); wined3d_mutex_lock(); wined3d_rendertarget_view_incref(view->wined3d_view); wined3d_mutex_unlock(); @@ -1024,13 +979,13 @@ static ULONG STDMETHODCALLTYPE d3d11_depthstencil_view_Release(ID3D11DepthStenci if (!refcount) { - ID3D11Device *device = view->device; + ID3D11Device2 *device = view->device; wined3d_mutex_lock(); wined3d_rendertarget_view_decref(view->wined3d_view); wined3d_mutex_unlock(); - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -1043,7 +998,7 @@ static void STDMETHODCALLTYPE d3d11_depthstencil_view_GetDevice(ID3D11DepthStenc TRACE("iface %p, device %p.\n", iface, device); - *device = view->device; + *device = (ID3D11Device *)view->device; ID3D11Device_AddRef(*device); } @@ -1160,7 +1115,7 @@ static void STDMETHODCALLTYPE d3d10_depthstencil_view_GetDevice(ID3D10DepthStenc TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_QueryInterface(view->device, &IID_ID3D10Device, (void **)device); + ID3D11Device2_QueryInterface(view->device, &IID_ID3D10Device, (void **)device); } static HRESULT STDMETHODCALLTYPE d3d10_depthstencil_view_GetPrivateData(ID3D10DepthStencilView *iface, @@ -1355,8 +1310,7 @@ static HRESULT d3d_depthstencil_view_init(struct d3d_depthstencil_view *view, st wined3d_private_store_init(&view->private_store); wined3d_mutex_unlock(); view->resource = resource; - view->device = &device->ID3D11Device_iface; - ID3D11Device_AddRef(view->device); + ID3D11Device2_AddRef(view->device = &device->ID3D11Device2_iface); return S_OK; } @@ -1449,7 +1403,7 @@ static ULONG STDMETHODCALLTYPE d3d11_rendertarget_view_AddRef(ID3D11RenderTarget if (refcount == 1) { - ID3D11Device_AddRef(view->device); + ID3D11Device2_AddRef(view->device); wined3d_mutex_lock(); wined3d_rendertarget_view_incref(view->wined3d_view); wined3d_mutex_unlock(); @@ -1467,13 +1421,13 @@ static ULONG STDMETHODCALLTYPE d3d11_rendertarget_view_Release(ID3D11RenderTarge if (!refcount) { - ID3D11Device *device = view->device; + ID3D11Device2 *device = view->device; wined3d_mutex_lock(); wined3d_rendertarget_view_decref(view->wined3d_view); wined3d_mutex_unlock(); - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -1486,7 +1440,7 @@ static void STDMETHODCALLTYPE d3d11_rendertarget_view_GetDevice(ID3D11RenderTarg TRACE("iface %p, device %p.\n", iface, device); - *device = view->device; + *device = (ID3D11Device *)view->device; ID3D11Device_AddRef(*device); } @@ -1603,7 +1557,7 @@ static void STDMETHODCALLTYPE d3d10_rendertarget_view_GetDevice(ID3D10RenderTarg TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_QueryInterface(view->device, &IID_ID3D10Device, (void **)device); + ID3D11Device2_QueryInterface(view->device, &IID_ID3D10Device, (void **)device); } static HRESULT STDMETHODCALLTYPE d3d10_rendertarget_view_GetPrivateData(ID3D10RenderTargetView *iface, @@ -1803,8 +1757,7 @@ static HRESULT d3d_rendertarget_view_init(struct d3d_rendertarget_view *view, st wined3d_private_store_init(&view->private_store); wined3d_mutex_unlock(); view->resource = resource; - view->device = &device->ID3D11Device_iface; - ID3D11Device_AddRef(view->device); + ID3D11Device2_AddRef(view->device = &device->ID3D11Device2_iface); return S_OK; } @@ -1898,7 +1851,7 @@ static ULONG STDMETHODCALLTYPE d3d11_shader_resource_view_AddRef(ID3D11ShaderRes if (refcount == 1) { - ID3D11Device_AddRef(view->device); + ID3D11Device2_AddRef(view->device); wined3d_mutex_lock(); wined3d_shader_resource_view_incref(view->wined3d_view); wined3d_mutex_unlock(); @@ -1916,13 +1869,13 @@ static ULONG STDMETHODCALLTYPE d3d11_shader_resource_view_Release(ID3D11ShaderRe if (!refcount) { - ID3D11Device *device = view->device; + ID3D11Device2 *device = view->device; wined3d_mutex_lock(); wined3d_shader_resource_view_decref(view->wined3d_view); wined3d_mutex_unlock(); - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -1935,7 +1888,7 @@ static void STDMETHODCALLTYPE d3d11_shader_resource_view_GetDevice(ID3D11ShaderR TRACE("iface %p, device %p.\n", iface, device); - *device = view->device; + *device = (ID3D11Device *)view->device; ID3D11Device_AddRef(*device); } @@ -2053,7 +2006,7 @@ static void STDMETHODCALLTYPE d3d10_shader_resource_view_GetDevice(ID3D10ShaderR TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_QueryInterface(view->device, &IID_ID3D10Device, (void **)device); + ID3D11Device2_QueryInterface(view->device, &IID_ID3D10Device, (void **)device); } static HRESULT STDMETHODCALLTYPE d3d10_shader_resource_view_GetPrivateData(ID3D10ShaderResourceView1 *iface, @@ -2304,8 +2257,7 @@ static HRESULT d3d_shader_resource_view_init(struct d3d_shader_resource_view *vi wined3d_private_store_init(&view->private_store); wined3d_mutex_unlock(); view->resource = resource; - view->device = &device->ID3D11Device_iface; - ID3D11Device_AddRef(view->device); + ID3D11Device2_AddRef(view->device = &device->ID3D11Device2_iface); return S_OK; } @@ -2384,7 +2336,7 @@ static ULONG STDMETHODCALLTYPE d3d11_unordered_access_view_AddRef(ID3D11Unordere if (refcount == 1) { - ID3D11Device_AddRef(view->device); + ID3D11Device2_AddRef(view->device); wined3d_mutex_lock(); wined3d_unordered_access_view_incref(view->wined3d_view); wined3d_mutex_unlock(); @@ -2402,13 +2354,13 @@ static ULONG STDMETHODCALLTYPE d3d11_unordered_access_view_Release(ID3D11Unorder if (!refcount) { - ID3D11Device *device = view->device; + ID3D11Device2 *device = view->device; wined3d_mutex_lock(); wined3d_unordered_access_view_decref(view->wined3d_view); wined3d_mutex_unlock(); - ID3D11Device_Release(device); + ID3D11Device2_Release(device); } return refcount; @@ -2421,7 +2373,7 @@ static void STDMETHODCALLTYPE d3d11_unordered_access_view_GetDevice(ID3D11Unorde TRACE("iface %p, device %p.\n", iface, device); - ID3D11Device_AddRef(*device = view->device); + ID3D11Device_AddRef(*device = (ID3D11Device *)view->device); } static HRESULT STDMETHODCALLTYPE d3d11_unordered_access_view_GetPrivateData(ID3D11UnorderedAccessView *iface, @@ -2614,7 +2566,7 @@ static HRESULT d3d11_unordered_access_view_init(struct d3d11_unordered_access_vi wined3d_private_store_init(&view->private_store); wined3d_mutex_unlock(); view->resource = resource; - ID3D11Device_AddRef(view->device = &device->ID3D11Device_iface); + ID3D11Device2_AddRef(view->device = &device->ID3D11Device2_iface); return S_OK; } diff --git a/dll/directx/wine/d3d12/d3d12.spec b/dll/directx/wine/d3d12/d3d12.spec index 613092bc88a0a..7c2ae9880674b 100644 --- a/dll/directx/wine/d3d12/d3d12.spec +++ b/dll/directx/wine/d3d12/d3d12.spec @@ -1,8 +1,11 @@ 100 stub GetBehaviorValue 101 stdcall D3D12CreateDevice(ptr long ptr ptr) 102 stdcall D3D12GetDebugInterface(ptr ptr) -103 stub D3D12CoreCreateLayeredDevice -104 stub D3D12CoreGetLayeredDeviceSize -105 stub D3D12CoreRegisterLayers -106 stub D3D12CreateRootSignatureDeserializer -107 stub D3D12SerializeRootSignature +@ stub D3D12CoreCreateLayeredDevice +@ stub D3D12CoreGetLayeredDeviceSize +@ stub D3D12CoreRegisterLayers +@ stdcall D3D12CreateRootSignatureDeserializer(ptr long ptr ptr) +#@ stub D3D12CreateVersionedRootSignatureDeserializer +@ stdcall D3D12EnableExperimentalFeatures(long ptr ptr ptr) +@ stdcall D3D12SerializeRootSignature(ptr long ptr ptr) +@ stdcall D3D12SerializeVersionedRootSignature(ptr ptr ptr) diff --git a/dll/directx/wine/d3d12/d3d12_main.c b/dll/directx/wine/d3d12/d3d12_main.c index c1598ca2a1a58..8d41497a2a434 100644 --- a/dll/directx/wine/d3d12/d3d12_main.c +++ b/dll/directx/wine/d3d12/d3d12_main.c @@ -20,23 +20,409 @@ #include "config.h" #include "wine/port.h" +#define COBJMACROS +#define VK_NO_PROTOTYPES +#define VKD3D_NO_VULKAN_H +#define VKD3D_NO_WIN32_TYPES +#ifndef USE_WIN32_VULKAN +#define USE_WIN32_VULKAN +#endif + #include "wine/debug.h" +#include "wine/heap.h" +#include "wine/vulkan.h" +#include "wine/vulkan_driver.h" + +#include "dxgi1_6.h" #include "d3d12.h" +//#include + +#include "initguid.h" +#include "wine/wined3d.h" +#include "wine/winedxgi.h" + WINE_DEFAULT_DEBUG_CHANNEL(d3d12); +WINE_DECLARE_DEBUG_CHANNEL(winediag); + +#ifdef USE_WIN32_VULKAN + +static HMODULE vulkan_module; + +/* FIXME: We should unload vulkan-1.dll. */ +static BOOL WINAPI load_vulkan_dll_once(INIT_ONCE *once, void *param, void **context) +{ + vulkan_module = LoadLibraryA("vulkan-1.dll"); + return TRUE; +} + +static PFN_vkGetInstanceProcAddr load_vulkan(void) +{ + static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT; + + InitOnceExecuteOnce(&init_once, load_vulkan_dll_once, NULL, NULL); + + if (vulkan_module) + return (void *)GetProcAddress(vulkan_module, "vkGetInstanceProcAddr"); + + return NULL; +} + +#else + +static PFN_vkGetInstanceProcAddr load_vulkan(void) +{ + const struct vulkan_funcs *vk_funcs; + HDC hdc; + + hdc = GetDC(0); + vk_funcs = __wine_get_vulkan_driver(hdc, WINE_VULKAN_DRIVER_VERSION); + ReleaseDC(0, hdc); + + if (vk_funcs) + return (PFN_vkGetInstanceProcAddr)vk_funcs->p_vkGetInstanceProcAddr; + + return NULL; +} + +#endif /* USE_WIN32_VULKAN */ HRESULT WINAPI D3D12GetDebugInterface(REFIID iid, void **debug) { - FIXME("iid %s, debug %p stub!\n", debugstr_guid(iid), debug); + TRACE("iid %s, debug %p.\n", debugstr_guid(iid), debug); - return E_NOTIMPL; + WARN("Returning DXGI_ERROR_SDK_COMPONENT_MISSING.\n"); + return DXGI_ERROR_SDK_COMPONENT_MISSING; +} + +HRESULT WINAPI D3D12EnableExperimentalFeatures(UINT feature_count, + const IID *iids, void *configurations, UINT *configurations_sizes) +{ + FIXME("feature_count %u, iids %p, configurations %p, configurations_sizes %p stub!\n", + feature_count, iids, configurations, configurations_sizes); + + return E_NOINTERFACE; +} + +static HRESULT d3d12_signal_event(HANDLE event) +{ + return SetEvent(event) ? S_OK : E_FAIL; +} + +struct d3d12_thread_data +{ + PFN_vkd3d_thread main_pfn; + void *data; +}; + +static DWORD WINAPI d3d12_thread_main(void *data) +{ + struct d3d12_thread_data *thread_data = data; + + thread_data->main_pfn(thread_data->data); + heap_free(thread_data); + return 0; +} + +static void *d3d12_create_thread(PFN_vkd3d_thread main_pfn, void *data) +{ + struct d3d12_thread_data *thread_data; + HANDLE thread; + + if (!(thread_data = heap_alloc(sizeof(*thread_data)))) + { + ERR("Failed to allocate thread data.\n"); + return NULL; + } + + thread_data->main_pfn = main_pfn; + thread_data->data = data; + + if (!(thread = CreateThread(NULL, 0, d3d12_thread_main, thread_data, 0, NULL))) + heap_free(thread_data); + + return thread; +} + +static HRESULT d3d12_join_thread(void *handle) +{ + HANDLE thread = handle; + DWORD ret; + + if ((ret = WaitForSingleObject(thread, INFINITE)) != WAIT_OBJECT_0) + ERR("Failed to wait for thread, ret %#x.\n", ret); + CloseHandle(thread); + return ret == WAIT_OBJECT_0 ? S_OK : E_FAIL; +} + +static HRESULT d3d12_get_adapter(IWineDXGIAdapter **wine_adapter, IUnknown *adapter) +{ + IDXGIAdapter *dxgi_adapter = NULL; + IDXGIFactory4 *factory = NULL; + HRESULT hr; + + if (!adapter) + { + if (FAILED(hr = CreateDXGIFactory2(0, &IID_IDXGIFactory4, (void **)&factory))) + { + WARN("Failed to create DXGI factory, hr %#x.\n", hr); + goto done; + } + + if (FAILED(hr = IDXGIFactory4_EnumAdapters(factory, 0, &dxgi_adapter))) + { + WARN("Failed to enumerate primary adapter, hr %#x.\n", hr); + goto done; + } + + adapter = (IUnknown *)dxgi_adapter; + } + + if (FAILED(hr = IUnknown_QueryInterface(adapter, &IID_IWineDXGIAdapter, (void **)wine_adapter))) + WARN("Invalid adapter %p, hr %#x.\n", adapter, hr); + +done: + if (dxgi_adapter) + IDXGIAdapter_Release(dxgi_adapter); + if (factory) + IDXGIFactory4_Release(factory); + + return hr; +} + +static BOOL check_vk_instance_extension(VkInstance vk_instance, + PFN_vkGetInstanceProcAddr pfn_vkGetInstanceProcAddr, const char *name) +{ + PFN_vkEnumerateInstanceExtensionProperties pfn_vkEnumerateInstanceExtensionProperties; + VkExtensionProperties *properties; + BOOL ret = FALSE; + unsigned int i; + uint32_t count; + + pfn_vkEnumerateInstanceExtensionProperties + = (void *)pfn_vkGetInstanceProcAddr(vk_instance, "vkEnumerateInstanceExtensionProperties"); + + if (pfn_vkEnumerateInstanceExtensionProperties(NULL, &count, NULL) < 0) + return FALSE; + + if (!(properties = heap_calloc(count, sizeof(*properties)))) + return FALSE; + + if (pfn_vkEnumerateInstanceExtensionProperties(NULL, &count, properties) >= 0) + { + for (i = 0; i < count; ++i) + { + if (!strcmp(properties[i].extensionName, name)) + { + ret = TRUE; + break; + } + } + } + + heap_free(properties); + return ret; +} + +static VkPhysicalDevice d3d12_get_vk_physical_device(struct vkd3d_instance *instance, + PFN_vkGetInstanceProcAddr pfn_vkGetInstanceProcAddr, const struct wine_dxgi_adapter_info *adapter_info) +{ + PFN_vkGetPhysicalDeviceProperties2 pfn_vkGetPhysicalDeviceProperties2 = NULL; + PFN_vkGetPhysicalDeviceProperties pfn_vkGetPhysicalDeviceProperties; + PFN_vkEnumeratePhysicalDevices pfn_vkEnumeratePhysicalDevices; + VkPhysicalDevice vk_physical_device = VK_NULL_HANDLE; + VkPhysicalDeviceIDProperties id_properties; + VkPhysicalDeviceProperties2 properties2; + VkPhysicalDeviceProperties properties; + VkPhysicalDevice *vk_physical_devices; + VkInstance vk_instance; + unsigned int i; + uint32_t count; + VkResult vr; + + vk_instance = vkd3d_instance_get_vk_instance(instance); + + pfn_vkEnumeratePhysicalDevices = (void *)pfn_vkGetInstanceProcAddr(vk_instance, "vkEnumeratePhysicalDevices"); + + pfn_vkGetPhysicalDeviceProperties = (void *)pfn_vkGetInstanceProcAddr(vk_instance, "vkGetPhysicalDeviceProperties"); + if (check_vk_instance_extension(vk_instance, pfn_vkGetInstanceProcAddr, VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME)) + pfn_vkGetPhysicalDeviceProperties2 = (void *)pfn_vkGetInstanceProcAddr(vk_instance, "vkGetPhysicalDeviceProperties2KHR"); + + if ((vr = pfn_vkEnumeratePhysicalDevices(vk_instance, &count, NULL)) < 0) + { + WARN("Failed to get device count, vr %d.\n", vr); + return VK_NULL_HANDLE; + } + if (!count) + { + WARN("No physical device available.\n"); + return VK_NULL_HANDLE; + } + + if (!(vk_physical_devices = heap_calloc(count, sizeof(*vk_physical_devices)))) + return VK_NULL_HANDLE; + + if ((vr = pfn_vkEnumeratePhysicalDevices(vk_instance, &count, vk_physical_devices)) < 0) + goto done; + + if (!IsEqualGUID(&adapter_info->driver_uuid, &GUID_NULL) && pfn_vkGetPhysicalDeviceProperties2) + { + TRACE("Matching adapters by UUIDs.\n"); + + for (i = 0; i < count; ++i) + { + memset(&id_properties, 0, sizeof(id_properties)); + id_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES; + + properties2.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROPERTIES_2; + properties2.pNext = &id_properties; + + pfn_vkGetPhysicalDeviceProperties2(vk_physical_devices[i], &properties2); + + if (!memcmp(id_properties.driverUUID, &adapter_info->driver_uuid, VK_UUID_SIZE) + && !memcmp(id_properties.deviceUUID, &adapter_info->device_uuid, VK_UUID_SIZE)) + { + vk_physical_device = vk_physical_devices[i]; + break; + } + } + } + + if (!vk_physical_device) + { + WARN("Matching adapters by PCI IDs.\n"); + + for (i = 0; i < count; ++i) + { + pfn_vkGetPhysicalDeviceProperties(vk_physical_devices[i], &properties); + + if (properties.vendorID == adapter_info->vendor_id && properties.deviceID == adapter_info->device_id) + { + vk_physical_device = vk_physical_devices[i]; + break; + } + } + } + + if (!vk_physical_device) + FIXME("Could not find Vulkan physical device for DXGI adapter.\n"); + +done: + heap_free(vk_physical_devices); + return vk_physical_device; } HRESULT WINAPI D3D12CreateDevice(IUnknown *adapter, D3D_FEATURE_LEVEL minimum_feature_level, REFIID iid, void **device) { - FIXME("adapter %p, minimum_feature_level %#x, iid %s, device %p stub!\n", + struct vkd3d_optional_instance_extensions_info optional_extensions_info; + struct vkd3d_instance_create_info instance_create_info; + PFN_vkGetInstanceProcAddr pfn_vkGetInstanceProcAddr; + struct vkd3d_device_create_info device_create_info; + struct wine_dxgi_adapter_info adapter_info; + struct vkd3d_instance *instance; + IWineDXGIAdapter *wine_adapter; + HRESULT hr; + + static const char * const instance_extensions[] = + { + VK_KHR_SURFACE_EXTENSION_NAME, + VK_KHR_WIN32_SURFACE_EXTENSION_NAME, + }; + static const char * const optional_instance_extensions[] = + { + VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME, + }; + static const char * const device_extensions[] = + { + VK_KHR_SWAPCHAIN_EXTENSION_NAME, + }; + + TRACE("adapter %p, minimum_feature_level %#x, iid %s, device %p.\n", adapter, minimum_feature_level, debugstr_guid(iid), device); + if (!(pfn_vkGetInstanceProcAddr = load_vulkan())) + { + ERR_(winediag)("Failed to load Vulkan library.\n"); + return E_FAIL; + } + + if (FAILED(hr = d3d12_get_adapter(&wine_adapter, adapter))) + return hr; + + if (FAILED(hr = IWineDXGIAdapter_get_adapter_info(wine_adapter, &adapter_info))) + { + WARN("Failed to get adapter info, hr %#x.\n", hr); + goto done; + } + + optional_extensions_info.type = VKD3D_STRUCTURE_TYPE_OPTIONAL_INSTANCE_EXTENSIONS_INFO; + optional_extensions_info.next = NULL; + optional_extensions_info.extensions = optional_instance_extensions; + optional_extensions_info.extension_count = ARRAY_SIZE(optional_instance_extensions); + + instance_create_info.type = VKD3D_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; + instance_create_info.next = &optional_extensions_info; + instance_create_info.pfn_signal_event = d3d12_signal_event; + instance_create_info.pfn_create_thread = d3d12_create_thread; + instance_create_info.pfn_join_thread = d3d12_join_thread; + instance_create_info.wchar_size = sizeof(WCHAR); + instance_create_info.pfn_vkGetInstanceProcAddr = pfn_vkGetInstanceProcAddr; + instance_create_info.instance_extensions = instance_extensions; + instance_create_info.instance_extension_count = ARRAY_SIZE(instance_extensions); + + if (FAILED(hr = vkd3d_create_instance(&instance_create_info, &instance))) + { + WARN("Failed to create vkd3d instance, hr %#x.\n", hr); + goto done; + } + + device_create_info.type = VKD3D_STRUCTURE_TYPE_DEVICE_CREATE_INFO; + device_create_info.next = NULL; + device_create_info.minimum_feature_level = minimum_feature_level; + device_create_info.instance = instance; + device_create_info.instance_create_info = NULL; + device_create_info.vk_physical_device = d3d12_get_vk_physical_device(instance, pfn_vkGetInstanceProcAddr, &adapter_info); + device_create_info.device_extensions = device_extensions; + device_create_info.device_extension_count = ARRAY_SIZE(device_extensions); + device_create_info.parent = (IUnknown *)wine_adapter; + device_create_info.adapter_luid = adapter_info.luid; + + hr = vkd3d_create_device(&device_create_info, iid, device); + + vkd3d_instance_decref(instance); + +done: + IWineDXGIAdapter_Release(wine_adapter); + return hr; +} + +HRESULT WINAPI D3D12CreateRootSignatureDeserializer(const void *data, SIZE_T data_size, + REFIID iid, void **deserializer) +{ + TRACE("data %p, data_size %lu, iid %s, deserializer %p.\n", + data, data_size, debugstr_guid(iid), deserializer); + + return vkd3d_create_root_signature_deserializer(data, data_size, iid, deserializer); +} + +HRESULT WINAPI D3D12SerializeRootSignature(const D3D12_ROOT_SIGNATURE_DESC *root_signature_desc, + D3D_ROOT_SIGNATURE_VERSION version, ID3DBlob **blob, ID3DBlob **error_blob) +{ + TRACE("root_signature_desc %p, version %#x, blob %p, error_blob %p.\n", + root_signature_desc, version, blob, error_blob); + + return vkd3d_serialize_root_signature(root_signature_desc, version, blob, error_blob); +} + +HRESULT WINAPI D3D12SerializeVersionedRootSignature(const D3D12_VERSIONED_ROOT_SIGNATURE_DESC *desc, + ID3DBlob **blob, ID3DBlob **error_blob) +{ + TRACE("desc %p, blob %p, error_blob %p.\n", desc, blob, error_blob); + + if (desc->Version == D3D_ROOT_SIGNATURE_VERSION_1_0) + return vkd3d_serialize_root_signature(&desc->Desc_1_0, desc->Version, blob, error_blob); + + FIXME("Unsupported version %#x.\n", desc->Version); return E_NOTIMPL; } diff --git a/dll/directx/wine/d3d12core/CMakeLists.txt b/dll/directx/wine/d3d12core/CMakeLists.txt deleted file mode 100644 index 1b46f2a71b642..0000000000000 --- a/dll/directx/wine/d3d12core/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ - -add_definitions( - -D__WINESRC__ - -DUSE_WIN32_OPENGL) - -include_directories(${REACTOS_SOURCE_DIR}/include/reactos/wine) - -spec2def(d3d12core.dll d3d12core.spec ADD_IMPORTLIB) - -list(APPEND SOURCE) - -add_library(d3d12core SHARED - ${SOURCE} - ${CMAKE_CURRENT_BINARY_DIR}/d3d12core_stubs.c - ${CMAKE_CURRENT_BINARY_DIR}/d3d12core.def) - -set_module_type(d3d12core win32dll) -target_link_libraries(d3d12core wine uuid) -add_dependencies(d3d12core d3d_idl_headers) -add_importlibs(d3d12core msvcrt dxgi kernel32 ntdll) -add_cd_file(TARGET d3d12core DESTINATION reactos/system32 FOR all) diff --git a/dll/directx/wine/d3d12core/Makefile.in b/dll/directx/wine/d3d12core/Makefile.in deleted file mode 100644 index 8778b66138b8f..0000000000000 --- a/dll/directx/wine/d3d12core/Makefile.in +++ /dev/null @@ -1 +0,0 @@ -MODULE = d3d12core.dll diff --git a/dll/directx/wine/d3d12core/d3d12core.spec b/dll/directx/wine/d3d12core/d3d12core.spec deleted file mode 100644 index c9c73bd4ee492..0000000000000 --- a/dll/directx/wine/d3d12core/d3d12core.spec +++ /dev/null @@ -1,2 +0,0 @@ -@ stub D3D12GetInterface -@ stub D3D12SDKVersion diff --git a/sdk/lib/dxguid/dxguid-mingw.c b/sdk/lib/dxguid/dxguid-mingw.c index 99ae79b7f14df..3e79ec98d521a 100644 --- a/sdk/lib/dxguid/dxguid-mingw.c +++ b/sdk/lib/dxguid/dxguid-mingw.c @@ -50,6 +50,8 @@ DEFINE_GUID(IID_ID3D10Device,0x9B7E4C0F,0x342C,0x4106,0xA1,0x9F,0x4F,0x27,0x04,0 DEFINE_GUID(IID_ID3D10Multithread,0x9B7E4E00,0x342C,0x4106,0xA1,0x9F,0x4F,0x27,0x04,0xF6,0x89,0xF0); #endif #if 1 +DEFINE_GUID(IID_ID3D10StateBlock, 0x0803425a, 0x57f5, 0x4dd6, 0x94, 0x65, 0xa8, 0x75, 0x70, 0x83, 0x4a, 0x08); + DEFINE_GUID(IID_IDXGIObject,0xaec22fb8,0x76f3,0x4639,0x9b,0xe0,0x28,0xeb,0x43,0xa6,0x7a,0x2e); DEFINE_GUID(IID_IDXGIDeviceSubObject,0x3d3e0379,0xf9de,0x4d58,0xbb,0x6c,0x18,0xd6,0x29,0x92,0xf1,0xa6); DEFINE_GUID(IID_IDXGIResource,0x035f3ab4,0x482e,0x4e50,0xb4,0x1f,0x8a,0x7f,0x8b,0xd8,0x96,0x0b); @@ -62,6 +64,8 @@ DEFINE_GUID(IID_IDXGISwapChain,0x310d36a0,0xd2e7,0x4c0a,0xaa,0x04,0x6a,0x9d,0x23 DEFINE_GUID(IID_IDXGIFactory1,0x770aae78,0xf26f,0x4dba,0xa8,0x29,0x25,0x3c,0x83,0xd1,0xb3,0x87); DEFINE_GUID(IID_IDXGIAdapter1,0x29038f61,0x3839,0x4626,0x91,0xfd,0x08,0x68,0x79,0x01,0x1a,0x05); DEFINE_GUID(IID_IDXGIDevice1,0x77db970f,0x6276,0x48ba,0xba,0x28,0x07,0x01,0x43,0xb4,0x39,0x2c); +DEFINE_GUID(IID_ID3D10Effect, 0x51b0ca8b, 0xec0b, 0x4519, 0x87, 0x0d, 0x8e, 0xe1, 0xcb, 0x50, 0x17, 0xc7); +DEFINE_GUID(IID_ID3D10ShaderReflection, 0xd40e20b6, 0xf8f7, 0x42ad, 0xab, 0x20, 0x4b, 0xaf, 0x8f, 0x15, 0xdf, 0xaa); DEFINE_GUID(IID_IDXGIDisplayControl,0xea9dbf1a,0xc88e,0x4486,0x85,0x4a,0x98,0xaa,0x01,0x38,0xf3,0x0c); DEFINE_GUID(IID_IDXGIOutputDuplication,0x191cfac3,0xa341,0x470d,0xb2,0x6e,0xa8,0x64,0xf4,0x28,0x31,0x9c);