SlimDX Texture2D from DataRectangle array

Posted by Rebekah Bryant on Game Development See other posts from Game Development or by Rebekah Bryant
Published on 2014-06-11T18:13:43Z Indexed on 2014/06/11 21:43 UTC
Read the original article Hit count: 356

Filed under:
|

I'm totally new to DirectX. I'm using SlimDX to create a texture consisting of 13046 DataRectangles. Here's my code. It's breaking on the Texture2D constructor with "E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809)." inParms is just a struct containing handle to a 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);
}

EDIT: Running with the Debug flag set, I got:

D3D11 ERROR: ID3D11Device::CreateTexture2D: The format (0x6, R32G32B32_FLOAT) cannot be bound as a RenderTarget, or cast to a format that could be bound as a RenderTarget. This is because the current graphics implementation does not even support this Format. Therefore this format does not support D3D11_BIND_RENDER_TARGET. Use CheckFormatSupport to check Format support. [ STATE_CREATION ERROR #92: CREATETEXTURE2D_UNSUPPORTEDFORMAT] D3D11 ERROR: ID3D11Device::CreateTexture2D: Returning E_INVALIDARG, meaning invalid parameters were passed. [ STATE_CREATION ERROR #104: CREATETEXTURE2D_INVALIDARG_RETURN]

© Game Development or respective owner

Related posts about directx11

Related posts about slimdx