DirectX 11初始化"工作"并且仅在呈现

时间:2015-09-24 12:54:08

标签: c# compatibility directx-11

有人知道使用DirectX11创建设备的原因,即使硬件不支持它吗?我有以下简化代码(这使用SlimDx,但我想这里的语言是第二重要的:

var form = frm;
form.Resize += form_Resize;
var desc = new SwapChainDescription()
{
    BufferCount = 1,
    ModeDescription = new ModeDescription(form.ClientSize.Width, form.ClientSize.Height, new Rational(60, 1), Format.R8G8B8A8_UNorm),
        IsWindowed = true,
        OutputHandle = form.Handle,
        SampleDescription = new SampleDescription(1, 0),
        SwapEffect = SwapEffect.Discard,
        Usage = Usage.RenderTargetOutput
        };

    Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, desc, out device, out swapChain);
    device.Factory.SetWindowAssociation(form.Handle, WindowAssociationFlags.IgnoreAll);
    Resize(form.ClientSize);

    sprite = new SpriteRendererSlimDx(device, m_lock);
    var textBlock = new TextBlockRendererSlimDx(sprite, "Arial", FontWeight.Bold, SlimDX.DirectWrite.FontStyle.Normal, FontStretch.Normal, 16);

    MessagePump.Run(form, () =>
    {
        device.ImmediateContext.ClearRenderTargetView(renderView, Color.DarkBlue);
        textBlock.DrawString("Hello World", Vector2.Zero, Color.Red);
        sprite.Flush();
        swapChain.Present(0, PresentFlags.None);
    });

代码打开一个窗口并绘制一些文本。它在支持功能级别11.0的图形卡上工作正常,但是如果我在老化的ATI Radeon HD 4550上运行相同的代码,它只支持功能级别10.1,则设备驱动程序会锁定并且Windows会重新启动显示驱动程序。

问题不在于(在示例中未示出)文本渲染,而是用于渲染三角形。调试显示锁定发生在swapChain.Present()调用上。

Directx 11 Compatiblilty表示我可能在使用Shader Level 5(我试图使用)时遇到问题,但通常我的问题是:为什么我不会得到一个普通的错误消息,如果不支持某些内容?如果卡不能这样做,驱动程序不应该尝试编译Shader Level 5,不应该吗?

更新 如果我只使用着色器级别4,则似乎也会发生错误。

0 个答案:

没有答案