diff --git a/base/vulkanexamplebase.cpp b/base/vulkanexamplebase.cpp index 66b105ac..cfa223f9 100644 --- a/base/vulkanexamplebase.cpp +++ b/base/vulkanexamplebase.cpp @@ -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(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, diff --git a/base/vulkanexamplebase.h b/base/vulkanexamplebase.h index 86366fe1..efaf9f0a 100644 --- a/base/vulkanexamplebase.h +++ b/base/vulkanexamplebase.h @@ -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) diff --git a/shadowmapping/shadowmapping.vcxproj b/shadowmapping/shadowmapping.vcxproj index 7f88346b..bc942035 100644 --- a/shadowmapping/shadowmapping.vcxproj +++ b/shadowmapping/shadowmapping.vcxproj @@ -39,7 +39,7 @@ true $(SolutionDir)\bin\ - $(SolutionDir)\bin\ + $(SolutionDir)\bin\intermediate\$(ProjectName)\$(ConfigurationName) true