ReactOS 0.4.17-dev-966-gf06eace
shader.c File Reference
#include "d3d9_private.h"
Include dependency graph for shader.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (d3d9)
 
static struct d3d9_vertexshader * impl_from_IDirect3DVertexShader9 (IDirect3DVertexShader9 *iface)
 
static HRESULT WINAPI d3d9_vertexshader_QueryInterface (IDirect3DVertexShader9 *iface, REFIID riid, void **out)
 
static ULONG WINAPI d3d9_vertexshader_AddRef (IDirect3DVertexShader9 *iface)
 
static ULONG WINAPI d3d9_vertexshader_Release (IDirect3DVertexShader9 *iface)
 
static HRESULT WINAPI d3d9_vertexshader_GetDevice (IDirect3DVertexShader9 *iface, IDirect3DDevice9 **device)
 
static HRESULT WINAPI d3d9_vertexshader_GetFunction (IDirect3DVertexShader9 *iface, void *data, UINT *data_size)
 
static void STDMETHODCALLTYPE d3d9_vertexshader_wined3d_object_destroyed (void *parent)
 
HRESULT vertexshader_init (struct d3d9_vertexshader *shader, struct d3d9_device *device, const DWORD *byte_code)
 
struct d3d9_vertexshader * unsafe_impl_from_IDirect3DVertexShader9 (IDirect3DVertexShader9 *iface)
 
static struct d3d9_pixelshader * impl_from_IDirect3DPixelShader9 (IDirect3DPixelShader9 *iface)
 
static HRESULT WINAPI d3d9_pixelshader_QueryInterface (IDirect3DPixelShader9 *iface, REFIID riid, void **out)
 
static ULONG WINAPI d3d9_pixelshader_AddRef (IDirect3DPixelShader9 *iface)
 
static ULONG WINAPI d3d9_pixelshader_Release (IDirect3DPixelShader9 *iface)
 
static HRESULT WINAPI d3d9_pixelshader_GetDevice (IDirect3DPixelShader9 *iface, IDirect3DDevice9 **device)
 
static HRESULT WINAPI d3d9_pixelshader_GetFunction (IDirect3DPixelShader9 *iface, void *data, UINT *data_size)
 
static void STDMETHODCALLTYPE d3d9_pixelshader_wined3d_object_destroyed (void *parent)
 
HRESULT pixelshader_init (struct d3d9_pixelshader *shader, struct d3d9_device *device, const DWORD *byte_code)
 
struct d3d9_pixelshader * unsafe_impl_from_IDirect3DPixelShader9 (IDirect3DPixelShader9 *iface)
 

Variables

static const IDirect3DVertexShader9Vtbl d3d9_vertexshader_vtbl
 
static const struct wined3d_parent_ops d3d9_vertexshader_wined3d_parent_ops
 
static const IDirect3DPixelShader9Vtbl d3d9_pixelshader_vtbl
 
static const struct wined3d_parent_ops d3d9_pixelshader_wined3d_parent_ops
 

Function Documentation

◆ d3d9_pixelshader_AddRef()

static ULONG WINAPI d3d9_pixelshader_AddRef ( IDirect3DPixelShader9 *  iface)
static

Definition at line 190 of file shader.c.

191{
194
195 TRACE("%p increasing refcount to %lu.\n", iface, refcount);
196
197 if (refcount == 1)
198 {
199 IDirect3DDevice9Ex_AddRef(shader->parent_device);
200 wined3d_shader_incref(shader->wined3d_shader);
201 }
202
203 return refcount;
204}
#define InterlockedIncrement
Definition: armddk.h:53
#define IDirect3DDevice9Ex_AddRef(p)
Definition: d3d9.h:1929
static struct d3d9_pixelshader * impl_from_IDirect3DPixelShader9(IDirect3DPixelShader9 *iface)
Definition: shader.c:167
ULONG CDECL wined3d_shader_incref(struct wined3d_shader *shader)
Definition: shader.c:2535
GLuint shader
Definition: glext.h:6030
#define TRACE(s)
Definition: solgame.cpp:4
uint32_t ULONG
Definition: typedefs.h:59

◆ d3d9_pixelshader_GetDevice()

static HRESULT WINAPI d3d9_pixelshader_GetDevice ( IDirect3DPixelShader9 *  iface,
IDirect3DDevice9 **  device 
)
static

Definition at line 224 of file shader.c.

225{
227
228 TRACE("iface %p, device %p.\n", iface, device);
229
230 *device = (IDirect3DDevice9 *)shader->parent_device;
232
233 TRACE("Returning device %p.\n", *device);
234
235 return D3D_OK;
236}
#define IDirect3DDevice9_AddRef(p)
Definition: d3d9.h:1335
#define D3D_OK
Definition: d3d.h:106
DWORD IDirect3DDevice9
Definition: dxva2api.idl:22
Definition: devices.h:37

◆ d3d9_pixelshader_GetFunction()

static HRESULT WINAPI d3d9_pixelshader_GetFunction ( IDirect3DPixelShader9 *  iface,
void *  data,
UINT *  data_size 
)
static

Definition at line 238 of file shader.c.

239{
241 HRESULT hr;
242
243 TRACE("iface %p, data %p, data_size %p.\n", iface, data, data_size);
244
246 hr = wined3d_shader_get_byte_code(shader->wined3d_shader, data, data_size);
248
249 return hr;
250}
HRESULT hr
Definition: delayimp.cpp:582
HRESULT CDECL wined3d_shader_get_byte_code(const struct wined3d_shader *shader, void *byte_code, UINT *byte_code_size)
Definition: shader.c:2612
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
void WINAPI wined3d_mutex_unlock(void)
Definition: wined3d_main.c:544
void WINAPI wined3d_mutex_lock(void)
Definition: wined3d_main.c:539

◆ d3d9_pixelshader_QueryInterface()

static HRESULT WINAPI d3d9_pixelshader_QueryInterface ( IDirect3DPixelShader9 *  iface,
REFIID  riid,
void **  out 
)
static

Definition at line 172 of file shader.c.

173{
174 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
175
176 if (IsEqualGUID(riid, &IID_IDirect3DPixelShader9)
178 {
180 *out = iface;
181 return S_OK;
182 }
183
184 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
185
186 *out = NULL;
187 return E_NOINTERFACE;
188}
#define WARN(fmt,...)
Definition: precomp.h:61
const GUID IID_IUnknown
#define IDirect3DPixelShader9_AddRef(p)
Definition: d3d9.h:1088
#define NULL
Definition: types.h:112
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
#define E_NOINTERFACE
Definition: winerror.h:3479

◆ d3d9_pixelshader_Release()

static ULONG WINAPI d3d9_pixelshader_Release ( IDirect3DPixelShader9 *  iface)
static

Definition at line 206 of file shader.c.

207{
210
211 TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
212
213 if (!refcount)
214 {
215 IDirect3DDevice9Ex *device = shader->parent_device;
216 wined3d_shader_decref(shader->wined3d_shader);
217 /* Release the device last, as it may cause the device to be destroyed. */
219 }
220
221 return refcount;
222}
#define InterlockedDecrement
Definition: armddk.h:52
#define IDirect3DDevice9Ex_Release(p)
Definition: d3d9.h:1930
ULONG CDECL wined3d_shader_decref(struct wined3d_shader *shader)
Definition: shader.c:2588
DWORD IDirect3DDevice9Ex
Definition: dxvahd.idl:22

◆ d3d9_pixelshader_wined3d_object_destroyed()

static void STDMETHODCALLTYPE d3d9_pixelshader_wined3d_object_destroyed ( void *  parent)
static

Definition at line 263 of file shader.c.

264{
265 free(parent);
266}
#define free
Definition: debug_ros.c:5
r parent
Definition: btrfs.c:3010

◆ d3d9_vertexshader_AddRef()

static ULONG WINAPI d3d9_vertexshader_AddRef ( IDirect3DVertexShader9 *  iface)
static

Definition at line 47 of file shader.c.

48{
51
52 TRACE("%p increasing refcount to %lu.\n", iface, refcount);
53
54 if (refcount == 1)
55 {
56 IDirect3DDevice9Ex_AddRef(shader->parent_device);
57 wined3d_shader_incref(shader->wined3d_shader);
58 }
59
60 return refcount;
61}
static struct d3d9_vertexshader * impl_from_IDirect3DVertexShader9(IDirect3DVertexShader9 *iface)
Definition: shader.c:24

◆ d3d9_vertexshader_GetDevice()

static HRESULT WINAPI d3d9_vertexshader_GetDevice ( IDirect3DVertexShader9 *  iface,
IDirect3DDevice9 **  device 
)
static

Definition at line 81 of file shader.c.

82{
84
85 TRACE("iface %p, device %p.\n", iface, device);
86
87 *device = (IDirect3DDevice9 *)shader->parent_device;
89
90 TRACE("Returning device %p.\n", *device);
91
92 return D3D_OK;
93}

◆ d3d9_vertexshader_GetFunction()

static HRESULT WINAPI d3d9_vertexshader_GetFunction ( IDirect3DVertexShader9 *  iface,
void *  data,
UINT *  data_size 
)
static

Definition at line 95 of file shader.c.

96{
98 HRESULT hr;
99
100 TRACE("iface %p, data %p, data_size %p.\n", iface, data, data_size);
101
103 hr = wined3d_shader_get_byte_code(shader->wined3d_shader, data, data_size);
105
106 return hr;
107}

◆ d3d9_vertexshader_QueryInterface()

static HRESULT WINAPI d3d9_vertexshader_QueryInterface ( IDirect3DVertexShader9 *  iface,
REFIID  riid,
void **  out 
)
static

Definition at line 29 of file shader.c.

30{
31 TRACE("iface %p, riid %s, out %p.\n", iface, debugstr_guid(riid), out);
32
33 if (IsEqualGUID(riid, &IID_IDirect3DVertexShader9)
35 {
37 *out = iface;
38 return S_OK;
39 }
40
41 WARN("%s not implemented, returning E_NOINTERFACE.\n", debugstr_guid(riid));
42
43 *out = NULL;
44 return E_NOINTERFACE;
45}
#define IDirect3DVertexShader9_AddRef(p)
Definition: d3d9.h:1050

◆ d3d9_vertexshader_Release()

static ULONG WINAPI d3d9_vertexshader_Release ( IDirect3DVertexShader9 *  iface)
static

Definition at line 63 of file shader.c.

64{
67
68 TRACE("%p decreasing refcount to %lu.\n", iface, refcount);
69
70 if (!refcount)
71 {
72 IDirect3DDevice9Ex *device = shader->parent_device;
73 wined3d_shader_decref(shader->wined3d_shader);
74 /* Release the device last, as it may cause the device to be destroyed. */
76 }
77
78 return refcount;
79}

◆ d3d9_vertexshader_wined3d_object_destroyed()

static void STDMETHODCALLTYPE d3d9_vertexshader_wined3d_object_destroyed ( void *  parent)
static

Definition at line 120 of file shader.c.

121{
122 free(parent);
123}

◆ impl_from_IDirect3DPixelShader9()

static struct d3d9_pixelshader * impl_from_IDirect3DPixelShader9 ( IDirect3DPixelShader9 *  iface)
inlinestatic

Definition at line 167 of file shader.c.

168{
169 return CONTAINING_RECORD(iface, struct d3d9_pixelshader, IDirect3DPixelShader9_iface);
170}
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

Referenced by d3d9_pixelshader_AddRef(), d3d9_pixelshader_GetDevice(), d3d9_pixelshader_GetFunction(), d3d9_pixelshader_Release(), and unsafe_impl_from_IDirect3DPixelShader9().

◆ impl_from_IDirect3DVertexShader9()

static struct d3d9_vertexshader * impl_from_IDirect3DVertexShader9 ( IDirect3DVertexShader9 *  iface)
inlinestatic

◆ pixelshader_init()

HRESULT pixelshader_init ( struct d3d9_pixelshader *  shader,
struct d3d9_device *  device,
const DWORD *  byte_code 
)

Definition at line 273 of file shader.c.

274{
276 HRESULT hr;
277
278 shader->refcount = 1;
279 shader->IDirect3DPixelShader9_iface.lpVtbl = &d3d9_pixelshader_vtbl;
280
281 desc.byte_code = byte_code;
282 desc.byte_code_size = ~(size_t)0;
283
285 hr = wined3d_shader_create_ps(device->wined3d_device, &desc, shader,
288 if (FAILED(hr))
289 {
290 WARN("Failed to created wined3d pixel shader, hr %#lx.\n", hr);
291 return hr;
292 }
293
294 shader->parent_device = &device->IDirect3DDevice9Ex_iface;
295 IDirect3DDevice9Ex_AddRef(shader->parent_device);
296
297 return D3D_OK;
298}
static const IDirect3DPixelShader9Vtbl d3d9_pixelshader_vtbl
Definition: shader.c:252
static const struct wined3d_parent_ops d3d9_pixelshader_wined3d_parent_ops
Definition: shader.c:268
HRESULT CDECL wined3d_shader_create_ps(struct wined3d_device *device, const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
Definition: shader.c:3291
unsigned int size_t
Definition: corecrt.h:203
#define FAILED(hr)
Definition: intsafe.h:51
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
const DWORD * byte_code
Definition: wined3d.h:2105

Referenced by d3d9_device_CreatePixelShader().

◆ unsafe_impl_from_IDirect3DPixelShader9()

struct d3d9_pixelshader * unsafe_impl_from_IDirect3DPixelShader9 ( IDirect3DPixelShader9 *  iface)

Definition at line 300 of file shader.c.

301{
302 if (!iface)
303 return NULL;
304 if (iface->lpVtbl != &d3d9_pixelshader_vtbl)
305 WARN("Pixel shader %p with the wrong vtbl %p\n", iface, iface->lpVtbl);
306
308}

Referenced by d3d9_device_SetPixelShader().

◆ unsafe_impl_from_IDirect3DVertexShader9()

struct d3d9_vertexshader * unsafe_impl_from_IDirect3DVertexShader9 ( IDirect3DVertexShader9 *  iface)

Definition at line 157 of file shader.c.

158{
159 if (!iface)
160 return NULL;
161 if (iface->lpVtbl != &d3d9_vertexshader_vtbl)
162 WARN("Vertex shader %p with the wrong vtbl %p\n", iface, iface->lpVtbl);
163
165}
static const IDirect3DVertexShader9Vtbl d3d9_vertexshader_vtbl
Definition: shader.c:109

Referenced by d3d9_device_SetVertexShader().

◆ vertexshader_init()

HRESULT vertexshader_init ( struct d3d9_vertexshader *  shader,
struct d3d9_device *  device,
const DWORD *  byte_code 
)

Definition at line 130 of file shader.c.

131{
133 HRESULT hr;
134
135 shader->refcount = 1;
136 shader->IDirect3DVertexShader9_iface.lpVtbl = &d3d9_vertexshader_vtbl;
137
138 desc.byte_code = byte_code;
139 desc.byte_code_size = ~(size_t)0;
140
142 hr = wined3d_shader_create_vs(device->wined3d_device, &desc, shader,
145 if (FAILED(hr))
146 {
147 WARN("Failed to create wined3d vertex shader, hr %#lx.\n", hr);
148 return hr;
149 }
150
151 shader->parent_device = &device->IDirect3DDevice9Ex_iface;
152 IDirect3DDevice9Ex_AddRef(shader->parent_device);
153
154 return D3D_OK;
155}
static const struct wined3d_parent_ops d3d9_vertexshader_wined3d_parent_ops
Definition: shader.c:125
HRESULT CDECL wined3d_shader_create_vs(struct wined3d_device *device, const struct wined3d_shader_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_shader **shader)
Definition: shader.c:3318

Referenced by d3d9_device_CreateVertexShader().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( d3d9  )

Variable Documentation

◆ d3d9_pixelshader_vtbl

const IDirect3DPixelShader9Vtbl d3d9_pixelshader_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI d3d9_pixelshader_QueryInterface(IDirect3DPixelShader9 *iface, REFIID riid, void **out)
Definition: shader.c:172
static ULONG WINAPI d3d9_pixelshader_AddRef(IDirect3DPixelShader9 *iface)
Definition: shader.c:190
static ULONG WINAPI d3d9_pixelshader_Release(IDirect3DPixelShader9 *iface)
Definition: shader.c:206
static HRESULT WINAPI d3d9_pixelshader_GetDevice(IDirect3DPixelShader9 *iface, IDirect3DDevice9 **device)
Definition: shader.c:224
static HRESULT WINAPI d3d9_pixelshader_GetFunction(IDirect3DPixelShader9 *iface, void *data, UINT *data_size)
Definition: shader.c:238

Definition at line 252 of file shader.c.

Referenced by pixelshader_init(), and unsafe_impl_from_IDirect3DPixelShader9().

◆ d3d9_pixelshader_wined3d_parent_ops

const struct wined3d_parent_ops d3d9_pixelshader_wined3d_parent_ops
static
Initial value:
=
{
}
static void STDMETHODCALLTYPE d3d9_pixelshader_wined3d_object_destroyed(void *parent)
Definition: shader.c:263

Definition at line 268 of file shader.c.

Referenced by pixelshader_init().

◆ d3d9_vertexshader_vtbl

const IDirect3DVertexShader9Vtbl d3d9_vertexshader_vtbl
static
Initial value:
=
{
}
static HRESULT WINAPI d3d9_vertexshader_GetFunction(IDirect3DVertexShader9 *iface, void *data, UINT *data_size)
Definition: shader.c:95
static HRESULT WINAPI d3d9_vertexshader_QueryInterface(IDirect3DVertexShader9 *iface, REFIID riid, void **out)
Definition: shader.c:29
static ULONG WINAPI d3d9_vertexshader_AddRef(IDirect3DVertexShader9 *iface)
Definition: shader.c:47
static HRESULT WINAPI d3d9_vertexshader_GetDevice(IDirect3DVertexShader9 *iface, IDirect3DDevice9 **device)
Definition: shader.c:81
static ULONG WINAPI d3d9_vertexshader_Release(IDirect3DVertexShader9 *iface)
Definition: shader.c:63

Definition at line 109 of file shader.c.

Referenced by unsafe_impl_from_IDirect3DVertexShader9(), and vertexshader_init().

◆ d3d9_vertexshader_wined3d_parent_ops

const struct wined3d_parent_ops d3d9_vertexshader_wined3d_parent_ops
static
Initial value:
=
{
}
static void STDMETHODCALLTYPE d3d9_vertexshader_wined3d_object_destroyed(void *parent)
Definition: shader.c:120

Definition at line 125 of file shader.c.

Referenced by vertexshader_init().