我使用SlimDX创建一个由13046个不同DataRectangle组成的纹理。这是我的代码。它使用" E_INVALIDARG在Texture2D构造函数上打破:将无效参数传递给返回函数(-2147024809)。" inParms只是一个包含Panel句柄的结构。
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);
}
答案 0 :(得分:1)
R32G32B32_Float(几乎每3个通道格式)不支持渲染目标使用。
所以你有不同的选择:
此外,要检查特定资源使用是否支持Format,您可以使用以下代码段:
public bool IsFormatSupported(Device dev, FormatSupport usage, Format format)
{
FormatSupport support = dev.CheckFormatSupport(format);
return (support | usage) == support;
}