From 995949a9f97dff16ad77425d88567930ff96b9bf Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Wed, 27 Feb 2019 20:46:21 +0000 Subject: [PATCH] [d3d10] Fix and cleanup S_FALSE handling --- src/d3d10/d3d10_device.cpp | 176 ++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 98 deletions(-) diff --git a/src/d3d10/d3d10_device.cpp b/src/d3d10/d3d10_device.cpp index 8e8f7fb54..f9485d354 100644 --- a/src/d3d10/d3d10_device.cpp +++ b/src/d3d10/d3d10_device.cpp @@ -110,13 +110,12 @@ namespace dxvk { reinterpret_cast(pInitialData), ppBuffer != nullptr ? &d3d11Buffer : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppBuffer != nullptr) { - *ppBuffer = static_cast(d3d11Buffer)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppBuffer = static_cast(d3d11Buffer)->GetD3D10Iface(); + + return S_OK; } @@ -144,13 +143,12 @@ namespace dxvk { reinterpret_cast(pInitialData), ppTexture1D != nullptr ? &d3d11Texture1D : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppTexture1D != nullptr) { - *ppTexture1D = static_cast(d3d11Texture1D)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppTexture1D = static_cast(d3d11Texture1D)->GetD3D10Iface(); + + return S_OK; } @@ -180,13 +178,12 @@ namespace dxvk { reinterpret_cast(pInitialData), ppTexture2D != nullptr ? &d3d11Texture2D : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppTexture2D != nullptr) { - *ppTexture2D = static_cast(d3d11Texture2D)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppTexture2D = static_cast(d3d11Texture2D)->GetD3D10Iface(); + + return S_OK; } @@ -215,13 +212,12 @@ namespace dxvk { reinterpret_cast(pInitialData), ppTexture3D != nullptr ? &d3d11Texture3D : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppTexture3D != nullptr) { - *ppTexture3D = static_cast(d3d11Texture3D)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppTexture3D = static_cast(d3d11Texture3D)->GetD3D10Iface(); + + return S_OK; } @@ -242,13 +238,12 @@ namespace dxvk { reinterpret_cast(pDesc), ppSRView ? &d3d11Srv : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppSRView != nullptr) { - *ppSRView = static_cast(d3d11Srv)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppSRView = static_cast(d3d11Srv)->GetD3D10Iface(); + + return S_OK; } @@ -269,13 +264,12 @@ namespace dxvk { reinterpret_cast(pDesc), ppSRView ? &d3d11View : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppSRView != nullptr) { - *ppSRView = static_cast(d3d11View)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppSRView = static_cast(d3d11View)->GetD3D10Iface(); + + return S_OK; } @@ -296,13 +290,12 @@ namespace dxvk { reinterpret_cast(pDesc), ppRTView ? &d3d11View : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppRTView != nullptr) { - *ppRTView = static_cast(d3d11View)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppRTView = static_cast(d3d11View)->GetD3D10Iface(); + + return S_OK; } @@ -366,13 +359,12 @@ namespace dxvk { d3d11Resource.ptr(), pDesc ? &d3d11Desc : nullptr, ppDepthStencilView ? &d3d11View : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppDepthStencilView != nullptr) { - *ppDepthStencilView = static_cast(d3d11View)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppDepthStencilView = static_cast(d3d11View)->GetD3D10Iface(); + + return S_OK; } @@ -396,8 +388,7 @@ namespace dxvk { if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppInputLayout) - *ppInputLayout = static_cast(d3d11InputLayout)->GetD3D10Iface(); + *ppInputLayout = static_cast(d3d11InputLayout)->GetD3D10Iface(); return hr; } @@ -415,13 +406,12 @@ namespace dxvk { pShaderBytecode, BytecodeLength, nullptr, ppVertexShader ? &d3d11Shader : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppVertexShader != nullptr) { - *ppVertexShader = static_cast(d3d11Shader)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppVertexShader = static_cast(d3d11Shader)->GetD3D10Iface(); + + return S_OK; } @@ -437,13 +427,12 @@ namespace dxvk { pShaderBytecode, BytecodeLength, nullptr, ppGeometryShader ? &d3d11Shader : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppGeometryShader != nullptr) { - *ppGeometryShader = static_cast(d3d11Shader)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppGeometryShader = static_cast(d3d11Shader)->GetD3D10Iface(); + + return S_OK; } @@ -477,13 +466,12 @@ namespace dxvk { D3D11_SO_NO_RASTERIZED_STREAM, nullptr, ppGeometryShader ? &d3d11Shader : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppGeometryShader != nullptr) { - *ppGeometryShader = static_cast(d3d11Shader)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppGeometryShader = static_cast(d3d11Shader)->GetD3D10Iface(); + + return S_OK; } @@ -499,13 +487,12 @@ namespace dxvk { pShaderBytecode, BytecodeLength, nullptr, ppPixelShader ? &d3d11Shader : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppPixelShader != nullptr) { - *ppPixelShader = static_cast(d3d11Shader)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppPixelShader = static_cast(d3d11Shader)->GetD3D10Iface(); + + return S_OK; } @@ -536,13 +523,12 @@ namespace dxvk { HRESULT hr = m_device->CreateBlendState(&d3d11Desc, ppBlendState ? &d3d11BlendState : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppBlendState != nullptr) { - *ppBlendState = static_cast(d3d11BlendState)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppBlendState = static_cast(d3d11BlendState)->GetD3D10Iface(); + + return S_OK; } @@ -556,13 +542,12 @@ namespace dxvk { reinterpret_cast(pBlendStateDesc), ppBlendState ? &d3d11BlendState : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppBlendState != nullptr) { - *ppBlendState = static_cast(d3d11BlendState)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppBlendState = static_cast(d3d11BlendState)->GetD3D10Iface(); + + return S_OK; } @@ -576,13 +561,12 @@ namespace dxvk { reinterpret_cast(pDepthStencilDesc), ppDepthStencilState ? &d3d11DepthStencilState : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppDepthStencilState != nullptr) { - *ppDepthStencilState = static_cast(d3d11DepthStencilState)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppDepthStencilState = static_cast(d3d11DepthStencilState)->GetD3D10Iface(); + + return S_OK; } @@ -596,13 +580,12 @@ namespace dxvk { reinterpret_cast(pRasterizerDesc), ppRasterizerState ? &d3d11RasterizerState : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppRasterizerState != nullptr) { - *ppRasterizerState = static_cast(d3d11RasterizerState)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppRasterizerState = static_cast(d3d11RasterizerState)->GetD3D10Iface(); + + return S_OK; } @@ -632,13 +615,12 @@ namespace dxvk { HRESULT hr = m_device->CreateSamplerState(&d3d11Desc, ppSamplerState ? &d3d11SamplerState : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppSamplerState) { - *ppSamplerState = static_cast(d3d11SamplerState)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppSamplerState = static_cast(d3d11SamplerState)->GetD3D10Iface(); + + return S_OK; } @@ -658,13 +640,12 @@ namespace dxvk { HRESULT hr = m_device->CreateQuery(&d3d11Desc, ppQuery ? &d3d11Query : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - - if (ppQuery != nullptr) { - *ppQuery = static_cast(d3d11Query)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + + *ppQuery = static_cast(d3d11Query)->GetD3D10Iface(); + + return S_OK; } @@ -681,13 +662,12 @@ namespace dxvk { HRESULT hr = m_device->CreatePredicate(&d3d11Desc, ppPredicate ? &d3d11Predicate : nullptr); - if (FAILED(hr)) + if (FAILED(hr) || hr == S_FALSE) return hr; - if (ppPredicate != nullptr) { - *ppPredicate = static_cast(d3d11Predicate)->GetD3D10Iface(); - return S_OK; - } return S_FALSE; + *ppPredicate = static_cast(d3d11Predicate)->GetD3D10Iface(); + + return S_OK; }