Hi folks, I’m trying to build my Unity game for UWP. I’ve done that before for a game I made using 2019.2 and had no issues. But for my new game, I’m using 2021.2 and HDRP. The game runs smoothly in editor and when I do a Standalone build and generate a .exe. But when I do a UWP build, the game runs terribly, with an FPS of <5. I have no idea why this is. I’ve been trying to profile it but can’t get that to work, but surely there should be something I’m missing if the game runs smoothly in editor and standalone. This feels really strange and I would really appreciate some help.
Are you by any chance running your game in “Debug” configuration?
Nope, running it in Master
That is unexpected. Profiling should work using “Release” build. Did you try using IL2CPP to build for Windows Standalone to see if it has similar issues to UWP?
The Windows standalone build uses IL2CPP by default right? The Standalone build runs pretty smooth, this only seems to happen with UWP
No, Windows Standalone does not use IL2CPP by default. It uses Mono.
Which build type are you using with UWP?
If you hit build, it will ignore the configuration selection in that settings page because it will spit out a Visual Studio project which will have that selection available in it. When using “D3D Project” build type, the “Build Configuration” setting is only relevant if you use the “Build & Run” option. Did you by any chance not change the build configuration in Visual Studio to something other than “Debug”?
No, I’m building using Master in VS too
Okay, so two things to try:
- Build Standalone player with IL2CPP to see if it has the issue;
- Use the profiler to figure out why it’s running slow.
There doesn’t seem to be an option to change it to IL2CPP? I swear this was possible in a previous version. Is there somewhere else I should be looking?
It’s in player settings under “Other Settings”:
Just tried it with IL2CPP and the performance in Standalone is still good. I’m now trying to figure out how to get the Profile to run with the UWP build
There are a couple gotchas with attaching a profiler to a UWP build:
- You need to enable Internet Client, Internet Client & Server and Private Networks capabilities in the application manifest;
- Build the player with “Autoconnect profiler” option.
Thanks, I was able to connect the profiler. I’m not entirely sure what to make for this. It seems the CPU is handling everything and I don’t see what the GPU is doing. Is that normal?
Under “Profiler Modules” on the top left you can add GPU view. Until you do that, you won’t know how busy the GPU is. That said, this screenshot looks incredibly suspicious. It seems to suggest it’s waiting for 120 ms for rendering to be complete. I wonder if it somehow ends up rendering on a wrong GPU (or perhaps even the CPU). A couple questions:
- Did you intend to run it on D3D12 and is your game on Windows Standalone also using D3D12?
- Can you attach the player log? It should tell which GPU the game is using. You can find it under %localappdata%\Packages<GamePackageName>\TempState.
- I changed to D3D12 recently hoping that would improve performance. The Standalone version is also using D3D12, yes.
2 I’ve attached the player log. Looks like it’s using the right GPU
7803246–986283–Player.log.txt (9.19 KB)
Can you show what the GPU looks like in the profiler?
The log you attached is from Windows Standalone build. Can you find the one from UWP build in the path I mentioned above?
Yep, it’s using the wrong graphics card. How do I make sure it uses the dedicated graphics card?
7805697–986838–UnityPlayer.log.txt (7.61 KB)
Add this code to Main.cpp in generated Visual Studio project:
extern "C"
{
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
}
Could you report a bug report on this so we could fix it?