internal unsafe void __MarshalTo(ref __Native @ref)
        {
            if (Categories != null && Categories.Length > 0)
            {
                @ref.NumCategories = Categories.Length;
                @ref.PCategoryList = UnsafeUtilities.AllocToPointer(Categories);
            }
            else
            {
                @ref.NumCategories = 0;
                @ref.PCategoryList = IntPtr.Zero;
            }

            if (Severities != null && Severities.Length > 0)
            {
                @ref.NumSeverities = Severities.Length;
                @ref.PSeverityList = UnsafeUtilities.AllocToPointer(Severities);
            }
            else
            {
                @ref.NumSeverities = 0;
                @ref.PSeverityList = IntPtr.Zero;
            }

            if (Ids != null && Ids.Length > 0)
            {
                @ref.NumIDs  = Ids.Length;
                @ref.PIDList = UnsafeUtilities.AllocToPointer(Ids);
            }
            else
            {
                @ref.NumIDs  = 0;
                @ref.PIDList = IntPtr.Zero;
            }
        }
Ejemplo n.º 2
0
 internal unsafe void __MarshalTo(ref __Native @ref)
 {
     @ref.NumParameters     = Parameters?.Length ?? 0;
     @ref.PParameters       = UnsafeUtilities.AllocToPointer(Parameters);
     @ref.NumStaticSamplers = StaticSamplers?.Length ?? 0;
     @ref.PStaticSamplers   = UnsafeUtilities.AllocToPointer(StaticSamplers);
     @ref.Flags             = Flags;
 }
 internal unsafe void __MarshalTo(ref __Native @ref)
 {
     @ref.NumCategories = Categories?.Length ?? 0;
     @ref.PCategoryList = UnsafeUtilities.AllocToPointer(Categories);
     @ref.NumSeverities = Severities?.Length ?? 0;
     @ref.PSeverityList = UnsafeUtilities.AllocToPointer(Severities);
     @ref.NumIDs        = Ids?.Length ?? 0;
     @ref.PIDList       = UnsafeUtilities.AllocToPointer(Ids);
 }
Ejemplo n.º 4
0
        internal void __MarshalTo(ref __Native @ref)
        {
            @ref.DataSize = DataSize;
            if (H264Profile != null)
            {
                @ref.pH264Profile = UnsafeUtilities.AllocToPointer <VideoEncoderProfileH264>(H264Profile);
            }

            if (HEVCProfile != null)
            {
                @ref.pHEVCProfile = UnsafeUtilities.AllocToPointer <VideoEncoderProfileHevc>(HEVCProfile);
            }
        }
Ejemplo n.º 5
0
 internal unsafe void __MarshalTo(ref __Native @ref)
 {
     if (Data?.Length > 0)
     {
         @ref.Bytecode = UnsafeUtilities.AllocToPointer(Data);
         @ref.Length   = Data.Length;
     }
     else
     {
         @ref.Bytecode = IntPtr.Zero;
         @ref.Length   = 0;
     }
 }
Ejemplo n.º 6
0
 internal unsafe void __MarshalTo(ref __Native @ref)
 {
     @ref.inputCount = InputCount;
     @ref.usage      = Usage;
     if (Data?.Length > 0)
     {
         @ref.data = UnsafeUtilities.AllocToPointer(Data);
     }
     else
     {
         @ref.data = IntPtr.Zero;
     }
     @ref.byteWidth = ByteWidth;
 }
Ejemplo n.º 7
0
    internal void __MarshalTo(ref __Native @ref)
    {
        @ref.Type        = Type;
        @ref.Flags       = Flags;
        @ref.NumDescs    = DescriptorsCount;
        @ref.DescsLayout = Layout;

        if (GeometryDescriptions != null &&
            GeometryDescriptions.Length > 0)
        {
            @ref.Union.pGeometryDescs = UnsafeUtilities.AllocToPointer(GeometryDescriptions);
        }
        else
        {
            @ref.Union.InstanceDescs = InstanceDescriptions;
        }
    }
        internal unsafe void __MarshalTo(ref __Native @ref)
        {
            @ref.shaderBufferSize = ShaderBufferWithInputSignature?.Length ?? 0;
            if (@ref.shaderBufferSize > 0)
            {
                @ref.shaderBufferWithInputSignature = UnsafeUtilities.AllocToPointer(ShaderBufferWithInputSignature);
            }

            @ref.elementCount = Elements?.Length ?? 0;
            if (@ref.elementCount > 0)
            {
                var nativeElements = (InputElementDescription.__Native *)Marshal.AllocHGlobal(sizeof(InputElementDescription.__Native) * @ref.elementCount);
                for (int i = 0; i < @ref.elementCount; i++)
                {
                    Elements[i].__MarshalTo(ref nativeElements[i]);
                }

                @ref.inputElements = nativeElements;
            }

            @ref.stride = Stride;
        }
    unsafe IntPtr ITensorDescriptionMarshal.__MarshalAlloc()
    {
        __Native * @ref = UnsafeUtilities.Alloc <__Native>();

        @ref->DataType       = DataType;
        @ref->Flags          = Flags;
        @ref->DimensionCount = Sizes.Length;
        @ref->PSizes         = UnsafeUtilities.AllocToPointer(Sizes);
        @ref->PStrides       = IntPtr.Zero;
        if (Strides != null)
        {
            if (Strides.Length != Sizes.Length)
            {
                throw new IndexOutOfRangeException("Strides must have the same length as Sizes.");
            }
            @ref->PStrides = UnsafeUtilities.AllocToPointer(Strides);
        }
        @ref->TotalTensorSizeInBytes        = TotalTensorSizeInBytes;
        @ref->GuaranteedBaseOffsetAlignment = GuaranteedBaseOffsetAlignment;

        return(new(@ref));
    }