完成图片序列输出
parent
8a36a4d721
commit
6e791134d7
|
@ -42,3 +42,6 @@ vulkan_asset_pack_gltf.zip
|
||||||
|
|
||||||
# vscode build file
|
# vscode build file
|
||||||
build/
|
build/
|
||||||
|
|
||||||
|
# output ppm image sequence
|
||||||
|
*.ppm
|
|
@ -107,7 +107,7 @@ endif()
|
||||||
|
|
||||||
|
|
||||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
file(GLOB SOURCE *.cpp )
|
file(GLOB SOURCE *.cpp )
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include "VulkanExampleBase.h"
|
#include "VulkanExampleBase.h"
|
||||||
|
|
||||||
|
|
||||||
std::vector<const char*> VulkanExampleBase::args;
|
std::vector<const char*> VulkanExampleBase::args;
|
||||||
|
|
||||||
VKAPI_ATTR VkBool32 VKAPI_CALL debugMessageCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objType, uint64_t srcObject, size_t location, int32_t msgCode, const char * pLayerPrefix, const char * pMsg, void * pUserData)
|
VKAPI_ATTR VkBool32 VKAPI_CALL debugMessageCallback(VkDebugReportFlagsEXT flags, VkDebugReportObjectTypeEXT objType, uint64_t srcObject, size_t location, int32_t msgCode, const char * pLayerPrefix, const char * pMsg, void * pUserData)
|
||||||
|
@ -317,6 +318,7 @@ void VulkanExampleBase::renderFrame()
|
||||||
auto tStart = std::chrono::high_resolution_clock::now();
|
auto tStart = std::chrono::high_resolution_clock::now();
|
||||||
|
|
||||||
render();
|
render();
|
||||||
|
|
||||||
frameCounter++;
|
frameCounter++;
|
||||||
auto tEnd = std::chrono::high_resolution_clock::now();
|
auto tEnd = std::chrono::high_resolution_clock::now();
|
||||||
auto tDiff = std::chrono::duration<double, std::milli>(tEnd - tStart).count();
|
auto tDiff = std::chrono::duration<double, std::milli>(tEnd - tStart).count();
|
||||||
|
|
|
@ -113,7 +113,7 @@ public:
|
||||||
uint32_t lastFPS = 0;
|
uint32_t lastFPS = 0;
|
||||||
|
|
||||||
struct Settings {
|
struct Settings {
|
||||||
bool validation = true;
|
bool validation = false;
|
||||||
bool fullscreen = false;
|
bool fullscreen = false;
|
||||||
bool vsync = false;
|
bool vsync = false;
|
||||||
bool multiSampling = true;
|
bool multiSampling = true;
|
||||||
|
|
|
@ -1792,7 +1792,7 @@ PlumageRender::PlumageRender()
|
||||||
}
|
}
|
||||||
file.close();
|
file.close();
|
||||||
|
|
||||||
std::cout << "Screenshot saved to disk" << std::endl;
|
std::cout << "Screenshot saved to " << filePath << std::endl;
|
||||||
|
|
||||||
// Clean up resources
|
// Clean up resources
|
||||||
vkUnmapMemory(device, dstImageMemory);
|
vkUnmapMemory(device, dstImageMemory);
|
||||||
|
@ -1807,18 +1807,20 @@ PlumageRender::PlumageRender()
|
||||||
{
|
{
|
||||||
|
|
||||||
std::string deviceFilePath = filePath.outputPath + "/device" + std::to_string(selectedPhysicalDeviceIndex);
|
std::string deviceFilePath = filePath.outputPath + "/device" + std::to_string(selectedPhysicalDeviceIndex);
|
||||||
|
|
||||||
|
if (savedFrameCounter == settings.outputFrameCount)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (_access(deviceFilePath.c_str(), 0) == -1)
|
if (_access(deviceFilePath.c_str(), 0) == -1)
|
||||||
{
|
{
|
||||||
_mkdir(deviceFilePath.c_str());
|
std::filesystem::create_directories(deviceFilePath.c_str());
|
||||||
}
|
}
|
||||||
|
std::string fileName = "/" + std::to_string(savedFrameCounter) + "result.ppm";
|
||||||
for (uint32_t i = 0; i < settings.outputFrameCount; i++)
|
|
||||||
{
|
|
||||||
std::string fileName = "/" + std::to_string(i) + "result.pmm";
|
|
||||||
std::string outputPath = deviceFilePath + fileName;
|
std::string outputPath = deviceFilePath + fileName;
|
||||||
//std::cout << outputPath << std::endl;
|
//std::cout << outputPath << std::endl;
|
||||||
writeImageToFile(outputPath);
|
writeImageToFile(outputPath.c_str());
|
||||||
}
|
savedFrameCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t PlumageRender::getMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties)
|
uint32_t PlumageRender::getMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties)
|
||||||
|
@ -1853,6 +1855,7 @@ PlumageRender::PlumageRender()
|
||||||
|
|
||||||
|
|
||||||
VK_CHECK_RESULT(vkWaitForFences(device, 1, &waitFences[frameIndex], VK_TRUE, UINT64_MAX));
|
VK_CHECK_RESULT(vkWaitForFences(device, 1, &waitFences[frameIndex], VK_TRUE, UINT64_MAX));
|
||||||
|
outputImageSequence();
|
||||||
VK_CHECK_RESULT(vkResetFences(device, 1, &waitFences[frameIndex]));
|
VK_CHECK_RESULT(vkResetFences(device, 1, &waitFences[frameIndex]));
|
||||||
|
|
||||||
VkResult acquire = swapChain.acquireNextImage(presentCompleteSemaphores[frameIndex], ¤tBuffer);
|
VkResult acquire = swapChain.acquireNextImage(presentCompleteSemaphores[frameIndex], ¤tBuffer);
|
||||||
|
|
|
@ -12,7 +12,9 @@
|
||||||
#include <locale>
|
#include <locale>
|
||||||
#include <codecvt>
|
#include <codecvt>
|
||||||
#include "algorithm"
|
#include "algorithm"
|
||||||
|
#include <iostream>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include "VulkanExampleBase.h"
|
#include "VulkanExampleBase.h"
|
||||||
|
@ -276,6 +278,8 @@ public:
|
||||||
|
|
||||||
UI* gui;
|
UI* gui;
|
||||||
|
|
||||||
|
uint64_t savedFrameCounter = 0;
|
||||||
|
|
||||||
|
|
||||||
PlumageRender();
|
PlumageRender();
|
||||||
~PlumageRender()
|
~PlumageRender()
|
||||||
|
|
Loading…
Reference in New Issue