1
0
mirror of https://github.com/doitsujin/dxvk.git synced 2024-12-02 10:24:12 +01:00

[dxgi/d3d11] Remove COM_QUERY_INTERFACE macro, reset pointers

May fix some crashes in applications that rely on the returned
pointer being set to nullptr before returning.
This commit is contained in:
Philip Rebohle 2018-04-02 12:52:02 +02:00
parent 77010d96e4
commit 2973c18055
22 changed files with 201 additions and 99 deletions

View File

@ -40,10 +40,15 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11BlendState::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11BlendState);
COM_QUERY_IFACE(riid, ppvObject, ID3D11BlendState1);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11BlendState)
|| riid == __uuidof(ID3D11BlendState1)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11BlendState::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -23,10 +23,15 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11Buffer::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11Resource);
COM_QUERY_IFACE(riid, ppvObject, ID3D11Buffer);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11Resource)
|| riid == __uuidof(ID3D11Buffer)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11Buffer::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -16,9 +16,14 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11ClassLinkage::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11ClassLinkage);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11ClassLinkage)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11ClassLinkage::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -16,9 +16,14 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11CommandList::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11CommandList);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11CommandList)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11CommandList::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -39,13 +39,16 @@ namespace dxvk {
}
HRESULT STDMETHODCALLTYPE D3D11DeviceContext::QueryInterface(
REFIID riid,
void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceContext);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceContext1);
HRESULT STDMETHODCALLTYPE D3D11DeviceContext::QueryInterface(REFIID riid, void** ppvObject) {
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11DeviceContext)
|| riid == __uuidof(ID3D11DeviceContext1)) {
*ppvObject = ref(this);
return S_OK;
}
if (riid == __uuidof(ID3DUserDefinedAnnotation))
return E_NOINTERFACE;

View File

@ -25,9 +25,14 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11DepthStencilState::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DepthStencilState);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11DepthStencilState)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11DepthStencilState::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -28,6 +28,8 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11DeviceContainer::QueryInterface(REFIID riid, void** ppvObject) {
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(IDXGIObject)) {
*ppvObject = ref(this);

View File

@ -27,9 +27,14 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11InputLayout::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11InputLayout);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11InputLayout)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11InputLayout::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -48,13 +48,21 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11Query::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11Asynchronous);
COM_QUERY_IFACE(riid, ppvObject, ID3D11Query);
*ppvObject = nullptr;
if (m_desc.Query == D3D11_QUERY_OCCLUSION_PREDICATE)
COM_QUERY_IFACE(riid, ppvObject, ID3D11Predicate);
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11Asynchronous)
|| riid == __uuidof(ID3D11Query)) {
*ppvObject = ref(this);
return S_OK;
}
if (riid == __uuidof(ID3D11Predicate)
&& m_desc.Query == D3D11_QUERY_OCCLUSION_PREDICATE) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11Query: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -69,10 +69,15 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11RasterizerState::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11RasterizerState);
COM_QUERY_IFACE(riid, ppvObject, ID3D11RasterizerState1);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11RasterizerState)
|| riid == __uuidof(ID3D11RasterizerState1)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11RasterizerState::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -53,9 +53,14 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11SamplerState::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11SamplerState);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11SamplerState)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11SamplerState::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -73,9 +73,14 @@ namespace dxvk {
~D3D11Shader() { }
HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void** ppvObject) final {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, Base);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(Base)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11Shader::QueryInterface: Unknown interface query");
return E_NOINTERFACE;

View File

@ -295,10 +295,15 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11Texture1D::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11Resource);
COM_QUERY_IFACE(riid, ppvObject, ID3D11Texture1D);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11Resource)
|| riid == __uuidof(ID3D11Texture1D)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11Texture1D::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
@ -355,10 +360,15 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11Texture2D::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11Resource);
COM_QUERY_IFACE(riid, ppvObject, ID3D11Texture2D);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11Resource)
|| riid == __uuidof(ID3D11Texture2D)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11Texture2D::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));
@ -417,10 +427,15 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11Texture3D::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11Resource);
COM_QUERY_IFACE(riid, ppvObject, ID3D11Texture3D);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11Resource)
|| riid == __uuidof(ID3D11Texture3D)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11Texture3D::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -20,10 +20,15 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11DepthStencilView::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11View);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DepthStencilView);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11View)
|| riid == __uuidof(ID3D11DepthStencilView)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11DepthStencilView::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -20,10 +20,15 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11RenderTargetView::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11View);
COM_QUERY_IFACE(riid, ppvObject, ID3D11RenderTargetView);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11View)
|| riid == __uuidof(ID3D11RenderTargetView)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11RenderTargetView::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -29,10 +29,15 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11ShaderResourceView::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11View);
COM_QUERY_IFACE(riid, ppvObject, ID3D11ShaderResourceView);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11View)
|| riid == __uuidof(ID3D11ShaderResourceView)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11ShaderResourceView::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -34,10 +34,15 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE D3D11UnorderedAccessView::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, ID3D11DeviceChild);
COM_QUERY_IFACE(riid, ppvObject, ID3D11View);
COM_QUERY_IFACE(riid, ppvObject, ID3D11UnorderedAccessView);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(ID3D11DeviceChild)
|| riid == __uuidof(ID3D11View)
|| riid == __uuidof(ID3D11UnorderedAccessView)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("D3D11UnorderedAccessView::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -26,11 +26,16 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE DxgiAdapter::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, IDXGIObject);
COM_QUERY_IFACE(riid, ppvObject, IDXGIAdapter);
COM_QUERY_IFACE(riid, ppvObject, IDXGIAdapter1);
COM_QUERY_IFACE(riid, ppvObject, IDXGIVkAdapter);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(IDXGIObject)
|| riid == __uuidof(IDXGIAdapter)
|| riid == __uuidof(IDXGIAdapter1)
|| riid == __uuidof(IDXGIVkAdapter)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("DxgiAdapter::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -16,13 +16,16 @@ namespace dxvk {
}
HRESULT STDMETHODCALLTYPE DxgiFactory::QueryInterface(
REFIID riid,
void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, IDXGIObject);
COM_QUERY_IFACE(riid, ppvObject, IDXGIFactory);
COM_QUERY_IFACE(riid, ppvObject, IDXGIFactory1);
HRESULT STDMETHODCALLTYPE DxgiFactory::QueryInterface(REFIID riid, void** ppvObject) {
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(IDXGIObject)
|| riid == __uuidof(IDXGIFactory)
|| riid == __uuidof(IDXGIFactory1)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("DxgiFactory::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -26,9 +26,14 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE DxgiOutput::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, IDXGIObject);
COM_QUERY_IFACE(riid, ppvObject, IDXGIOutput);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(IDXGIObject)
|| riid == __uuidof(IDXGIOutput)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("DxgiOutput::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -60,10 +60,15 @@ namespace dxvk {
HRESULT STDMETHODCALLTYPE DxgiSwapChain::QueryInterface(REFIID riid, void** ppvObject) {
COM_QUERY_IFACE(riid, ppvObject, IUnknown);
COM_QUERY_IFACE(riid, ppvObject, IDXGIObject);
COM_QUERY_IFACE(riid, ppvObject, IDXGIDeviceSubObject);
COM_QUERY_IFACE(riid, ppvObject, IDXGISwapChain);
*ppvObject = nullptr;
if (riid == __uuidof(IUnknown)
|| riid == __uuidof(IDXGIObject)
|| riid == __uuidof(IDXGIDeviceSubObject)
|| riid == __uuidof(IDXGISwapChain)) {
*ppvObject = ref(this);
return S_OK;
}
Logger::warn("DxgiSwapChain::QueryInterface: Unknown interface query");
Logger::warn(str::format(riid));

View File

@ -3,15 +3,6 @@
#include <atomic>
#include "com_include.h"
#define COM_QUERY_IFACE(riid, ppvObject, Iface) \
do { \
if (riid == __uuidof(Iface)) { \
this->AddRef(); \
*ppvObject = static_cast<Iface*>(this); \
return S_OK; \
} \
} while (0)
namespace dxvk {