1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
#if API < 11
extern "C" HRESULT STDMETHODCALLTYPE D3D10CreateBlob(
__in SIZE_T NumBytes,
__out LPD3D10BLOB *ppBuffer
);
HRESULT STDMETHODCALLTYPE D3D10CreateBlob(
__in SIZE_T NumBytes,
__out LPD3D10BLOB *ppBuffer
)
{
void* data = malloc(NumBytes);
if(!data)
return E_OUTOFMEMORY;
*ppBuffer = new GalliumD3DBlob(data, NumBytes);
return S_OK;
}
LPCSTR STDMETHODCALLTYPE D3D10GetPixelShaderProfile(
__in ID3D10Device *pDevice
)
{
return "ps_4_0";
}
LPCSTR STDMETHODCALLTYPE D3D10GetVertexShaderProfile(
__in ID3D10Device *pDevice
)
{
return "vs_4_0";
}
LPCSTR STDMETHODCALLTYPE D3D10GetGeometryShaderProfile(
__in ID3D10Device *pDevice
)
{
return "gs_4_0";
}
static HRESULT dxbc_assemble_as_blob(struct dxbc_chunk_header** chunks, unsigned num_chunks, ID3D10Blob** blob)
{
std::pair<void*, size_t> p = dxbc_assemble(chunks, num_chunks);
if(!p.first)
return E_OUTOFMEMORY;
*blob = new GalliumD3DBlob(p.first, p.second);
return S_OK;
}
HRESULT D3D10GetInputSignatureBlob(
__in const void *pShaderBytecode,
__in SIZE_T BytecodeLength,
__out ID3D10Blob **ppSignatureBlob
)
{
dxbc_chunk_signature* sig = dxbc_find_signature(pShaderBytecode, BytecodeLength, false);
if(!sig)
return E_FAIL;
return dxbc_assemble_as_blob((dxbc_chunk_header**)&sig, 1, ppSignatureBlob);
}
HRESULT D3D10GetOutputSignatureBlob(
__in const void *pShaderBytecode,
__in SIZE_T BytecodeLength,
__out ID3D10Blob **ppSignatureBlob
)
{
dxbc_chunk_signature* sig = dxbc_find_signature(pShaderBytecode, BytecodeLength, true);
if(!sig)
return E_FAIL;
return dxbc_assemble_as_blob((dxbc_chunk_header**)&sig, 1, ppSignatureBlob);
}
HRESULT D3D10GetInputAndOutputSignatureBlob(
__in const void *pShaderBytecode,
__in SIZE_T BytecodeLength,
__out ID3D10Blob **ppSignatureBlob
)
{
dxbc_chunk_signature* sigs[2];
sigs[0] = dxbc_find_signature(pShaderBytecode, BytecodeLength, false);
if(!sigs[0])
return E_FAIL;
sigs[1] = dxbc_find_signature(pShaderBytecode, BytecodeLength, true);
if(!sigs[1])
return E_FAIL;
return dxbc_assemble_as_blob((dxbc_chunk_header**)&sigs, 2, ppSignatureBlob);
}
#endif
|