mf/session: Implement support for sinks that provide sample allocators.
[wine.git] / dlls / d3dx10_43 / d3dx10_43_main.c
blobb1c13d9e8ab83801e377ea1217d4fb873db220db
1 /*
2 * D3DX10 main file
4 * Copyright (c) 2010 Owen Rudge for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 #include "wine/debug.h"
24 #include <stdarg.h>
26 #define COBJMACROS
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winuser.h"
31 #include "objbase.h"
33 #include "d3d10_1.h"
34 #include "d3dx10.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(d3dx);
38 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
40 switch (fdwReason)
42 case DLL_WINE_PREATTACH:
43 return FALSE; /* prefer native version */
44 case DLL_PROCESS_ATTACH:
45 DisableThreadLibraryCalls(hinstDLL);
46 break;
49 return TRUE;
52 /***********************************************************************
53 * D3DX10CheckVersion
55 * Checks whether we are compiling against the correct d3d and d3dx library.
57 BOOL WINAPI D3DX10CheckVersion(UINT d3dsdkvers, UINT d3dxsdkvers)
59 if ((d3dsdkvers == D3D10_SDK_VERSION) && (d3dxsdkvers == 43))
60 return TRUE;
62 return FALSE;
65 HRESULT WINAPI D3DX10CreateEffectFromFileA(const char *filename, const D3D10_SHADER_MACRO *defines,
66 ID3D10Include *include, const char *profile, UINT hlslflags, UINT fxflags, ID3D10Device *device,
67 ID3D10EffectPool *effectpool, ID3DX10ThreadPump *pump, ID3D10Effect **effect, ID3D10Blob **errors,
68 HRESULT *hresult)
70 FIXME("filename %s, defines %p, include %p, profile %s, hlslflags %#x, fxflags %#x, "
71 "device %p, effectpool %p, pump %p, effect %p, errors %p, hresult %p\n",
72 debugstr_a(filename), defines, include, debugstr_a(profile), hlslflags, fxflags,
73 device, effectpool, pump, effect, errors, hresult);
75 return E_NOTIMPL;
78 HRESULT WINAPI D3DX10CreateEffectFromFileW(const WCHAR *filename, const D3D10_SHADER_MACRO *defines,
79 ID3D10Include *include, const char *profile, UINT hlslflags, UINT fxflags, ID3D10Device *device,
80 ID3D10EffectPool *effectpool, ID3DX10ThreadPump *pump, ID3D10Effect **effect, ID3D10Blob **errors,
81 HRESULT *hresult)
83 FIXME("filename %s, defines %p, include %p, profile %s, hlslflags %#x, fxflags %#x, "
84 "device %p, effectpool %p, pump %p, effect %p, errors %p, hresult %p\n",
85 debugstr_w(filename), defines, include, debugstr_a(profile), hlslflags, fxflags, device,
86 effectpool, pump, effect, errors, hresult);
88 return E_NOTIMPL;
91 HRESULT WINAPI D3DX10CreateEffectFromMemory(const void *data, SIZE_T datasize, const char *filename,
92 const D3D10_SHADER_MACRO *defines, ID3D10Include *include, const char *profile, UINT hlslflags,
93 UINT fxflags, ID3D10Device *device, ID3D10EffectPool *effectpool, ID3DX10ThreadPump *pump,
94 ID3D10Effect **effect, ID3D10Blob **errors, HRESULT *hresult)
96 FIXME("data %p, datasize %lu, filename %s, defines %p, include %p, profile %s, hlslflags %#x, fxflags %#x, "
97 "device %p, effectpool %p, pump %p, effect %p, errors %p, hresult %p\n",
98 data, datasize, debugstr_a(filename), defines, include, debugstr_a(profile), hlslflags, fxflags, device,
99 effectpool, pump, effect, errors, hresult);
101 return E_NOTIMPL;
104 HRESULT WINAPI D3DX10CreateEffectPoolFromMemory(const void *data, SIZE_T datasize, const char *filename,
105 const D3D10_SHADER_MACRO *defines, ID3D10Include *include, const char *profile, UINT hlslflags,
106 UINT fxflags, ID3D10Device *device, ID3DX10ThreadPump *pump, ID3D10EffectPool **effectpool,
107 ID3D10Blob **errors, HRESULT *hresult)
109 FIXME("data %p, datasize %lu, filename %s, defines %p, include %p, profile %s, hlslflags %#x, fxflags %#x, "
110 "device %p, pump %p, effectpool %p, errors %p, hresult %p.\n",
111 data, datasize, debugstr_a(filename), defines, include, debugstr_a(profile), hlslflags, fxflags, device,
112 pump, effectpool, errors, hresult);
114 return E_NOTIMPL;
117 HRESULT WINAPI D3DX10UnsetAllDeviceObjects(ID3D10Device *device)
119 static ID3D10ShaderResourceView * const views[D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT];
120 static ID3D10RenderTargetView * const target_views[D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT];
121 static ID3D10SamplerState * const sampler_states[D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT];
122 static ID3D10Buffer * const buffers[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
123 static const unsigned int so_offsets[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT] =
124 {~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u, ~0u};
125 static const unsigned int strides[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
126 static const unsigned int offsets[D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT];
127 static const float blend_factors[4];
129 TRACE("device %p.\n", device);
131 if (!device)
132 return E_INVALIDARG;
134 ID3D10Device_VSSetConstantBuffers(device, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, buffers);
135 ID3D10Device_PSSetConstantBuffers(device, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, buffers);
136 ID3D10Device_GSSetConstantBuffers(device, 0, D3D10_COMMONSHADER_CONSTANT_BUFFER_API_SLOT_COUNT, buffers);
138 ID3D10Device_VSSetSamplers(device, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, sampler_states);
139 ID3D10Device_PSSetSamplers(device, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, sampler_states);
140 ID3D10Device_GSSetSamplers(device, 0, D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT, sampler_states);
142 ID3D10Device_VSSetShaderResources(device, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, views);
143 ID3D10Device_PSSetShaderResources(device, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, views);
144 ID3D10Device_GSSetShaderResources(device, 0, D3D10_COMMONSHADER_INPUT_RESOURCE_SLOT_COUNT, views);
146 ID3D10Device_VSSetShader(device, NULL);
147 ID3D10Device_PSSetShader(device, NULL);
148 ID3D10Device_GSSetShader(device, NULL);
150 ID3D10Device_OMSetRenderTargets(device, D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT, target_views, NULL);
152 ID3D10Device_IASetIndexBuffer(device, NULL, DXGI_FORMAT_R32_UINT, 0);
153 ID3D10Device_IASetInputLayout(device, NULL);
154 ID3D10Device_IASetVertexBuffers(device, 0, D3D10_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT, buffers, strides, offsets);
156 ID3D10Device_SOSetTargets(device, D3D10_SO_BUFFER_SLOT_COUNT, buffers, so_offsets);
158 ID3D10Device_OMSetBlendState(device, NULL, blend_factors, 0);
159 ID3D10Device_OMSetDepthStencilState(device, NULL, 0);
161 ID3D10Device_RSSetState(device, NULL);
163 ID3D10Device_SetPredication(device, NULL, FALSE);
165 return S_OK;
168 HRESULT WINAPI D3DX10CreateDevice(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type,
169 HMODULE swrast, unsigned int flags, ID3D10Device **device)
171 HRESULT hr;
173 TRACE("adapter %p, driver_type %d, swrast %p, flags %#x, device %p.\n", adapter, driver_type,
174 swrast, flags, device);
176 if (SUCCEEDED(hr = D3D10CreateDevice1(adapter, driver_type, swrast, flags, D3D10_FEATURE_LEVEL_10_1,
177 D3D10_SDK_VERSION, (ID3D10Device1 **)device)))
178 return hr;
180 if (SUCCEEDED(hr = D3D10CreateDevice1(adapter, driver_type, swrast, flags, D3D10_FEATURE_LEVEL_10_0,
181 D3D10_SDK_VERSION, (ID3D10Device1 **)device)))
182 return hr;
184 return hr;
187 HRESULT WINAPI D3DX10CreateDeviceAndSwapChain(IDXGIAdapter *adapter, D3D10_DRIVER_TYPE driver_type,
188 HMODULE swrast, unsigned int flags, DXGI_SWAP_CHAIN_DESC *desc, IDXGISwapChain **swapchain,
189 ID3D10Device **device)
191 HRESULT hr;
193 TRACE("adapter %p, driver_type %d, swrast %p, flags %#x, desc %p, swapchain %p, device %p.\n",
194 adapter, driver_type, swrast, flags, desc, swapchain, device);
196 if (SUCCEEDED(hr = D3D10CreateDeviceAndSwapChain1(adapter, driver_type, swrast, flags, D3D10_FEATURE_LEVEL_10_1,
197 D3D10_1_SDK_VERSION, desc, swapchain, (ID3D10Device1 **)device)))
198 return hr;
200 return D3D10CreateDeviceAndSwapChain1(adapter, driver_type, swrast, flags, D3D10_FEATURE_LEVEL_10_0,
201 D3D10_1_SDK_VERSION, desc, swapchain, (ID3D10Device1 **)device);
204 HRESULT WINAPI D3DX10CreateTextureFromMemory(ID3D10Device *device, const void *src_data,
205 SIZE_T src_data_size, D3DX10_IMAGE_LOAD_INFO *loadinfo, ID3DX10ThreadPump *pump,
206 ID3D10Resource **texture, HRESULT *hresult)
208 FIXME("device %p, src_data %p, src_data_size %lu, loadinfo %p, pump %p, texture %p, "
209 "hresult %p, stub!\n",
210 device, src_data, src_data_size, loadinfo, pump, texture, hresult);
212 return E_NOTIMPL;
215 HRESULT WINAPI D3DX10FilterTexture(ID3D10Resource *texture, UINT src_level, UINT filter)
217 FIXME("texture %p, src_level %u, filter %#x stub!\n", texture, src_level, filter);
219 return E_NOTIMPL;
222 HRESULT WINAPI D3DX10GetFeatureLevel1(ID3D10Device *device, ID3D10Device1 **device1)
224 TRACE("device %p, device1 %p.\n", device, device1);
226 return ID3D10Device_QueryInterface(device, &IID_ID3D10Device1, (void **)device1);
229 D3DX_CPU_OPTIMIZATION WINAPI D3DXCpuOptimizations(BOOL enable)
231 FIXME("enable %#x stub.\n", enable);
233 return D3DX_NOT_OPTIMIZED;
236 HRESULT WINAPI D3DX10LoadTextureFromTexture(ID3D10Resource *src_texture, D3DX10_TEXTURE_LOAD_INFO *load_info,
237 ID3D10Resource *dst_texture)
239 FIXME("src_texture %p, load_info %p, dst_texture %p stub!\n", src_texture, load_info, dst_texture);
241 return E_NOTIMPL;