libobs-d3d11: Don't depend on specific D3DCompiler

I do not want the D3D11 library to depend on a specific compiler
version.  This way, I do not have to distribute D3D Compiler libraries
with the program (proprietary binary blobs).  Any particular version
works because the API for the D3DCompiler function appears to be the
same; the only things that change are other features and additions
mostly (at least as far as I can tell).  Using any version available on
the system should be more than sufficient rather than depending on some
specific D3D compiler version.

If the user doesn't have it, a download of the latest D3D distributables
should be fine, though it should work with the ones that come with
windows 7+ as well.
This commit is contained in:
jp9000
2014-10-03 14:29:47 -07:00
parent 0f15cc143e
commit a1b46c0fa5
4 changed files with 32 additions and 4 deletions

View File

@@ -135,6 +135,31 @@ gs_swap_chain::gs_swap_chain(gs_device *device, const gs_init_data *data)
Init(data);
}
void gs_device::InitCompiler()
{
char d3dcompiler[40] = {};
int ver = 49;
while (ver > 30) {
sprintf_s(d3dcompiler, 40, "D3DCompiler_%02d.dll", ver);
HMODULE module = LoadLibraryA(d3dcompiler);
if (module) {
d3dCompile = (pD3DCompile)GetProcAddress(module,
"D3DCompile");
if (d3dCompile) {
return;
}
FreeLibrary(module);
}
ver--;
}
throw "Could not find any D3DCompiler libraries";
}
void gs_device::InitFactory(uint32_t adapterIdx, IDXGIAdapter1 **padapter)
{
HRESULT hr;
@@ -423,6 +448,7 @@ gs_device::gs_device(const gs_init_data *data)
curSamplers[i] = NULL;
}
InitCompiler();
InitFactory(data->adapter, adapter.Assign());
InitDevice(data, adapter);
device_set_render_target(this, NULL, NULL);