2010-07-30 16:21:43 +02:00
|
|
|
/*
|
|
|
|
* Direct3D shader compiler main file
|
|
|
|
*
|
|
|
|
* Copyright 2010 Matteo Bruni for CodeWeavers
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
2010-08-15 17:05:31 +02:00
|
|
|
#include "d3dcompiler_private.h"
|
|
|
|
|
2010-07-30 16:21:43 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3dcompiler);
|
|
|
|
|
|
|
|
BOOL WINAPI DllMain(HINSTANCE inst, DWORD reason, LPVOID reserved)
|
|
|
|
{
|
|
|
|
switch (reason)
|
|
|
|
{
|
|
|
|
case DLL_WINE_PREATTACH:
|
|
|
|
return FALSE; /* prefer native version */
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
DisableThreadLibraryCalls(inst);
|
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
2010-08-15 17:05:31 +02:00
|
|
|
|
|
|
|
HRESULT WINAPI D3DCreateBlob(SIZE_T data_size, ID3DBlob **blob)
|
|
|
|
{
|
|
|
|
struct d3dcompiler_blob *object;
|
|
|
|
HRESULT hr;
|
|
|
|
|
|
|
|
TRACE("data_size %lu, blob %p\n", data_size, blob);
|
|
|
|
|
|
|
|
if (!blob)
|
|
|
|
{
|
|
|
|
WARN("Invalid blob specified.\n");
|
|
|
|
return D3DERR_INVALIDCALL;
|
|
|
|
}
|
|
|
|
|
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate D3D blob object memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
hr = d3dcompiler_blob_init(object, data_size);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to initialize blob, hr %#x.\n", hr);
|
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
*blob = (ID3DBlob *)object;
|
|
|
|
|
|
|
|
TRACE("Created ID3DBlob %p\n", object);
|
|
|
|
|
|
|
|
return S_OK;
|
|
|
|
}
|
2010-10-03 15:11:47 +02:00
|
|
|
|
|
|
|
HRESULT WINAPI D3DGetBlobPart(const void *data, SIZE_T data_size, D3D_BLOB_PART part, UINT flags, ID3DBlob **blob)
|
|
|
|
{
|
2010-10-03 15:11:54 +02:00
|
|
|
TRACE("data %p, data_size %lu, part %s, flags %#x, blob %p\n", data,
|
|
|
|
data_size, debug_d3dcompiler_d3d_blob_part(part), flags, blob);
|
2010-10-03 15:11:47 +02:00
|
|
|
|
2010-10-03 15:11:54 +02:00
|
|
|
return d3dcompiler_get_blob_part(data, data_size, part, flags, blob);
|
2010-10-03 15:11:47 +02:00
|
|
|
}
|
2010-10-03 15:12:00 +02:00
|
|
|
|
|
|
|
HRESULT WINAPI D3DGetInputSignatureBlob(const void *data, SIZE_T data_size, ID3DBlob **blob)
|
|
|
|
{
|
|
|
|
TRACE("data %p, data_size %lu, blob %p\n", data, data_size, blob);
|
|
|
|
|
|
|
|
return d3dcompiler_get_blob_part(data, data_size, D3D_BLOB_INPUT_SIGNATURE_BLOB, 0, blob);
|
|
|
|
}
|
2010-10-03 15:12:06 +02:00
|
|
|
|
|
|
|
HRESULT WINAPI D3DGetOutputSignatureBlob(const void *data, SIZE_T data_size, ID3DBlob **blob)
|
|
|
|
{
|
|
|
|
TRACE("data %p, data_size %lu, blob %p\n", data, data_size, blob);
|
|
|
|
|
|
|
|
return d3dcompiler_get_blob_part(data, data_size, D3D_BLOB_OUTPUT_SIGNATURE_BLOB, 0, blob);
|
|
|
|
}
|
2010-10-03 15:12:12 +02:00
|
|
|
|
|
|
|
HRESULT WINAPI D3DGetInputAndOutputSignatureBlob(const void *data, SIZE_T data_size, ID3DBlob **blob)
|
|
|
|
{
|
|
|
|
TRACE("data %p, data_size %lu, blob %p\n", data, data_size, blob);
|
|
|
|
|
|
|
|
return d3dcompiler_get_blob_part(data, data_size, D3D_BLOB_INPUT_AND_OUTPUT_SIGNATURE_BLOB, 0, blob);
|
|
|
|
}
|
2010-10-03 15:12:17 +02:00
|
|
|
|
|
|
|
HRESULT WINAPI D3DGetDebugInfo(const void *data, SIZE_T data_size, ID3DBlob **blob)
|
|
|
|
{
|
|
|
|
TRACE("data %p, data_size %lu, blob %p\n", data, data_size, blob);
|
|
|
|
|
|
|
|
return d3dcompiler_get_blob_part(data, data_size, D3D_BLOB_DEBUG_INFO, 0, blob);
|
|
|
|
}
|
2010-10-12 19:25:26 +02:00
|
|
|
|
|
|
|
HRESULT WINAPI D3DStripShader(const void *data, SIZE_T data_size, UINT flags, ID3D10Blob **blob)
|
|
|
|
{
|
|
|
|
TRACE("data %p, data_size %lu, flags %#x, blob %p\n", data, data_size, flags, blob);
|
|
|
|
|
|
|
|
return d3dcompiler_strip_shader(data, data_size, flags, blob);
|
|
|
|
}
|
2010-11-01 22:18:24 +01:00
|
|
|
|
|
|
|
HRESULT WINAPI D3DReflect(const void *data, SIZE_T data_size, REFIID riid, void **reflector)
|
|
|
|
{
|
2010-11-01 22:18:56 +01:00
|
|
|
struct d3dcompiler_shader_reflection *object;
|
2010-11-26 12:43:51 +01:00
|
|
|
HRESULT hr;
|
2010-11-01 22:18:56 +01:00
|
|
|
|
2010-11-26 12:43:51 +01:00
|
|
|
TRACE("data %p, data_size %lu, riid %s, blob %p\n", data, data_size, debugstr_guid(riid), reflector);
|
|
|
|
|
|
|
|
if (!IsEqualGUID(riid, &IID_ID3D11ShaderReflection))
|
|
|
|
{
|
|
|
|
WARN("Wrong riid %s, accept only %s!\n", debugstr_guid(riid), debugstr_guid(&IID_ID3D11ShaderReflection));
|
|
|
|
return E_NOINTERFACE;
|
|
|
|
}
|
2010-11-01 22:18:24 +01:00
|
|
|
|
2010-11-01 22:18:56 +01:00
|
|
|
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
|
|
|
|
if (!object)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate D3D compiler shader reflection object memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2010-11-26 12:43:51 +01:00
|
|
|
hr = d3dcompiler_shader_reflection_init(object, data, data_size);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
WARN("Failed to initialize shader reflection\n");
|
|
|
|
HeapFree(GetProcessHeap(), 0, object);
|
|
|
|
return hr;
|
|
|
|
}
|
2010-11-01 22:18:56 +01:00
|
|
|
|
2010-11-26 12:43:51 +01:00
|
|
|
*reflector = object;
|
2010-11-01 22:18:56 +01:00
|
|
|
|
|
|
|
TRACE("Created ID3D11ShaderReflection %p\n", object);
|
|
|
|
|
|
|
|
return S_OK;
|
2010-11-01 22:18:24 +01:00
|
|
|
}
|