update GPUselection
parent
dfeca1b376
commit
c609c5a354
|
@ -481,24 +481,12 @@ void VulkanExampleBase::initVulkan()
|
||||||
std::cerr << "Could not enumerate physical devices!" << std::endl;
|
std::cerr << "Could not enumerate physical devices!" << std::endl;
|
||||||
exit(err);
|
exit(err);
|
||||||
}
|
}
|
||||||
uint32_t selectedDevice = 0;
|
uint32_t selectedDevice = settings.selectedPhysicalDeviceIndex;
|
||||||
#if !defined(VK_USE_PLATFORM_ANDROID_KHR)
|
if (settings.selectedPhysicalDeviceIndex > gpuCount)
|
||||||
for (size_t i = 0; i < args.size(); i++) {
|
{
|
||||||
if ((args[i] == std::string("-g")) || (args[i] == std::string("--gpu"))) {
|
std::cerr << "wrong GPU selection,check selectedPhysicalDeviceIndex in config file,fallback to 0" << std::endl;
|
||||||
char* endptr;
|
selectedDevice = 0;
|
||||||
selectedPhysicalDeviceIndex = strtol(args[i + 1], &endptr, 10);
|
|
||||||
if (endptr != args[i + 1]) {
|
|
||||||
if (selectedPhysicalDeviceIndex > gpuCount - 1) {
|
|
||||||
std::cerr << "Selected device index " << selectedPhysicalDeviceIndex << " is out of range, reverting to device 0 (use -listgpus to show available Vulkan devices)" << std::endl;
|
|
||||||
} else {
|
|
||||||
std::cout << "Selected Vulkan device " << selectedPhysicalDeviceIndex << std::endl;
|
|
||||||
selectedDevice = selectedPhysicalDeviceIndex;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
physicalDevice = physicalDevices[selectedDevice];
|
physicalDevice = physicalDevices[selectedDevice];
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ protected:
|
||||||
//void windowResize();
|
//void windowResize();
|
||||||
public:
|
public:
|
||||||
static std::vector<const char*> args;
|
static std::vector<const char*> args;
|
||||||
uint32_t selectedPhysicalDeviceIndex = 0;
|
|
||||||
bool prepared = false;
|
bool prepared = false;
|
||||||
uint32_t width = 1280;
|
uint32_t width = 1280;
|
||||||
uint32_t height = 720;
|
uint32_t height = 720;
|
||||||
|
@ -102,6 +102,7 @@ public:
|
||||||
}signal;
|
}signal;
|
||||||
|
|
||||||
struct Settings {
|
struct Settings {
|
||||||
|
uint32_t selectedPhysicalDeviceIndex = 7;
|
||||||
bool validation = true; // 校验层开关
|
bool validation = true; // 校验层开关
|
||||||
bool fullscreen = false; // 全屏开关
|
bool fullscreen = false; // 全屏开关
|
||||||
bool vsync = false; // 垂直同步开关
|
bool vsync = false; // 垂直同步开关
|
||||||
|
|
Loading…
Reference in New Issue