libobs-d3d11: Store dxgi adapter used for device
Keeping a reference is useful, and additionally allows pruning a bit of duplicated code in the dupicator object.master
parent
9b50334806
commit
29eea269fc
|
@ -20,20 +20,9 @@
|
||||||
static inline bool get_monitor(gs_device_t *device, int monitor_idx,
|
static inline bool get_monitor(gs_device_t *device, int monitor_idx,
|
||||||
IDXGIOutput **dxgiOutput)
|
IDXGIOutput **dxgiOutput)
|
||||||
{
|
{
|
||||||
ComPtr<IDXGIAdapter> dxgiAdapter;
|
|
||||||
ComPtr<IDXGIDevice> dxgiDevice;
|
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
hr = device->device->QueryInterface(__uuidof(IDXGIDevice),
|
hr = device->adapter->EnumOutputs(monitor_idx, dxgiOutput);
|
||||||
(void**)dxgiDevice.Assign());
|
|
||||||
if (FAILED(hr))
|
|
||||||
throw HRError("Failed to query IDXGIDevice", hr);
|
|
||||||
|
|
||||||
hr = dxgiDevice->GetAdapter(dxgiAdapter.Assign());
|
|
||||||
if (FAILED(hr))
|
|
||||||
throw HRError("Failed to get adapter", hr);
|
|
||||||
|
|
||||||
hr = dxgiAdapter->EnumOutputs(monitor_idx, dxgiOutput);
|
|
||||||
if (FAILED(hr)) {
|
if (FAILED(hr)) {
|
||||||
if (hr == DXGI_ERROR_NOT_FOUND)
|
if (hr == DXGI_ERROR_NOT_FOUND)
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -171,7 +171,7 @@ void gs_device::InitCompiler()
|
||||||
throw "Could not find any D3DCompiler libraries";
|
throw "Could not find any D3DCompiler libraries";
|
||||||
}
|
}
|
||||||
|
|
||||||
void gs_device::InitFactory(uint32_t adapterIdx, IDXGIAdapter1 **padapter)
|
void gs_device::InitFactory(uint32_t adapterIdx)
|
||||||
{
|
{
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
IID factoryIID = (GetWinVer() >= 0x602) ? dxgiFactory2 :
|
IID factoryIID = (GetWinVer() >= 0x602) ? dxgiFactory2 :
|
||||||
|
@ -181,7 +181,7 @@ void gs_device::InitFactory(uint32_t adapterIdx, IDXGIAdapter1 **padapter)
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
throw UnsupportedHWError("Failed to create DXGIFactory", hr);
|
throw UnsupportedHWError("Failed to create DXGIFactory", hr);
|
||||||
|
|
||||||
hr = factory->EnumAdapters1(adapterIdx, padapter);
|
hr = factory->EnumAdapters1(adapterIdx, &adapter);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
throw UnsupportedHWError("Failed to enumerate DXGIAdapter", hr);
|
throw UnsupportedHWError("Failed to enumerate DXGIAdapter", hr);
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ const static D3D_FEATURE_LEVEL featureLevels[] =
|
||||||
D3D_FEATURE_LEVEL_9_3,
|
D3D_FEATURE_LEVEL_9_3,
|
||||||
};
|
};
|
||||||
|
|
||||||
void gs_device::InitDevice(uint32_t adapterIdx, IDXGIAdapter *adapter)
|
void gs_device::InitDevice(uint32_t adapterIdx)
|
||||||
{
|
{
|
||||||
wstring adapterName;
|
wstring adapterName;
|
||||||
DXGI_ADAPTER_DESC desc;
|
DXGI_ADAPTER_DESC desc;
|
||||||
|
@ -423,8 +423,6 @@ void gs_device::UpdateViewProjMatrix()
|
||||||
gs_device::gs_device(uint32_t adapterIdx)
|
gs_device::gs_device(uint32_t adapterIdx)
|
||||||
: curToplogy (D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED)
|
: curToplogy (D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED)
|
||||||
{
|
{
|
||||||
ComPtr<IDXGIAdapter1> adapter;
|
|
||||||
|
|
||||||
matrix4_identity(&curProjMatrix);
|
matrix4_identity(&curProjMatrix);
|
||||||
matrix4_identity(&curViewMatrix);
|
matrix4_identity(&curViewMatrix);
|
||||||
matrix4_identity(&curViewProjMatrix);
|
matrix4_identity(&curViewProjMatrix);
|
||||||
|
@ -437,8 +435,8 @@ gs_device::gs_device(uint32_t adapterIdx)
|
||||||
}
|
}
|
||||||
|
|
||||||
InitCompiler();
|
InitCompiler();
|
||||||
InitFactory(adapterIdx, adapter.Assign());
|
InitFactory(adapterIdx);
|
||||||
InitDevice(adapterIdx, adapter);
|
InitDevice(adapterIdx);
|
||||||
device_set_render_target(this, NULL, NULL);
|
device_set_render_target(this, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -613,6 +613,7 @@ struct mat4float {
|
||||||
|
|
||||||
struct gs_device {
|
struct gs_device {
|
||||||
ComPtr<IDXGIFactory1> factory;
|
ComPtr<IDXGIFactory1> factory;
|
||||||
|
ComPtr<IDXGIAdapter1> adapter;
|
||||||
ComPtr<ID3D11Device> device;
|
ComPtr<ID3D11Device> device;
|
||||||
ComPtr<ID3D11DeviceContext> context;
|
ComPtr<ID3D11DeviceContext> context;
|
||||||
|
|
||||||
|
@ -652,8 +653,8 @@ struct gs_device {
|
||||||
matrix4 curViewProjMatrix;
|
matrix4 curViewProjMatrix;
|
||||||
|
|
||||||
void InitCompiler();
|
void InitCompiler();
|
||||||
void InitFactory(uint32_t adapterIdx, IDXGIAdapter1 **adapter);
|
void InitFactory(uint32_t adapterIdx);
|
||||||
void InitDevice(uint32_t adapterIdx, IDXGIAdapter *adapter);
|
void InitDevice(uint32_t adapterIdx);
|
||||||
|
|
||||||
ID3D11DepthStencilState *AddZStencilState();
|
ID3D11DepthStencilState *AddZStencilState();
|
||||||
ID3D11RasterizerState *AddRasterState();
|
ID3D11RasterizerState *AddRasterState();
|
||||||
|
|
Loading…
Reference in New Issue