2 * Direct3D shader compiler main file
4 * Copyright 2010 Matteo Bruni 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
28 #include "wine/debug.h"
30 #include "d3dcompiler_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler);
34 BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved)
38 case DLL_WINE_PREATTACH:
39 return FALSE; /* prefer native version */
40 case DLL_PROCESS_ATTACH:
41 DisableThreadLibraryCalls(inst);
43 case DLL_PROCESS_DETACH:
49 HRESULT WINAPI D3DCreateBlob(SIZE_T data_size, ID3DBlob **blob)
51 struct d3dcompiler_blob *object;
54 TRACE("data_size %lu, blob %p\n", data_size, blob);
58 WARN("Invalid blob specified.\n");
59 return D3DERR_INVALIDCALL;
62 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
65 ERR("Failed to allocate D3D blob object memory\n");
69 hr = d3dcompiler_blob_init(object, data_size);
72 WARN("Failed to initialize blob, hr %#x.\n", hr);
73 HeapFree(GetProcessHeap(), 0, object);
77 *blob = (ID3DBlob *)object;
79 TRACE("Created ID3DBlob %p\n", object);
84 HRESULT WINAPI D3DGetBlobPart(const void *data, SIZE_T data_size, D3D_BLOB_PART part, UINT flags, ID3DBlob **blob)
86 TRACE("data %p, data_size %lu, part %s, flags %#x, blob %p\n", data,
87 data_size, debug_d3dcompiler_d3d_blob_part(part), flags, blob);
89 return d3dcompiler_get_blob_part(data, data_size, part, flags, blob);
92 HRESULT WINAPI D3DGetInputSignatureBlob(const void *data, SIZE_T data_size, ID3DBlob **blob)
94 TRACE("data %p, data_size %lu, blob %p\n", data, data_size, blob);
96 return d3dcompiler_get_blob_part(data, data_size, D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, blob);
99 HRESULT WINAPI D3DGetOutputSignatureBlob(const void *data, SIZE_T data_size, ID3DBlob **blob)
101 TRACE("data %p, data_size %lu, blob %p\n", data, data_size, blob);
103 return d3dcompiler_get_blob_part(data, data_size, D3D_BLOB_OUTPUT_SIGNATURE_BLOB, 0, blob);
106 HRESULT WINAPI D3DGetInputAndOutputSignatureBlob(const void *data, SIZE_T data_size, ID3DBlob **blob)
108 TRACE("data %p, data_size %lu, blob %p\n", data, data_size, blob);
110 return d3dcompiler_get_blob_part(data, data_size, D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB, 0, blob);
113 HRESULT WINAPI D3DGetDebugInfo(const void *data, SIZE_T data_size, ID3DBlob **blob)
115 TRACE("data %p, data_size %lu, blob %p\n", data, data_size, blob);
117 return d3dcompiler_get_blob_part(data, data_size, D3D_BLOB_DEBUG_INFO, 0, blob);
120 HRESULT WINAPI D3DStripShader(const void *data, SIZE_T data_size, UINT flags, ID3D10Blob **blob)
122 TRACE("data %p, data_size %lu, flags %#x, blob %p\n", data, data_size, flags, blob);
124 return d3dcompiler_strip_shader(data, data_size, flags, blob);
127 HRESULT WINAPI D3DReflect(const void *data, SIZE_T data_size, REFIID riid, void **reflector)
129 struct d3dcompiler_shader_reflection *object;
132 TRACE("data %p, data_size %lu, riid %s, blob %p\n", data, data_size, debugstr_guid(riid), reflector);
134 if (!IsEqualGUID(riid, &IID_ID3D11ShaderReflection))
136 WARN("Wrong riid %s, accept only %s!\n", debugstr_guid(riid), debugstr_guid(&IID_ID3D11ShaderReflection));
137 return E_NOINTERFACE;
140 object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
143 ERR("Failed to allocate D3D compiler shader reflection object memory\n");
144 return E_OUTOFMEMORY;
147 hr = d3dcompiler_shader_reflection_init(object, data, data_size);
150 WARN("Failed to initialize shader reflection\n");
151 HeapFree(GetProcessHeap(), 0, object);
157 TRACE("Created ID3D11ShaderReflection %p\n", object);