0

I'm using SharpDX to run compute shaders and I use constant buffers for some inputs. I create the constant buffers myself and use them in compute shaders like this:

// 'device' type is SharpDX.Direct3D11.Device
// 'constBuf' type is SharpDX.Direct3D11.Buffer
device.ImmediateContext.ComputeShader.SetConstantBuffer(0, constBuf);

I would like to start using SharpDX.Toolkit to manage constant buffers. The Toolkit gives me objects of type SharpDX.Toolkit.Graphics.Buffer. How can I use that to set the constant buffer for my compute shader?

shoelzer
  • 10,648
  • 2
  • 28
  • 49
  • Question is why do you want to use the Toolkit? What kind of benefits do you expect using it? – xoofx Mar 19 '13 at 00:57
  • @xoofx I'm already using SharpDX, so I think it makes sense to use the Toolkit instead of rolling my own `ConstantBuffer` class. I'm still fairly new to DirectX and SharpDX, so it's certainly possible that this is a bad idea but it's what I'm thinking right now. – shoelzer Mar 19 '13 at 01:58
  • 1
    I don't fully see what are the benefits just for the constant buffer in the Toolkit. The only benefits would be to use the Effect framework (where the constant buffer handling is completely hidden) but that would require some significant changes in your code. Otherwise, you can just use this buffer as you use them in your shader. Buffers in the Toolkit are castable to Direct3D11.Buffer anyway, so you can try. – xoofx Mar 19 '13 at 14:00
  • @xoofx Thanks! That answers my question and it's good general info for me. I'd accept if this was an answer... – shoelzer Mar 19 '13 at 16:20

1 Answers1

0

xoofx answered my question in a comment, so I'm going to copy it here.

I don't fully see what are the benefits just for the constant buffer in the Toolkit. The only benefits would be to use the Effect framework (where the constant buffer handling is completely hidden) but that would require some significant changes in your code. Otherwise, you can just use this buffer as you use them in your shader. Buffers in the Toolkit are castable to Direct3D11.Buffer anyway, so you can try.

Community
  • 1
  • 1
shoelzer
  • 10,648
  • 2
  • 28
  • 49