想手动创建 device 失败

This commit is contained in:
xsl
2025-10-19 17:07:49 +08:00
parent 2284911161
commit 572c53c0f4
3 changed files with 14 additions and 10 deletions
+2
View File
@@ -178,6 +178,8 @@ void Application::createLogicalDevice() {
throw std::runtime_error("failed to create logical device!"); throw std::runtime_error("failed to create logical device!");
} }
v_device = std::make_unique<vkb::core::DeviceC>(v_gpu, device, surface);
vkGetDeviceQueue(device, indices.graphicsFamily.value(), 0, &graphicsQueue); vkGetDeviceQueue(device, indices.graphicsFamily.value(), 0, &graphicsQueue);
vkGetDeviceQueue(device, indices.presentFamily.value(), 0, &presentQueue); vkGetDeviceQueue(device, indices.presentFamily.value(), 0, &presentQueue);
} }
+2
View File
@@ -47,6 +47,8 @@ public:
bool isInited() { return inited; } bool isInited() { return inited; }
protected: protected:
std::unique_ptr< vkb::core::InstanceC> v_instance;
std::unique_ptr<vkb::PhysicalDevice> v_gpu;
std::unique_ptr<vkb::core::DeviceC> v_device; std::unique_ptr<vkb::core::DeviceC> v_device;
VkPhysicalDevice physicalDevice = VK_NULL_HANDLE; // 物理设备 VkPhysicalDevice physicalDevice = VK_NULL_HANDLE; // 物理设备
VkDevice device; // 逻辑设备 VkDevice device; // 逻辑设备
+10 -10
View File
@@ -18,20 +18,20 @@ void FaceApp::initVulkan()
void FaceApp::generate_quad() void FaceApp::generate_quad()
{ {
std::vector<TextureLoadingVertexStructure>& vertices = obj_vertices; //std::vector<TextureLoadingVertexStructure>& vertices = obj_vertices;
std::vector<uint32_t> indices = obj_indices; //std::vector<uint32_t> indices = obj_indices;
index_count = static_cast<uint32_t>(indices.size()); //index_count = static_cast<uint32_t>(indices.size());
auto vertex_buffer_size = vkb::to_u32(vertices.size() * sizeof(TextureLoadingVertexStructure)); //auto vertex_buffer_size = vkb::to_u32(vertices.size() * sizeof(TextureLoadingVertexStructure));
auto index_buffer_size = vkb::to_u32(indices.size() * sizeof(uint32_t)); //auto index_buffer_size = vkb::to_u32(indices.size() * sizeof(uint32_t));
vkb::core::DeviceC& cDevice = reinterpret_cast<vkb::core::DeviceC&>(*v_device); //vkb::core::DeviceC& cDevice = reinterpret_cast<vkb::core::DeviceC&>(*v_device);
auto vertex_buffer = std::make_unique<vkb::core::BufferC>(cDevice, vertex_buffer_size,VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_VERTEX_BUFFER_BIT,VMA_MEMORY_USAGE_CPU_TO_GPU); //auto vertex_buffer = std::make_unique<vkb::core::BufferC>(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); //vertex_buffer->update(vertices.data(), vertex_buffer_size);
index_buffer = std::make_unique<vkb::core::BufferC>(cDevice,index_buffer_size,VK_BUFFER_USAGE_TRANSFER_DST_BIT | VK_BUFFER_USAGE_INDEX_BUFFER_BIT,VMA_MEMORY_USAGE_CPU_TO_GPU); //index_buffer = std::make_unique<vkb::core::BufferC>(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); //index_buffer->update(indices.data(), index_buffer_size);
} }