完成outputImageSequence
parent
81c289ea9c
commit
9cbbb01a83
|
@ -113,7 +113,7 @@ public:
|
|||
uint32_t lastFPS = 0;
|
||||
|
||||
struct Settings {
|
||||
bool validation = false;
|
||||
bool validation = true;
|
||||
bool fullscreen = false;
|
||||
bool vsync = false;
|
||||
bool multiSampling = true;
|
||||
|
|
|
@ -130,6 +130,8 @@ PlumageRender::PlumageRender()
|
|||
renderPassBeginInfo.clearValueCount = settings.multiSampling ? 3 : 2;
|
||||
renderPassBeginInfo.pClearValues = clearValues;
|
||||
|
||||
|
||||
|
||||
for (uint32_t i = 0; i < commandBuffers.size(); ++i) {
|
||||
renderPassBeginInfo.framebuffer = frameBuffers[i];
|
||||
|
||||
|
@ -185,6 +187,7 @@ PlumageRender::PlumageRender()
|
|||
|
||||
vkCmdEndRenderPass(currentCB);
|
||||
VK_CHECK_RESULT(vkEndCommandBuffer(currentCB));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -657,6 +660,9 @@ PlumageRender::PlumageRender()
|
|||
}
|
||||
//Create Tone Mapping render pipeline
|
||||
//CreateToneMappingPipeline();
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
// generate two cube maps
|
||||
|
@ -1586,8 +1592,13 @@ PlumageRender::PlumageRender()
|
|||
}
|
||||
|
||||
// todo :根据physicalDeviceIndex确定子文件夹路径,frameIndex确定fileName
|
||||
void PlumageRender::writeImageToFile(std::string filePath,std::string fileName)
|
||||
void PlumageRender::writeImageToFile(std::string filePath)
|
||||
{
|
||||
|
||||
bool surpportBlit = true;
|
||||
|
||||
|
||||
|
||||
char* imageData;
|
||||
// create dst image to copy
|
||||
VkImageCreateInfo imageCreateInfo(vks::initializers::imageCreateInfo());
|
||||
|
@ -1622,7 +1633,7 @@ PlumageRender::PlumageRender()
|
|||
VkCommandBufferAllocateInfo cmdBufferAllocInfo;
|
||||
VkCommandBuffer copyCmd;
|
||||
VK_CHECK_RESULT(vkAllocateCommandBuffers(device, &cmdBufferAllocInfo, ©Cmd));
|
||||
VkCommandBufferBeginInfo cmdBufferBeginInfo(vks::initializers::commandBufferBeginInfo());
|
||||
VkCommandBufferBeginInfo cmdBufferBeginInfo = vks::initializers::commandBufferBeginInfo();
|
||||
VK_CHECK_RESULT(vkBeginCommandBuffer(copyCmd, &cmdBufferBeginInfo));
|
||||
|
||||
vks::tools::insertImageMemoryBarrier(copyCmd, dstImage, 0, VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT, VkImageSubresourceRange{ VK_IMAGE_ASPECT_COLOR_BIT,0,1,0,1 });
|
||||
|
@ -1657,7 +1668,7 @@ PlumageRender::PlumageRender()
|
|||
|
||||
imageData += subResourceLayout.offset;
|
||||
|
||||
std::ofstream file(fileName, std::ios::out | std::ios::binary);
|
||||
std::ofstream file(filePath, std::ios::out | std::ios::binary);
|
||||
|
||||
// ppm header
|
||||
file << "P6\n" << width << "\n" << height << "\n" << 255 << "\n";
|
||||
|
@ -1683,21 +1694,32 @@ PlumageRender::PlumageRender()
|
|||
}
|
||||
file.close();
|
||||
|
||||
std::cout << "Framebuffer image saved to " << filePath << fileName << std::endl;
|
||||
std::cout << "Framebuffer image saved to " << filePath << std::endl;
|
||||
|
||||
// Clean up resources
|
||||
vkUnmapMemory(device, dstImageMemory);
|
||||
vkFreeMemory(device, dstImageMemory, nullptr);
|
||||
vkDestroyImage(device, dstImage, nullptr);
|
||||
|
||||
vkQueueWaitIdle(queue);
|
||||
|
||||
}
|
||||
|
||||
void PlumageRender::outputImageSequence(VkImage image, std::string filePath)
|
||||
void PlumageRender::outputImageSequence()
|
||||
{
|
||||
|
||||
std::string deviceFilePath = filePath.outputPath + "/device" + std::to_string(selectedPhysicalDeviceIndex);
|
||||
if (_access(deviceFilePath.c_str(),0) == -1)
|
||||
{
|
||||
_mkdir(deviceFilePath.c_str());
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < settings.outputFrameCount; i++)
|
||||
{
|
||||
std::string fileName = std::to_string(i) + "result.pmm";
|
||||
std::string filePath = std::to_string(selectedPhysicalDeviceIndex);
|
||||
std::string fileName = "/" + std::to_string(i) + "result.pmm";
|
||||
std::string outputPath = deviceFilePath + fileName;
|
||||
//std::cout << outputPath << std::endl;
|
||||
writeImageToFile(outputPath);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1729,6 +1751,9 @@ PlumageRender::PlumageRender()
|
|||
//加入写到文件的函数
|
||||
//swapChainImage = swapChain.images[frameIndex];
|
||||
//outputImageSequeue(swapChainImage,filePath.imageSequenceFilePath);
|
||||
|
||||
|
||||
|
||||
VK_CHECK_RESULT(vkWaitForFences(device, 1, &waitFences[frameIndex], VK_TRUE, UINT64_MAX));
|
||||
VK_CHECK_RESULT(vkResetFences(device, 1, &waitFences[frameIndex]));
|
||||
|
||||
|
@ -1799,8 +1824,6 @@ PlumageRender::PlumageRender()
|
|||
updateUniformBuffers();
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void PlumageRender::fileDropped(std::string filename)
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include <chrono>
|
||||
#include <map>
|
||||
#include <io.h>
|
||||
#include <direct.h>
|
||||
#include <locale>
|
||||
#include <codecvt>
|
||||
#include "algorithm"
|
||||
|
@ -160,10 +161,9 @@ public:
|
|||
std::string ttfFilePath = getAssetPath() + "/data/Roboto-Medium.ttf";
|
||||
|
||||
// output file path
|
||||
// imageSequence
|
||||
std::string imageSequenceFilePath = getAssetPath() + "/output/imageSequence";
|
||||
// screen shot image
|
||||
std::string screenShotFilePath = getAssetPath() + "/output/screenShot";
|
||||
|
||||
std::string outputPath = getAssetPath() + "output/imageSequence";
|
||||
|
||||
|
||||
} filePath;
|
||||
|
||||
|
@ -217,7 +217,7 @@ public:
|
|||
};
|
||||
|
||||
struct Settings {
|
||||
bool validation = false;
|
||||
bool validation = true;
|
||||
bool fullscreen = false;
|
||||
bool vsync = false;
|
||||
bool multiSampling = true;
|
||||
|
@ -346,9 +346,9 @@ public:
|
|||
void windowResized();
|
||||
void prepare();
|
||||
void submitWork(VkCommandBuffer cmdBuffer, VkQueue queue);
|
||||
void writeImageToFile(std::string filePath, std::string fileName);
|
||||
void outputImageSequence(VkImage image,std::string filePath);
|
||||
void outputScreenShot(VkImage image, std::string filePath);
|
||||
void writeImageToFile(std::string filePath);
|
||||
void outputImageSequence();
|
||||
void outputScreenShot();
|
||||
uint32_t getMemoryTypeIndex(uint32_t typeBits, VkMemoryPropertyFlags properties);
|
||||
virtual void render();
|
||||
virtual void updateUIOverlay();
|
||||
|
|
Loading…
Reference in New Issue