From a3c614bc48e3ac818164b8781bb97d968a66c037 Mon Sep 17 00:00:00 2001 From: Marijn Suijten Date: Thu, 6 Mar 2025 11:01:09 +0100 Subject: [PATCH] Add missing SAL Annotations for improved COM API wrapping Since the API exposed by some of these headers uses COM, annotating them with the necessary SAL annotations make it more convenient to generate comprehensive external bindings for them, such as in Rust: https://github.com/Traverse-Research/amd-ext-d3d-rs --- AmdDxExt.h | 4 ++-- AmdDxExtApi.h | 4 ++-- AmdDxExtIface.h | 4 ++-- AmdDxExtPerfProfile.h | 2 +- AmdDxExtPerfProfileApi.h | 2 +- AmdExtD3D.h | 18 +++++++++--------- AmdExtD3DCommandListMarkerApi.h | 2 +- AmdExtD3DDeviceApi.h | 7 +++---- AmdExtGpaInterfaceApi.h | 2 +- 9 files changed, 22 insertions(+), 23 deletions(-) diff --git a/AmdDxExt.h b/AmdDxExt.h index 82bd88e..453cc72 100644 --- a/AmdDxExt.h +++ b/AmdDxExt.h @@ -8,7 +8,7 @@ /** *************************************************************************************************** * @file amddxext.h -* @brief AMD D3D Exension API include file. +* @brief AMD D3D Extension API include file. *************************************************************************************************** */ #ifndef _AMDDXEXT_H_ @@ -44,4 +44,4 @@ enum AmdDxExtFeatureToken AmdDxExtFeature_DeviceCtxSupport = 3, // Device Ctx Support }; -#endif // _AMDDXEXT_H_ \ No newline at end of file +#endif // _AMDDXEXT_H_ diff --git a/AmdDxExtApi.h b/AmdDxExtApi.h index 7b4f11a..85c2ac8 100644 --- a/AmdDxExtApi.h +++ b/AmdDxExtApi.h @@ -8,7 +8,7 @@ /** *************************************************************************************************** * @file amddxextapi.h -* @brief AMD D3D Exension API include file. This is the main include file for apps using extensions. +* @brief AMD D3D Extension API include file. This is the main include file for apps using extensions. *************************************************************************************************** */ #ifndef _AMDDXEXTAPI_H_ @@ -26,7 +26,7 @@ interface ID3D11Device; interface ID3D10Resource; interface ID3D11Resource; -// App must use GetProcAddress, etc. to retrive this exported function +// App must use GetProcAddress, etc. to retrieve this exported function // The associated typedef provides a convenient way to define the function pointer HRESULT __cdecl AmdDxExtCreate(ID3D10Device* pDevice, IAmdDxExt** ppExt); typedef HRESULT (__cdecl *PFNAmdDxExtCreate)(ID3D10Device* pDevice, IAmdDxExt** ppExt); diff --git a/AmdDxExtIface.h b/AmdDxExtIface.h index 263bab0..ac5cc8a 100644 --- a/AmdDxExtIface.h +++ b/AmdDxExtIface.h @@ -10,7 +10,7 @@ *************************************************************************************************** * @file amddxextiface.h * @brief -* AMD D3D Exension API include file. This is a helper include file for extensions. It +* AMD D3D Extension API include file. This is a helper include file for extensions. It * provides a common base class for all extension interfaces *************************************************************************************************** */ @@ -38,4 +38,4 @@ class IAmdDxExtInterface virtual ~IAmdDxExtInterface() = 0 {}; }; -#endif // _AMDDXEXTIFACE_H_ \ No newline at end of file +#endif // _AMDDXEXTIFACE_H_ diff --git a/AmdDxExtPerfProfile.h b/AmdDxExtPerfProfile.h index 73c7781..9f333c8 100644 --- a/AmdDxExtPerfProfile.h +++ b/AmdDxExtPerfProfile.h @@ -9,7 +9,7 @@ *************************************************************************************************** * @file amddxextperfprofile.h * @brief -* AMD D3D Exension API include file. This is a helper include file for extensions. It +* AMD D3D Extension API include file. This is a helper include file for extensions. It * provides a common base class for all extension interfaces *************************************************************************************************** */ diff --git a/AmdDxExtPerfProfileApi.h b/AmdDxExtPerfProfileApi.h index 781ff35..4478037 100644 --- a/AmdDxExtPerfProfileApi.h +++ b/AmdDxExtPerfProfileApi.h @@ -10,7 +10,7 @@ *************************************************************************************************** * @file amddxextperfprofileapi.h * @brief -* AMD D3D Perf Profile Exension API include file. +* AMD D3D Perf Profile Extension API include file. * This is the main include file for apps using perf profile extension. *************************************************************************************************** */ diff --git a/AmdExtD3D.h b/AmdExtD3D.h index 3d9cac7..ac329ce 100644 --- a/AmdExtD3D.h +++ b/AmdExtD3D.h @@ -26,7 +26,7 @@ /** *********************************************************************************************************************** * @file AmdExtD3D.h -* @brief AMD D3D Exension API factory include file. +* @brief AMD D3D Extension API factory include file. *********************************************************************************************************************** */ #pragma once @@ -45,10 +45,10 @@ // The app must use GetProcAddress, etc. to retrieve this exported function // The associated typedef provides a convenient way to define the function pointer HRESULT __cdecl AmdExtD3DCreateInterface( - IUnknown* pOuter, ///< [in] object on which to base this new interface; usually a D3D device - REFIID riid, ///< ID of the requested interface - void** ppvObject); ///< [out] The result interface object -typedef HRESULT (__cdecl *PFNAmdExtD3DCreateInterface)(IUnknown* pOuter, REFIID riid, void** ppvObject); + IUnknown* pOuter, ///< [in] object on which to base this new interface; usually a D3D device + REFIID riid, ///< ID of the requested interface + _COM_Outptr_ void** ppvObject); ///< [out] The result interface object +typedef HRESULT (__cdecl *PFNAmdExtD3DCreateInterface)(IUnknown* pOuter, REFIID riid, _COM_Outptr_ void** ppvObject); /** *********************************************************************************************************************** @@ -62,8 +62,8 @@ IAmdExtD3DFactory : public IUnknown { public: virtual HRESULT CreateInterface( - IUnknown* pOuter, ///< [in] An object on which to base this new interface; the required object type - ///< is usually a device object but not always - REFIID riid, ///< The ID of the requested interface - void** ppvObject) = 0; ///< [out] The result interface object + IUnknown* pOuter, ///< [in] An object on which to base this new interface; the required object type + ///< is usually a device object but not always + REFIID riid, ///< The ID of the requested interface + _COM_Outptr_ void** ppvObject) = 0; ///< [out] The result interface object }; diff --git a/AmdExtD3DCommandListMarkerApi.h b/AmdExtD3DCommandListMarkerApi.h index c97f552..b1e63e5 100644 --- a/AmdExtD3DCommandListMarkerApi.h +++ b/AmdExtD3DCommandListMarkerApi.h @@ -51,4 +51,4 @@ IAmdExtD3DCommandListMarker : public IUnknown virtual VOID PopMarker() = 0; /// Set a command list marker to indicate a rendering activity virtual VOID SetMarker(const char* pMarker) = 0; -}; \ No newline at end of file +}; diff --git a/AmdExtD3DDeviceApi.h b/AmdExtD3DDeviceApi.h index a26a67d..e96d096 100644 --- a/AmdExtD3DDeviceApi.h +++ b/AmdExtD3DDeviceApi.h @@ -25,9 +25,8 @@ */ #pragma once -#include "unknwn.h" +#include #include -#include "AmdExtD3DDeviceApi.h" /** *********************************************************************************************************************** @@ -88,7 +87,7 @@ IAmdExtD3DDevice : public IUnknown const AmdExtD3DCreateInfo* pAmdExtCreateInfo, const D3D12_GRAPHICS_PIPELINE_STATE_DESC* pDesc, REFIID riid, - void** ppPipelineState) = 0; + _COM_Outptr_ void** ppPipelineState) = 0; }; /** @@ -103,4 +102,4 @@ IAmdExtD3DDevice1 : public IAmdExtD3DDevice virtual VOID PushMarker(ID3D12GraphicsCommandList* pGfxCmdList, const char* pMarker) = 0; virtual VOID PopMarker(ID3D12GraphicsCommandList* pGfxCmdList) = 0; virtual VOID SetMarker(ID3D12GraphicsCommandList* pGfxCmdList, const char* pMarker) = 0; -}; \ No newline at end of file +}; diff --git a/AmdExtGpaInterfaceApi.h b/AmdExtGpaInterfaceApi.h index 0f153d1..fd60557 100644 --- a/AmdExtGpaInterfaceApi.h +++ b/AmdExtGpaInterfaceApi.h @@ -81,7 +81,7 @@ IAmdExtGpaSession : public IUnknown virtual UINT32 BeginSample(ID3D12GraphicsCommandList* pGfxCmdList, const AmdExtGpaSampleConfig& config) = 0; virtual VOID EndSample(ID3D12GraphicsCommandList* pGfxCmdList, UINT32 sampleId) = 0; virtual bool IsReady() const = 0; - virtual HRESULT GetResults(UINT32 sampleId, size_t* pSizeInBytes, void *pData) const = 0; + virtual HRESULT GetResults(UINT32 sampleId, _Inout_ size_t* pSizeInBytes, _Out_writes_bytes_opt_(*pSizeInBytes) void *pData) const = 0; virtual HRESULT Reset() = 0; virtual VOID CopyResults(ID3D12GraphicsCommandList* pGfxCmdList) = 0; };