本文整理匯總了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;
}
}
//.........這裏部分代碼省略.........
示例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];
//.........這裏部分代碼省略.........
示例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;
}
示例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);
}
示例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(", ", " | ")));
}
}*/
}
示例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);
}