Added device name and frame rate counter to window title

This commit is contained in:
saschawillems 2016-03-13 16:51:00 +01:00
parent af653e7bcf
commit 66607e2d2f
3 changed files with 32 additions and 3 deletions

View file

@ -75,6 +75,14 @@ VkResult VulkanExampleBase::createDevice(VkDeviceQueueCreateInfo requestedQueues
return vkCreateDevice(physicalDevice, &deviceCreateInfo, nullptr, &device);
}
std::string VulkanExampleBase::getWindowTitle()
{
std::string device(deviceProperties.deviceName);
std::string windowTitle;
windowTitle = title + " - " + device + " - " + std::to_string(frameCounter) + " fps";
return windowTitle;
}
bool VulkanExampleBase::checkCommandBuffers()
{
for (auto& cmdBuffer : drawCmdBuffers)
@ -303,6 +311,7 @@ void VulkanExampleBase::renderLoop()
DispatchMessage(&msg);
}
render();
frameCounter++;
auto tEnd = std::chrono::high_resolution_clock::now();
auto tDiff = std::chrono::duration<double, std::milli>(tEnd - tStart).count();
frameTimer = (float)tDiff / 1000.0f;
@ -315,6 +324,16 @@ void VulkanExampleBase::renderLoop()
timer -= 1.0f;
}
}
fpsTimer += (float)tDiff;
if (fpsTimer > 1000.0f)
{
#ifdef _WIN32
std::string windowTitle = getWindowTitle();
SetWindowText(window, windowTitle.c_str());
#endif
fpsTimer = 0.0f;
frameCounter = 0.0f;
}
}
#else
xcb_flush(connection);
@ -563,6 +582,8 @@ void VulkanExampleBase::initVulkan(bool enableValidation)
err = createDevice(queueCreateInfo, enableValidation);
assert(!err);
vkGetPhysicalDeviceProperties(physicalDevice, &deviceProperties);
// Gather physical device memory properties
vkGetPhysicalDeviceMemoryProperties(physicalDevice, &deviceMemoryProperties);
@ -710,10 +731,10 @@ HWND VulkanExampleBase::setupWindow(HINSTANCE hinstance, WNDPROC wndproc)
AdjustWindowRectEx(&windowRect, dwStyle, FALSE, dwExStyle);
std::string windowTitle = getWindowTitle();
window = CreateWindowEx(0,
name.c_str(),
title.c_str(),
// WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_SYSMENU,
windowTitle.c_str(),
dwStyle | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
windowRect.left,
windowRect.top,

View file

@ -41,17 +41,25 @@ class VulkanExampleBase
private:
// Set to true when example is created with enabled validation layers
bool enableValidation = false;
// fps timer (one second interval)
float fpsTimer = 0.0f;
// Create application wide Vulkan instance
VkResult createInstance(bool enableValidation);
// Create logical Vulkan device based on physical device
VkResult createDevice(VkDeviceQueueCreateInfo requestedQueues, bool enableValidation);
// Get window title with example name, device, et.
std::string getWindowTitle();
protected:
// Last frame time, measured using a high performance timer (if available)
float frameTimer = 1.0f;
// Frame counter to display fps
uint32_t frameCounter = 0;
// Vulkan instance, stores all per-application states
VkInstance instance;
// Physical device (GPU) that Vulkan will ise
VkPhysicalDevice physicalDevice;
// Stores physical device properties (for e.g. checking device limits)
VkPhysicalDeviceProperties deviceProperties;
// Stores all available memory (type) properties for the physical device
VkPhysicalDeviceMemoryProperties deviceMemoryProperties;
// Logical device, application's view of the physical device (GPU)

View file

@ -39,7 +39,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)\bin\</OutDir>
<IntDir>$(SolutionDir)\bin\</IntDir>
<IntDir>$(SolutionDir)\bin\intermediate\$(ProjectName)\$(ConfigurationName)</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>true</LinkIncremental>