d3dcompiler: Add initial reflection parsing.

This commit is contained in:
Rico Schüller 2010-11-26 12:43:51 +01:00 committed by Alexandre Julliard
parent 4ad97d404d
commit 5b2286a5bd
3 changed files with 53 additions and 5 deletions

View File

@ -127,8 +127,15 @@ HRESULT WINAPI D3DStripShader(const void *data, SIZE_T data_size, UINT flags, ID
HRESULT WINAPI D3DReflect(const void *data, SIZE_T data_size, REFIID riid, void **reflector)
{
struct d3dcompiler_shader_reflection *object;
HRESULT hr;
FIXME("data %p, data_size %lu, riid %s, blob %p stub!\n", data, data_size, debugstr_guid(riid), reflector);
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;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (!object)
@ -137,10 +144,15 @@ HRESULT WINAPI D3DReflect(const void *data, SIZE_T data_size, REFIID riid, void
return E_OUTOFMEMORY;
}
object->vtbl = &d3dcompiler_shader_reflection_vtbl;
object->refcount = 1;
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;
}
*reflector = (ID3D11ShaderReflection *)object;
*reflector = object;
TRACE("Created ID3D11ShaderReflection %p\n", object);

View File

@ -58,13 +58,15 @@ HRESULT d3dcompiler_get_blob_part(const void *data, SIZE_T data_size, D3D_BLOB_P
HRESULT d3dcompiler_strip_shader(const void *data, SIZE_T data_size, UINT flags, ID3DBlob **blob) DECLSPEC_HIDDEN;
/* ID3D11ShaderReflection */
extern const struct ID3D11ShaderReflectionVtbl d3dcompiler_shader_reflection_vtbl DECLSPEC_HIDDEN;
struct d3dcompiler_shader_reflection
{
const struct ID3D11ShaderReflectionVtbl *vtbl;
LONG refcount;
};
/* reflection handling */
HRESULT d3dcompiler_shader_reflection_init(struct d3dcompiler_shader_reflection *reflection, const void *data, SIZE_T data_size) DECLSPEC_HIDDEN;
/* Shader assembler definitions */
typedef enum _shader_type {
ST_VERTEX,

View File

@ -241,3 +241,37 @@ const struct ID3D11ShaderReflectionVtbl d3dcompiler_shader_reflection_vtbl =
d3dcompiler_shader_reflection_GetMinFeatureLevel,
d3dcompiler_shader_reflection_GetThreadGroupSize,
};
HRESULT d3dcompiler_shader_reflection_init(struct d3dcompiler_shader_reflection *reflection,
const void *data, SIZE_T data_size)
{
struct dxbc src_dxbc;
HRESULT hr;
unsigned int i;
reflection->vtbl = &d3dcompiler_shader_reflection_vtbl;
reflection->refcount = 1;
hr = dxbc_parse(data, data_size, &src_dxbc);
if (FAILED(hr))
{
WARN("Failed to parse reflection\n");
return hr;
}
for (i = 0; i < src_dxbc.count; ++i)
{
struct dxbc_section *section = &src_dxbc.sections[i];
switch (section->tag)
{
default:
FIXME("Unhandled section %s!\n", debugstr_an((const char *)&section->tag, 4));
break;
}
}
dxbc_destroy(&src_dxbc);
return hr;
}