Jump to content
  • Advertisement
Sign in to follow this  
dave09cbank

Flicker when rendering multiple shapes over image texture

This topic is 736 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 ?

Edited by dave09cbank

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!