【问题标题】:SlimDX Texture2D from DataRectangle array来自 DataRectangle 数组的 SlimDX Texture2D
【发布时间】:2014-06-11 16:38:48
【问题描述】:

我正在使用 SlimDX 创建一个由 13046 个不同 DataRectangle 组成的纹理。这是我的代码。它使用“E_INVALIDARG:将无效参数传递给返回函数(-2147024809)”破坏了 Texture2D 构造函数。 inParms 只是一个包含面板句柄的结构。

public Renderer(Parameters inParms, ref DataRectangle[] inShapes)
    {
        Texture2DDescription description = new Texture2DDescription()
        {
            Width = 500,
            Height = 500,
            MipLevels = 1,
            ArraySize = inShapes.Length,
            Format = Format.R32G32B32_Float,
            SampleDescription = new SampleDescription(1, 0),
            Usage = ResourceUsage.Default,
            BindFlags = BindFlags.RenderTarget | BindFlags.ShaderResource,
            CpuAccessFlags = CpuAccessFlags.None,
            OptionFlags = ResourceOptionFlags.None
        };

        SwapChainDescription chainDescription = new SwapChainDescription()
        {
            BufferCount = 1,
            IsWindowed = true,
            Usage = Usage.RenderTargetOutput,
            ModeDescription = new ModeDescription(0, 0, new Rational(60, 1), Format.R8G8B8A8_UNorm),
            SampleDescription = new SampleDescription(1, 0),
            Flags = SwapChainFlags.None,
            OutputHandle = inParms.Handle,
            SwapEffect = SwapEffect.Discard
        };

        Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, chainDescription, out mDevice, out mSwapChain);

        Texture2D texture = new Texture2D(Device, description, inShapes);
}

【问题讨论】:

    标签: directx-11 texture2d slimdx


    【解决方案1】:

    R32G32B32_Float(以及几乎每 3 通道格式)不支持用于渲染目标。

    所以你有不同的选择:

    • 改用 R32G32B32A32_Float(意味着您需要在添加额外通道时更改数据矩形)。
    • 删除 BindFlags.RenderTarget 标志。如果您只想读取此资源,则不需要此标志。当您提供初始数据时,您也可以将 Usage 更改为 ResourceUsage.Immutable。

    此外,要检查特定资源使用情况是否支持格式,您可以使用以下 sn-p:

        public bool IsFormatSupported(Device dev, FormatSupport usage, Format format)
        {
            FormatSupport support = dev.CheckFormatSupport(format);
            return (support | usage) == support;
        }
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-06-03
    • 2017-12-09
    • 1970-01-01
    • 1970-01-01
    • 2015-10-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多