ReactOS 0.4.17-dev-934-g091855f
dxgi_main.c File Reference
#include "dxgi_private.h"
Include dependency graph for dxgi_main.c:

Go to the source code of this file.

Classes

struct  dxgi_main
 

Macros

#define DXGI_INIT_GUID
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (dxgi)
 
static void dxgi_main_cleanup (void)
 
BOOL WINAPI DllMain (HINSTANCE inst, DWORD reason, void *reserved)
 
HRESULT WINAPI CreateDXGIFactory2 (UINT flags, REFIID iid, void **factory)
 
HRESULT WINAPI CreateDXGIFactory1 (REFIID iid, void **factory)
 
HRESULT WINAPI CreateDXGIFactory (REFIID iid, void **factory)
 
static BOOL get_layer (enum dxgi_device_layer_id id, struct dxgi_device_layer *layer)
 
static HRESULT register_d3d10core_layers (HMODULE d3d10core)
 
HRESULT WINAPI DXGID3D10CreateDevice (HMODULE d3d10core, IDXGIFactory *factory, IDXGIAdapter *adapter, unsigned int flags, const D3D_FEATURE_LEVEL *feature_levels, unsigned int level_count, void **device)
 
HRESULT WINAPI DXGID3D10RegisterLayers (const struct dxgi_device_layer *layers, UINT layer_count)
 
HRESULT WINAPI DXGIGetDebugInterface1 (UINT flags, REFIID iid, void **debug)
 

Variables

static struct dxgi_main dxgi_main
 

Macro Definition Documentation

◆ DXGI_INIT_GUID

#define DXGI_INIT_GUID

Definition at line 20 of file dxgi_main.c.

Function Documentation

◆ CreateDXGIFactory()

HRESULT WINAPI CreateDXGIFactory ( REFIID  iid,
void **  factory 
)

Definition at line 73 of file dxgi_main.c.

74{
75 TRACE("iid %s, factory %p.\n", debugstr_guid(iid), factory);
76
77 return dxgi_factory_create(iid, factory, FALSE);
78}
#define FALSE
Definition: types.h:117
HRESULT dxgi_factory_create(REFIID riid, void **factory, BOOL extended)
Definition: factory.c:585
#define debugstr_guid
Definition: kernel32.h:35
#define TRACE(s)
Definition: solgame.cpp:4
Definition: main.c:439

Referenced by d3d10_create_device(), d3d10_create_device1(), and fill_videocontroller().

◆ CreateDXGIFactory1()

HRESULT WINAPI CreateDXGIFactory1 ( REFIID  iid,
void **  factory 
)

Definition at line 66 of file dxgi_main.c.

67{
68 TRACE("iid %s, factory %p.\n", debugstr_guid(iid), factory);
69
70 return dxgi_factory_create(iid, factory, TRUE);
71}
#define TRUE
Definition: types.h:120

Referenced by d3d11_create_device().

◆ CreateDXGIFactory2()

HRESULT WINAPI CreateDXGIFactory2 ( UINT  flags,
REFIID  iid,
void **  factory 
)

Definition at line 56 of file dxgi_main.c.

57{
58 TRACE("flags %#x, iid %s, factory %p.\n", flags, debugstr_guid(iid), factory);
59
60 if (flags)
61 FIXME("Ignoring flags %#x.\n", flags);
62
63 return dxgi_factory_create(iid, factory, TRUE);
64}
#define FIXME(fmt,...)
Definition: precomp.h:53
GLbitfield flags
Definition: glext.h:7161

Referenced by d3d12_get_adapter().

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  inst,
DWORD  reason,
void *  reserved 
)

Definition at line 39 of file dxgi_main.c.

40{
41 switch (reason)
42 {
45 break;
46
48 if (!reserved)
50 break;
51 }
52
53 return TRUE;
54}
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1971
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
r reserved
Definition: btrfs.c:3006
static void dxgi_main_cleanup(void)
Definition: dxgi_main.c:33

◆ dxgi_main_cleanup()

static void dxgi_main_cleanup ( void  )
static

Definition at line 33 of file dxgi_main.c.

34{
37}
#define free
Definition: debug_ros.c:5
#define FreeLibrary(x)
Definition: compat.h:748
HMODULE d3d10core
Definition: dxgi_main.c:27
struct dxgi_device_layer * device_layers
Definition: dxgi_main.c:28

Referenced by DllMain().

◆ DXGID3D10CreateDevice()

HRESULT WINAPI DXGID3D10CreateDevice ( HMODULE  d3d10core,
IDXGIFactory *  factory,
IDXGIAdapter *  adapter,
unsigned int  flags,
const D3D_FEATURE_LEVEL *  feature_levels,
unsigned int  level_count,
void **  device 
)

Definition at line 135 of file dxgi_main.c.

137{
138 struct layer_get_size_args get_size_args;
139 struct dxgi_device_layer d3d10_layer;
140 struct dxgi_device *dxgi_device;
141 UINT device_size;
142 DWORD count;
143 HRESULT hr;
144
145 TRACE("d3d10core %p, factory %p, adapter %p, flags %#x, feature_levels %p, level_count %u, device %p.\n",
146 d3d10core, factory, adapter, flags, feature_levels, level_count, device);
147
148 if (flags)
149 FIXME("Ignoring flags %#x.\n", flags);
150
151 if (TRACE_ON(dxgi))
153
154 hr = register_d3d10core_layers(d3d10core);
155 if (FAILED(hr))
156 {
157 ERR("Failed to register d3d10core layers, returning %#lx.\n", hr);
158 return hr;
159 }
160
161 if (!get_layer(DXGI_DEVICE_LAYER_D3D10_DEVICE, &d3d10_layer))
162 {
163 ERR("Failed to get D3D10 device layer.\n");
164 return E_FAIL;
165 }
166
167 count = 0;
168 hr = d3d10_layer.init(d3d10_layer.id, &count, NULL);
169 if (FAILED(hr))
170 {
171 WARN("Failed to initialize D3D10 device layer.\n");
172 return E_FAIL;
173 }
174
175 get_size_args.unknown0 = 0;
176 get_size_args.unknown1 = 0;
177 get_size_args.unknown2 = NULL;
178 get_size_args.unknown3 = NULL;
179 get_size_args.adapter = adapter;
180 get_size_args.interface_major = 10;
181 get_size_args.interface_minor = 1;
182 get_size_args.version_build = 4;
183 get_size_args.version_revision = 6000;
184
185 device_size = d3d10_layer.get_size(d3d10_layer.id, &get_size_args, 0);
186 device_size += sizeof(*dxgi_device);
187
188 if (!(dxgi_device = calloc(1, device_size)))
189 {
190 ERR("Failed to allocate device memory.\n");
191 return E_OUTOFMEMORY;
192 }
193
194 hr = dxgi_device_init(dxgi_device, &d3d10_layer, factory, adapter, feature_levels, level_count);
195 if (FAILED(hr))
196 {
197 WARN("Failed to initialize device, hr %#lx.\n", hr);
199 *device = NULL;
200 return hr;
201 }
202
203 TRACE("Created device %p.\n", dxgi_device);
205
206 return S_OK;
207}
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
@ DXGI_DEVICE_LAYER_D3D10_DEVICE
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_FAIL
Definition: ddrawi.h:102
HRESULT hr
Definition: delayimp.cpp:582
#define NULL
Definition: types.h:112
HRESULT dxgi_device_init(struct dxgi_device *device, struct dxgi_device_layer *layer, IDXGIFactory *factory, IDXGIAdapter *adapter, const D3D_FEATURE_LEVEL *feature_levels, unsigned int level_count)
Definition: device.c:486
#define TRACE_ON(x)
Definition: compat.h:75
static HRESULT register_d3d10core_layers(HMODULE d3d10core)
Definition: dxgi_main.c:100
static BOOL get_layer(enum dxgi_device_layer_id id, struct dxgi_device_layer *layer)
Definition: dxgi_main.c:80
void dump_feature_levels(const D3D_FEATURE_LEVEL *feature_levels, unsigned int level_count)
Definition: utils.c:410
unsigned long DWORD
Definition: ntddk_ex.h:95
return adapter
GLuint GLuint GLsizei count
Definition: gl.h:1545
unsigned int UINT
Definition: sysinfo.c:13
static D3D_DRIVER_TYPE HMODULE UINT const D3D_FEATURE_LEVEL * feature_levels
Definition: hlsl_d3d11.c:28
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define calloc
Definition: rosglue.h:14
Definition: devices.h:37
IWineDXGIDevice IWineDXGIDevice_iface
Definition: dxgi_private.h:129

Referenced by D3D10CoreCreateDevice(), and D3D11CoreCreateDevice().

◆ DXGID3D10RegisterLayers()

HRESULT WINAPI DXGID3D10RegisterLayers ( const struct dxgi_device_layer *  layers,
UINT  layer_count 
)

Definition at line 209 of file dxgi_main.c.

210{
211 UINT i;
212 struct dxgi_device_layer *new_layers;
213
214 TRACE("layers %p, layer_count %u\n", layers, layer_count);
215
217
218 new_layers = realloc(dxgi_main.device_layers,
219 (dxgi_main.layer_count + layer_count) * sizeof(*new_layers));
220
221 if (!new_layers)
222 {
224 ERR("Failed to allocate layer memory\n");
225 return E_OUTOFMEMORY;
226 }
227
228 for (i = 0; i < layer_count; ++i)
229 {
230 const struct dxgi_device_layer *layer = &layers[i];
231
232 TRACE("layer %d: id %#x, init %p, get_size %p, create %p\n",
233 i, layer->id, layer->init, layer->get_size, layer->create);
234
235 new_layers[dxgi_main.layer_count + i] = *layer;
236 }
237
238 dxgi_main.device_layers = new_layers;
239 dxgi_main.layer_count += layer_count;
240
242
243 return S_OK;
244}
#define realloc
Definition: debug_ros.c:6
GLenum GLuint GLint GLint layer
Definition: glext.h:7007
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
UINT layer_count
Definition: dxgi_main.c:29
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:544
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:539

Referenced by D3D11CoreRegisterLayers().

◆ DXGIGetDebugInterface1()

HRESULT WINAPI DXGIGetDebugInterface1 ( UINT  flags,
REFIID  iid,
void **  debug 
)

Definition at line 246 of file dxgi_main.c.

247{
248 TRACE("flags %#x, iid %s, debug %p.\n", flags, debugstr_guid(iid), debug);
249
250 WARN("Returning DXGI_ERROR_SDK_COMPONENT_MISSING.\n");
252}
#define debug(msg)
Definition: key_call.c:71
#define DXGI_ERROR_SDK_COMPONENT_MISSING
Definition: winerror.h:7151

◆ get_layer()

static BOOL get_layer ( enum dxgi_device_layer_id  id,
struct dxgi_device_layer *  layer 
)
static

Definition at line 80 of file dxgi_main.c.

81{
82 UINT i;
83
85
86 for (i = 0; i < dxgi_main.layer_count; ++i)
87 {
88 if (dxgi_main.device_layers[i].id == id)
89 {
92 return TRUE;
93 }
94 }
95
97 return FALSE;
98}

Referenced by DXGID3D10CreateDevice().

◆ register_d3d10core_layers()

static HRESULT register_d3d10core_layers ( HMODULE  d3d10core)
static

Definition at line 100 of file dxgi_main.c.

101{
103
104 if (!dxgi_main.d3d10core)
105 {
106 HRESULT hr;
107 HRESULT (WINAPI *d3d11core_register_layers)(void);
108 HMODULE mod;
109 BOOL ret;
110
111 if (!(ret = GetModuleHandleExA(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (const char *)d3d10core, &mod)))
112 {
114 return E_FAIL;
115 }
116
117 d3d11core_register_layers = (void *)GetProcAddress(mod, "D3D11CoreRegisterLayers");
118 hr = d3d11core_register_layers();
119 if (FAILED(hr))
120 {
121 ERR("Failed to register d3d11 layers, returning %#lx.\n", hr);
124 return hr;
125 }
126
128 }
129
131
132 return S_OK;
133}
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:68
#define GetProcAddress(x, y)
Definition: compat.h:753
BOOL WINAPI GetModuleHandleExA(IN DWORD dwFlags, IN LPCSTR lpModuleName OPTIONAL, OUT HMODULE *phModule)
Definition: loader.c:896
return ret
Definition: mutex.c:147
unsigned int BOOL
Definition: ntddk_ex.h:94
#define HRESULT
Definition: msvc.h:7
#define WINAPI
Definition: msvc.h:6

Referenced by DXGID3D10CreateDevice().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( dxgi  )

Variable Documentation

◆ dxgi_main

Definition at line 31 of file dxgi_main.c.