Horizontal flashes while drawing texture

I am rendering movie to my direct3D device, alongwith other sprites. I draw textures using TransformedColoredTextured vertices.

I get horizontal flashes in the movie, on random basis. Any idea what i need to look forward. Are there any suggested settings for texture

Thanks....



Answer this question

Horizontal flashes while drawing texture

  • P__M

    There is another interesting observation. I have tested my application with dual processor, and it gives horizontal flashes. With single processor system, it behaves alright. All other configurations are the same.

    Any idea, what could be causing it, and how to get arround it


  • dialadave

    I am not changing this parameter at all. Its in its default. However i suspect following may also have some thing to do with it

    presentParams.SwapEffect = SwapEffect.Discard;
    presentParams.PresentFlag = PresentFlag.Video;

    Is it that i must change this parameter, and make sure its not "PresentInterval.Immediate". If so what its value should be...


  • JoseSP

    I am using StretchRectangle to copy the texture generated by directShow to the texture i am trying to draw.

    private int PresentHelper(VMR.VMR9PresentationInfo lpPresInfo)
    {
    int hr = 0;
    try
    {
    if(privateTexture != null)
    {
    Marshal.AddRef(lpPresInfo.lpSurf);
    using(Surface surface = new Surface(lpPresInfo.lpSurf))
    {
    device.StretchRectangle(
    surface,
    new Rectangle(0, 0, surface.Description.Width, surface.Description.Height),
    privateSurface,
    new Rectangle(0, 0, privateSurface.Description.Width, privateSurface.Description.Height),
    TextureFilter.None);
    }
    return 0;
    }
    catch (DirectXException e)
    {
    return e.ErrorCode;
    }
    catch(Exception Ex)
    {
    return E_FAIL;
    }
    }

    The render loop then picks up the "privateTexture" object and draws it using vertices. Yes there is a very good chance that loop may attenpt writing when this method is busy writing the texture, but i am locking this texture in render loop using C# lock statement:

    lock(allocator) //privateTexture is in allocator object
    {
    //Rest of rendering code
    }

    Theoratically this should not have any conflicts


  • Visualprojects

    If you use multithreading I am sure that this caused your problems. I believe that it happens because your DirectShow thread is still updating your texture at the time your render thread already use it for drawing.

    Using Join(1) sounds not like the right solution for me. You should use a lock on the data object that contains the video. How do you transfer the video from DirectShow to Direct3D Do you use one texture and Lock/Unlock it in the DirectShow thread or do you use two textures and UpdateTexture



  • Nick Berezansky

    Do you have an example of using a query object to do this

    (Done a bit of searching and can't find anything so far...)

    Thanks...


  • DJK60160

    Yes... seems the case... is there any other way to pick texture from a surface
  • Niels Greve Andersen

    Yes.. the application is already multithreaded. Infact i believe it is its multithreading thats causing the trouble. Since movie is comming from DirectShow, and therefore has to be in different thread, it probably tends to conflict more often with the render loop. On single processor, the thresd are processed in time-swaping manner, so it relatively less likely both threads will capture the processing , and there always remains some sort of sequence. When both threads are executed simultaneously, they might give some unwanted effect.

    Just my idea... might be wrong, but some how i managed to solve it. Not sure what exactly it means. I added System.Threading.CurrentThread.Join(1) statement every time one render loop is terminated - (probalby it reduces the probablility that movie thread would conflict with render loop) - whatever ther reason is.. it worked. Some one may have a better comment on it.....


  • Mattews

    You could use GetRenderTargetData to transfer the video to a system buffer but copying data from the video card to system memory to copy it back again sounds bad.

    Have you try to use a query object to make sure that your DirectShow thread waits until the image is transfer is done



  • Jeffrey Wang

    The default value for the presentation interval includes V-Sync.

    Do you use multithreading in your application In the case you don’t you may run in a driver problem. The newest nVidia drivers have some optimizations for multi processor/core systems. But the don’t always works right. There is a registry key to disable these optimizations. In the case you use nVidia hardware I can check my nodes for this key.



  • davegauthier

    Sounds like a missing V-Sync glitch. Can you please check the “PresentationInterval“ member on your “D3DPRESENT_PARAMETERS“ It should not “D3DPRESENT_INTERVAL_IMMEDIATE“.



  • traveller

    A lock on one side will not help much. You need to make sure that you have locks in both threads. But I think the problem is different. The StretchRectangle call does not copy the content of the surface immediately it will only add a command to a list. If the GPU reaches this command it is highly possible that DirectShow updates the source surface at the same time with new data.



  • Horizontal flashes while drawing texture