Skip to main content
GameDev.net gamedev.net
🔒 Locked

[SlimDX] DirectX 11 Query

Started by GoodFun Nov 18, 2010 at 12:14 PM 8 replies 5.1k views
Original Post
GoodFun
GoodFun
Hi there,

I'm working on a compute shader in DirectX 11. I want to dispatch the compute shader and then wait for it to complete. Under DirectX 10, I could check with IsDataAvailable if the query has completed, I haven't been able to find the corresponding method on how to do this in DirectX 11.

This is the code I'm currently using, reduced to just the necessary parts:

SlimDX.Direct3D11.QueryDescription queryDescription = new QueryDescription(QueryType.Event, QueryFlags.None);SlimDX.Direct3D11.Query query = new Query(device, queryDescription);device.ImmediateContext.ComputeShader.Set(compute);device.ImmediateContext.ComputeShader.SetUnorderedAccessView(computeResult, 0);device.ImmediateContext.ComputeShader.SetShaderResource(pointerView, 0);device.ImmediateContext.ComputeShader.SetShaderResource(spanView, 1);device.ImmediateContext.Dispatch(8, 4096, 1);device.ImmediateContext.End(query);// want to check here on when the compute shader has finishedstring outFileName = Path.Combine(outFilePath, Path.ChangeExtension(Path.GetFileName(fileName), ".dds"));Texture2D.ToFile(device.ImmediateContext, outputTexture, ImageFileFormat.Dds, outFileName);


Any help is greatly appreciated.

Thanks
Marcel
GoodFun
GoodFun
Spent some more time looking for an answer but information around this is very slim at this point... have any of the SlimDX team worked with DirectCompute yet?
GoodFun
GoodFun
Still no one with an answer to this???
Mike.Popoloski
Mike.Popoloski
Sorry, I still don't have hardware that supports compute shaders, so I haven't had a chance to play with it. I don't think anyone else on the SlimDX team has either.
Mike Popoloski | Journal | SlimDX
Adam_42
Adam_42
I'm not at all familiar with DirectCompute, however a quick look through the documentation suggests that what you want to do is check if device.ImmediateContext.GetData(query, AsynchronousFlags.DoNotFlush) fails. If it does then it's not done yet.
GoodFun
GoodFun
Adam,

I saw that possibility but that means it has to move the data back over the PCIe bus... I don't want to do that, I just need to know when the shader has completed...
DieterVW
DieterVW
What are you trying to do that requires you to know on the CPU side if something has completed? Any such message of completion will require a message to be sent from the GPU to the CPU.
GoodFun
GoodFun
At this point I'm trying to time the execution of the ComputeShader. Eventually I will have another Compute or Pixel shader running after this initial one that will use the resource created by the first ComputeShader.
DieterVW
DieterVW
You won't need a query for this because the driver can determine dependencies and will wait until operations from your compute shader are complete before running the pixel shader pass. Just submit all the commands in the order you want them completed and you'll be in good shape.
jpetrie
jpetrie
I've implemented an IsDataAvailable() method that can be used to stimulate the native call sequences required to determine if a query has data available without actually passing that data back across the bus.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.