当前位置: 首页>>代码示例>>C#>>正文


C# Device.CheckMultisampleQualityLevels方法代码示例

本文整理汇总了C#中SharpDX.Direct3D11.Device.CheckMultisampleQualityLevels方法的典型用法代码示例。如果您正苦于以下问题:C# Device.CheckMultisampleQualityLevels方法的具体用法?C# Device.CheckMultisampleQualityLevels怎么用?C# Device.CheckMultisampleQualityLevels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SharpDX.Direct3D11.Device的用法示例。


在下文中一共展示了Device.CheckMultisampleQualityLevels方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateAdaptersList

        unsafe static MyAdapterInfo[] CreateAdaptersList()
        {
            List<MyAdapterInfo> adaptersList = new List<MyAdapterInfo>();

            var factory = GetFactory();
            FeatureLevel[] featureLevels = { FeatureLevel.Level_11_0 };

            int adapterIndex = 0;

            LogInfoFromWMI();

            for(int i=0; i<factory.Adapters.Length; i++)
            {
                var adapter = factory.Adapters[i];
                Device adapterTestDevice = null;
                try
                {
                    adapterTestDevice = new Device(adapter, DeviceCreationFlags.None, featureLevels);
                }
                catch(SharpDXException e)
                {

                }

                bool supportedDevice = adapterTestDevice != null;

                bool supportsConcurrentResources = false;
                bool supportsCommandLists = false;
                if (supportedDevice)
                {
                    adapterTestDevice.CheckThreadingSupport(out supportsConcurrentResources, out supportsCommandLists);
                }

                // DedicatedSystemMemory = bios or DVMT preallocated video memory, that cannot be used by OS - need retest on pc with only cpu/chipset based graphic
                // DedicatedVideoMemory = discrete graphic video memory
                // SharedSystemMemory = aditional video memory, that can be taken from OS RAM when needed
                void * vramptr = ((IntPtr)(adapter.Description.DedicatedSystemMemory != 0 ? adapter.Description.DedicatedSystemMemory : adapter.Description.DedicatedVideoMemory)).ToPointer();
                UInt64 vram = (UInt64)vramptr;
                void * svramptr = ((IntPtr)adapter.Description.SharedSystemMemory).ToPointer();
                UInt64 svram = (UInt64)svramptr;

                // microsoft software renderer allocates 256MB shared memory, cpu integrated graphic on notebooks has 0 preallocated, all shared
                supportedDevice = supportedDevice && (vram > 500000000 || svram > 500000000);

                var deviceDesc = String.Format("{0}, dev id: {1}, mem: {2}, shared mem: {3}, Luid: {4}, rev: {5}, subsys id: {6}, vendor id: {7}",
                    adapter.Description.Description,
                    adapter.Description.DeviceId,
                    vram,
                    svram,
                    adapter.Description.Luid,
                    adapter.Description.Revision,
                    adapter.Description.SubsystemId,
                    adapter.Description.VendorId
                    );

                var info = new MyAdapterInfo
                {
                    Name = adapter.Description.Description,
                    DeviceName = adapter.Description.Description,
                    Description = deviceDesc,
                    IsDx11Supported = supportedDevice,
                    AdapterDeviceId = i,
                    Priority = VendorPriority(adapter.Description.VendorId),
                    HDRSupported = true,
                    MaxTextureSize = SharpDX.Direct3D11.Texture2D.MaximumTexture2DSize,
                    VRAM = vram > 0 ? vram : svram,
                    Has512MBRam = (vram > 500000000 || svram > 500000000),
                    MultithreadedRenderingSupported = supportsCommandLists
                };

                if(info.VRAM >= 2000000000)
                {
                    info.MaxTextureQualitySupported = MyTextureQuality.HIGH;
                }
                else if (info.VRAM >= 1000000000)
                {
                    info.MaxTextureQualitySupported = MyTextureQuality.MEDIUM;
                }
                else
                { 
                    info.MaxTextureQualitySupported = MyTextureQuality.LOW;
                }

                info.MaxAntialiasingModeSupported = MyAntialiasingMode.FXAA;
                if (supportedDevice)
                {
                    if (adapterTestDevice.CheckMultisampleQualityLevels(Format.R11G11B10_Float, 2) > 0)
                    {
                        info.MaxAntialiasingModeSupported = MyAntialiasingMode.MSAA_2;
                    }
                    if (adapterTestDevice.CheckMultisampleQualityLevels(Format.R11G11B10_Float, 4) > 0)
                    {
                        info.MaxAntialiasingModeSupported = MyAntialiasingMode.MSAA_4;
                    }
                    if (adapterTestDevice.CheckMultisampleQualityLevels(Format.R11G11B10_Float, 8) > 0)
                    {
                        info.MaxAntialiasingModeSupported = MyAntialiasingMode.MSAA_8;
                    }
                }

//.........这里部分代码省略.........
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:101,代码来源:MyRender-Adapters.cs

示例2: CreateAdaptersList

        unsafe static MyAdapterInfo[] CreateAdaptersList()
        {
            List<MyAdapterInfo> adaptersList = new List<MyAdapterInfo>();

            var factory = GetFactory();
            FeatureLevel[] featureLevels = { FeatureLevel.Level_11_0 };

            int adapterIndex = 0;

            LogInfoFromWMI();

            for(int i=0; i<factory.Adapters.Length; i++)
            {
                var adapter = factory.Adapters[i];
                Device adapterTestDevice = null;
                try
                {
                    adapterTestDevice = new Device(adapter, DeviceCreationFlags.None, featureLevels);
                }
                catch(SharpDXException e)
                {

                }

                bool supportedDevice = adapterTestDevice != null;

                bool supportsConcurrentResources = false;
                bool supportsCommandLists = false;
                if (supportedDevice)
                {
                    adapterTestDevice.CheckThreadingSupport(out supportsConcurrentResources, out supportsCommandLists);
                }

                void* ptr = ((IntPtr)adapter.Description.DedicatedVideoMemory).ToPointer();
                ulong vram = (ulong)ptr;

                var deviceDesc = String.Format("{0}, dev id: {1}, shared mem: {2}, Luid: {3}, rev: {4}, subsys id: {5}, vendor id: {6}",
                    adapter.Description.Description,
                    adapter.Description.DeviceId,
                    vram,
                    adapter.Description.Luid,
                    adapter.Description.Revision,
                    adapter.Description.SubsystemId,
                    adapter.Description.VendorId
                    );

                var info = new MyAdapterInfo
                {
                    Name = adapter.Description.Description,
                    DeviceName = adapter.Description.Description,
                    Description = deviceDesc,
                    IsSupported = supportedDevice,
                    AdapterDeviceId = i,

                    Has512MBRam = vram > 500000000,
                    HDRSupported = true,
                    MaxTextureSize = SharpDX.Direct3D11.Texture2D.MaximumTexture2DSize,

                    VRAM = vram,
                    MultithreadedRenderingSupported = supportsCommandLists
                };

                if(vram >= 2000000000)
                {
                    info.MaxTextureQualitySupported = MyTextureQuality.HIGH;
                }
                else if (vram >= 1000000000)
                {
                    info.MaxTextureQualitySupported = MyTextureQuality.MEDIUM;
                }
                else
                { 
                    info.MaxTextureQualitySupported = MyTextureQuality.LOW;
                }

                info.MaxAntialiasingModeSupported = MyAntialiasingMode.FXAA;
                if (supportedDevice)
                {
                    if (adapterTestDevice.CheckMultisampleQualityLevels(Format.R11G11B10_Float, 2) > 0)
                    {
                        info.MaxAntialiasingModeSupported = MyAntialiasingMode.MSAA_2;
                    }
                    if (adapterTestDevice.CheckMultisampleQualityLevels(Format.R11G11B10_Float, 4) > 0)
                    {
                        info.MaxAntialiasingModeSupported = MyAntialiasingMode.MSAA_4;
                    }
                    if (adapterTestDevice.CheckMultisampleQualityLevels(Format.R11G11B10_Float, 8) > 0)
                    {
                        info.MaxAntialiasingModeSupported = MyAntialiasingMode.MSAA_8;
                    }
                }

                LogAdapterInfoBegin(ref info);

                if(supportedDevice)
                {
                    for(int j=0; j<factory.Adapters[i].Outputs.Length; j++)
                    {
                        var output = factory.Adapters[i].Outputs[j];

//.........这里部分代码省略.........
开发者ID:leandro1129,项目名称:SpaceEngineers,代码行数:101,代码来源:MyRender-Adapters.cs

示例3: DetectSampleDescription

 static SharpDX.DXGI.SampleDescription DetectSampleDescription(Device device, SharpDX.DXGI.Format format)
 {
     var desc = new SharpDX.DXGI.SampleDescription();
     for (int multisample_count = Device.MultisampleCountMaximum; multisample_count > 0; --multisample_count)
     {
     int quality_levels = device.CheckMultisampleQualityLevels(format, multisample_count);
     if (quality_levels > 0)
     {
         desc.Count = multisample_count;
         desc.Quality = quality_levels - 1;
         break;
     }
     }
     Console.WriteLine("sample count {0} quality {1}", desc.Count, desc.Quality);
     return desc;
 }
开发者ID:3dcustom,项目名称:tsoview-dx,代码行数:16,代码来源:Viewer.cs

示例4: CreateDeviceAndSwapChain

        public void CreateDeviceAndSwapChain(RenderForm form)
        {
            FeatureLevel[] featureLevels = { FeatureLevel.Level_11_0, FeatureLevel.Level_10_0 };
            Device = new Device(DriverType.Hardware, DeviceCreationFlags.None, featureLevels);

            if(ConfigurationManager.Config.AntiAliasing)
                _maxQualityLevel = Device.CheckMultisampleQualityLevels(Format.B8G8R8A8_UNorm, 4);

            var swapChainDescription = new SwapChainDescription
            {
                BufferCount = 1, // Set to a single back buffer (double buffering)
                ModeDescription = new ModeDescription(form.ClientSize.Width, form.ClientSize.Height, _refreshRate, Format.R8G8B8A8_UNorm),
                IsWindowed = ConfigurationManager.Config.WindowedMode,
                OutputHandle = form.Handle,
                SampleDescription = ConfigurationManager.Config.AntiAliasing ? new SampleDescription(4, _maxQualityLevel-1) : new SampleDescription(1, 0),
                SwapEffect = SwapEffect.Discard,
                Usage = Usage.RenderTargetOutput
            };

            SwapChain = new SwapChain(new Factory(), Device, swapChainDescription);

            DeviceContext = Device.ImmediateContext;

            SwapChain.GetParent<Factory>().MakeWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAll);
        }
开发者ID:ndech,项目名称:PlaneSimulator,代码行数:25,代码来源:DX11.cs

示例5: CAdapter

        public CAdapter(Adapter1 dxgiAdapter, int index)
        {
            this.dxgiAdapter = dxgiAdapter;
            this.index = index;

            AdapterDescription1 dxgiDesc = dxgiAdapter.Description1;
            desc = new AdapterDescription
            {
                Description = dxgiDesc.Description,
                VendorId = dxgiDesc.VendorId,
                DeviceId = dxgiDesc.DeviceId,
                SubSysId = dxgiDesc.SubsystemId,
                Revision = dxgiDesc.Revision,
                DedicatedVideoMemory = dxgiDesc.DedicatedVideoMemory,
                DedicatedSystemMemory = dxgiDesc.DedicatedSystemMemory,
                SharedSystemMemory = dxgiDesc.SharedSystemMemory,
                AdapterLuidHigh = (int)(dxgiDesc.Luid >> 32),
                AdapterLuidLow = (int)(dxgiDesc.Luid & 0x00000000FFFFFFFF),
                Flags = CtBeholder.AdapterFlags(dxgiDesc.Flags)
            };

            outputs = dxgiAdapter.Outputs.Select(o => new COutput(o)).ToArray();

            using (var d3dDevice = new Device(dxgiAdapter))
            {
                switch (d3dDevice.FeatureLevel)
                {
                    case FeatureLevel.Level_9_1: apiVersion = new ApiVersion(9, 1); break;
                    case FeatureLevel.Level_9_3: apiVersion = new ApiVersion(9, 3); break;
                    case FeatureLevel.Level_9_2: apiVersion = new ApiVersion(9, 2); break;
                    case FeatureLevel.Level_10_0: apiVersion = new ApiVersion(10, 0); break;
                    case FeatureLevel.Level_10_1: apiVersion = new ApiVersion(10, 1); break;
                    case FeatureLevel.Level_11_0: apiVersion = new ApiVersion(11, 0); break;
                    default: throw new ArgumentOutOfRangeException("d3dDevice.FeatureLevel");
                }

                restrictions = new AdapterRestrictions
                {
                    UniformBufferSlots = CommonShaderStage.ConstantBufferApiSlotCount,
                    SamplerSlots = CommonShaderStage.SamplerSlotCount,
                    ShaderResourceSlots = CommonShaderStage.InputResourceSlotCount,
                    UnorderedAccessResourceSlots = ComputeShaderStage.UnorderedAccessViewSlotCount,
                    MaxVertexStreams = InputAssemblerStage.VertexInputResourceSlotCount,
                    MaxVertexStreamElementCount = InputAssemblerStage.VertexInputStructureElementCount,
                    MaxStreamOutputTargets = 4,
                    MaxViewports = 16,
                    MaxRenderTargets = 8,
                    MaxThreadGroupsX = d3dDevice.FeatureLevel == FeatureLevel.Level_11_0 ? ComputeShaderStage.ThreadGroupMaximumX : 768,
                    MaxThreadGroupsY = d3dDevice.FeatureLevel == FeatureLevel.Level_11_0 ? ComputeShaderStage.ThreadGroupMaximumY : 768,
                    MaxThreadGroupsZ = d3dDevice.FeatureLevel == FeatureLevel.Level_11_0 ? ComputeShaderStage.ThreadGroupMaximumZ : 1,
                    MaxThreadGroupsTotal = d3dDevice.FeatureLevel == FeatureLevel.Level_11_0 ? ComputeShaderStage.ThreadGroupMaximumThreadsPerGroup : 768
                };

                var allFormats = ((ExplicitFormat[])Enum.GetValues(typeof(ExplicitFormat))).Select(x => (Format)x).ToArray();

                formatsSupport = allFormats.Select(d3dDevice.CheckFormatSupport).ToArray();
                formatInfos = allFormats.Where(f => f != 0).Select(CtBeholder.FormatInfo).ToArray();
                //depthStencilFormatInfos = allFormats.Where(f => (formatsSupport[(int)f] & DepthStencilSupportMask) != 0).Select(CtBeholder.DepthStencilFormatInfo).ToArray();
                vertexElementFormats = allFormats.Where(f => (formatsSupport[(int)f] & VertexElementSupportMask) != 0).Select(f => (ExplicitFormat)f).ToArray();

                multisampleQualityLevels = new int[allFormats.Length, MultisampleCountsToTry.Length];

                for (int i = 0; i < allFormats.Length; i++)
                    for (int j = 0; j < MultisampleCountsToTry.Length; j++)
                        multisampleQualityLevels[i, j] = d3dDevice.CheckMultisampleQualityLevels((Format)i, MultisampleCountsToTry[j]);
            }
            /*
            using (var writer = new System.IO.StreamWriter("Formats.txt"))
            {
                for (int i = 0; i < formatsSupport.Length; i++)
                {
                    writer.WriteLine(string.Format("{0, -30}:{1}", (Format)i, formatsSupport[i].ToString().Replace(", ", " | ")));
                }
            }*/
        }
开发者ID:Zulkir,项目名称:Beholder,代码行数:75,代码来源:CAdapter.cs

示例6: CreateDeviceAndSwapChain

        public void CreateDeviceAndSwapChain(RenderForm form)
        {
            FeatureLevel[] featureLevels = { FeatureLevel.Level_11_0 };
            #if GPU_DEBUG
            //Use https://dev.windows.com/en-us/develop/graphics-debugging-and-frame-analysis-update on Windows 10 to install debug layer.
            Device = new Device(DriverType.Hardware, DeviceCreationFlags.Debug, featureLevels);
            #else
            Device = new Device(DriverType.Hardware, DeviceCreationFlags.None, featureLevels);
            #endif
            if(ConfigurationManager.Config.AntiAliasing)
                _maxQualityLevel = Device.CheckMultisampleQualityLevels(Format.B8G8R8A8_UNorm, 4);

            var swapChainDescription = new SwapChainDescription
            {
                BufferCount = 1, // Set to a single back buffer (double buffering)
                ModeDescription = new ModeDescription(form.ClientSize.Width, form.ClientSize.Height, _refreshRate, Format.R8G8B8A8_UNorm),
                IsWindowed = ConfigurationManager.Config.WindowedMode,
                OutputHandle = form.Handle,
                SampleDescription = ConfigurationManager.Config.AntiAliasing ? new SampleDescription(4, _maxQualityLevel-1) : new SampleDescription(1, 0),
                SwapEffect = SwapEffect.Discard,
                Usage = Usage.RenderTargetOutput
            };

            SwapChain = new SwapChain(new Factory(), Device, swapChainDescription);

            DeviceContext = Device.ImmediateContext;

            SwapChain.GetParent<Factory>().MakeWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAll);
        }
开发者ID:ndech,项目名称:Alpha,代码行数:29,代码来源:DX11.cs


注:本文中的SharpDX.Direct3D11.Device.CheckMultisampleQualityLevels方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。