From 361708bd11b2ed1a1edd06c23be2b02598410494 Mon Sep 17 00:00:00 2001 From: Xiang Silian Date: Mon, 20 Oct 2025 21:16:39 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8Android=20=E4=B8=8A=E4=B9=9F=E6=8A=8A?= =?UTF-8?q?=E8=84=B8=E7=94=BB=E5=87=BA=E6=9D=A5=E4=BA=86=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vulkan/FaceApp.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/vulkan/FaceApp.cpp b/vulkan/FaceApp.cpp index d11a4e2..8e290b1 100644 --- a/vulkan/FaceApp.cpp +++ b/vulkan/FaceApp.cpp @@ -501,7 +501,7 @@ void FaceApp::render(VkCommandBuffer commandBuffer) #ifdef _WIN32 vkCmdDrawIndexed(commandBuffer, obj_indices.size(), 1, 0, 0, 0); #else - if (getCurrentTimeMillis() - last_update_time < 1000) + if (getCurrentTimeMillis() - last_update_time < 2000) { vkCmdDrawIndexed(commandBuffer, obj_indices.size(), 1, 0, 0, 0); } @@ -510,11 +510,28 @@ void FaceApp::render(VkCommandBuffer commandBuffer) void FaceApp::createVmaAllocator() { - VmaAllocatorCreateInfo allocatorInfo = {}; + //VmaAllocatorCreateInfo allocatorInfo = {}; + //allocatorInfo.physicalDevice = physicalDevice; + //allocatorInfo.device = device; + //allocatorInfo.instance = instance; + //allocatorInfo.vulkanApiVersion = VK_API_VERSION_1_0; + //vmaCreateAllocator(&allocatorInfo, &allocator); + + // 1. 设置 Vulkan 函数指针 + VmaVulkanFunctions vulkanFunctions{}; + vulkanFunctions.vkGetInstanceProcAddr = vkGetInstanceProcAddr; + vulkanFunctions.vkGetDeviceProcAddr = vkGetDeviceProcAddr; + + // 2. 配置 Allocator + VmaAllocatorCreateInfo allocatorInfo{}; allocatorInfo.physicalDevice = physicalDevice; allocatorInfo.device = device; allocatorInfo.instance = instance; - vmaCreateAllocator(&allocatorInfo, &allocator); + allocatorInfo.vulkanApiVersion = VK_API_VERSION_1_0; + allocatorInfo.pVulkanFunctions = &vulkanFunctions; + + + VkResult result = vmaCreateAllocator(&allocatorInfo, &allocator); } void FaceApp::initVulkan() @@ -537,6 +554,7 @@ void FaceApp::initVulkan() create_pipelines_bg(); uploadVertexData(); + last_update_time = getCurrentTimeMillis(); faceAppInited = true; #if _WIN32