Sligthly rework validation layer logging to tet file

This commit is contained in:
Sascha Willems 2025-06-16 22:34:21 +02:00
parent 2e6bf58914
commit d34494602c
10 changed files with 47 additions and 26 deletions

View file

@ -802,7 +802,7 @@ VulkanExampleBase::VulkanExampleBase()
// Command line arguments
commandLineParser.add("help", { "--help" }, 0, "Show help");
commandLineParser.add("validation", { "-v", "--validation" }, 0, "Enable validation layers");
commandLineParser.add("validationlog", { "-vl", "--validationlog" }, 0, "Log validation messages to a textfile (validation.txt)");
commandLineParser.add("validationlogfile", { "-vl", "--validationlogfile" }, 0, "Log validation messages to a textfile");
commandLineParser.add("vsync", { "-vs", "--vsync" }, 0, "Enable V-Sync");
commandLineParser.add("fullscreen", { "-f", "--fullscreen" }, 0, "Start in fullscreen mode");
commandLineParser.add("width", { "-w", "--width" }, 1, "Set window width");
@ -831,12 +831,8 @@ VulkanExampleBase::VulkanExampleBase()
if (commandLineParser.isSet("validation")) {
settings.validation = true;
}
if (commandLineParser.isSet("validationlog")) {
if (commandLineParser.isSet("validationlogfile")) {
vks::debug::logToFile = true;
std::ofstream logfile;
logfile.open("validation.txt", std::ios_base::app);
logfile << std::endl << "Sample: " << name << std::endl;
logfile.close();
}
if (commandLineParser.isSet("vsync")) {
settings.vsync = true;
@ -1034,6 +1030,11 @@ bool VulkanExampleBase::initVulkan()
this->settings.validation = true;
#endif
// Validation messages can be stored, e.g. to be used in external tools like CI/CD
if (commandLineParser.isSet("validationlogfile")) {
vks::debug::log("Sample: " + title);
}
// Create the instance
VkResult result = createInstance();
if (result != VK_SUCCESS) {