locked
My Direct2D app in Windows 8.1 is showing graphics artifacts and faint squares on the last redrawn area

    Question

  • My Direct2D app works great in Windows 8.0 in Windows 8.1 it has minor graphics artifacts and tiny white pixel glitches. And the last area redrawn has a faint square around it. Not sure why this is happening but it worked fine in 8.0. I even tried upgrading it to 8.1 project and it does the same thing. Anyone know anything about this?

    SB Software Developer


    • Edited by Sacha Bwin Wednesday, October 23, 2013 10:09 PM addition
    Wednesday, October 23, 2013 10:08 PM

All replies

  • That doesn't ring any bells. Do you see this on all systems or just on one or a few?

    --Rob

    Thursday, October 24, 2013 7:26 PM
    Owner
  • It happens on my Desktop and my Surface Pro and it did not happen when I had 8.0 loaded on either system. Only 8.1. I am using a VirtualSurfaceImageSource on an Image element to draw my Direct2D to. It worked great before.

    SB Software Developer

    Thursday, October 24, 2013 11:14 PM
  • Can you provide a minimal repro sample?

    --Rob

    Tuesday, October 29, 2013 12:28 AM
    Owner
  • Well it seems to be related to the Bitmap Caching method that I used. For some reason the Bitmap Drawing from the Bitmap Cache to the Direct2D Surface is 1 pixel off to the right and down on Windows 8.1.

    This only happens on Windows 8.1 and not 8.0.  Works perfect on 8.0 with the exact same app code.


    SB Software Developer

    Thursday, October 31, 2013 12:46 AM
  • Is your desktop running in high DPI mode? If so, can you reproduce this after turning that off? It may be a rounding error from the magnification.

    --Rob

    Thursday, October 31, 2013 10:46 PM
    Owner
  • I think it might have been that the DPI of the Surface was higher than the Bitmap Cache. I was scaling the bitmap up to output to the surface.  Which was possibly causing lower resolutions after I implemented the Bitmap Cache instead of drawing directly to the surface. 

    I am actually ripping apart my DirectX engine and rewriting it so hopefully when I'm done it doesn't have this problem anymore.  But that was one major issue that I saw.


    SB Software Developer

    Thursday, October 31, 2013 11:13 PM
  • So I rewrote a lot of my Direct2D engine and made the Bitmap that I'm using as a cache the same dpi as the DX Surface and the same thing still happens. No matter what system no mater what DPI/resolution with Windows 8.1 this happens.  Still works great in Windows 8.0!  Here is a sample image. 

    What is happening here is the Begin Draw is called to update the DX Surface with a specific update rect.  I am also using a transform and PushAxisAlignedClip.  (if I refresh the entire image this does not happen but it is extremely slow.)  Then the entire Cached Bitmap is copied to the surface and the new geometry is added.  It only updates the rect specified in the PushAxisAlignedClip like its supposed to.  I have tried adjusting the PushAxisAlignedClip and Transform and the same thing happens.  I should mention this line moves where the update rect is.

    Here is an excerpt of the code in my BeginDraw method:

    updateRectNative.left = static_cast<LONG>(updateRect.X);
    		updateRectNative.top = static_cast<LONG>(updateRect.Y);
    		updateRectNative.right = static_cast<LONG>(updateRect.X + updateRect.Width);
    		updateRectNative.bottom = static_cast<LONG>(updateRect.Y + updateRect.Height);
    
    
    
    
    
    		D2DFactoryLock factoryLock(m_d2dFactory.Get());
    		// Begin drawing - returns a target surface and an offset to use as the top left origin when drawing.
    		HRESULT beginDrawHR = m_sisNative->BeginDraw(updateRectNative, &surface, &offset);
    
    
    		if (beginDrawHR == DXGI_ERROR_DEVICE_REMOVED || beginDrawHR == DXGI_ERROR_DEVICE_RESET)
    		{
    			// If the device has been removed or reset, attempt to recreate it and continue drawing.
    			CreateDeviceResources();
    			BeginDraw(updateRect);
    		}
    		else
    		{
    			// Notify the caller by throwing an exception if any other error was encountered.
    			DX::ThrowIfFailed(
    				beginDrawHR
    				);
    		}
    
    		// Create render target.
    		//ComPtr<ID2D1Bitmap1> bitmap;
    		DX::ThrowIfFailed(
    			m_d2dContext->CreateBitmapFromDxgiSurface(
    			surface.Get(), NULL, &m_d2dTargetBitmap
    			));
    
    		// Set context's render target.
    		m_d2dContext->SetTarget(m_d2dTargetBitmap.Get());
    
    		// Begin drawing using D2D context.
    		m_d2dContext->BeginDraw();
    
    		
    		
    
    
    
    
    
    
    		// Apply clip
    		m_d2dContext->PushAxisAlignedClip(
    			D2D1::RectF(
    			static_cast<float>(-offset.x - 10),
    			static_cast<float>(-offset.y - 10),
    			static_cast<float>(offset.x + updateRect.Width),
    			static_cast<float>(offset.y + updateRect.Height)
    			),
    			D2D1_ANTIALIAS_MODE_ALIASED  //D2D1_ANTIALIAS_MODE_PER_PRIMITIVE
    			);
    
    
    		// Apply transform
    		m_d2dContext->SetTransform(
    			D2D1::Matrix3x2F::Translation(
    			static_cast<float>((offset.x - updateRect.X) * sizeDPIRatioInvert),
    			static_cast<float>((offset.y - updateRect.Y) * sizeDPIRatioInvert)
    			));

    Next in a separate method I just copy the cache bitmap and then draw geometry over it.

    m_d2dContext->DrawBitmap(m_d2dBitmapRTCache.Get());


    SB Software Developer


    • Edited by Sacha Bwin Wednesday, November 06, 2013 9:28 PM Update
    Wednesday, November 06, 2013 9:22 PM
  • Hello,

    We are tracking various reports like this for both D2D and D3D. At this time we believe that this behavior is likely due to problems at the driver level. We continue to investigate and hope to have root cause soon.

    Thanks,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Thursday, November 07, 2013 4:39 PM
    Moderator
  • Thanks

    SB Software Developer

    Saturday, November 09, 2013 8:36 PM
  • I should mention that this happens on my NVidia and Intel chipsets the same.

    SB Software Developer

    Monday, November 11, 2013 7:13 PM
  • Please disregard my last post as this is not solved and is a major graphical problem for my app.

    SB Software Developer

    Tuesday, November 12, 2013 6:50 PM
  • Hello,

    Based on the latest information for the driver issue that I am tracking I don't think what you are seeing is related. Can you create a small VS sample app and upload it to your SkyDrive? I will grab it and take a look.

    Have you tried running your app under PIX? You might be able to get some information about the areas of missing pixels. Remember PIX is not built into VS 2013. It can be found here: "debug->Graphics->debug installed app package".

    Thanks,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Wednesday, November 13, 2013 10:21 PM
    Moderator
  • I am having very strange behavior that could be related.  So I have a XAML Image that I am setting the .Source = to a VitualSurfaceImageSource that I have created.  Say the VirtualSurfaceImageSource is set to 2048 x 2048.

    C#

    VirtualSurfaceImageSource virtualSIS =

    newVirtualSurfaceImageSource(2048, 2048);

    xamlImage.Source = virtualSIS;

    So after that in the BeginDraw (above) I create the Bitmap from the dxgi surface. 

    C++

    DX::ThrowIfFailed(

    m_d2dContext->CreateBitmapFromDxgiSurface(

    surface.Get(),

    NULL, &m_d2dTargetBitmap

    ));

    Then when I set the target of the context to the bitmap created and get the size of the context it is 2048 x 2080 for some reason.

    m_d2dContext->SetTarget(m_d2dTargetBitmap.Get());

     

    size = m_d2dContext->GetSize();

    //(size = 2048 x 2080)

    Is this normal?


    SB Software Developer



    • Edited by Sacha Bwin Friday, November 15, 2013 3:26 AM question
    Friday, November 15, 2013 3:13 AM
  • Hello,

    Yes this is normal. Some video drivers have strange alignment requirements for textures.

    I hope this helps,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Saturday, November 16, 2013 12:45 AM
    Moderator
  • This is still happening on Windows 8.1 only!  I think this is related to putting a VirtualSurfaceImageSource as the source for a XAML image source and scaling the XAML image.  It puts random white dots all over the image that quickly disappear even in areas that are not redrawn.  The dots seem to be in the same horizontal area as the redrawn area though.  It works prefect on 8.0 and happens on all 8.1 devices tested on.  Can Microsoft please fix this? 

    SB Software Developer

    Wednesday, January 22, 2014 1:00 AM
  • Have you tried using the "swap chain panel" on W8.1 instead of the "surface image source"?

    http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.swapchainpanel.swapchainpanel.aspx

    -James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/


    Saturday, January 25, 2014 12:05 AM
    Moderator
  • Can I make the source of a XAML image the swap chain panel?

    I didn't think this was possible as XAML handles all of my scaling and rotation for me.  Also it is written from the ground up, 40,000 lines of code, to use the source of a XAML image as a VSIS.  It's works on 8.0 why not 8.1?  They messed it up.


    SB Software Developer

    Sunday, January 26, 2014 12:11 AM
  • Hello,

    It is very possible that there is a regression bug in the code. If you can take a couple hours and put together a sample app that reproduces the problem in a very simple way I can investigate further and file a bug as appropriate.

    Thanks,

    James


    Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/

    Wednesday, January 29, 2014 11:29 PM
    Moderator