Search code examples
multithreadingslimdxdirectx-11

Deferred context does not render anything


i'm trying to understand how multithreaded rendering work in dx11, so i started without any threads, just make one deferred context, and try to render triangle with it


the code is here https://gist.github.com/998406 i modifed SlimDX MiniTri sample for this way -> make deferred context with

var deferredContext = new DeviceContext(device);

next i bind shader to it and render it

deferredContext.ClearState();
deferredContext.InputAssembler.InputLayout = layout;
deferredContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleList;
deferredContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertices2, 32, 0));

 for (int i = 0; i < technique.Description.PassCount; ++i){
                              pass.Apply(deferredContext);
                              deferredContext.Draw(3, 0);}

then try to get command list and execute it

CommandList dc_cl = deferredContext.FinishCommandList(false);
device.ImmediateContext.ExecuteCommandList(dc_cl, true);

what i'm expecting to see is 2 triangles but it only render immdeiate context, but if i clear screen in deffered context like deferredContext.ClearRenderTargetView(renderView, Color.Tomato); my screen now in tomato color, but still no triangles


also when i added this deferred context PIX stop working, witch means that i'm doing something terrible wrong


Solution

  • As the deferred context is not the same as your original context you need to re-set render targets for your deferred device in addition to fixing your command list arguments.

    This explains why your device is cleared but no geometry is being rendered.