Wednesday, April 7, 2010

SlimDX Issue

In my previous post I mentioned how my next goal was to use the Compute Shader to write directly to the backbuffer. Unfortunately, it appears that this is not currently possible using SlimDX.

In order to write to the backbuffer, the swap chain needs to be created with an unordered access usage flag. This means that that resource can then be used as a UAV output in a Compute Shader. There are a couple examples floating around online where people have done this using the DXGI_USAGE_UNORDERED_ACCESS flag in C++ code.

In SlimDX, that enumeration has been wrapped into the Usage enumeration in the DXGI namespace. However, it is missing an UnorderedAccess option. It contains all of the other ones defined in the original C++ code though. I believe it was just a mistake and accidentally missed during the update to DX11. (At least I hope it wasn't intentional!)

I posted an issue on the SlimDX Google Code page, so hopefully this gets resolved.

2 comments:

jpetrie said...

Hi! Thanks for reporting the bug, we'll get it fixed. In the mean time, you could work around the omission by or'ing the value of the usage flag into whatever other flags you're specifying (with a cast) -- I believe the value of DXGI_USAGE_UNORDERED_ACCESS is 1024, so something like "other flags | (DXGI.Usage)1024" should do the trick for you.

Patrick said...

Ah thank you very much. I don't know why I didn't think about ORing it with the actual integer value. I'll give it a try, but it should work.

Thanks again.