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