From 2284911161a56753ed7d44080bcff5c2eb0b3dc1 Mon Sep 17 00:00:00 2001 From: xiangsilian Date: Sun, 19 Oct 2025 16:26:38 +0800 Subject: [PATCH] =?UTF-8?q?Windows=20=E4=B8=8B=E9=9D=A2=E7=BB=88=E4=BA=8E?= =?UTF-8?q?=E6=98=AF=E7=BC=96=E8=AF=91=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 13 +++++++++++++ vulkan/Application.h | 4 ++++ vulkan/FaceApp.cpp | 31 ++++++++++++------------------- vulkan/FaceApp.h | 2 +- 4 files changed, 30 insertions(+), 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a9f6a69..94fa73c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,6 +6,10 @@ set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +if(MSVC) + add_compile_options(/Zc:__cplusplus) +endif() + if(CMAKE_SYSTEM_NAME STREQUAL "Android") @@ -93,9 +97,18 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR WIN32) vulkan/FaceApp.cpp vulkan/main.cpp vulkan/lodepng.cpp + third_party/vma/src/VmaUsage.h + third_party/vma/src/VmaUsage.cpp + third_party/fmt/src/format.cc + vulkan/framework/common/error.cpp + vulkan/framework/common/strings.cpp + vulkan/framework/core/allocated.cpp + ) endif() target_compile_definitions(sample PRIVATE VK_NO_PROTOTYPES) target_compile_definitions(sample PRIVATE GLM_ENABLE_EXPERIMENTAL) +target_compile_definitions(sample PRIVATE VULKAN_HPP_NO_STRUCT_CONSTRUCTORS) + diff --git a/vulkan/Application.h b/vulkan/Application.h index eef18b5..669ddf6 100644 --- a/vulkan/Application.h +++ b/vulkan/Application.h @@ -5,6 +5,9 @@ #include "AppBase.h" #include #include +#include +#include "framework/core/buffer.h" +#include "framework/core/device.h" struct Texture { @@ -44,6 +47,7 @@ public: bool isInited() { return inited; } protected: + std::unique_ptr v_device; VkPhysicalDevice physicalDevice = VK_NULL_HANDLE; // 物理设备 VkDevice device; // 逻辑设备 VkQueue graphicsQueue; // 图形队列 diff --git a/vulkan/FaceApp.cpp b/vulkan/FaceApp.cpp index 6a3065a..84c2d67 100644 --- a/vulkan/FaceApp.cpp +++ b/vulkan/FaceApp.cpp @@ -1,5 +1,5 @@ #include "FaceApp.h" - +#include "common/helpers.h" FaceApp::FaceApp(/* args */) { @@ -18,27 +18,20 @@ void FaceApp::initVulkan() void FaceApp::generate_quad() { - //std::vector& vertices = obj_vertices; - //std::vector indices = obj_indices; + std::vector& vertices = obj_vertices; + std::vector indices = obj_indices; - //index_count = static_cast(indices.size()); + index_count = static_cast(indices.size()); - //auto vertex_buffer_size = vkb::to_u32(vertices.size() * sizeof(TextureLoadingVertexStructure)); - //auto index_buffer_size = vkb::to_u32(indices.size() * sizeof(uint32_t)); + auto vertex_buffer_size = vkb::to_u32(vertices.size() * sizeof(TextureLoadingVertexStructure)); + auto index_buffer_size = vkb::to_u32(indices.size() * sizeof(uint32_t)); - //// Create buffers - //// For the sake of simplicity we won't stage the vertex data to the gpu memory - //// Vertex buffer - //vertex_buffer = std::make_unique(get_device(), - // vertex_buffer_size, - // VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT, - // VMA_MEMORY_USAGE_CPU_TO_GPU); - //vertex_buffer->update(vertices.data(), vertex_buffer_size); + vkb::core::DeviceC& cDevice = reinterpret_cast(*v_device); - //index_buffer = std::make_unique(get_device(), - // index_buffer_size, - // VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT, - // VMA_MEMORY_USAGE_CPU_TO_GPU); + auto vertex_buffer = std::make_unique(cDevice, vertex_buffer_size,VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,VMA_MEMORY_USAGE_CPU_TO_GPU); + vertex_buffer->update(vertices.data(), vertex_buffer_size); - //index_buffer->update(indices.data(), index_buffer_size); + index_buffer = std::make_unique(cDevice,index_buffer_size,VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT,VMA_MEMORY_USAGE_CPU_TO_GPU); + + index_buffer->update(indices.data(), index_buffer_size); } diff --git a/vulkan/FaceApp.h b/vulkan/FaceApp.h index 6b0b2fb..1b32319 100644 --- a/vulkan/FaceApp.h +++ b/vulkan/FaceApp.h @@ -2,7 +2,7 @@ #define __FaceApp_H__ #include "Application.h" -#include "framework/core/buffer.h" + struct TextureLoadingVertexStructure