Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/dxc/DxilContainer/DxcContainerBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class DxcContainerBuilder : public IDxcContainerBuilder {
HRESULT STDMETHODCALLTYPE RemovePart(UINT32 fourCC) override;
// Builds a container of the given container builder state
HRESULT STDMETHODCALLTYPE
SerializeContainer(IDxcOperationResult **ppResult) override;
SerializeContainer(_COM_Outptr_ IDxcOperationResult **ppResult) override;

DXC_MICROCOM_TM_ADDREF_RELEASE_IMPL()
DXC_MICROCOM_TM_CTOR(DxcContainerBuilder)
Expand Down
34 changes: 17 additions & 17 deletions include/dxc/dxcapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ struct IDxcIncludeHandler;
/// This can be used with GetProcAddress to get the DxcCreateInstance function.
typedef HRESULT(__stdcall *DxcCreateInstanceProc)(_In_ REFCLSID rclsid,
_In_ REFIID riid,
_Out_ LPVOID *ppv);
_COM_Outptr_ LPVOID *ppv);

/// \brief Typedef for DxcCreateInstance2 function pointer.
///
/// This can be used with GetProcAddress to get the DxcCreateInstance2 function.
typedef HRESULT(__stdcall *DxcCreateInstance2Proc)(_In_ IMalloc *pMalloc,
_In_ REFCLSID rclsid,
_In_ REFIID riid,
_Out_ LPVOID *ppv);
_COM_Outptr_ LPVOID *ppv);

/// \brief Creates a single uninitialized object of the class associated with a
/// specified CLSID.
Expand All @@ -71,18 +71,17 @@ typedef HRESULT(__stdcall *DxcCreateInstance2Proc)(_In_ IMalloc *pMalloc,
///
/// While this function is similar to CoCreateInstance, there is no COM
/// involvement.
extern "C" DXC_API_IMPORT
HRESULT __stdcall DxcCreateInstance(_In_ REFCLSID rclsid, _In_ REFIID riid,
_Out_ LPVOID *ppv);
extern "C" DXC_API_IMPORT HRESULT __stdcall
DxcCreateInstance(_In_ REFCLSID rclsid, _In_ REFIID riid,
_COM_Outptr_ LPVOID *ppv);

/// \brief Version of DxcCreateInstance that takes an IMalloc interface.
///
/// This can be used to create an instance of the compiler with a custom memory
/// allocator.
extern "C" DXC_API_IMPORT
HRESULT __stdcall DxcCreateInstance2(_In_ IMalloc *pMalloc,
_In_ REFCLSID rclsid, _In_ REFIID riid,
_Out_ LPVOID *ppv);
extern "C" DXC_API_IMPORT HRESULT __stdcall
DxcCreateInstance2(_In_ IMalloc *pMalloc, _In_ REFCLSID rclsid,
_In_ REFIID riid, _COM_Outptr_ LPVOID *ppv);

// For convenience, equivalent definitions to CP_UTF8 and CP_UTF16.
#define DXC_CP_UTF8 65001
Expand Down Expand Up @@ -684,8 +683,9 @@ struct IDxcUtils : public IUnknown {
/// newly created reflection interface.
///
/// Use this with interfaces such as ID3D12ShaderReflection.
virtual HRESULT STDMETHODCALLTYPE CreateReflection(
_In_ const DxcBuffer *pData, REFIID iid, void **ppvReflection) = 0;
virtual HRESULT STDMETHODCALLTYPE
CreateReflection(_In_ const DxcBuffer *pData, REFIID iid,
_COM_Outptr_result_maybenull_ void **ppvReflection) = 0;

/// \brief Build arguments that can be passed to the Compile method.
virtual HRESULT STDMETHODCALLTYPE BuildArguments(
Expand Down Expand Up @@ -849,18 +849,18 @@ struct IDxcCompiler3 : public IUnknown {
LPCWSTR *pArguments, ///< Array of pointers to arguments.
_In_ UINT32 argCount, ///< Number of arguments.
_In_opt_ IDxcIncludeHandler
*pIncludeHandler, ///< user-provided interface to handle include
///< directives (optional).
_In_ REFIID riid, ///< Interface ID for the result.
_Out_ LPVOID *ppResult ///< IDxcResult: status, buffer, and errors.
*pIncludeHandler, ///< user-provided interface to handle include
///< directives (optional).
_In_ REFIID riid, ///< Interface ID for the result.
_COM_Outptr_ LPVOID *ppResult ///< IDxcResult: status, buffer, and errors.
) = 0;

/// \brief Disassemble a program.
virtual HRESULT STDMETHODCALLTYPE Disassemble(
_In_ const DxcBuffer
*pObject, ///< Program to disassemble: dxil container or bitcode.
_In_ REFIID riid, ///< Interface ID for the result.
_Out_ LPVOID
_COM_Outptr_ LPVOID
*ppResult ///< IDxcResult: status, disassembly text, and errors.
) = 0;
};
Expand Down Expand Up @@ -933,7 +933,7 @@ struct IDxcContainerBuilder : public IUnknown {
///
/// \param ppResult Pointer to variable to receive the result.
virtual HRESULT STDMETHODCALLTYPE
SerializeContainer(_Out_ IDxcOperationResult **ppResult) = 0;
SerializeContainer(_COM_Outptr_ IDxcOperationResult **ppResult) = 0;
};

CROSS_PLATFORM_UUIDOF(IDxcAssembler, "091f7a26-1c1f-4948-904b-e6e3a8a771d5")
Expand Down
2 changes: 1 addition & 1 deletion include/dxc/dxcapi.internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ CROSS_PLATFORM_UUIDOF(IDxcContainerEventsHandler,
struct IDxcContainerEventsHandler : public IUnknown {
public:
virtual HRESULT STDMETHODCALLTYPE
OnDxilContainerBuilt(IDxcBlob *pSource, IDxcBlob **ppTarget) = 0;
OnDxilContainerBuilt(IDxcBlob *pSource, _COM_Outptr_ IDxcBlob **ppTarget) = 0;
};

CROSS_PLATFORM_UUIDOF(IDxcContainerEvent,
Expand Down
5 changes: 2 additions & 3 deletions include/dxc/dxcdxrfallbackcompiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ CLSID_SCOPE const GUID CLSID_DxcDxrFallbackCompiler = {
0x4b72,
{0x9e, 0x10, 0x63, 0xcd, 0x97, 0xdf, 0x57, 0xf0}};

typedef HRESULT(__stdcall *DxcCreateDxrFallbackCompilerProc)(REFCLSID rclsid,
REFIID riid,
LPVOID *ppv);
typedef HRESULT(__stdcall *DxcCreateDxrFallbackCompilerProc)(
REFCLSID rclsid, REFIID riid, _COM_Outptr_ LPVOID *ppv);

#endif
32 changes: 24 additions & 8 deletions include/dxc/dxcisense.h
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,12 @@ struct IDxcCodeCompleteResults;
struct IDxcCompletionResult;
struct IDxcCompletionString;

// TODO for nullonfailure:
// https://learn.microsoft.com/en-us/cpp/code-quality/annotating-function-parameters-and-return-values
// > Certain interface conventions presume that output parameters are nullified
// on failure. Except for explicitly COM code, the forms in the following table
// are preferred. For COM code, use the corresponding COM forms that are listed
// in the previous section.
CROSS_PLATFORM_UUIDOF(IDxcCursor, "1467b985-288d-4d2a-80c1-ef89c42c40bc")
struct IDxcCursor : public IUnknown {
virtual HRESULT STDMETHODCALLTYPE
Expand Down Expand Up @@ -725,7 +731,7 @@ struct IDxcCursor : public IUnknown {
/// cursor.</summary>
virtual HRESULT STDMETHODCALLTYPE
GetSnappedChild(_In_ IDxcSourceLocation *location,
_Outptr_result_maybenull_ IDxcCursor **pResult) = 0;
_COM_Outptr_result_maybenull_ IDxcCursor **pResult) = 0;
};

CROSS_PLATFORM_UUIDOF(IDxcDiagnostic, "4f76b234-3659-4d33-99b0-3b0db994b564")
Expand All @@ -736,6 +742,7 @@ struct IDxcDiagnostic : public IUnknown {
virtual HRESULT STDMETHODCALLTYPE
GetSeverity(_Out_ DxcDiagnosticSeverity *pResult) = 0;
virtual HRESULT STDMETHODCALLTYPE
// COM_Outptr_?
GetLocation(_Outptr_result_nullonfailure_ IDxcSourceLocation **pResult) = 0;
virtual HRESULT STDMETHODCALLTYPE
GetSpelling(_Outptr_result_maybenull_ LPSTR *pResult) = 0;
Expand All @@ -744,10 +751,12 @@ struct IDxcDiagnostic : public IUnknown {
virtual HRESULT STDMETHODCALLTYPE GetNumRanges(_Out_ unsigned *pResult) = 0;
virtual HRESULT STDMETHODCALLTYPE
GetRangeAt(unsigned index,
// COM_Outptr_?
_Outptr_result_nullonfailure_ IDxcSourceRange **pResult) = 0;
virtual HRESULT STDMETHODCALLTYPE GetNumFixIts(_Out_ unsigned *pResult) = 0;
virtual HRESULT STDMETHODCALLTYPE
GetFixItAt(unsigned index,
// COM_Outptr_?
_Outptr_result_nullonfailure_ IDxcSourceRange **pReplacementRange,
_Outptr_result_maybenull_ LPSTR *pText) = 0;
};
Expand All @@ -766,10 +775,12 @@ struct IDxcFile : public IUnknown {
CROSS_PLATFORM_UUIDOF(IDxcInclusion, "0c364d65-df44-4412-888e-4e552fc5e3d6")
struct IDxcInclusion : public IUnknown {
virtual HRESULT STDMETHODCALLTYPE
// COM_Outptr_?
GetIncludedFile(_Outptr_result_nullonfailure_ IDxcFile **pResult) = 0;
virtual HRESULT STDMETHODCALLTYPE GetStackLength(_Out_ unsigned *pResult) = 0;
virtual HRESULT STDMETHODCALLTYPE
GetStackItem(unsigned index,
// COM_Outptr_?
_Outptr_result_nullonfailure_ IDxcSourceLocation **pResult) = 0;
};

Expand All @@ -790,6 +801,7 @@ struct IDxcIntelliSense : public IUnknown {
GetDefaultEditingTUOptions(_Out_ DxcTranslationUnitFlags *pValue) = 0;
virtual HRESULT STDMETHODCALLTYPE CreateUnsavedFile(
_In_ LPCSTR fileName, _In_ LPCSTR contents, unsigned contentLength,
// COM_Outptr_?
_Outptr_result_nullonfailure_ IDxcUnsavedFile **pResult) = 0;
};

Expand All @@ -805,7 +817,7 @@ struct IDxcIndex : public IUnknown {
int num_command_line_args,
_In_count_(num_unsaved_files) IDxcUnsavedFile **unsaved_files,
unsigned num_unsaved_files, DxcTranslationUnitFlags options,
_Out_ IDxcTranslationUnit **pTranslationUnit) = 0;
_COM_Outptr_ IDxcTranslationUnit **pTranslationUnit) = 0;
};

CROSS_PLATFORM_UUIDOF(IDxcSourceLocation,
Expand All @@ -814,7 +826,7 @@ struct IDxcSourceLocation : public IUnknown {
virtual HRESULT STDMETHODCALLTYPE IsEqualTo(_In_ IDxcSourceLocation *other,
_Out_ BOOL *pResult) = 0;
virtual HRESULT STDMETHODCALLTYPE GetSpellingLocation(
_Outptr_opt_ IDxcFile **pFile, _Out_opt_ unsigned *pLine,
_COM_Outptr_opt_ IDxcFile **pFile, _Out_opt_ unsigned *pLine,
_Out_opt_ unsigned *pCol, _Out_opt_ unsigned *pOffset) = 0;
virtual HRESULT STDMETHODCALLTYPE IsNull(_Out_ BOOL *pResult) = 0;
virtual HRESULT STDMETHODCALLTYPE
Expand All @@ -826,9 +838,9 @@ CROSS_PLATFORM_UUIDOF(IDxcSourceRange, "f1359b36-a53f-4e81-b514-b6b84122a13f")
struct IDxcSourceRange : public IUnknown {
virtual HRESULT STDMETHODCALLTYPE IsNull(_Out_ BOOL *pValue) = 0;
virtual HRESULT STDMETHODCALLTYPE
GetStart(_Out_ IDxcSourceLocation **pValue) = 0;
GetStart(_COM_Outptr IDxcSourceLocation **pValue) = 0;
virtual HRESULT STDMETHODCALLTYPE
GetEnd(_Out_ IDxcSourceLocation **pValue) = 0;
GetEnd(_COM_Outptr IDxcSourceLocation **pValue) = 0;
virtual HRESULT STDMETHODCALLTYPE GetOffsets(_Out_ unsigned *startOffset,
_Out_ unsigned *endOffset) = 0;
};
Expand All @@ -837,30 +849,34 @@ CROSS_PLATFORM_UUIDOF(IDxcToken, "7f90b9ff-a275-4932-97d8-3cfd234482a2")
struct IDxcToken : public IUnknown {
virtual HRESULT STDMETHODCALLTYPE GetKind(_Out_ DxcTokenKind *pValue) = 0;
virtual HRESULT STDMETHODCALLTYPE
GetLocation(_Out_ IDxcSourceLocation **pValue) = 0;
GetLocation(_COM_Outptr_ IDxcSourceLocation **pValue) = 0;
virtual HRESULT STDMETHODCALLTYPE
GetExtent(_Out_ IDxcSourceRange **pValue) = 0;
GetExtent(_COM_Outptr_ IDxcSourceRange **pValue) = 0;
virtual HRESULT STDMETHODCALLTYPE GetSpelling(_Out_ LPSTR *pValue) = 0;
};

CROSS_PLATFORM_UUIDOF(IDxcTranslationUnit,
"9677dee0-c0e5-46a1-8b40-3db3168be63d")
struct IDxcTranslationUnit : public IUnknown {
virtual HRESULT STDMETHODCALLTYPE GetCursor(_Out_ IDxcCursor **pCursor) = 0;
virtual HRESULT STDMETHODCALLTYPE
GetCursor(_COM_Outptr_ IDxcCursor **pCursor) = 0;
virtual HRESULT STDMETHODCALLTYPE
Tokenize(_In_ IDxcSourceRange *range,
_Outptr_result_buffer_maybenull_(*pTokenCount) IDxcToken ***pTokens,
_Out_ unsigned *pTokenCount) = 0;
virtual HRESULT STDMETHODCALLTYPE
GetLocation(_In_ IDxcFile *file, unsigned line, unsigned column,
// COM_Outptr_?
_Outptr_result_nullonfailure_ IDxcSourceLocation **pResult) = 0;
virtual HRESULT STDMETHODCALLTYPE
GetNumDiagnostics(_Out_ unsigned *pValue) = 0;
virtual HRESULT STDMETHODCALLTYPE
GetDiagnostic(unsigned index,
// COM_Outptr_?
_Outptr_result_nullonfailure_ IDxcDiagnostic **pValue) = 0;
virtual HRESULT STDMETHODCALLTYPE
GetFile(_In_ const char *name,
// COM_Outptr_?
_Outptr_result_nullonfailure_ IDxcFile **pResult) = 0;
virtual HRESULT STDMETHODCALLTYPE
GetFileName(_Outptr_result_maybenull_ LPSTR *pResult) = 0;
Expand Down
15 changes: 7 additions & 8 deletions projects/dxilconv/include/DxbcConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,16 @@
#ifndef _MSC_VER
extern "C"
#endif
DXC_API_IMPORT HRESULT __stdcall DxcCreateInstance(_In_ REFCLSID rclsid,
_In_ REFIID riid,
_Out_ LPVOID *ppv);
DXC_API_IMPORT HRESULT __stdcall
DxcCreateInstance(_In_ REFCLSID rclsid, _In_ REFIID riid,
_COM_Outptr_ LPVOID *ppv);

#ifndef _MSC_VER
extern "C"
#endif
DXC_API_IMPORT HRESULT __stdcall DxcCreateInstance2(_In_ IMalloc *pMalloc,
_In_ REFCLSID rclsid,
_In_ REFIID riid,
_Out_ LPVOID *ppv);
DXC_API_IMPORT HRESULT __stdcall
DxcCreateInstance2(_In_ IMalloc *pMalloc, _In_ REFCLSID rclsid,
_In_ REFIID riid, _COM_Outptr_ LPVOID *ppv);

struct __declspec(uuid("5F956ED5-78D1-4B15-8247-F7187614A041")) IDxbcConverter
: public IUnknown {
Expand All @@ -47,7 +46,7 @@ struct __declspec(uuid("5F956ED5-78D1-4B15-8247-F7187614A041")) IDxbcConverter
_In_ UINT32 NumOutputSignatureElements,
_In_opt_z_ LPCVOID pPatchConstantSignature,
_In_ UINT32 NumPatchConstantSignatureElements,
_In_opt_z_ LPCWSTR pExtraOptions, _Out_ IDxcBlob **ppDxilModule,
_In_opt_z_ LPCWSTR pExtraOptions, _COM_Outptr_ IDxcBlob **ppDxilModule,
_Outptr_result_maybenull_z_ LPWSTR *ppDiag) = 0;
};

Expand Down
4 changes: 2 additions & 2 deletions projects/dxilconv/lib/DxbcConverter/DxbcConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ __override HRESULT STDMETHODCALLTYPE DxbcConverter::ConvertInDriver(
UINT32 NumInputSignatureElements, LPCVOID pOutputSignature,
UINT32 NumOutputSignatureElements, LPCVOID pPatchConstantSignature,
UINT32 NumPatchConstantSignatureElements, LPCWSTR pExtraOptions,
IDxcBlob **ppDxilModule, LPWSTR *ppDiag) {
_COM_Outptr_ IDxcBlob **ppDxilModule, LPWSTR *ppDiag) {
DxcThreadMalloc TM(m_pMalloc);
LARGE_INTEGER start, end;
QueryPerformanceCounter(&start);
Expand Down Expand Up @@ -339,7 +339,7 @@ void DxbcConverter::ConvertInDriverImpl(
UINT32 NumOutputSignatureElements,
const D3D12DDIARG_SIGNATURE_ENTRY_0012 *pPatchConstantSignature,
UINT32 NumPatchConstantSignatureElements, LPCWSTR pExtraOptions,
IDxcBlob **ppDxcBlob, LPWSTR *ppDiag) {
_COM_Outptr_ IDxcBlob **ppDxcBlob, LPWSTR *ppDiag) {
IFTARG(pByteCode);
IFTARG(ppDxcBlob);
UINT SizeInUINTs = pByteCode[1];
Expand Down
4 changes: 2 additions & 2 deletions projects/dxilconv/lib/DxbcConverter/DxbcConverterImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ class DxbcConverter : public IDxbcConverter {
UINT32 NumInputSignatureElements, LPCVOID pOutputSignature,
UINT32 NumOutputSignatureElements, LPCVOID pPatchConstantSignature,
UINT32 NumPatchConstantSignatureElements, LPCWSTR pExtraOptions,
IDxcBlob **ppDxilModule, LPWSTR *ppDiag) override;
_COM_Outptr_ IDxcBlob **ppDxilModule, LPWSTR *ppDiag) override;

protected:
LLVMContext m_Ctx;
Expand Down Expand Up @@ -534,7 +534,7 @@ class DxbcConverter : public IDxbcConverter {
UINT32 NumOutputSignatureElements,
const D3D12DDIARG_SIGNATURE_ENTRY_0012 *pPatchConstantSignature,
UINT32 NumPatchConstantSignatureElements, LPCWSTR pExtraOptions,
IDxcBlob **ppDxcBlob, LPWSTR *ppDiag);
_COM_Outptr_ IDxcBlob **ppDxcBlob, LPWSTR *ppDiag);

virtual void LogConvertResult(bool InDriver,
const LARGE_INTEGER *pQPCConvertStart,
Expand Down
Loading
Loading