完成图片序列输出

pull/1/head
ink-soul 2024-03-26 18:04:18 +08:00
parent 8a36a4d721
commit 6e791134d7
6 changed files with 26 additions and 14 deletions

5
.gitignore vendored
View File

@ -41,4 +41,7 @@ vulkan_asset_pack_gltf.zip
*.zip
# vscode build file
build/
build/
# output ppm image sequence
*.ppm

View File

@ -107,7 +107,7 @@ endif()
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
file(GLOB SOURCE *.cpp )

View File

@ -8,6 +8,7 @@
#include "VulkanExampleBase.h"
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)
@ -317,6 +318,7 @@ void VulkanExampleBase::renderFrame()
auto tStart = std::chrono::high_resolution_clock::now();
render();
frameCounter++;
auto tEnd = std::chrono::high_resolution_clock::now();
auto tDiff = std::chrono::duration<double, std::milli>(tEnd - tStart).count();

View File

@ -113,7 +113,7 @@ public:
uint32_t lastFPS = 0;
struct Settings {
bool validation = true;
bool validation = false;
bool fullscreen = false;
bool vsync = false;
bool multiSampling = true;

View File

@ -303,7 +303,7 @@ PlumageRender::PlumageRender()
uint32_t materialCount = 0;
uint32_t meshCount = 0;
// Environment samplers (radiance, irradiance, brdf lut)
// Environment samplers (radiance, irradiance, brdflut)
imageSamplerCount += 3;
std::vector<glTFModel::Model*> modellist = { &models.skybox, &models.scene };
@ -1792,7 +1792,7 @@ PlumageRender::PlumageRender()
}
file.close();
std::cout << "Screenshot saved to disk" << std::endl;
std::cout << "Screenshot saved to " << filePath << std::endl;
// Clean up resources
vkUnmapMemory(device, dstImageMemory);
@ -1807,18 +1807,20 @@ PlumageRender::PlumageRender()
{
std::string deviceFilePath = filePath.outputPath + "/device" + std::to_string(selectedPhysicalDeviceIndex);
if (_access(deviceFilePath.c_str(),0) == -1)
if (savedFrameCounter == settings.outputFrameCount)
{
_mkdir(deviceFilePath.c_str());
return;
}
for (uint32_t i = 0; i < settings.outputFrameCount; i++)
if (_access(deviceFilePath.c_str(), 0) == -1)
{
std::string fileName = "/" + std::to_string(i) + "result.pmm";
std::string outputPath = deviceFilePath + fileName;
//std::cout << outputPath << std::endl;
writeImageToFile(outputPath);
std::filesystem::create_directories(deviceFilePath.c_str());
}
std::string fileName = "/" + std::to_string(savedFrameCounter) + "result.ppm";
std::string outputPath = deviceFilePath + fileName;
//std::cout << outputPath << std::endl;
writeImageToFile(outputPath.c_str());
savedFrameCounter++;
}
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));
outputImageSequence();
VK_CHECK_RESULT(vkResetFences(device, 1, &waitFences[frameIndex]));
VkResult acquire = swapChain.acquireNextImage(presentCompleteSemaphores[frameIndex], &currentBuffer);

View File

@ -12,7 +12,9 @@
#include <locale>
#include <codecvt>
#include "algorithm"
#include <iostream>
#include <sys/stat.h>
#include <filesystem>
#include <vulkan/vulkan.h>
#include "VulkanExampleBase.h"
@ -275,6 +277,8 @@ public:
} prefilterPushBlock;
UI* gui;
uint64_t savedFrameCounter = 0;
PlumageRender();