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