Flicker when rendering multiple shapes over image texture

Started by
4 comments, last by dave09cbank 7 years, 9 months ago

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
Advertisement

How are you going with this ? Normally you don't have to use Flush() although I don't think that's the problem. Also, do you need to invalidate the surface ? That, to me, sounds like it could be a source of flickering issues. Also check how you're using the zbuffer, are your geometries positioned at the same z-level ? That can cause flickering.

Thanks for the reply @Gavin.

I am required to call flush in order for the updated pixels and DirectX commands to be pushed to the GPU.

I also need to call invalidate and its similar to swap panel's present call as i'm using directx with WPF.

However, as recommended iv changed the z-level to be different which has helped quite a lot. however, odd times i see the flicker. this could be related to how how i'm drawing maybe ... not sure at this point.

I know this issue has been partially dealt with however my question is:

If you have multiple quads being drawn (say n number of them) then do each of them need to be on a different z-level especially when they are displaying textures ?

If you have multiple quads being drawn (say n number of them) then do each of them need to be on a different z-level especially when they are displaying textures ?

If you are enabling depth testing and writes then they want different z coordinates.

If you just want them to appear in the order you draw them in then disable depth writes and depth tests.

Ok i understand now.

However, I do not set the depth testing to be enabled/disabled at all.

Is it enabled by default in Directx11 ?

Now i update my render texture(by background image) by updating texture data via mapping on every frame.

If i understand correctly then i would enable the depth testing before updating the background and then disable it before i draw my shapes especially when the shapes are filled with texture ?

And if i got this incorrect then please feel free to correct me.

Thanks.

This topic is closed to new replies.

Advertisement