public unsafe Result Link(string entryName, string targetProfile, string[] libNames, string[] arguments, out IDxcOperationResult?result) { IntPtr *libNamesPtr = (IntPtr *)0; IntPtr *argumentsPtr = (IntPtr *)0; try { if (libNames?.Length > 0) { libNamesPtr = Interop.AllocToPointers(libNames, libNames.Length); } if (arguments?.Length > 0) { argumentsPtr = Interop.AllocToPointers(arguments, arguments.Length); } Result hr = Link(entryName, targetProfile, (IntPtr)libNamesPtr, (libNames?.Length) ?? 0, (IntPtr)argumentsPtr, (arguments?.Length) ?? 0, out result); if (hr.Failure) { result = default; return(default);
public unsafe IDxcOperationResult Compile(IDxcBlob source, string sourceName, string entryPoint, string targetProfile, string[] arguments, int argumentsCount, DxcDefine[] defines, IDxcIncludeHandler includeHandler) { IntPtr *argumentsPtr = (IntPtr *)0; try { if (arguments != null && argumentsCount > 0) { argumentsPtr = Interop.AllocToPointers(arguments, argumentsCount); } Compile(source, sourceName, entryPoint, targetProfile, (IntPtr)argumentsPtr, argumentsCount, defines, includeHandler, out IDxcOperationResult? result).CheckError(); return(result !); } finally { if (argumentsPtr != null) { Interop.Free(argumentsPtr); } } }
public unsafe Result CompileWithDebug(IDxcBlob source, string sourceName, string entryPoint, string targetProfile, string[] arguments, int argumentsCount, DxcDefine[] defines, IDxcIncludeHandler includeHandler, out IDxcOperationResult?result, out string?debugBlobName, out IDxcBlob?debugBlob) { IntPtr *argumentsPtr = (IntPtr *)0; try { IntPtr debugBlobNameOut = default; if (arguments != null && argumentsCount > 0) { argumentsPtr = Interop.AllocToPointers(arguments, argumentsCount); } Result hr = CompileWithDebug(source, sourceName, entryPoint, targetProfile, (IntPtr)argumentsPtr, argumentsCount, defines, includeHandler, out result, new IntPtr(&debugBlobNameOut), out debugBlob); if (debugBlobNameOut != IntPtr.Zero) { debugBlobName = Marshal.PtrToStringUni(debugBlobNameOut); } else { debugBlobName = string.Empty; } if (hr.Failure) { result = default; return(hr); } return(hr); } finally { if (argumentsPtr != null) { Interop.Free(argumentsPtr); } } }
public unsafe Result Compile <T>(string source, string[] arguments, IDxcIncludeHandler includeHandler, out T?result) where T : ComObject { IntPtr shaderSourcePtr = Marshal.StringToHGlobalAnsi(source); IntPtr *argumentsPtr = (IntPtr *)0; DxcBuffer buffer = new() { Ptr = shaderSourcePtr, Size = source.Length, Encoding = Dxc.DXC_CP_ACP }; try { int argumentsCount = 0; if (arguments != null && arguments.Length > 0) { argumentsCount = arguments.Length; argumentsPtr = Interop.AllocToPointers(arguments); } Result hr = Compile(ref buffer, (IntPtr)argumentsPtr, argumentsCount, includeHandler, typeof(T).GUID, out IntPtr nativePtr); if (hr.Failure) { result = default; return(hr); } result = MarshallingHelpers.FromPointer <T>(nativePtr); return(hr); } finally { if (shaderSourcePtr != IntPtr.Zero) { Marshal.FreeHGlobal(shaderSourcePtr); } if (argumentsPtr != null) { Interop.Free(argumentsPtr); } } }
public unsafe Result Compile(IDxcBlob source, string sourceName, string entryPoint, string targetProfile, string[] arguments, int argumentsCount, DxcDefine[] defines, IDxcIncludeHandler includeHandler, out IDxcOperationResult?result) { IntPtr *argumentsPtr = (IntPtr *)0; try { if (arguments != null && argumentsCount > 0) { argumentsPtr = Interop.AllocToPointers(arguments, argumentsCount); } Result hr = Compile(source, sourceName, entryPoint, targetProfile, (IntPtr)argumentsPtr, argumentsCount, defines, includeHandler, out result); if (hr.Failure) { result = default; return(hr); } return(hr); } finally { if (argumentsPtr != null) { Interop.Free(argumentsPtr); } } }
public unsafe Result AddArgumentsUTF8(string[] arguments, int argumentsCount) { IntPtr *argumentsPtr = (IntPtr *)0; try { if (arguments != null && argumentsCount > 0) { argumentsPtr = Interop.AllocToPointers(arguments, argumentsCount); } return(AddArgumentsUTF8((IntPtr)argumentsPtr, argumentsCount)); } finally { if (argumentsPtr != null) { Interop.Free(argumentsPtr); } } }