mirror of
https://github.com/doitsujin/dxvk.git
synced 2025-01-18 02:52:10 +01:00
[dxgi] Reset pointers before returning an error
Also fixes a refcount issue and minor code formatting issues.
This commit is contained in:
parent
87f9bcfd75
commit
6babc22ec0
@ -60,8 +60,10 @@ namespace dxvk {
|
||||
if (ppOutput == nullptr)
|
||||
return DXGI_ERROR_INVALID_CALL;
|
||||
|
||||
if (Output > 0)
|
||||
if (Output > 0) {
|
||||
*ppOutput = nullptr;
|
||||
return DXGI_ERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
// TODO support multiple monitors
|
||||
HMONITOR monitor = ::MonitorFromPoint({ 0, 0 }, MONITOR_DEFAULTTOPRIMARY);
|
||||
@ -72,7 +74,7 @@ namespace dxvk {
|
||||
|
||||
HRESULT STDMETHODCALLTYPE DxgiAdapter::GetDesc(DXGI_ADAPTER_DESC* pDesc) {
|
||||
if (pDesc == nullptr)
|
||||
return E_INVALIDARG;
|
||||
return DXGI_ERROR_INVALID_CALL;
|
||||
|
||||
DXGI_ADAPTER_DESC1 desc1;
|
||||
HRESULT hr = this->GetDesc1(&desc1);
|
||||
@ -176,16 +178,18 @@ namespace dxvk {
|
||||
HRESULT DxgiAdapter::GetOutputFromMonitor(
|
||||
HMONITOR Monitor,
|
||||
IDXGIOutput** ppOutput) {
|
||||
Com<IDXGIOutput> output;
|
||||
if (ppOutput == nullptr)
|
||||
return DXGI_ERROR_INVALID_CALL;
|
||||
|
||||
for (uint32_t i = 0; SUCCEEDED(EnumOutputs(i, &output)); i++) {
|
||||
for (uint32_t i = 0; SUCCEEDED(EnumOutputs(i, ppOutput)); i++) {
|
||||
DXGI_OUTPUT_DESC outputDesc;
|
||||
output->GetDesc(&outputDesc);
|
||||
(*ppOutput)->GetDesc(&outputDesc);
|
||||
|
||||
if (outputDesc.Monitor == Monitor) {
|
||||
*ppOutput = output.ref();
|
||||
if (outputDesc.Monitor == Monitor)
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
(*ppOutput)->Release();
|
||||
(*ppOutput) = nullptr;
|
||||
}
|
||||
|
||||
// No such output found
|
||||
|
@ -51,6 +51,9 @@ namespace dxvk {
|
||||
|
||||
HRESULT STDMETHODCALLTYPE DxgiDevice::GetAdapter(
|
||||
IDXGIAdapter** pAdapter) {
|
||||
if (pAdapter == nullptr)
|
||||
return DXGI_ERROR_INVALID_CALL;
|
||||
|
||||
*pAdapter = static_cast<IDXGIAdapter*>(m_adapter.ref());
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -41,6 +41,10 @@ namespace dxvk {
|
||||
HRESULT STDMETHODCALLTYPE DxgiFactory::CreateSoftwareAdapter(
|
||||
HMODULE Module,
|
||||
IDXGIAdapter** ppAdapter) {
|
||||
if (ppAdapter == nullptr)
|
||||
return DXGI_ERROR_INVALID_CALL;
|
||||
|
||||
*ppAdapter = nullptr;
|
||||
Logger::err("DxgiFactory::CreateSoftwareAdapter: Software adapters not supported");
|
||||
return DXGI_ERROR_UNSUPPORTED;
|
||||
}
|
||||
@ -52,6 +56,7 @@ namespace dxvk {
|
||||
IDXGISwapChain** ppSwapChain) {
|
||||
if (ppSwapChain == nullptr || pDesc == nullptr || pDevice == NULL)
|
||||
return DXGI_ERROR_INVALID_CALL;
|
||||
|
||||
if (pDesc->OutputWindow == nullptr)
|
||||
return DXGI_ERROR_INVALID_CALL;
|
||||
|
||||
@ -73,8 +78,7 @@ namespace dxvk {
|
||||
|
||||
IDXGIAdapter1* handle = nullptr;
|
||||
HRESULT hr = this->EnumAdapters1(Adapter, &handle);
|
||||
if (SUCCEEDED(hr))
|
||||
*ppAdapter = handle;
|
||||
*ppAdapter = handle;
|
||||
return hr;
|
||||
}
|
||||
|
||||
@ -85,8 +89,10 @@ namespace dxvk {
|
||||
if (ppAdapter == nullptr)
|
||||
return DXGI_ERROR_INVALID_CALL;
|
||||
|
||||
if (Adapter >= m_adapters.size())
|
||||
if (Adapter >= m_adapters.size()) {
|
||||
*ppAdapter = nullptr;
|
||||
return DXGI_ERROR_NOT_FOUND;
|
||||
}
|
||||
|
||||
*ppAdapter = ref(new DxgiAdapter(
|
||||
this, m_adapters.at(Adapter)));
|
||||
|
@ -36,9 +36,7 @@ namespace dxvk {
|
||||
}
|
||||
|
||||
|
||||
HRESULT STDMETHODCALLTYPE DxgiOutput::GetParent(
|
||||
REFIID riid,
|
||||
void **ppParent) {
|
||||
HRESULT STDMETHODCALLTYPE DxgiOutput::GetParent(REFIID riid, void **ppParent) {
|
||||
return m_adapter->QueryInterface(riid, ppParent);
|
||||
}
|
||||
|
||||
|
@ -141,6 +141,7 @@ namespace dxvk {
|
||||
|
||||
if (ppTarget != nullptr) {
|
||||
*ppTarget = nullptr;
|
||||
|
||||
if (!m_desc.Windowed)
|
||||
hr = this->GetContainingOutput(ppTarget);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user