Exemplo n.º 1
0
        public static ComPtr<IDiaSymbol> GetSymbol(this IDiaSymbol symbol, SymTagEnum symTag, string name, Predicate<IDiaSymbol> filter = null) {
            var result = new ComPtr<IDiaSymbol>();

            IDiaEnumSymbols enumSymbols;
            symbol.findChildren(symTag, name, 1, out enumSymbols);
            using (ComPtr.Create(enumSymbols)) {
                int n = enumSymbols.count;
                if (n == 0) {
                    Debug.Fail("Symbol '" + name + "' was not found.");
                    throw new ArgumentException();
                }

                try {
                    for (int i = 0; i < n; ++i) {
                        using (var item = ComPtr.Create(enumSymbols.Item((uint)i))) {
                            if (filter == null || filter(item.Object)) {
                                if (result.Object == null) {
                                    result = item.Detach();
                                } else {
                                    Debug.Fail("Found more than one symbol named '" + name + "' and matching the filter.");
                                    throw new ArgumentException();
                                }
                            }
                        }
                    }
                } catch {
                    result.Dispose();
                    throw;
                }
            }

            return result;
        }
Exemplo n.º 2
0
		public void Dispose()
		{
			if (_inputStream != null)
				Xpcom.DisposeObject( ref _inputStream );
			_inputStream = null;
			GC.SuppressFinalize(this);
		}
Exemplo n.º 3
0
		internal GeckoNode(object domObject)
		{
			if (domObject is nsIDOMNode)
				_domNode = new ComPtr<nsIDOMNode>((nsIDOMNode)domObject);
			else
				throw new ArgumentException("domObject is not a nsIDOMNode");
		}
Exemplo n.º 4
0
		public StorageStream()
		{
			_storageStream = Xpcom.CreateInstance2<nsIStorageStream>( Contracts.StorageStream );

			_storageStream.Instance.Init( 1024 * 32, 1024 * 1024 * 16 );

		}
Exemplo n.º 5
0
		public ChromeContext()
		{			
			using (var appShallSvc = Xpcom.GetService2<nsIAppShellService>(Contracts.AppShellService))
			{
				webNav = appShallSvc.Instance.CreateWindowlessBrowser(true).AsComPtr();
				webNav.Instance.LoadURI("chrome://global/content/alerts/alert.xul", 0, null, null, null);
			}
		}
		private GeckoSelection(nsISelection selection)
		{
			// selection is always NOT null, when we use Create function
			//if (selection == null)
			//	throw new ArgumentException("selection");

			_selection = new ComPtr<nsISelection>(selection);
		}
Exemplo n.º 7
0
 internal InputStream(nsIInputStream inputStream)
 {
     _inputStream = new ComPtr<nsIInputStream>( inputStream );
     var seekableStream = Xpcom.QueryInterface<nsISeekableStream>(inputStream);
     if ( _seekable = seekableStream != null )
     {
         _seekableStream = new ComPtr<nsISeekableStream>( seekableStream );
     }
 }
Exemplo n.º 8
0
		internal OutputStream(nsIOutputStream outputStream)
		{
			_outputStream = new ComPtr<nsIOutputStream>( outputStream );
			var seekableStream = Xpcom.QueryInterface<nsISeekableStream>( outputStream );
			if ( _seekable = (seekableStream != null) )
			{
				_seekableStream = new ComPtr<nsISeekableStream>( seekableStream );
			}
			_binaryOutputStream = Xpcom.CreateInstance2<nsIBinaryOutputStream>(Contracts.BinaryOutputStream);
			_binaryOutputStream.Instance.SetOutputStream( _outputStream.Instance );
		}
Exemplo n.º 9
0
		static public void Shutdown()
		{
			if (_prefService != null)
				_prefService.Dispose();
			if (_user != null)
				_user.Dispose();
			if (_default != null)
				_default.Dispose();
			_prefService = null;
			_user = null;
			_default = null;
		}
Exemplo n.º 10
0
		/// <param name="flags">see nsICertOverrideServiceConsts</param>
		public static void RememberValidityOverride(Uri url, ComPtr<nsIX509Cert> cert, int flags)
		{
			if (url == null)
				throw new ArgumentNullException("url");

			using (var aHostName = new nsACString(url.Host))
			{
				using (var svc = GetService())
				{
					svc.Instance.RememberValidityOverride(aHostName, url.Port, cert.Instance, (uint)flags, true);
				}
			}
		}
Exemplo n.º 11
0
    public static ComPtr<IDiaSymbol> FindChildSymbol(ComPtr<IDiaSymbol> parent, SymTagEnum tag, string name) {
      var result = new ComPtr<IDiaSymbol>();

      IDiaEnumSymbols enumerator;
      parent.Ptr.findChildren(tag, name, 1, out enumerator);
      using (ComPtr.Create(enumerator)) {
        if (enumerator.count == 0)
          return new ComPtr<IDiaSymbol>();

        result = ComPtr.Create(enumerator.Item((uint)0));
      }

      return result;
    }
Exemplo n.º 12
0
        public static int GetActiveObject(string progID, out ComPtr p)
        {
            int hr = 0;
            Guid clsid = Guid.Empty;
            IntPtr pUnk = IntPtr.Zero;
            p = IntPtr.Zero;

            if (Succeeded(hr = GetActiveObject(progID, out pUnk)))
            {
                p = new ComPtr(pUnk);
                Marshal.Release(pUnk);
            }

            return hr;
        }
Exemplo n.º 13
0
        public static int CreateInstance(string progID, out ComPtr p)
        {
            int hr = 0;
            Guid clsid = Guid.Empty;
            IntPtr pUnk = IntPtr.Zero;
            p = IntPtr.Zero;

            if (Succeeded(hr = CreateInstance(progID, out pUnk)))
            {
                p = new ComPtr(pUnk);
                Marshal.Release(pUnk);
            }

            return hr;
        }
Exemplo n.º 14
0
		public static bool HasMatchingOverride(Uri url, ComPtr<nsIX509Cert> cert)
		{
			if (url == null)
				throw new ArgumentNullException("url");

			using (var aHostName = new nsACString(url.Host))
			{
				uint flags = 0;
				bool isTemp = false;
				using (var overrideSvc = GetService())
				{
					return overrideSvc.Instance.HasMatchingOverride(aHostName, url.Port, cert.Instance, ref flags, ref isTemp);
				}
			}
		}
Exemplo n.º 15
0
		/// <summary/>
		private void Dispose(bool fDisposing)
		{
			System.Diagnostics.Debug.WriteLineIf(!fDisposing, "****** Missing Dispose() call for " + GetType() + ". *******");
			if (fDisposing && !IsDisposed)
			{
				// dispose managed and unmanaged objects
				if (webNav != null)
					webNav.Dispose();
				if (command != null)
					command.Dispose();
				_isInitialized = false;
			}
			webNav = null;
			command = null;
			IsDisposed = true;
		}
Exemplo n.º 16
0
 public static ComPtr<IDiaSymbol>[] GetSymbols(this IDiaSymbol symbol, SymTagEnum symTag, string name) {
     IDiaEnumSymbols enumSymbols;
     symbol.findChildren(symTag, name, 1, out enumSymbols);
     using (ComPtr.Create(enumSymbols)) {
         int n = enumSymbols.count;
         var result = new ComPtr<IDiaSymbol>[n];
         try {
             for (int i = 0; i < n; ++i) {
                 result[i] = ComPtr.Create(enumSymbols.Item((uint)i));
             }
         } catch {
             foreach (var item in result) {
                 item.Dispose();
             }
             throw;
         }
         return result;
     }
 }
Exemplo n.º 17
0
        protected override void OnHandleCreated(EventArgs e)
        {
#if GTK
            if (Xpcom.IsMono)
            {
                base.OnHandleCreated(e);
                m_wrapper.Init();
            }
#endif
            if (!this.DesignMode)
            {
                Xpcom.Initialize();
                WindowCreator.Register();
#if !GTK
                LauncherDialogFactory.Register();
#endif

                WebBrowser      = Xpcom.CreateInstance <nsIWebBrowser>(Contracts.WebBrowser);
                WebBrowserFocus = ( nsIWebBrowserFocus )WebBrowser;
                BaseWindow      = ( nsIBaseWindow )WebBrowser;
                WebNav          = ( nsIWebNavigation )WebBrowser;

                WebBrowser.SetContainerWindowAttribute(this);
#if GTK
                if (Xpcom.IsMono)
                {
                    BaseWindow.InitWindow(m_wrapper.BrowserWindow.Handle, IntPtr.Zero, 0, 0, this.Width, this.Height);
                }
                else
#endif
                BaseWindow.InitWindow(this.Handle, IntPtr.Zero, 0, 0, this.Width, this.Height);


                BaseWindow.Create();

                Guid nsIWebProgressListenerGUID  = typeof(nsIWebProgressListener).GUID;
                Guid nsIWebProgressListener2GUID = typeof(nsIWebProgressListener2).GUID;
                WebBrowser.AddWebBrowserListener(this.GetWeakReference(), ref nsIWebProgressListenerGUID);
                WebBrowser.AddWebBrowserListener(this.GetWeakReference(), ref nsIWebProgressListener2GUID);

                if (UseHttpActivityObserver)
                {
                    ObserverService.AddObserver(this, ObserverNotifications.HttpRequests.HttpOnModifyRequest, false);
                    Net.HttpActivityDistributor.AddObserver(this);
                }

                // var domEventListener = new GeckoDOMEventListener(this);

                {
                    var domWindow = WebBrowser.GetContentDOMWindowAttribute();
                    EventTarget = domWindow.GetWindowRootAttribute().AsComPtr();
                    Marshal.ReleaseComObject(domWindow);
                }

                foreach (string sEventName in this.DefaultEvents)
                {
                    using (var eventType = new nsAString(sEventName))
                    {
                        EventTarget.Instance.AddEventListener(eventType, this, true, true, 2);
                    }
                }

                // history
                {
                    var sessionHistory = WebNav.GetSessionHistoryAttribute();
                    if (sessionHistory != null)
                    {
                        sessionHistory.AddSHistoryListener(this);
                    }
                }

                BaseWindow.SetVisibilityAttribute(true);

                // this fix prevents the browser from crashing if the first page loaded is invalid (missing file, invalid URL, etc)
                if (Document != null)
                {
                    // only for html documents
                    Document.Cookie = "";
                }
            }

            base.OnHandleCreated(e);
        }
 internal CertificateValidity(nsIX509CertValidity validity)
 {
     _validity = new ComPtr <nsIX509CertValidity>(validity);
 }
Exemplo n.º 19
0
 public GeckoWindow(nsIDOMWindow window)
 {
     //Interop.ComDebug.WriteDebugInfo( window );
     _domWindow = new ComPtr <nsIDOMWindow>(window);
 }
Exemplo n.º 20
0
 public GeckoWindow(mozIDOMWindowProxy window, nsISupports innerWindow, bool?ownRCW = null)
 {
     _domWindowProxy = new ComPtr <mozIDOMWindowProxy> (window, ownRCW ?? !Xpcom.GCFreesRCWsByDefault);
     _innerWindow    = new ComPtr <nsISupports>(innerWindow, ownRCW ?? !Xpcom.GCFreesRCWsByDefault);
     _window         = new Lazy <Window>(() => new WebIDL.Window(_domWindowProxy.Instance, _innerWindow?.Instance ?? (nsISupports)_domWindowProxy.Instance));
 }
Exemplo n.º 21
0
 /// <summary>
 /// Creates a new <see cref="PipelineData"/> instance with the specified parameters.
 /// </summary>
 /// <param name="d3D12RootSignature">The <see cref="ID3D12RootSignature"/> value for the current shader.</param>
 /// <param name="d3D12PipelineState">The compiled pipeline state to reuse for the current shader.</param>
 public PipelineData(ID3D12RootSignature *d3D12RootSignature, ID3D12PipelineState *d3D12PipelineState)
 {
     this.d3D12RootSignature = new ComPtr <ID3D12RootSignature>(d3D12RootSignature);
     this.d3D12PipelineState = new ComPtr <ID3D12PipelineState>(d3D12PipelineState);
 }
 static WindowWatcher()
 {
     _watcher = Xpcom.GetService2 <nsIWindowWatcher>(Contracts.WindowWatcher);
 }
Exemplo n.º 23
0
		internal CertTreeItem(nsICertTreeItem certTreeItem)
		{
			_certTreeItem = new ComPtr<nsICertTreeItem>(certTreeItem);
		}
Exemplo n.º 24
0
 public Screen(nsIScreen screen)
 {
     _screen = new ComPtr<nsIScreen>( screen );
 }
Exemplo n.º 25
0
 private GeckoWindow(nsIDOMWindow window)
 {
     //Interop.ComDebug.WriteDebugInfo( window );
     _domWindow = new ComPtr<nsIDOMWindow>(window);
 }
Exemplo n.º 26
0
        public WicImageFrame(WicImageContainer decoder, uint index)
        {
            Container = decoder;

            using var frame = default(ComPtr <IWICBitmapFrameDecode>);
            HRESULT.Check(decoder.WicDecoder->GetFrame(index, frame.GetAddressOf()));

            using var source = new ComPtr <IWICBitmapSource>((IWICBitmapSource *)frame.Get());

            double dpix, dpiy;

            HRESULT.Check(frame.Get()->GetResolution(&dpix, &dpiy));
            (DpiX, DpiY) = (dpix, dpiy);

            uint frameWidth, frameHeight;

            HRESULT.Check(frame.Get()->GetSize(&frameWidth, &frameHeight));

            using var metareader = default(ComPtr <IWICMetadataQueryReader>);
            if (SUCCEEDED(frame.Get()->GetMetadataQueryReader(metareader.GetAddressOf())))
            {
                string orientationPath =
                    MagicImageProcessor.EnableXmpOrientation ? Wic.Metadata.OrientationWindowsPolicy :
                    Container.ContainerFormat == FileFormat.Jpeg ? Wic.Metadata.OrientationJpeg :
                    Wic.Metadata.OrientationExif;

                ExifOrientation   = ((Orientation)metareader.GetValueOrDefault <ushort>(orientationPath)).Clamp();
                WicMetadataReader = metareader.Detach();
            }

            using var preview = default(ComPtr <IWICBitmapSource>);
            if (decoder.IsRawContainer && index == 0 && SUCCEEDED(decoder.WicDecoder->GetPreview(preview.GetAddressOf())))
            {
                uint pw, ph;
                HRESULT.Check(preview.Get()->GetSize(&pw, &ph));

                if (pw == frameWidth && ph == frameHeight)
                {
                    source.Attach(preview.Detach());
                }
            }

            using var transform = default(ComPtr <IWICBitmapSourceTransform>);
            if (SUCCEEDED(source.Get()->QueryInterface(__uuidof <IWICBitmapSourceTransform>(), (void **)transform.GetAddressOf())))
            {
                uint tw = 1, th = 1;
                HRESULT.Check(transform.Get()->GetClosestSize(&tw, &th));

                SupportsNativeScale = tw < frameWidth || th < frameHeight;
            }

            using var ptransform = default(ComPtr <IWICPlanarBitmapSourceTransform>);
            if (SUCCEEDED(source.Get()->QueryInterface(__uuidof <IWICPlanarBitmapSourceTransform>(), (void **)ptransform.GetAddressOf())))
            {
                var fmts = WicTransforms.PlanarPixelFormats;
                var desc = stackalloc WICBitmapPlaneDescription[fmts.Length];
                fixed(Guid *pfmt = fmts)
                {
                    uint tw = frameWidth, th = frameHeight, st = 0;

                    HRESULT.Check(ptransform.Get()->DoesSupportTransform(
                                      &tw, &th,
                                      WICBitmapTransformOptions.WICBitmapTransformRotate0, WICPlanarOptions.WICPlanarOptionsDefault,
                                      pfmt, desc, (uint)fmts.Length, (int *)&st
                                      ));

                    SupportsPlanarProcessing = st != 0;
                }

                ChromaSubsampling =
                    desc[1].Width < desc[0].Width && desc[1].Height < desc[0].Height ? WICJpegYCrCbSubsamplingOption.WICJpegYCrCbSubsampling420 :
                    desc[1].Width < desc[0].Width ? WICJpegYCrCbSubsamplingOption.WICJpegYCrCbSubsampling422 :
                    desc[1].Height < desc[0].Height ? WICJpegYCrCbSubsamplingOption.WICJpegYCrCbSubsampling440 :
                    WICJpegYCrCbSubsamplingOption.WICJpegYCrCbSubsampling444;
            }

            var guid = default(Guid);

            HRESULT.Check(source.Get()->GetPixelFormat(&guid));
            if (PixelFormat.FromGuid(guid).NumericRepresentation == PixelNumericRepresentation.Indexed)
            {
                var newFormat = PixelFormat.Bgr24Bpp;
                if (Container.ContainerFormat == FileFormat.Gif && Container.FrameCount > 1)
                {
                    newFormat = PixelFormat.Bgra32Bpp;
                }
                else
                {
                    using var pal = default(ComPtr <IWICPalette>);
                    HRESULT.Check(Wic.Factory->CreatePalette(pal.GetAddressOf()));
                    HRESULT.Check(source.Get()->CopyPalette(pal));

                    int bval;
                    if (SUCCEEDED(pal.Get()->HasAlpha(&bval)) && bval != 0)
                    {
                        newFormat = PixelFormat.Bgra32Bpp;
                    }
                    else if ((SUCCEEDED(pal.Get()->IsGrayscale(&bval)) && bval != 0) || (SUCCEEDED(pal.Get()->IsBlackWhite(&bval)) && bval != 0))
                    {
                        newFormat = PixelFormat.Grey8Bpp;
                    }
                }

                var nfmt = newFormat.FormatGuid;
                using var conv = default(ComPtr <IWICFormatConverter>);
                HRESULT.Check(Wic.Factory->CreateFormatConverter(conv.GetAddressOf()));
                HRESULT.Check(conv.Get()->Initialize(source, &nfmt, WICBitmapDitherType.WICBitmapDitherTypeNone, null, 0.0, WICBitmapPaletteType.WICBitmapPaletteTypeCustom));

                source.Attach((IWICBitmapSource *)conv.Detach());
            }

            WicFrame  = frame.Detach();
            WicSource = source.Detach();
        }
Exemplo n.º 27
0
 internal SearchSubmission(nsISearchSubmission searchSubmission)
 {
     _searchSubmission = new ComPtr<nsISearchSubmission>(searchSubmission);
     //???
     _searchSubmission.Instance.GetPostDataAttribute();
 }
Exemplo n.º 28
0
 public WinTaskbar()
 {
     _winTaskbar = Xpcom.CreateInstance2 <nsIWinTaskbar>(Contracts.WindowsTaskbar);
 }
Exemplo n.º 29
0
		static ConsoleService()
		{
			_consoleService = Xpcom.GetService2<nsIConsoleService>(Contracts.ConsoleService);
		}
Exemplo n.º 30
0
 static DnsService()
 {
     _dnsService = Xpcom.GetService2 <nsIDNSService>(Contracts.DnsService);
 }
Exemplo n.º 31
0
 static VersionComparator()
 {
     _versionComparator = Xpcom.GetService2 <nsIVersionComparator>(Contracts.VersionComparator);
 }
Exemplo n.º 32
0
 /// <summary>
 /// Returns the address of the underlying pointer in the <see cref="ComPtr{T}"/>.
 /// </summary>
 /// <param name="comPtr">A pointer to the encapsulated pointer to take the address of</param>
 /// <typeparam name="T">The type of the underlying pointer</typeparam>
 /// <returns>A pointer to the underlying pointer</returns>
 public static T **GetAddressOf <T>(ComPtr <T> *comPtr) where T : unmanaged =>
 (T **)comPtr;
Exemplo n.º 33
0
    /// <summary>
    /// Creates a new <see cref="Buffer{T}"/> instance with the specified parameters.
    /// </summary>
    /// <param name="device">The <see cref="GraphicsDevice"/> associated with the current instance.</param>
    /// <param name="length">The number of items to store in the current buffer.</param>
    /// <param name="elementSizeInBytes">The size in bytes of each buffer item (including padding, if any).</param>
    /// <param name="resourceType">The resource type for the current buffer.</param>
    /// <param name="allocationMode">The allocation mode to use for the new resource.</param>
    private protected Buffer(GraphicsDevice device, int length, uint elementSizeInBytes, ResourceType resourceType, AllocationMode allocationMode)
    {
        device.ThrowIfDisposed();

        if (resourceType == ResourceType.Constant)
        {
            Guard.IsBetweenOrEqualTo(length, 1, D3D12.D3D12_REQ_CONSTANT_BUFFER_ELEMENT_COUNT, nameof(length));
        }
        else
        {
            // The maximum length is set such that the aligned buffer size can't exceed uint.MaxValue
            Guard.IsBetweenOrEqualTo(length, 1, (uint.MaxValue / elementSizeInBytes) & ~255, nameof(length));
        }

        if (TypeInfo <T> .IsDoubleOrContainsDoubles &&
            device.D3D12Device->CheckFeatureSupport <D3D12_FEATURE_DATA_D3D12_OPTIONS>(D3D12_FEATURE_D3D12_OPTIONS).DoublePrecisionFloatShaderOps == 0)
        {
            UnsupportedDoubleOperationsException.Throw <T>();
        }

        nint usableSizeInBytes    = checked ((nint)(length * elementSizeInBytes));
        nint effectiveSizeInBytes = resourceType == ResourceType.Constant ? AlignmentHelper.Pad(usableSizeInBytes, D3D12.D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT) : usableSizeInBytes;

        SizeInBytes    = usableSizeInBytes;
        GraphicsDevice = device;
        Length         = length;

#if NET6_0_OR_GREATER
        this.allocation    = device.Allocator->CreateResource(device.Pool, resourceType, allocationMode, (ulong)effectiveSizeInBytes);
        this.d3D12Resource = new ComPtr <ID3D12Resource>(this.allocation.Get()->GetResource());
#else
        this.d3D12Resource = device.D3D12Device->CreateCommittedResource(resourceType, (ulong)effectiveSizeInBytes, device.IsCacheCoherentUMA);
#endif

        device.RegisterAllocatedResource();
        device.RentShaderResourceViewDescriptorHandles(out this.d3D12ResourceDescriptorHandles);
        device.RentShaderResourceViewDescriptorHandles(out this.d3D12ResourceDescriptorHandlesForTypedUnorderedAccessView);

        switch (resourceType)
        {
        case ResourceType.Constant:
            device.D3D12Device->CreateConstantBufferView(this.d3D12Resource.Get(), effectiveSizeInBytes, this.d3D12ResourceDescriptorHandles.D3D12CpuDescriptorHandle);
            break;

        case ResourceType.ReadOnly:
            device.D3D12Device->CreateShaderResourceView(this.d3D12Resource.Get(), (uint)length, elementSizeInBytes, this.d3D12ResourceDescriptorHandles.D3D12CpuDescriptorHandle);
            break;

        case ResourceType.ReadWrite:
            device.D3D12Device->CreateUnorderedAccessView(this.d3D12Resource.Get(), (uint)length, elementSizeInBytes, this.d3D12ResourceDescriptorHandles.D3D12CpuDescriptorHandle);
            device.D3D12Device->CreateUnorderedAccessViewForClear(
                this.d3D12Resource.Get(),
                DXGI_FORMAT_R32_UINT,
                (uint)(usableSizeInBytes / sizeof(uint)),
                this.d3D12ResourceDescriptorHandlesForTypedUnorderedAccessView.D3D12CpuDescriptorHandle,
                this.d3D12ResourceDescriptorHandlesForTypedUnorderedAccessView.D3D12CpuDescriptorHandleNonShaderVisible);
            break;
        }

        this.d3D12Resource.Get()->SetName(this);
    }
Exemplo n.º 34
0
 /// <summary>
 /// Returns the address of the underlying pointer in the <see cref="ComPtr{T}"/>.
 /// This operation is only defined if <paramref name="comPtr"/> is pinned in memory for duration between the
 /// invocation of this method and the final use of the return
 /// </summary>
 /// <param name="comPtr">A pointer to the encapsulated pointer to take the address of</param>
 /// <typeparam name="T">The type of the underlying pointer</typeparam>
 /// <returns>A pointer to the underlying pointer</returns>
 public static void **GetVoidAddressOf <T>(ComPtr <T> *comPtr) where T : unmanaged =>
 (void **)comPtr;
Exemplo n.º 35
0
 public GeckoNamedNodeMap(nsIDOMMozNamedAttrMap map)
 {
     // map should be not null
     this._map = new ComPtr <nsIDOMMozNamedAttrMap>(map);
 }
Exemplo n.º 36
0
 internal TraceableChannel(nsITraceableChannel traceableChannel)
 {
     _traceableChannel = new ComPtr <nsITraceableChannel>(traceableChannel);
 }
Exemplo n.º 37
0
 internal RentedCommandAllocator(ComPtr <ID3D12CommandAllocator> value)
 {
     Debug.Assert(value.Get() != null);
     _value = value;
 }
Exemplo n.º 38
0
 static CertificateDatabase()
 {
     _certDb  = Xpcom.GetService2 <nsIX509CertDB>(Contracts.X509CertDb);
     _certDb2 = Xpcom.GetService2 <nsIX509CertDB2>(Contracts.X509CertDb);
 }
        //For debugging window leak
        //private static int _windowCount = 0;

        static WindowMediator()
        {
            _windowMediator = Xpcom.GetService2 <nsIWindowMediator>(Contracts.WindowMediator);
        }
Exemplo n.º 40
0
 static CookieManager()
 {
     _cookieManager = Xpcom.GetService2 <nsICookieManager2>(Contracts.CookieManager);
 }
Exemplo n.º 41
0
            /// <inheritdoc/>
            public bool MoveNext()
            {
                if (!this.isInitialized)
                {
                    this.isInitialized = true;

                    fixed(IDXGIFactory6 **dxgiFactory6 = this.dxgiFactory6)
                    {
                        CreateDXGIFactory6(dxgiFactory6);
                    }
                }

                if (this.isCompleted)
                {
                    return(false);
                }

                while (true)
                {
                    using ComPtr <IDXGIAdapter1> dxgiAdapter1 = default;

                    HRESULT enumAdapters1Result = this.dxgiFactory6.Get()->EnumAdapterByGpuPreference(
                        this.index,
                        DXGI_GPU_PREFERENCE_HIGH_PERFORMANCE,
                        Windows.__uuidof <IDXGIAdapter1>(),
                        dxgiAdapter1.GetVoidAddressOf());

                    if (enumAdapters1Result == DXGI.DXGI_ERROR_NOT_FOUND)
                    {
                        this.dxgiFactory6.Get()->EnumWarpAdapter(Windows.__uuidof <IDXGIAdapter1>(), dxgiAdapter1.GetVoidAddressOf()).Assert();

                        DXGI_ADAPTER_DESC1 dxgiDescription1;

                        dxgiAdapter1.Get()->GetDesc1(&dxgiDescription1).Assert();

                        HRESULT createDeviceResult = DirectX.D3D12CreateDevice(
                            dxgiAdapter1.AsIUnknown().Get(),
                            D3D_FEATURE_LEVEL_11_0,
                            Windows.__uuidof <ID3D12Device>(),
                            null);

                        if (Windows.SUCCEEDED(createDeviceResult) &&
                            this.predicate?.Invoke(new GraphicsDeviceInfo(&dxgiDescription1)) != false)
                        {
                            using ComPtr <ID3D12Device> d3D12Device = default;

                            DirectX.D3D12CreateDevice(
                                dxgiAdapter1.AsIUnknown().Get(),
                                D3D_FEATURE_LEVEL_11_0,
                                Windows.__uuidof <ID3D12Device>(),
                                d3D12Device.GetVoidAddressOf()).Assert();

                            this.graphicsDevice = GetOrCreateDevice(d3D12Device.Get(), (IDXGIAdapter *)dxgiAdapter1.Get(), &dxgiDescription1);
                            this.isCompleted    = true;

                            return(true);
                        }

                        return(false);
                    }
                    else
                    {
                        enumAdapters1Result.Assert();

                        this.index++;

                        DXGI_ADAPTER_DESC1 dxgiDescription1;

                        dxgiAdapter1.Get()->GetDesc1(&dxgiDescription1).Assert();

                        if (dxgiDescription1.VendorId == MicrosoftVendorId &&
                            dxgiDescription1.DeviceId == WarpDeviceId)
                        {
                            continue;
                        }

                        HRESULT createDeviceResult = DirectX.D3D12CreateDevice(
                            dxgiAdapter1.AsIUnknown().Get(),
                            D3D_FEATURE_LEVEL_11_0,
                            Windows.__uuidof <ID3D12Device>(),
                            null);

                        if (Windows.SUCCEEDED(createDeviceResult) &&
                            this.predicate?.Invoke(new GraphicsDeviceInfo(&dxgiDescription1)) != false)
                        {
                            using ComPtr <ID3D12Device> d3D12Device = default;

                            DirectX.D3D12CreateDevice(
                                dxgiAdapter1.AsIUnknown().Get(),
                                D3D_FEATURE_LEVEL_11_0,
                                Windows.__uuidof <ID3D12Device>(),
                                d3D12Device.GetVoidAddressOf()).Assert();

                            if (d3D12Device.Get()->IsShaderModelSupported(D3D_SHADER_MODEL_6_0))
                            {
                                this.graphicsDevice = GetOrCreateDevice(d3D12Device.Get(), (IDXGIAdapter *)dxgiAdapter1.Get(), &dxgiDescription1);

                                return(true);
                            }
                        }
                    }
                }
            }
Exemplo n.º 42
0
 static AppShellService()
 {
     _appShellService = Xpcom.GetService2 <nsIAppShellService>(Contracts.AppShellService);
 }
Exemplo n.º 43
0
        protected override void OnHandleDestroyed(EventArgs e)
        {
            if (BaseWindow != null)
            {
                this.Stop();

                nsIDocShell docShell = Xpcom.QueryInterface <nsIDocShell>(BaseWindow);
                if (docShell != null && !docShell.IsBeingDestroyed())
                {
                    try
                    {
                        var window = Xpcom.QueryInterface <nsIDOMWindow>(docShell);
                        if (window != null)
                        {
                            try
                            {
                                if (!window.GetClosedAttribute())
                                {
                                    window.Close();
                                }
                            }
                            finally
                            {
                                Xpcom.FreeComObject(ref window);
                            }
                        }
                    }
                    finally
                    {
                        Xpcom.FreeComObject(ref docShell);
                    }
                }

                if (EventTarget != null)
                {
                    //Remove Event Listener
                    foreach (string sEventType in this.DefaultEvents)
                    {
                        using (var eventType = new nsAString(sEventType))
                        {
                            EventTarget.Instance.RemoveEventListener(eventType, this, true);
                        }
                    }
                    EventTarget.Dispose();
                    EventTarget = null;
                }

                BaseWindow.Destroy();

                Xpcom.FreeComObject(ref CommandParams);

                var webBrowserFocus = this.WebBrowserFocus;
                this.WebBrowserFocus = null;
                Xpcom.FreeComObject(ref webBrowserFocus);
                Xpcom.FreeComObject(ref WebNav);
                Xpcom.FreeComObject(ref BaseWindow);
                Xpcom.FreeComObject(ref WebBrowser);
#if GTK
                if (m_wrapper != null)
                {
                    m_wrapper.Dispose();
                }
#endif
            }

            base.OnHandleDestroyed(e);
        }
Exemplo n.º 44
0
        public ComPtrTreeNode(ComPropertyInfo comPropertyInfo, ComPtr comPtr)
            : this(comPropertyInfo.Name, comPtr)
        {
            _comPropertyInfo = comPropertyInfo;

            if ((_comPropertyInfo != null) && (_comPropertyInfo.GetFunction != null))
            {
                _comFunctionInfo = _comPropertyInfo.GetFunction;
                _getFunctionHasParameters = _comPropertyInfo.GetFunctionHasParameters;
            }
        }
Exemplo n.º 45
0
 public void CompileTest_Ok()
 {
     using ComPtr <IDxcBlob> dxcBlob = ShaderCompiler.Instance.CompileShader(ShaderSource.AsSpan());
 }
Exemplo n.º 46
0
        private ComTreeNode GetChild(ComPtr comPtr, ComPropertyInfo comPropertyInfo)
        {
            if (comPtr == null) return null;
            if (comPropertyInfo == null) return null;
            if (comPtr.IsInvalid) return null;

            ComFunctionInfo getFunctionInfo = comPropertyInfo.GetFunction;

            if (getFunctionInfo == null) return null;
            if (getFunctionInfo.IsRestricted) return null;

            ComTreeNode comTreeNode = null;
            object propertyValue = null;

            if (getFunctionInfo.Parameters.Length == 0)
            {
                try
                {
                    comPtr.TryInvokePropertyGet(getFunctionInfo.DispId, out propertyValue);
                }
                catch
                {
                    GlobalExceptionHandler.HandleException();
                }

                if (propertyValue == null)
                {
                    switch (getFunctionInfo.ReturnParameter.VariantType)
                    {
                        case VarEnum.VT_DISPATCH:
                        case VarEnum.VT_PTR:
                        case VarEnum.VT_ARRAY:
                        case VarEnum.VT_UNKNOWN:
                            propertyValue = new ComPtr(IntPtr.Zero);
                            break;
                    }
                }

                if (propertyValue is ComPtr)
                {
                    comTreeNode = new ComPtrTreeNode(comPropertyInfo, (ComPtr)propertyValue);

                    if (((ComPtr)propertyValue).IsInvalid == false)
                    {
                        comTreeNode.Nodes.Add(String.Empty);
                    }
                }
                else
                {
                    comTreeNode = new ComPropertyTreeNode(comPropertyInfo, propertyValue);
                }
            }
            else
            {
                switch (getFunctionInfo.ReturnParameter.VariantType)
                {
                    case VarEnum.VT_DISPATCH:
                    case VarEnum.VT_PTR:
                    case VarEnum.VT_ARRAY:
                    case VarEnum.VT_UNKNOWN:
                        comTreeNode = new ComPtrTreeNode(comPropertyInfo, new ComPtr());
                        break;
                    default:
                        comTreeNode = new ComPropertyTreeNode(comPropertyInfo, null);
                        break;

                }
            }

            return comTreeNode;
        }
Exemplo n.º 47
0
        public ComTreeNode AddRootNode(ComPtr p, string caption)
        {
            ComPtrTreeNode comObjectRootTreeNode = new ComPtrTreeNode(caption, p);

            comObjectRootTreeNode.Nodes.Add("...");
            Nodes.Add(comObjectRootTreeNode);
            SelectedNode = comObjectRootTreeNode;
            comObjectRootTreeNode.Expand();

            return comObjectRootTreeNode;
        }
Exemplo n.º 48
0
    public void CompileTest_Fail()
    {
        var faultyShader = ShaderSource.Replace("ids.x", "ids.X");

        using ComPtr <IDxcBlob> dxcBlob = ShaderCompiler.Instance.CompileShader(faultyShader.AsSpan());
    }
Exemplo n.º 49
0
        private ComTreeNode[] GetChildren(ComPtr comPtr)
        {
            if (comPtr == null) return new ComTreeNode[] { };

            ComTypeInfo comTypeInfo = comPtr.TryGetComTypeInfo();

            if (comTypeInfo == null) return new ComTreeNode[] { };

            List<ComTreeNode> childNodes = new List<ComTreeNode>();

            try
            {
                foreach (ComPropertyInfo comPropertyInfo in comTypeInfo.Properties)
                {
                    // Special case. MailSession is a PITA property that causes modal dialog.
                    if (comPropertyInfo.Name.Equals("MailSession"))
                    {
                        continue;
                    }

                    ComTreeNode comTreeNode = GetChild(comPtr, comPropertyInfo);

                    if (comTreeNode != null)
                    {
                        if ((comTreeNode is ComPropertyTreeNode) && (_showProperties == false))
                        {
                            continue;
                        }

                        childNodes.Add(comTreeNode);
                    }
                }

                if (comPtr.TryIsCollection())
                {
                    int count = comPtr.TryGetItemCount();

                    try
                    {
                        ComFunctionInfo comFunctionInfo = comTypeInfo.Methods.Where(x => x.Name.Equals("Item", StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

                        if (comFunctionInfo != null)
                        {
                            // Solid Edge is supposed to be 1 based index but some collections are 0 based.
                            // Application->Customization->RibbonBarThemes seems to be 0 based.
                            for (int i = 0; i <= count; i++)
                            {
                                object returnValue = null;
                                if (MarshalEx.Succeeded(comPtr.TryInvokeMethod("Item", new object[] { i }, out returnValue)))
                                {
                                    ComPtr pItem = returnValue as ComPtr;
                                    if ((pItem != null) && (pItem.IsInvalid == false))
                                    {
                                        ComPtrItemTreeNode comPtrItemTreeNode = new ComPtrItemTreeNode((ComPtr)returnValue, comFunctionInfo);
                                        comPtrItemTreeNode.Caption = String.Format("{0}({1})", comFunctionInfo.Name, i);
                                        comPtrItemTreeNode.Nodes.Add("...");
                                        childNodes.Add(comPtrItemTreeNode);
                                    }
                                }
                            }
                        }
                    }
                    catch
                    {
                        GlobalExceptionHandler.HandleException();
                    }
                }

                if (_showMethods)
                {
                    foreach (ComFunctionInfo comFunctionInfo in comTypeInfo.GetMethods(true))
                    {
                        if (comFunctionInfo.IsRestricted) continue;

                        ComMethodTreeNode comMethodTreeNode = new ComMethodTreeNode(comFunctionInfo);
                        childNodes.Add(comMethodTreeNode);
                    }
                }
            }
            catch
            {
                GlobalExceptionHandler.HandleException();
            }

            return childNodes.ToArray();
        }
Exemplo n.º 50
0
 static ScreenManager()
 {
     _screenManager = Xpcom.GetService2 <nsIScreenManager>(Contracts.ScreenManager);
 }
Exemplo n.º 51
0
 internal CertificateValidity( nsIX509CertValidity validity )
 {
     _validity = new ComPtr<nsIX509CertValidity>( validity );
 }
Exemplo n.º 52
0
 static CategoryManager()
 {
     _categoryManager = Xpcom.GetService2 <nsICategoryManager>(Contracts.CategoryManager);
 }
Exemplo n.º 53
0
 static ScreenManager()
 {
     _screenManager = Xpcom.GetService2<nsIScreenManager>(Contracts.ScreenManager);
 }
Exemplo n.º 54
0
 static IOService()
 {
     _service = Xpcom.GetService2 <nsIIOService2>(Contracts.NetworkIOService);
 }
 static PrivateBrowsingService()
 {
     _privateBrowsingService = Xpcom.GetService2<nsIPrivateBrowsingService>(Contracts.PrivateBrowsing);
 }
Exemplo n.º 56
0
    /// <inheritdoc/>
    public override unsafe void OnUpdate(TimeSpan time)
    {
        if (this.isResizePending)
        {
            ApplyResize();

            this.isResizePending = false;
        }

        // Generate the new frame
        GraphicsDevice.Default.ForEach(this.texture !, this.shaderFactory(time));

        using ComPtr <ID3D12Resource> d3D12Resource = default;

        // Get the underlying ID3D12Resource pointer for the texture
        _ = InteropServices.TryGetID3D12Resource(this.texture !, Windows.__uuidof <ID3D12Resource>(), (void **)d3D12Resource.GetAddressOf());

        // Get the target back buffer to update
        ID3D12Resource *d3D12ResourceBackBuffer = this.currentBufferIndex switch
        {
            0 => this.d3D12Resource0.Get(),
            1 => this.d3D12Resource1.Get(),
            _ => null
        };

        this.currentBufferIndex ^= 1;

        // Reset the command list and command allocator
        this.d3D12CommandAllocator.Get()->Reset();
        this.d3D12GraphicsCommandList.Get()->Reset(this.d3D12CommandAllocator.Get(), null);

        D3D12_RESOURCE_BARRIER *d3D12ResourceBarriers = stackalloc D3D12_RESOURCE_BARRIER[]
        {
            D3D12_RESOURCE_BARRIER.InitTransition(
                d3D12Resource.Get(),
                D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_UNORDERED_ACCESS,
                D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COPY_SOURCE),
            D3D12_RESOURCE_BARRIER.InitTransition(
                d3D12ResourceBackBuffer,
                D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COMMON,
                D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COPY_DEST)
        };

        // Transition the resources to COPY_DEST and COPY_SOURCE respectively
        d3D12GraphicsCommandList.Get()->ResourceBarrier(2, d3D12ResourceBarriers);

        // Copy the generated frame to the target back buffer
        d3D12GraphicsCommandList.Get()->CopyResource(d3D12ResourceBackBuffer, d3D12Resource.Get());

        d3D12ResourceBarriers[0] = D3D12_RESOURCE_BARRIER.InitTransition(
            d3D12Resource.Get(),
            D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COPY_SOURCE,
            D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_UNORDERED_ACCESS);

        d3D12ResourceBarriers[1] = D3D12_RESOURCE_BARRIER.InitTransition(
            d3D12ResourceBackBuffer,
            D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COPY_DEST,
            D3D12_RESOURCE_STATES.D3D12_RESOURCE_STATE_COMMON);

        // Transition the resources back to COMMON and UNORDERED_ACCESS respectively
        d3D12GraphicsCommandList.Get()->ResourceBarrier(2, d3D12ResourceBarriers);

        d3D12GraphicsCommandList.Get()->Close();

        // Execute the command list to perform the copy
        this.d3D12CommandQueue.Get()->ExecuteCommandLists(1, (ID3D12CommandList **)d3D12GraphicsCommandList.GetAddressOf());
        this.d3D12CommandQueue.Get()->Signal(this.d3D12Fence.Get(), this.nextD3D12FenceValue);

        // Present the new frame
        this.dxgiSwapChain1.Get()->Present(0, 0);

        if (this.nextD3D12FenceValue > this.d3D12Fence.Get()->GetCompletedValue())
        {
            this.d3D12Fence.Get()->SetEventOnCompletion(this.nextD3D12FenceValue, default);
        }

        this.nextD3D12FenceValue++;
    }
}
Exemplo n.º 57
0
 static CategoryManager()
 {
     _categoryManager = Xpcom.GetService2<nsICategoryManager>(Contracts.CategoryManager);
 }
Exemplo n.º 58
0
    /// <inheritdoc/>
    public override unsafe void OnInitialize(HWND hwnd)
    {
        // Get the underlying ID3D12Device in use
        fixed(ID3D12Device **d3D12Device = this.d3D12Device)
        {
            _ = InteropServices.TryGetID3D12Device(GraphicsDevice.Default, Windows.__uuidof <ID3D12Device>(), (void **)d3D12Device);
        }

        // Create the direct command queue to use
        fixed(ID3D12CommandQueue **d3D12CommandQueue = this.d3D12CommandQueue)
        {
            D3D12_COMMAND_QUEUE_DESC d3D12CommandQueueDesc;

            d3D12CommandQueueDesc.Type     = D3D12_COMMAND_LIST_TYPE.D3D12_COMMAND_LIST_TYPE_DIRECT;
            d3D12CommandQueueDesc.Priority = (int)D3D12_COMMAND_QUEUE_PRIORITY.D3D12_COMMAND_QUEUE_PRIORITY_NORMAL;
            d3D12CommandQueueDesc.Flags    = D3D12_COMMAND_QUEUE_FLAGS.D3D12_COMMAND_QUEUE_FLAG_NONE;
            d3D12CommandQueueDesc.NodeMask = 0;

            _ = d3D12Device.Get()->CreateCommandQueue(
                &d3D12CommandQueueDesc,
                Windows.__uuidof <ID3D12CommandQueue>(),
                (void **)d3D12CommandQueue);
        }

        // Create the direct fence
        fixed(ID3D12Fence **d3D12Fence = this.d3D12Fence)
        {
            _ = this.d3D12Device.Get()->CreateFence(
                0,
                D3D12_FENCE_FLAGS.D3D12_FENCE_FLAG_NONE,
                Windows.__uuidof <ID3D12Fence>(),
                (void **)d3D12Fence);
        }

        // Create the swap chain to display frames
        fixed(IDXGISwapChain1 **dxgiSwapChain1 = this.dxgiSwapChain1)
        {
            using ComPtr <IDXGIFactory2> dxgiFactory2 = default;

            _ = DirectX.CreateDXGIFactory2(DXGI.DXGI_CREATE_FACTORY_DEBUG, Windows.__uuidof <IDXGIFactory2>(), (void **)dxgiFactory2.GetAddressOf());

            DXGI_SWAP_CHAIN_DESC1 dxgiSwapChainDesc1 = default;

            dxgiSwapChainDesc1.AlphaMode   = DXGI_ALPHA_MODE.DXGI_ALPHA_MODE_IGNORE;
            dxgiSwapChainDesc1.BufferCount = 2;
            dxgiSwapChainDesc1.Flags       = 0;
            dxgiSwapChainDesc1.Format      = DXGI_FORMAT.DXGI_FORMAT_R8G8B8A8_UNORM;
            dxgiSwapChainDesc1.Width       = 0;
            dxgiSwapChainDesc1.Height      = 0;
            dxgiSwapChainDesc1.SampleDesc  = new DXGI_SAMPLE_DESC(count: 1, quality: 0);
            dxgiSwapChainDesc1.Scaling     = DXGI_SCALING.DXGI_SCALING_STRETCH;
            dxgiSwapChainDesc1.Stereo      = 0;
            dxgiSwapChainDesc1.SwapEffect  = DXGI_SWAP_EFFECT.DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;

            _ = dxgiFactory2.Get()->CreateSwapChainForHwnd(
                (IUnknown *)d3D12CommandQueue.Get(),
                hwnd,
                &dxgiSwapChainDesc1,
                null,
                null,
                dxgiSwapChain1);
        }

        // Create the command allocator to use
        fixed(ID3D12CommandAllocator **d3D12CommandAllocator = this.d3D12CommandAllocator)
        {
            this.d3D12Device.Get()->CreateCommandAllocator(
                D3D12_COMMAND_LIST_TYPE.D3D12_COMMAND_LIST_TYPE_DIRECT,
                Windows.__uuidof <ID3D12CommandAllocator>(),
                (void **)d3D12CommandAllocator);
        }

        // Create the reusable command list to copy data to the back buffers
        fixed(ID3D12GraphicsCommandList **d3D12GraphicsCommandList = this.d3D12GraphicsCommandList)
        {
            this.d3D12Device.Get()->CreateCommandList(
                0,
                D3D12_COMMAND_LIST_TYPE.D3D12_COMMAND_LIST_TYPE_DIRECT,
                d3D12CommandAllocator,
                null,
                Windows.__uuidof <ID3D12GraphicsCommandList>(),
                (void **)d3D12GraphicsCommandList);
        }

        // Close the command list to prepare it for future use
        this.d3D12GraphicsCommandList.Get()->Close();
    }
Exemplo n.º 59
0
		internal CacheDeviceInfo(nsICacheDeviceInfo cacheDeviceInfo)
		{
			_cacheDeviceInfo = new ComPtr<nsICacheDeviceInfo>(cacheDeviceInfo);
		}
    protected override void CreateAssets()
    {
        _inputLayout = CreateInputLayout();
        CreateBuffers();
        base.CreateAssets();

        ID3D11InputLayout *CreateInputLayout()
        {
            using ComPtr <ID3DBlob> vertexShaderBlob = null;
            using ComPtr <ID3DBlob> pixelShaderBlob  = null;

            fixed(char *fileName = GetAssetFullPath(@"D3D11\Assets\Shaders\HelloTriangle.hlsl"))
            fixed(ID3D11VertexShader **vertexShader = &_vertexShader)
            fixed(ID3D11PixelShader **pixelShader   = &_pixelShader)
            {
                var entryPoint = 0x00006E69614D5356;    // VSMain
                var target     = 0x0000305F345F7376;    // vs_4_0

                ThrowIfFailed(D3DCompileFromFile((ushort *)fileName, null, null, (sbyte *)&entryPoint, (sbyte *)&target, 0, 0, vertexShaderBlob.GetAddressOf(), null));

                ThrowIfFailed(D3DDevice->CreateVertexShader(vertexShaderBlob.Get()->GetBufferPointer(), vertexShaderBlob.Get()->GetBufferSize(), pClassLinkage: null, vertexShader));

                entryPoint = 0x00006E69614D5350;        // PSMain
                target     = 0x0000305F345F7370;        // ps_4_0
                ThrowIfFailed(D3DCompileFromFile((ushort *)fileName, null, null, (sbyte *)&entryPoint, (sbyte *)&target, 0, 0, pixelShaderBlob.GetAddressOf(), null));

                ThrowIfFailed(D3DDevice->CreatePixelShader(pixelShaderBlob.Get()->GetBufferPointer(), pixelShaderBlob.Get()->GetBufferSize(), pClassLinkage: null, pixelShader));
            }

            var inputElementDescs = stackalloc D3D11_INPUT_ELEMENT_DESC[2];
            {
                var semanticName0 = stackalloc sbyte[9];
                {
                    ((ulong *)semanticName0)[0] = 0x4E4F495449534F50;      // POSITION
                }
                inputElementDescs[0] = new D3D11_INPUT_ELEMENT_DESC {
                    SemanticName         = semanticName0,
                    SemanticIndex        = 0,
                    Format               = DXGI_FORMAT_R32G32B32_FLOAT,
                    InputSlot            = 0,
                    AlignedByteOffset    = 0,
                    InputSlotClass       = D3D11_INPUT_PER_VERTEX_DATA,
                    InstanceDataStepRate = 0
                };

                var semanticName1 = 0x000000524F4C4F43;                     // COLOR
                inputElementDescs[1] = new D3D11_INPUT_ELEMENT_DESC {
                    SemanticName         = (sbyte *)&semanticName1,
                    SemanticIndex        = 0,
                    Format               = DXGI_FORMAT_R32G32B32A32_FLOAT,
                    InputSlot            = 0,
                    AlignedByteOffset    = 12,
                    InputSlotClass       = D3D11_INPUT_PER_VERTEX_DATA,
                    InstanceDataStepRate = 0
                };
            }

            ID3D11InputLayout *inputLayout;

            ThrowIfFailed(D3DDevice->CreateInputLayout(inputElementDescs, NumElements: 2, vertexShaderBlob.Get()->GetBufferPointer(), vertexShaderBlob.Get()->GetBufferSize(), &inputLayout));
            return(inputLayout);
        }
    }