I'm rendering video frames with multiple color filled shapes over it using SharpDx and D3D11.
Rendering seems to be fine when just rendering the video frame and is as expected.
Now if i draw a single color filled shape it is drawn and rendered as expected.
Hoever, the problem occurs when I'm trying to render more than one color filled shapes over a video frame texture.
Apart from first colored shape , all other shapes drawn flicker when rendered thus showing the pixels under neath which are the pixels for the rendered video frame.
Any ideas as to why does this occur ?
If any more information is required then do let me know.
P.S. Using ShaprDx and Directx11
Thanks.
EDIT:
1. Setting video frame shader resource:
var srv = new ShaderResourceView(DxDevice, textureToUpdate);
DxDevice.ImmediateContext.PixelShader.SetShaderResource(0, srv);
srv.Dispose();
2. Code to draw primitives: (Called in a loop for each object including the image texture)
DxDevice.ImmediateContext.InputAssembler.InputLayout = m_shaderData.InputLayoutConfig;
DxDevice.ImmediateContext.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
DxDevice.ImmediateContext.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(m_displayQuadvertices, VertexPositionColor.SizeInBytes, 0));
DxDevice.ImmediateContext.VertexShader.Set(m_shaderData.VertexShaderConfig);
DxDevice.ImmediateContext.PixelShader.Set(m_shaderData.PixelShaderConfig);
DxDevice.ImmediateContext.Draw(4, 0);
DxDevice.ImmediateContext.Flush();
above code is called for image texture quad and then any object (say a color filled quad) is drawn.
In addition i i'm using WPF hence i use D3dImage control.
3. Invalidating: (D3DImage control)
m_imgSource.InvalidateD3DImage(invalidateRectArea); // to invalidate the area of back buffer for rendering
As for the video frame which is decoded and then gets mapped to the texture by setting the shader resource onthe pixel shader.
Calling the code order:
call code block 1
loop
{
call code block 2
}
call code block 3