| 813 | } |
| 814 | |
| 815 | void Editor::SaveToFile(const std::string& filepath, VulkanHelper::CommandBuffer commandBuffer) |
| 816 | { |
| 817 | VulkanHelper::Image postProcessorImage = m_PostProcessor.GetOutputImageView().GetImage(); |
| 818 | VulkanHelper::Buffer::Config bufferConfig{}; |
| 819 | bufferConfig.Device = m_Device; |
| 820 | bufferConfig.Size = (uint64_t)(postProcessorImage.GetWidth() * postProcessorImage.GetHeight() * 4); |
| 821 | bufferConfig.Usage = VulkanHelper::Buffer::Usage::TRANSFER_DST_BIT; |
| 822 | bufferConfig.CpuMapable = true; |
| 823 | bufferConfig.DebugName = "Save to file Buffer"; |
| 824 | VulkanHelper::Buffer buffer = VulkanHelper::Buffer::New(bufferConfig).Value(); |
| 825 | |
| 826 | postProcessorImage.TransitionImageLayout(VulkanHelper::Image::Layout::TRANSFER_SRC_OPTIMAL, commandBuffer); |
| 827 | VH_ASSERT(buffer.CopyFromImage(commandBuffer, postProcessorImage) == VulkanHelper::VHResult::OK, "Failed to copy image to buffer"); |
| 828 | |
| 829 | VH_ASSERT(commandBuffer.EndRecording() == VulkanHelper::VHResult::OK, "Failed to end command buffer recording"); |
| 830 | VH_ASSERT(commandBuffer.SubmitAndWait() == VulkanHelper::VHResult::OK, "Failed to submit command buffer"); |
| 831 | VH_ASSERT(commandBuffer.BeginRecording(VulkanHelper::CommandBuffer::Usage::ONE_TIME_SUBMIT_BIT) == VulkanHelper::VHResult::OK, "Failed to begin command buffer recording"); |
| 832 | void* mappedData = buffer.Map().Value(); |
| 833 | stbi_write_png( |
| 834 | filepath.c_str(), |
| 835 | (int)postProcessorImage.GetWidth(), |
| 836 | (int)postProcessorImage.GetHeight(), |
| 837 | 4, |
| 838 | mappedData, |
| 839 | (int)postProcessorImage.GetWidth() * 4 |
| 840 | ); |
| 841 | |
| 842 | buffer.Unmap(); |
| 843 | } |
| 844 | |
| 845 | void Editor::RenderVolumeSettings() |
| 846 | { |
nothing calls this directly
no test coverage detected