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.master
parent
0f15cc143e
commit
a1b46c0fa5
|
@ -29,7 +29,6 @@ set_target_properties(libobs-d3d11
|
|||
target_link_libraries(libobs-d3d11
|
||||
libobs
|
||||
d3d11
|
||||
dxgi
|
||||
d3dcompiler)
|
||||
dxgi)
|
||||
|
||||
install_obs_core(libobs-d3d11)
|
||||
|
|
|
@ -180,8 +180,8 @@ void gs_shader::Compile(const char *shaderString, const char *file,
|
|||
if (!shaderString)
|
||||
throw "No shader string specified";
|
||||
|
||||
hr = D3DCompile(shaderString, strlen(shaderString), file, NULL, NULL,
|
||||
"main", target,
|
||||
hr = device->d3dCompile(shaderString, strlen(shaderString), file, NULL,
|
||||
NULL, "main", target,
|
||||
D3D10_SHADER_OPTIMIZATION_LEVEL1, 0,
|
||||
shader, errorsBlob.Assign());
|
||||
if (FAILED(hr)) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -605,6 +605,8 @@ struct gs_device {
|
|||
ID3D11BlendState *curBlendState;
|
||||
D3D11_PRIMITIVE_TOPOLOGY curToplogy;
|
||||
|
||||
pD3DCompile d3dCompile;
|
||||
|
||||
gs_rect viewport;
|
||||
|
||||
vector<mat4float> projStack;
|
||||
|
@ -613,6 +615,7 @@ struct gs_device {
|
|||
matrix4 curViewMatrix;
|
||||
matrix4 curViewProjMatrix;
|
||||
|
||||
void InitCompiler();
|
||||
void InitFactory(uint32_t adapterIdx, IDXGIAdapter1 **adapter);
|
||||
void InitDevice(const gs_init_data *data, IDXGIAdapter *adapter);
|
||||
|
||||
|
|
Loading…
Reference in New Issue