优化内存读取

This commit is contained in:
xsl
2025-11-29 11:35:56 +08:00
parent 9c71e40c97
commit 1859706412
814 changed files with 911 additions and 128 deletions
+19 -2
View File
@@ -1,5 +1,6 @@
#include "FaceApp.h"
#include "hardcode_data.h"
#include "lodepng.h"
#include <sstream>
#include <queue>
#include <vector>
@@ -721,12 +722,18 @@ void FaceApp::initVulkan()
{
m_texs_ex.resize(kMaxTexture);
}
std::vector<unsigned char> data = readFileUnsignedChar("demo0.png", false);
std::vector<unsigned char> image;
unsigned w, h;
unsigned error = lodepng::decode(image, w, h, data, LCT_RGBA, 8);
for (int i = 0; i < kMaxTexture; ++i)
{
loadTexture("demo0.png", m_texs[i], true);
loadTexture(image, image.size(), w, h, m_texs[i], true);
if (kThick)
{
loadTexture("demo0_ex.png", m_texs_ex[i], true);
loadTexture(image, image.size(), w, h, m_texs_ex[i], true);
}
}
@@ -1142,6 +1149,16 @@ void FaceApp::destroyTexture(VkDevice device, Texture& texture) {
vkFreeMemory(device, texture.device_memory, nullptr);
texture.device_memory = VK_NULL_HANDLE;
}
if (texture.stagingBuffer != VK_NULL_HANDLE)
{
vkDestroyBuffer(device, texture.stagingBuffer, nullptr);
}
if (texture.stagingBufferMemory != VK_NULL_HANDLE)
{
vkFreeMemory(device, texture.stagingBufferMemory, nullptr);
}
}
void FaceApp::cleanupResources(VkDevice device, VmaAllocator allocator) {