jscript: Use single string instance for strings representing NULL BSTR instead of...
[wine] / dlls / d3d10 / shader.c
1 /*
2  * Copyright 2009 Henri Verbeet for CodeWeavers
3  * Copyright 2010 Rico Schüller
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18  *
19  */
20
21 #include "config.h"
22 #include "wine/port.h"
23
24 #include "d3d10_private.h"
25
26 WINE_DEFAULT_DEBUG_CHANNEL(d3d10);
27
28 /* IUnknown methods */
29
30 static inline struct d3d10_shader_reflection *impl_from_ID3D10ShaderReflection(ID3D10ShaderReflection *iface)
31 {
32     return CONTAINING_RECORD(iface, struct d3d10_shader_reflection, ID3D10ShaderReflection_iface);
33 }
34
35 static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_QueryInterface(ID3D10ShaderReflection *iface, REFIID riid, void **object)
36 {
37     TRACE("iface %p, riid %s, object %p\n", iface, debugstr_guid(riid), object);
38
39     if (IsEqualGUID(riid, &IID_ID3D10ShaderReflection)
40             || IsEqualGUID(riid, &IID_IUnknown))
41     {
42         IUnknown_AddRef(iface);
43         *object = iface;
44         return S_OK;
45     }
46
47     WARN("%s not implemented, returning E_NOINTERFACE\n", debugstr_guid(riid));
48
49     *object = NULL;
50     return E_NOINTERFACE;
51 }
52
53 static ULONG STDMETHODCALLTYPE d3d10_shader_reflection_AddRef(ID3D10ShaderReflection *iface)
54 {
55     struct d3d10_shader_reflection *This = impl_from_ID3D10ShaderReflection(iface);
56     ULONG refcount = InterlockedIncrement(&This->refcount);
57
58     TRACE("%p increasing refcount to %u\n", This, refcount);
59
60     return refcount;
61 }
62
63 static ULONG STDMETHODCALLTYPE d3d10_shader_reflection_Release(ID3D10ShaderReflection *iface)
64 {
65     struct d3d10_shader_reflection *This = impl_from_ID3D10ShaderReflection(iface);
66     ULONG refcount = InterlockedDecrement(&This->refcount);
67
68     TRACE("%p decreasing refcount to %u\n", This, refcount);
69
70     if (!refcount)
71     {
72         HeapFree(GetProcessHeap(), 0, This);
73     }
74
75     return refcount;
76 }
77
78 /* ID3D10ShaderReflection methods */
79
80 static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetDesc(ID3D10ShaderReflection *iface, D3D10_SHADER_DESC *desc)
81 {
82     FIXME("iface %p, desc %p stub!\n", iface, desc);
83
84     return E_NOTIMPL;
85 }
86
87 static struct ID3D10ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3d10_shader_reflection_GetConstantBufferByIndex(
88         ID3D10ShaderReflection *iface, UINT index)
89 {
90     FIXME("iface %p, index %u stub!\n", iface, index);
91
92     return NULL;
93 }
94
95 static struct ID3D10ShaderReflectionConstantBuffer * STDMETHODCALLTYPE d3d10_shader_reflection_GetConstantBufferByName(
96         ID3D10ShaderReflection *iface, LPCSTR name)
97 {
98     FIXME("iface %p, name \"%s\" stub!\n", iface, name);
99
100     return NULL;
101 }
102
103 static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetResourceBindingDesc(
104         ID3D10ShaderReflection *iface, UINT index, D3D10_SHADER_INPUT_BIND_DESC *desc)
105 {
106     FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc);
107
108     return E_NOTIMPL;
109 }
110
111 static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetInputParameterDesc(
112         ID3D10ShaderReflection *iface, UINT index, D3D10_SIGNATURE_PARAMETER_DESC *desc)
113 {
114     FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc);
115
116     return E_NOTIMPL;
117 }
118
119 static HRESULT STDMETHODCALLTYPE d3d10_shader_reflection_GetOutputParameterDesc(
120         ID3D10ShaderReflection *iface, UINT index, D3D10_SIGNATURE_PARAMETER_DESC *desc)
121 {
122     FIXME("iface %p, index %u, desc %p stub!\n", iface, index, desc);
123
124     return E_NOTIMPL;
125 }
126
127 const struct ID3D10ShaderReflectionVtbl d3d10_shader_reflection_vtbl =
128 {
129     /* IUnknown methods */
130     d3d10_shader_reflection_QueryInterface,
131     d3d10_shader_reflection_AddRef,
132     d3d10_shader_reflection_Release,
133     /* ID3D10Effect methods */
134     d3d10_shader_reflection_GetDesc,
135     d3d10_shader_reflection_GetConstantBufferByIndex,
136     d3d10_shader_reflection_GetConstantBufferByName,
137     d3d10_shader_reflection_GetResourceBindingDesc,
138     d3d10_shader_reflection_GetInputParameterDesc,
139     d3d10_shader_reflection_GetOutputParameterDesc,
140 };
141
142 HRESULT WINAPI D3D10CompileShader(const char *data, SIZE_T data_size, const char *filename,
143         const D3D10_SHADER_MACRO *defines, ID3D10Include *include, const char *entrypoint,
144         const char *profile, UINT flags, ID3D10Blob **shader, ID3D10Blob **error_messages)
145 {
146     /* Forward to d3dcompiler */
147     return D3DCompile(data, data_size, filename, defines, include,
148             entrypoint, profile, flags, 0, shader, error_messages);
149 }
150
151 HRESULT WINAPI D3D10DisassembleShader(const void *data, SIZE_T data_size,
152         BOOL color_code, const char *comments, ID3D10Blob **disassembly)
153 {
154     TRACE("data %p, data_size %#lx, color_code %#x, comments %p, disassembly %p.\n",
155             data, data_size, color_code, comments, disassembly);
156
157     return D3DDisassemble(data, data_size, color_code ? D3D_DISASM_ENABLE_COLOR_CODE : 0, comments, disassembly);
158 }