无效的参数传递给返回函数

无效的参数传递给返回函数

本文介绍了E_INVALIDARG:无效的参数传递给返回函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个简单的SlimDX示例,以测试某些性能与GDI的关系,但不幸的是,我一开始就陷入了困境.我已经在VS2010中创建了简单的控制台应用程序,并将此代码添加到了程序的主要方法中:

I'm trying to make simple SlimDX example to test some performance vs GDI and unfortunately I got stuck on the very beginning. I've created simple Console Application in VS2010 and added this code to programs main method:

        // 0. STEP
        SlimDX.Direct3D10.Device device = new SlimDX.Direct3D10.Device(DriverType.Hardware, DeviceCreationFlags.BgraSupport);
        SlimDX.Direct2D.Factory factory = new SlimDX.Direct2D.Factory();

        // 1. STEP
        Texture2DDescription textureDesc = new Texture2DDescription();
        textureDesc.Width = 512;
        textureDesc.Height = 512;
        textureDesc.MipLevels = 1;
        textureDesc.ArraySize = 1;
        textureDesc.Format = SlimDX.DXGI.Format.R8G8B8A8_UNorm;
        textureDesc.SampleDescription = new SampleDescription(1, 0);
        textureDesc.Usage = ResourceUsage.Default;
        textureDesc.BindFlags = BindFlags.RenderTarget;
        textureDesc.CpuAccessFlags = CpuAccessFlags.None;
        textureDesc.OptionFlags = ResourceOptionFlags.None;
        Texture2D maskTexture = new Texture2D(device, textureDesc);

        // 2. STEP
        SlimDX.DXGI.Surface surface = maskTexture.AsSurface();

        // 3. STEPpro
        RenderTargetProperties props = new RenderTargetProperties
        {
            HorizontalDpi = 96,
            VerticalDpi = 96,
            MinimumFeatureLevel = SlimDX.Direct2D.FeatureLevel.Default,
            PixelFormat = new PixelFormat(SlimDX.DXGI.Format.Unknown, AlphaMode.Premultiplied),
            Type = RenderTargetType.Default,
            Usage = RenderTargetUsage.None
        };
        RenderTarget target = RenderTarget.FromDXGI(factory, surface, props);

这会在RenderTarget.FromDXGI调用中崩溃,并显示以下消息:

This crashes on the RenderTarget.FromDXGI call with this message:

Additional information: E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809)

不幸的是,我无法启用此SO问题中所述的DirectX调试输出: DirectX 10调试输出不起作用

Unfortunately, I could not enable DirectX debug output as stated in this SO question:DirectX 10 debug output not working

...所以,这就是我所拥有的.

... so, this is all I've got.

但是,我已经在家里(win8.1,vs2013)和工作环境(win7,vs2010sp1)都尝试过,并且当我使用2013年的Graphics Diagnostics调试应用程序时,它都可以正常工作.当我开始常规调试或尝试手动启动exe时,它不起作用.在工作中根本不起作用.

BUT, I've tried this both at home (win8.1, vs2013) and at work (win7, vs2010sp1) and at home it works when I debug the app using Graphics Diagnostics from 2013. It doesn't work when I start regular debug or try to start exe manualy. At work it does not work at all.

有仅来自代码的想法吗?我有点在这里绝望. :(

Any ideas just from code? I'm kinda desperate here. :(

推荐答案

我刚刚注意到您对其他答案的评论.这是我使用的创建函数:

I just noticed your comment on my other answer. Here is the creation function I use:

    public static Texture2D CreateRenderTexture(this RenderHelper helper, int width, int height)
    {
        Texture2DDescription description = new Texture2DDescription
        {
            ArraySize = 1,
            BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
            CpuAccessFlags = CpuAccessFlags.None,
            Format = SlimDX.DXGI.Format.B8G8R8A8_UNorm,
            Width = width,
            Height = height,
            MipLevels = 1,
            OptionFlags = ResourceOptionFlags.None,
            SampleDescription = new SlimDX.DXGI.SampleDescription(1, 0),
            Usage = ResourceUsage.Default,
        };

        return new Texture2D(helper.Device, description);
    }

这篇关于E_INVALIDARG:无效的参数传递给返回函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 13:02