How do we debug WinUI apps with Pix #10727
Replies: 2 comments 1 reply
-
@Gavin-Williams You need to dynamically load the PIX runtime to be able to allow PIX access to your application. Here is a link to how I was able to achieve this in the past (it's been a few months since I tested this though). static std::wstring GetLatestWinPixGpuCapturerPath()
{
LPWSTR programFilesPath = nullptr;
SHGetKnownFolderPath(FOLDERID_ProgramFiles, KF_FLAG_DEFAULT, NULL, &programFilesPath);
std::wstring pixSearchPath = programFilesPath + std::wstring(L"\\Microsoft PIX\\*");
WIN32_FIND_DATA findData;
bool foundPixInstallation = false;
wchar_t newestVersionFound[MAX_PATH];
HANDLE hFind = FindFirstFile(pixSearchPath.c_str(), &findData);
if (hFind != INVALID_HANDLE_VALUE)
{
do
{
if (((findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) &&
(findData.cFileName[0] != '.'))
{
if (!foundPixInstallation || wcscmp(newestVersionFound, findData.cFileName) <= 0)
{
foundPixInstallation = true;
StringCchCopy(newestVersionFound, _countof(newestVersionFound), findData.cFileName);
}
}
} while (FindNextFile(hFind, &findData) != 0);
}
FindClose(hFind);
if (!foundPixInstallation)
{
// TODO: Error, no PIX installation found
}
wchar_t output[MAX_PATH];
StringCchCopy(output, pixSearchPath.length(), pixSearchPath.data());
StringCchCat(output, MAX_PATH, &newestVersionFound[0]);
StringCchCat(output, MAX_PATH, L"\\WinPixGpuCapturer.dll");
return &output[0];
} And then before you setup your device // Check to see if a copy of WinPixGpuCapturer.dll has already been injected into the application.
// This may happen if the application is launched through the PIX UI.
if (GetModuleHandle(L"WinPixGpuCapturer.dll") == 0)
{
LoadLibrary(GetLatestWinPixGpuCapturerPath().c_str());
} There is more info about it in this blog post https://devblogs.microsoft.com/pix/taking-a-capture But yeah, basically once you do this you should be able to attach to your app and capture |
Beta Was this translation helpful? Give feedback.
-
I'm closing this. I couldn't even use native code debugging in the project, so it was getting too difficult to do any debugging. I've rebuilt the project and discovered that there is no error in my code until I attach Pix. Both Wndbg and VS are now showing an issue with my texture resource (when Pix tries to capture). The error doesn't mean anything to me right now. But I will rewrite my texture code and try to isolate the issue. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm having a pretty poor experience debugging Dx12 apps in WinUI with Pix.
I do have one app that can I capture frames in - although after capturing two frames the app crashes. I think it's the first Dx12 test I put together earlier this year. But the new project has not worked with Pix. It never captures.
What are the requirements for configuring and architecting a WinUI app in order for Pix to be able to capture frames?
Beta Was this translation helpful? Give feedback.
All reactions