WPF on Rendering Tier 2 machine still using Software Rendering - c#

I have a WPF application in which I put a check for the rendering tier and on my dev machine it reports Tier 2 every time. As far as I know this means that it has full hardware rendering capability. Which it should, it's a new system running an Nvidia 550M chip. But when I check with WPFPerf, it shows that the entire app is rendering in software mode! What can I check to figure out what is causing this?
One thought is could it be that I have AllowTransparancy set to True? (It's a borderless window, so I had to use it).

NVidia 555M? That sounds like Optimus issue. I had this issue with some games - the GPU-chooser doesn't detect a performance intensive application and runs it on the GPU integrated in CPU.
I never had this issue with a WPF app though (I think the integrated GPU should be tier 2 as well, at least it appears to be on my Core i7).
Try going to NVidia Control Panel -> Manage 3D Settings -> add your application there. If you are using VS debugger, add the X.vshost.exe as well.

Related

Force windows to use the best graphic card available

I have a WPF application which has a small 3D Engine on some specific pages (integrated via WindowsFormsHost).
I've seen that on many laptops with several graphic cards (dedicated and integrated) Windows would by default use the integrated one which in many cases will not be good enough to run my 3D Engine.
For example all my games are automatically executed with the dedicated GPU. Is there a way to show windows this WPF application needs the best GPU available ?
I understand that you can change that choice in your graphic card's settings but it's a complicated manipulation for most of the final users.
These two threads might be helpful:
- https://gamedev.stackexchange.com/questions/58546/how-can-i-set-my-application-to-run-on-the-high-performance-gpu-by-default
- https://stackoverflow.com/questions/16823372/forcing-machine-to-use-dedicated-graphics-card Christopher Oezbek's answer may be of interest
- https://stackoverflow.com/questions/29504891/laptop-dual-video-cards-how-to-programatically-detect-and-or-choose-which-one
The solution posted by axon seems promising

Performance of WPF Application on Windows 8 tablet

I have a WPF application developed on a Windows 7 - 32 bit desktop. The app runs fine in the development system. It also runs smoothly on Windows 8 32 & 64 bit desktops.
When I run the same application on a tablet with Windows 8 - 32 bit, the application UI responds very slowly and runs very slowly. This application is actually used to monitor data received over UDP.
The tablet I am using is an HP ElitePad 900 which has Intel Atom Z2760 / 1.8 GHz (Dual Core), 2GB RAM.
I don't think the hardware is what is causing the problem.
I tried setting the ProcessRenderingOption as
RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;
in the application startup. But still no change. I need some suggestions/answers as to what the problem maybe.
FYI the tablet has Windows 8 not RTM, so it allows desktop applications also to run.
If there is no difference when you set ProcessRenderMode = SoftwareOnly, it is helpful to investigate the cause of problem.
Situation 1
If your app uses effects that can't be handled by GPU,
it is always rendered by CPU regardless ProcessRenderMode setting.
Thus, ProcessRenderMode is implicitly set SoftwareOnly.
So when you set the setting SoftwareOnly explicitly, it has no effect.
In this case, your app's performance depends on CPU throughput.
ATOM may be poor than your desktop CPU, the result can be explained.
Situation 2
If your tablet's GPU has not enough to render WPF effects,
some effects are rendered by CPU. This causes performance down.
You can check WPF GPU capability with System.Windows.Media.RenderCapability class.
Conclusion
The cause is
CPU throughput because your app is always rendered by software. Or
poor GPU capability to render WPF rich effects.

Is WPF Hardware-accelerated when Window AllowsTransparency = true?

I have been looking at making my own window frame in WPF, similar to Visual Studio. I have read that setting AllowsTransparency = true would force WPF to render in software-mode. This example is the source of my confusion (emphasis mine), which states:
Complete customization of WPF window can be done only when AllowsTransparency is set to "True", which causes that the window is software rendered which might be not as fast GPU rendering.
However, I've read elsewhere that with window layering you can have hardware-acceleration and this is what WPF does. I also find it hard to imagine that Visual Studio 2013 -with its custom frame and transparent border blur- would be software-rendered.
Is there a definitive answer to the question (assuming Windows 7 onwards), Is WPF Hardware-accelerated when Window AllowsTransparency is true?
It seems that transparent windows (AllowsTransparency = true) are hardware accelerated for Windows Vista and upper: HW Acceleration of Layered Windows
There is also an hotfix to make it work under windows XP as well: http://support.microsoft.com/kb/937106/en-us
I'll add my two cents too.
Yes, it's true. From Vista onwards, we have hardware acceleration for layered windows, and there seems to be a hotfix for XP aswell.
This is where the good news stop.
Don't try and use AllowsTransparency - trust me, there's just so much that can and WILL go wrong, despite it being hardware accelerated. Ofcourse, think about your use case: if it's simple hobby project, not an enterprise level application, then, go ahead.
Some of the problems I've personally experienced:
major performance, believe or not, "performance problems with AllowsTransparency" is not made up concept. Animations suck.
Integration with other technologies. I remember integrating DirectShow solution to a window that had AllowsTransparency true. It did not work, as DirectShow does not support rendering to a window that is layered.
This guy seems to be even talking that software rendering is sometimes faster than hardware, for layered windows, which I kind of agree. My experience has also shown that "hardware acceleration" is nothing spectacular on WPF.
I remember switching to software rendering, and saw no performance loss. In fact, I suggest to disable hardware rendering because it's complex, and it causes visual bugs, if you're targeting wide area of different configurations (XP, XP64, Vista, Win7, different video cards) - famous black spots.
By the way, VS2010 SP1 disables hardware rendering for visual studio on XP, even if it supports it. Why? "A significant number of crash reports stemming from the hardware acceleration"
That said, Visual Studio2013 does not use AllowsTransparency - correct me if I am wrong, but Snoop revealed that the main window has AllowsTransparency set false.
How can you have a custom chrome window, that is not layered & PERFORMS well? This is quite complex subject, but you can get started if you google for "WPF Custom Chrome library". I suspect VS does something similiar.

Wpf performance hungry test app to test if Citrix is using GPU for rendering and if it makes any difference

We have a Wpf app hosted by a single Citrix Server used by up to 8 remote users. The WPF app is usually used with a high resolution and multiple monitors at the same time so we want to make sure the GPU is used for rendering instead of CPU.
We are using grids, canvases, checkboxes and all kind of WPF controls.
I want to test if it adds any value to use 3D acceleration hardware on the Citrix servers because we are about to order new hardware and I am not sure if it is worth spending the extra money.
Some info is given away by Citrix on link below so I think of writing WPF "hungry" test app but I am not sure what it should look like.
http://support.citrix.com/proddocs/topic/xendesktop-7/hd-3d-gpu-acceleration-win-server-os.html
EDIT
Any idea what this WPF app should look like so I can make sure it uses GPU or is there a better way to test this? Which wpf controls should I use in the test app or is there similar test app written already?
Many Thanks
As a general rule, the composition of your WPF app will not affect whether the CPU (software rendering) or the GPU (hardware rendering) is used. WPF will always use hardware rendering when it is available on the machine, and will fallback to software rendering if it can't find hardware support.
Having said that, there are some things that WPF will always render using software rendering. E.g. the legacy effects derived from BitmapEffect.
You can use the WPF perf tools to see whether software rendering is being used:
http://msdn.microsoft.com/en-us/library/aa969767%28v=vs.110%29.aspx
The Perforator tool has an option to highlight sections of the app rendered in software with a purple tint.
So to answer your question, pretty much any WPF app you can create will use hardware rendering, just don't use anything derived from BitmapEffect. You can double check that software rendering isn't used by running the app on your desktop first and using Perforator to profile it. Once you've confirmed it doesn't use any software rendering you can test it in your Citrix environment with/with-out 3D hardware installed to see what kind of performance improvements you get.

Minimize Windows 8 Store App while tracking location with GPS

I'm working on a metro app and am having trouble finding how not to show the application.
We recently deployed tablets to our field reps, and need to add gps tracking. GPS is much easier to deal with in the metro libs (it's like 4 lines of code vs. unmanaged) so we're hoping to be able to push a metro app instead of spending time coding a winforms/wpf desktop app (the tablets are full version windows, so it's an option if we can't hide a metro app. I feel like it should be possible though as the start screen tiles update automatically without opening the main program).
In WPF, it's fairly simple to make a window invisible. I'm creating the metro app in wpf, but it uses different libs than desktop and I may just not know how to do it.
In desktop programs, it's fairly simple. You do something along the lines of:
<Page
x:Class = xxxxxxxx
..
Visibility="Hidden">
Unfortunately, with metro, the only options I have are collapsed and visible. Collapsed doesn't seem to have any effect, unless it's just because it's not deployed and visual studio shows it anyway...
So basically I'm trying to figure out if there's a way to start the program minimized or hidden so that it doesn't interrupt the field reps every time it takes their location.
If you really want to make a metro app and want it to run "minimised" you will need to look at background task. To start the background task the user would still need to start the app at least once, futhermore background task have limitation how how often and how long they can run. Also there is a lot of constraint on deploying a windows store app if you cannot publish it in the store.
If your goal is to just have access to GPS through C# apis, the GPS is actually one of the winRT api you can use from the desktop, you can find a tutorial on how to access winRT api from the desktop here
Here is the complete list of winRT api accessible from the desktop (You can find Geoposition class among them).
Have you looked into creating a background task that transmits GPS? The background task can run without the app running.
I am not entirely certain you can voluntarily minimize a Windows Store App on a user's behalf. I see nothing in IntelliSense about it, nor have I found anything online or see any app do it.
However, be aware that deploying the app without using the Windows Store -- sideloading -- requires Windows 8 Enterprise edition computers joined to the domain OR Windows 8 Pro with a sideloading key ($30 per key, purchased in packs of at least 100.) Perhaps a WPF app with unmanaged code is worth the money and effort.

Categories

Resources