android 表面,扩展,实例都创建成功
This commit is contained in:
+27
-1
@@ -1,4 +1,11 @@
|
||||
#include "AppBase.h"
|
||||
#include <assert.h>
|
||||
|
||||
|
||||
void VK_CHECK(VkResult ret)
|
||||
{
|
||||
assert(ret == VK_SUCCESS);
|
||||
}
|
||||
|
||||
std::vector<char> AppBase::readFile(const std::string& enginePath)
|
||||
{
|
||||
@@ -55,6 +62,18 @@ bool AppBase::checkValidationLayerSupport() {
|
||||
return true;
|
||||
}
|
||||
|
||||
void checkInstanceExtensions() {
|
||||
uint32_t extensionCount = 0;
|
||||
vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);
|
||||
|
||||
std::vector<VkExtensionProperties> extensions(extensionCount);
|
||||
vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, extensions.data());
|
||||
|
||||
logOut << "Android Available instance extensions:" << std::endl;
|
||||
for (const auto& extension : extensions) {
|
||||
logOut << "ExtensionName:" << extension.extensionName << " Version:" << extension.specVersion << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void AppBase::createInstance()
|
||||
{
|
||||
@@ -84,7 +103,14 @@ void AppBase::createInstance()
|
||||
for(int i = 0; i < glfwExtensionCount; i++) {
|
||||
extensions.push_back(glfwExtensions[i]);
|
||||
}
|
||||
#else
|
||||
checkInstanceExtensions();
|
||||
// Android: 手动添加必要的扩展
|
||||
extensions.push_back(VK_KHR_SURFACE_EXTENSION_NAME);
|
||||
extensions.push_back(VK_KHR_ANDROID_SURFACE_EXTENSION_NAME);
|
||||
|
||||
// 可选:添加这些扩展以获得更好的兼容性
|
||||
extensions.push_back(VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
|
||||
#endif
|
||||
|
||||
if (enableValidationLayers) {
|
||||
@@ -160,7 +186,7 @@ QueueFamilyIndices AppBase::findQueueFamilies(VkPhysicalDevice device, VkSurface
|
||||
indices.graphicsFamily = i;
|
||||
}
|
||||
VkBool32 presentSupport = false;
|
||||
vkGetPhysicalDeviceSurfaceSupportKHR(device, i, surface, &presentSupport);
|
||||
VK_CHECK(vkGetPhysicalDeviceSurfaceSupportKHR(device, i, surface, &presentSupport));
|
||||
if (presentSupport) {
|
||||
indices.presentFamily = i;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user