-
Notifications
You must be signed in to change notification settings - Fork 646
[Win8.1] SwapChainPanel scaling is ignored #287
Comments
You are right, DPI-Scaling is not yet implemented for the outer Direct3DUserControl. However, there is a callback method called DisplayProperties_LogicalDpiChanged. The name remains from deprecated DisplayProperties.LogicalDpi, but in fact it uses DisplayInformation.LogicalDpi. Feel free to rename the method and implement your solution in place. Creating a Pull request for your changes would let others participate in your enhancement. Even better would be looking for a solution not to scale the SwapChain in View, but to resize the render area. This reduces calculations and improves picture quality. So I did not implement it, because this might be to much for some users not prefering to have the render area resized by DPI-scaling. |
I just offered a Pull-Request renaming the method an adding a
|
Actually if I understand this correctly the solution I described above does exactly that. Currently the element is scalled up by WinRT logical scaling. But if you apply inversed scale on swapChain2.MatrixTransform it will be scalled back to hardware resolution so its effect is canceled out. I tested it on the device and I couldn't see any scaling artifacts. |
Thanks for the Pull-Request. I will try to implement this in this method. |
Cool :) |
I also added a stub for CompositionScaleChanged event. I think you will need it also :) |
This should be best visible not on downscaling, but on upscaling. Have you tried this with a scale factor of 2x or 3x. If pixels are still 1:1 crips then, it is perfect :) I think it is save to create a swapChain2 instead of swapChain1 initially. This would make your cast
unnecessary. Also you could try using double or different rounding strategy on the float-values to avoid 1px gap. But you probably know by yourself, and this is fine tuning I would do as a final step. |
I have implemented these changes and created a pull request (I'm a GitHub noob, so let me know if this isn't the right way to do publish changes). I've added two sliders on MainPage so you can test with different transformations. I didn't make it clear in the bug report but what I was originally looking for is implementing this in the Toolkit. It seems more complex to plug this into exisitng architecture so I appreciate if someone could point me in right direction. |
I will look at it soon, at first it looks good. Are changes in "SharpDX.sln.DotSettings" really needed? "3. Scale DirectX content smoothly and precisely But I think even this sample is not completely DPI-Scale aware. Did you try it on your Surface Pro? Same steps should be done but completely in C#. Did you lookup the class where SwapChain1 was defined? You maybe can avoid the cast. |
I really appreciate that you have already integrated supported for SwapChainPanel control. However when runing sample app on Surface Pro device the output isn't scaled correctly to screen size. See screenshot where I added colored rectangles to indicate bounds. Notice how that game content overlaps with these bounds.
You can reproduce this in simulator by changing resolution (monitor button) to 1920x1080 (140%). In this case windows applies scaling to adjust the logical DPI. You can read more here.
Here is mention of SwapChainPanel size synchronization in this post: http://blogs.windows.com/windows/b/appbuilder/archive/2013/11/19/what-s-new-for-xaml-and-directx-interop-in-windows-8-1.aspx
There are CompositionScaleX/Y properties exposed specifically to accomodate this. Usage with DirectX can be found in this sample http://code.msdn.microsoft.com/windowsapps/XAML-SwapChainPanel-00cb688b
I've tried to implement this in SharpDX adding this code to SwapChainGraphicsPresenter (here scaling values are hard-coded):
There are few more places where DPI scaling should be applied but this change seems to fix the issue. See the 2nd screenshot.
Notice however that there is 1px black line on right and bottom edge. For some reason size used to create back buffer is one-pixel shorter than it should be.
Finally DisplayProperties.LogicalDpi is deprecated and DisplayInformation.LogicalDpi should be used instead.
The text was updated successfully, but these errors were encountered: