예제 #1
0
        /// <summary>	
        /// <p>Get the storage filter at the top of the storage-filter stack.</p>	
        /// </summary>	
        /// <returns>The storage filter at the top of the storage-filter stack.</returns>	
        /// <msdn-id>ff476560</msdn-id>	
        /// <unmanaged>HRESULT ID3D11InfoQueue::GetStorageFilter([In] void* pFilter,[InOut] SIZE_T* pFilterByteLength)</unmanaged>	
        /// <unmanaged-short>ID3D11InfoQueue::GetStorageFilter</unmanaged-short>	
        public unsafe SharpDX.Direct3D11.InfoQueueFilter GetStorageFilter()
        {
            var sizeFilter = PointerSize.Zero;
            GetStorageFilter(IntPtr.Zero, ref sizeFilter);

            if(sizeFilter == 0)
            {
                return null;
            }
            var filter = stackalloc byte[(int)sizeFilter];
            GetStorageFilter((IntPtr)filter, ref sizeFilter);

            var queueNative = new InfoQueueFilter();
            queueNative.__MarshalFrom(ref *(InfoQueueFilter.__Native*)filter);

            return queueNative;
        }
예제 #2
0
 static private void InitDebugOutput()
 {
     if (VRage.MyCompilationSymbols.DX11Debug && VRage.MyCompilationSymbols.DX11DebugOutput)
     {
         DebugInfoQueue = Device.QueryInterface<InfoQueue>();
         DebugInfoQueue.SetBreakOnSeverity(MessageSeverity.Corruption, true);
         DebugInfoQueue.SetBreakOnSeverity(MessageSeverity.Error, true);
         DebugInfoQueue.MessageCountLimit = 4096;
         DebugInfoQueue.ClearStorageFilter();
         if (! VRage.MyCompilationSymbols.DX11DebugOutputEnableInfo)
         {
             InfoQueueFilter filter = new InfoQueueFilter();
             filter.DenyList = new InfoQueueFilterDescription();
             filter.DenyList.Severities = new MessageSeverity[1];
             filter.DenyList.Severities[0] = MessageSeverity.Information;
             DebugInfoQueue.AddStorageFilterEntries(filter);
         }
     }
 }
예제 #3
0
 static private void InitDebugOutput()
 {
     if (VRage.MyCompilationSymbols.DX11Debug && VRage.MyCompilationSymbols.DX11DebugOutput)
     {
         DebugInfoQueue = Device.QueryInterface <InfoQueue>();
         DebugInfoQueue.SetBreakOnSeverity(MessageSeverity.Corruption, true);
         DebugInfoQueue.SetBreakOnSeverity(MessageSeverity.Error, true);
         DebugInfoQueue.MessageCountLimit = 4096;
         DebugInfoQueue.ClearStorageFilter();
         if (!VRage.MyCompilationSymbols.DX11DebugOutputEnableInfo)
         {
             InfoQueueFilter filter = new InfoQueueFilter();
             filter.DenyList               = new InfoQueueFilterDescription();
             filter.DenyList.Severities    = new MessageSeverity[1];
             filter.DenyList.Severities[0] = MessageSeverity.Information;
             DebugInfoQueue.AddStorageFilterEntries(filter);
         }
     }
 }
예제 #4
0
    public unsafe InfoQueueFilter?GetRetrievalFilter()
    {
        PointerSize sizeFilter = PointerSize.Zero;

        GetRetrievalFilter(IntPtr.Zero, ref sizeFilter);

        if (sizeFilter == 0)
        {
            return(null);
        }

        byte *filter = stackalloc byte[(int)sizeFilter];

        GetRetrievalFilter((IntPtr)filter, ref sizeFilter);

        InfoQueueFilter queueNative = new InfoQueueFilter();

        queueNative.__MarshalFrom(ref *(InfoQueueFilter.__Native *)filter);
        return(queueNative);
    }
예제 #5
0
        /// <summary>
        /// <p>Get the retrieval filter at the top of the retrieval-filter stack.</p>
        /// </summary>
        /// <returns>The retrieval filter at the top of the retrieval-filter stack.</returns>
        /// <msdn-id>ff476558</msdn-id>
        /// <unmanaged>HRESULT ID3D11InfoQueue::GetRetrievalFilter([In] void* pFilter,[InOut] SIZE_T* pFilterByteLength)</unmanaged>
        /// <unmanaged-short>ID3D11InfoQueue::GetRetrievalFilter</unmanaged-short>
        public unsafe SharpDX.Direct3D11.InfoQueueFilter GetRetrievalFilter()
        {
            var sizeFilter = PointerSize.Zero;

            GetRetrievalFilter(IntPtr.Zero, ref sizeFilter);

            if (sizeFilter == 0)
            {
                return(null);
            }
            var filter = stackalloc byte[(int)sizeFilter];

            GetRetrievalFilter((IntPtr)filter, ref sizeFilter);

            var queueNative = new InfoQueueFilter();

            queueNative.__MarshalFrom(ref *(InfoQueueFilter.__Native *)filter);

            return(queueNative);
        }
    public unsafe InfoQueueFilter?GetRetrievalFilter(Guid producer)
    {
        var sizeFilter = PointerSize.Zero;

        GetRetrievalFilter(producer, IntPtr.Zero, ref sizeFilter);

        if (sizeFilter == 0)
        {
            return(null);
        }
        var filter = stackalloc byte[(int)sizeFilter];

        GetRetrievalFilter(producer, (IntPtr)filter, ref sizeFilter);

        var queueNative = new InfoQueueFilter();

        queueNative.__MarshalFrom(ref *(InfoQueueFilter.__Native *)filter);

        return(queueNative);
    }
예제 #7
0
        /// <summary>
        ///     Initializes the specified device.
        /// </summary>
        /// <param name="graphicsProfiles">The graphics profiles.</param>
        /// <param name="deviceCreationFlags">The device creation flags.</param>
        /// <param name="windowHandle">The window handle.</param>
        private void InitializePlatformDevice(GraphicsProfile[] graphicsProfiles, DeviceCreationFlags deviceCreationFlags, object windowHandle)
        {
            if (nativeDevice != null)
            {
                // Destroy previous device
                ReleaseDevice();
            }

            rendererName = Adapter.NativeAdapter.Description.Description;

            // Profiling is supported through pix markers
            IsProfilingSupported = true;

            // Command lists are thread-safe and execute deferred
            IsDeferred = true;

            bool isDebug = (deviceCreationFlags & DeviceCreationFlags.Debug) != 0;

            if (isDebug)
            {
                SharpDX.Direct3D12.DebugInterface.Get().EnableDebugLayer();
            }

            // Create Device D3D12 with feature Level based on profile
            for (int index = 0; index < graphicsProfiles.Length; index++)
            {
                var graphicsProfile = graphicsProfiles[index];
                try
                {
                    // D3D12 supports only feature level 11+
                    var level = graphicsProfile.ToFeatureLevel();
                    if (level < SharpDX.Direct3D.FeatureLevel.Level_11_0)
                    {
                        level = SharpDX.Direct3D.FeatureLevel.Level_11_0;
                    }

                    nativeDevice = new SharpDX.Direct3D12.Device(Adapter.NativeAdapter, level);

                    RequestedProfile    = graphicsProfile;
                    CurrentFeatureLevel = level;
                    break;
                }
                catch (Exception)
                {
                    if (index == graphicsProfiles.Length - 1)
                    {
                        throw;
                    }
                }
            }

            // Describe and create the command queue.
            var queueDesc = new SharpDX.Direct3D12.CommandQueueDescription(SharpDX.Direct3D12.CommandListType.Direct);

            NativeCommandQueue = nativeDevice.CreateCommandQueue(queueDesc);
            //queueDesc.Type = CommandListType.Copy;
            NativeCopyCommandQueue = nativeDevice.CreateCommandQueue(queueDesc);
            TimestampFrequency     = NativeCommandQueue.TimestampFrequency;

            SrvHandleIncrementSize     = NativeDevice.GetDescriptorHandleIncrementSize(DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView);
            SamplerHandleIncrementSize = NativeDevice.GetDescriptorHandleIncrementSize(DescriptorHeapType.Sampler);

            if (isDebug)
            {
                var debugDevice = nativeDevice.QueryInterfaceOrNull <DebugDevice>();
                if (debugDevice != null)
                {
                    var infoQueue = debugDevice.QueryInterfaceOrNull <InfoQueue>();
                    if (infoQueue != null)
                    {
                        MessageId[] disabledMessages =
                        {
                            // This happens when render target or depth stencil clear value is diffrent
                            // than provided during resource allocation.
                            MessageId.CleardepthstencilviewMismatchingclearvalue,
                            MessageId.ClearrendertargetviewMismatchingclearvalue,

                            // This occurs when there are uninitialized descriptors in a descriptor table,
                            // even when a shader does not access the missing descriptors.
                            MessageId.InvalidDescriptorHandle,

                            // These happen when capturing with VS diagnostics
                            MessageId.MapInvalidNullRange,
                            MessageId.UnmapInvalidNullRange,
                        };

                        // Disable irrelevant debug layer warnings
                        InfoQueueFilter filter = new InfoQueueFilter
                        {
                            DenyList = new InfoQueueFilterDescription
                            {
                                Ids = disabledMessages
                            }
                        };
                        infoQueue.AddStorageFilterEntries(filter);

                        //infoQueue.SetBreakOnSeverity(MessageSeverity.Error, true);
                        //infoQueue.SetBreakOnSeverity(MessageSeverity.Warning, true);

                        infoQueue.Dispose();
                    }
                    debugDevice.Dispose();
                }
            }

            // Prepare pools
            CommandAllocators = new CommandAllocatorPool(this);
            SrvHeaps          = new HeapPool(this, SrvHeapSize, DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView);
            SamplerHeaps      = new HeapPool(this, SamplerHeapSize, DescriptorHeapType.Sampler);

            // Prepare descriptor allocators
            SamplerAllocator            = new DescriptorAllocator(this, DescriptorHeapType.Sampler);
            ShaderResourceViewAllocator = new DescriptorAllocator(this, DescriptorHeapType.ConstantBufferViewShaderResourceViewUnorderedAccessView);
            DepthStencilViewAllocator   = new DescriptorAllocator(this, DescriptorHeapType.DepthStencilView);
            RenderTargetViewAllocator   = new DescriptorAllocator(this, DescriptorHeapType.RenderTargetView);

            // Prepare copy command list (start it closed, so that every new use start with a Reset)
            NativeCopyCommandAllocator = NativeDevice.CreateCommandAllocator(CommandListType.Direct);
            NativeCopyCommandList      = NativeDevice.CreateCommandList(CommandListType.Direct, NativeCopyCommandAllocator, null);
            NativeCopyCommandList.Close();

            // Fence for next frame and resource cleaning
            nativeFence     = NativeDevice.CreateFence(0, FenceFlags.None);
            nativeCopyFence = NativeDevice.CreateFence(0, FenceFlags.None);
        }