SiliconStudio / xenko

Old repo for Xenko Game Engine. Please use https://github.com/xenko3d/xenko instead.
http://xenko.com
1.54k stars 343 forks source link

Problem with GPU buffers with DX12 #592

Open matmuze opened 7 years ago

matmuze commented 7 years ago

Hi there, I am experimenting with Xenko and custom shaders.

In my sample I need to pass custom information stored in structured buffer to the shader program.

To declare the buffer I do something like this:

Buffer PositionBuffer = Buffer.Structured.New(graphicsDevice, positions).DisposeBy(this);

This runs well with DX11 but with DX12 I get the following error:

Unhandled Exception: System.NotImplementedException: The method or operation is not implemented.
   at SiliconStudio.Xenko.Graphics.Buffer.Recreate(IntPtr dataPointer)
   at SiliconStudio.Xenko.Graphics.Buffer.InitializeFromImpl(BufferDescription description, BufferFlags viewFlags, PixelFormat viewFormat, IntPtr dataPointer)
   at SiliconStudio.Xenko.Graphics.Buffer.New(GraphicsDevice device, Int32 bufferSize, Int32 elementSize, BufferFlags bufferFlags, PixelFormat viewFormat, GraphicsResourceUsage usage)
   at SiliconStudio.Xenko.Graphics.Buffer.Structured.New(GraphicsDevice device, Int32 count, Int32 elementSize, Boolean isUnorderedAccess)
matmuze commented 7 years ago

Well I inspected the source code and it seems structured buffers are not implemented for DX12... :(

public void Recreate(IntPtr dataPointer)
{
    ...

    if ((bufferFlags & BufferFlags.StructuredBuffer) != 0)
    {
        throw new NotImplementedException();
        if (bufferDescription.StructureByteStride == 0)
            throw new ArgumentException("Element size cannot be set to 0 for structured buffer");
    }
Benlitz commented 7 years ago

Hello,

Sorry to say that indeed Structured buffers are not implemented yet for DX12. We'll let you know when they will.

matmuze commented 7 years ago

Any ETA ? I want this feature very badly...

mafiesto4 commented 7 years ago

Hello, we fixed this issue internally. Will be probably released in version 2.1.