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