1 #if API < 11
2 extern "C" HRESULT STDMETHODCALLTYPE D3D10CreateBlob(
3 SIZE_T num_bytes,
4 LPD3D10BLOB *out_buffer
5 );
6
D3D10CreateBlob(SIZE_T num_bytes,LPD3D10BLOB * out_buffer)7 HRESULT 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
D3D10GetPixelShaderProfile(ID3D10Device * device)19 LPCSTR STDMETHODCALLTYPE D3D10GetPixelShaderProfile(
20 ID3D10Device *device
21 )
22 {
23 return "ps_4_0";
24 }
25
D3D10GetVertexShaderProfile(ID3D10Device * device)26 LPCSTR STDMETHODCALLTYPE D3D10GetVertexShaderProfile(
27 ID3D10Device *device
28 )
29 {
30 return "vs_4_0";
31 }
32
D3D10GetGeometryShaderProfile(ID3D10Device * device)33 LPCSTR STDMETHODCALLTYPE D3D10GetGeometryShaderProfile(
34 ID3D10Device *device
35 )
36 {
37 return "gs_4_0";
38 }
39
dxbc_assemble_as_blob(struct dxbc_chunk_header ** chunks,unsigned num_chunks,ID3D10Blob ** blob)40 static 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
D3D10GetInputSignatureBlob(const void * shader_bytecode,SIZE_T bytecode_length,ID3D10Blob ** signature_blob)49 HRESULT 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, DXBC_FIND_INPUT_SIGNATURE);
56 if(!sig)
57 return E_FAIL;
58
59 return dxbc_assemble_as_blob((dxbc_chunk_header**)&sig, 1, signature_blob);
60 }
61
D3D10GetOutputSignatureBlob(const void * shader_bytecode,SIZE_T bytecode_length,ID3D10Blob ** signature_blob)62 HRESULT 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, DXBC_FIND_OUTPUT_SIGNATURE);
69 if(!sig)
70 return E_FAIL;
71
72 return dxbc_assemble_as_blob((dxbc_chunk_header**)&sig, 1, signature_blob);
73 }
74
D3D10GetInputAndOutputSignatureBlob(const void * shader_bytecode,SIZE_T bytecode_length,ID3D10Blob ** signature_blob)75 HRESULT 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, DXBC_FIND_INPUT_SIGNATURE);
83 if(!sigs[0])
84 return E_FAIL;
85 sigs[1] = dxbc_find_signature(shader_bytecode, bytecode_length, DXBC_FIND_OUTPUT_SIGNATURE);
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