【问题标题】:Shared Resources in SlimDX with DX10SlimDX 与 DX10 共享资源
【发布时间】:2010-07-07 18:00:46
【问题描述】:

我正在试用 DX10 的共享资源功能,因为我的一个项目需要这个功能。但我找不到太多示例或代码,尤其是使用 SlimDX。根据 DX10 文档,我只需要将资源指定为共享,然后我可以使用来自另一个应用程序的 OpenSharedResource() 打开它。在 SlimDX 中使用一个简单的测试应用程序,我做了以下操作

        Texture2D tex = new Texture2D(device, new Texture2DDescription()
        {
            ArraySize = 1,
            BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
            CpuAccessFlags = CpuAccessFlags.None,
            Format = Format.B8G8R8A8_UNorm,
            Height = 128,
            Width = 128,
            MipLevels = 1,
            OptionFlags = ResourceOptionFlags.Shared,
            SampleDescription = new SampleDescription(1, 0),
            Usage = ResourceUsage.Default,
        });

        Texture2D tex2 = device.OpenSharedResource<Texture2D>(tex.ComPointer);

但我不断收到此错误

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

我似乎无法弄清楚出了什么问题,因为 tex.ComPointer 可能不是 OpenSharedResource 的正确指针,或者不支持 Texture2D(文档中没有明确提到它不在)

通过指定 pHandle 传递给 CreateTexture 函数的另一种选择在 SlimDX 中不可用,或者我不知道。

有人试过这个成功吗?一些帮助将不胜感激。

谢谢

【问题讨论】:

    标签: directx direct3d slimdx direct3d10


    【解决方案1】:

    我发现我的代码存在问题。我需要使用 DXGI 来检索共享句柄(不是指针)。以下代码完美运行

    SlimDX.DXGI.Resource r = new Resource(tex);
    
    Texture2D tex2 = device.OpenSharedResource<Texture2D>(r.SharedHandle);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-10
      • 2015-10-27
      • 1970-01-01
      • 2022-12-12
      • 1970-01-01
      • 1970-01-01
      • 2018-12-19
      • 2011-08-17
      相关资源
      最近更新 更多