Asked by:
D3D depth issue and D2D render flash after update device from Lumia Black to Lumia Denim

Question
-
Hi,
Yestoday I updated my lumia 929 device from Lumia Black to Lumia Denim. I develope game on this device.
My game is D2D and D3D Interop with silverlight 8.1 program. Then problem occured. The depth of 3D objects become wrong. And the d2d content will flash time to time. I use d2d to render text.
However, I solved the depth problem by setting up DepthStencilState. But the d2d content flash problem doesn't solved.
Not only Lumia 929, but 930, 638 and many devices.
In lumia 525 and 520t, my game still works fine.
Can anyone help me ?
Any help will be appliciated, thank you.
Friday, February 13, 2015 2:36 PM
All replies
-
Hello,
I am trying to invite an expert coming into this thread. There will be some delay.
Thank you for understanding.
Regards,
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place. Click HERE to participate the survey.
Monday, February 16, 2015 1:52 AMModerator -
Hello,
Can you provide more detail concerning how you are rendering your text with D2D? Are you doing the D2D update on the UI thread? I think we just need more detail before we can offer any suggestions.
Thanks,
James
Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
Tuesday, February 17, 2015 12:34 AMModerator -
Hello,
Can you provide more detail concerning how you are rendering your text with D2D? Are you doing the D2D update on the UI thread? I think we just need more detail before we can offer any suggestions.
Thanks,
James
Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
Hi, thank you for your reply.
What do you mean D2D update?I draw D2D content on the UI thread.
I render text like below
void YHMText::DrawCustom(wstring str, float scale, float posX, float posY, float layoutX, float layoutY, float opacity, float rotationAngle, int colorID) { mText = str; if (mIsResourceLoaded && opacity > 0.0f) { mText = str; DX::ThrowIfFailed(m_dwriteFactory->CreateTextLayout(mText.c_str(), (uint32) mText.length(), mTextFormat.Get(), layoutX / scale, layoutY / scale, &mTextLayout)); DWRITE_TEXT_RANGE range = { 0 }; range.length = static_cast<uint32>(mText.length()); DX::ThrowIfFailed(mTextLayout->SetFontCollection(mFontCollection.Get(), range)); #ifdef YHMWINRT Windows::Foundation::Size logicalSize = mDeviceResources->GetLogicalSize(); #endif #ifdef YHMSILVERLIGHT Windows::Foundation::Size logicalSize = mDeviceResources->GetRenderTargetSize(); #endif float dpiScale = 1.0f; #if (NTDDI_VERSION == NTDDI_WIN8) dpiScale = 96.0f / mDeviceResources->GetDPI(); #endif D2D1::Matrix3x2F screenTranslation; D2D1::Matrix3x2F screenScale; D2D1::Matrix3x2F globelScale = D2D1::Matrix3x2F::Scale(scale, scale); D2D1_POINT_2F center; center.x = posX * logicalSize.Width / 1920.0f * dpiScale; center.y = posY * logicalSize.Height / 1080.0f * dpiScale; D2D1::Matrix3x2F rotation = D2D1::Matrix3x2F::Rotation(rotationAngle, center); if (gScreenMode == YHMScreenMode::Portrait) { screenTranslation = D2D1::Matrix3x2F::Translation(posX * logicalSize.Width / 1080.0f * dpiScale, posY * logicalSize.Width / 1080.0f * dpiScale); screenScale = D2D1::Matrix3x2F::Scale(logicalSize.Width / 1080.0f * dpiScale, logicalSize.Width / 1080.0f * dpiScale); } if (gScreenMode == YHMScreenMode::Landerscape) { screenTranslation = D2D1::Matrix3x2F::Translation(posX * logicalSize.Width / 1920.0f * dpiScale, posY * logicalSize.Height / 1080.0f * dpiScale); screenScale = D2D1::Matrix3x2F::Scale(logicalSize.Width / 1920.0f * dpiScale, logicalSize.Height / 1080.0f * dpiScale); } m_d2dContext->SetTransform(screenScale * globelScale * screenTranslation * mDeviceResources->GetOrientationTransform2D() * rotation); DX::ThrowIfFailed(mTextFormat->SetTextAlignment(mTextAlignment)); mDeviceResources->BeginDrawD2D(); mBrush[colorID]->SetOpacity(opacity); m_d2dContext->DrawTextLayout(D2D1::Point2F(0.f, 0.f), mTextLayout.Get(), mBrush[colorID].Get(), D2D1_DRAW_TEXT_OPTIONS_NO_SNAP); mBrush[colorID]->SetOpacity(1.0f); mDeviceResources->EndDrawD2D(); } }
This works fine with Lumia Black. But in Lumia Denim, my d2d text may flash.
I noticed that the flash problem usually occured when D3D content draw first. In my render methods, d3d content and d2d content are place together.
Tuesday, February 17, 2015 3:03 AM -
Hello,
Sounds like you are not rendering with the v-sync. You should be able to do this by seting the SetMaximumFrameLatency to 1. This should avoid any flicker.
I hope this helps,
James
Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
Tuesday, February 17, 2015 10:00 PMModerator -
Hello,
Sounds like you are not rendering with the v-sync. You should be able to do this by seting the SetMaximumFrameLatency to 1. This should avoid any flicker.
I hope this helps,
James
Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
Hi, I have try this but doesn't work.
My game is a winrt based program. The rendering frame is already limited to 60 fps automatically.
Wednesday, February 18, 2015 9:01 AM -
Hello,
Calling SetMaximumFrameLatency and setting it to 1 will lock the render loop to the refresh rate of the display (in the US this is 60 fps). This is expected since we are requesting that we only update the display when the device is ready to redraw the screen.
If calling SetMaximumFrameLatency and setting it to 1 doesn't resolve the problem I can't really come up with anything else off the top of my head. I don't see anything obvious in your D2D code and as long as you are not using XAML interop then AFAIK there are no major changes to the DirectX stack in Denim.
If you can provide a very small Visual Studio 2013 sample that reproduces the problem, zip it up, put it on you one drive and post a link here I can take a quick look and let you know if I find anything obvious.
Thanks,
James
Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
Wednesday, February 18, 2015 11:44 PMModerator -
Hello,
Calling SetMaximumFrameLatency and setting it to 1 will lock the render loop to the refresh rate of the display (in the US this is 60 fps). This is expected since we are requesting that we only update the display when the device is ready to redraw the screen.
If calling SetMaximumFrameLatency and setting it to 1 doesn't resolve the problem I can't really come up with anything else off the top of my head. I don't see anything obvious in your D2D code and as long as you are not using XAML interop then AFAIK there are no major changes to the DirectX stack in Denim.
If you can provide a very small Visual Studio 2013 sample that reproduces the problem, zip it up, put it on you one drive and post a link here I can take a quick look and let you know if I find anything obvious.
Thanks,
James
Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
Hi, James.
Thank you for response. I upload a simple project to onedrive.:http://1drv.ms/1zpTqC6
It's a universal app. The windows phone project is the one have flash problem.
In this sample, I simply render two line of text, one is "Normal Mode" and the other one is "Time Mode".But only "Normal Mode" rendered.
Thank you again.
Thursday, February 19, 2015 12:17 PM -
Hello,
Thank you very much for uploading the sample. Unfortunately I don't have time to look at it today but I will take a look early next week and let you know what I find.
Thanks,
James
Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
Friday, February 20, 2015 11:51 PMModerator -
Hello,
Thank you very much for providing your code. Unfortunately I am not able to reproduce your issue using my HTC device.
I would ask that you please generate a VS graphics log while the issue is occurring using the code you sent to me. Please set the "frames to capture" to a value that will allow you to capture enough frames to capture the issue in progress. Once I have your log I will take a look at it and see if I can get any useful information out of it.
Thanks,
James
Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
Tuesday, February 24, 2015 1:43 AMModerator -
Thank you very much for helping me.
I don't know how to generate a VS graphics log.
But I have a new found.
The flash problem occured when I using my own font collection.
If using system font. My game works fine.
DWRITE_TEXT_RANGE range = { 0, mText.length() };
DX::ThrowIfFailed(mTextLayout->SetFontCollection(mFontCollection.Get(), range));Wednesday, February 25, 2015 2:19 PM -
Hello,
That was a good find. Are you satisfied with this solution?
The DirectX debugging tools in Visual Studio are incredibly powerful and can help you track down problems like you describe. Check out this //build presentation for an excellent overview of how to use the tool: DirectX Graphics Debugging Tools
-James
Windows SDK Technologies - Microsoft Developer Services - http://blogs.msdn.com/mediasdkstuff/
Monday, March 2, 2015 10:11 PMModerator