Fix : Added prerequisite checks for using VK_Layer_Validation #105922

Merged
Jeroen Bakker merged 16 commits from :vk_debug_break_down into main 2023-03-28 10:45:56 +02:00
1 changed files with 10 additions and 28 deletions
Showing only changes of commit 91b662925b - Show all commits

View File

@ -18,13 +18,11 @@
#endif #endif
#include <vector> #include <vector>
#include <sys/stat.h>
#include <cassert> #include <cassert>
vnapdv marked this conversation as resolved
Review

Please run make format when push and configure clang-format to your IDE. This file has several issues where it doesn't match our code style.

Please run make format when push and configure clang-format to your IDE. This file has several issues where it doesn't match our code style.
Review

Please run make format when push and configure clang-format to your IDE. This file has several issues where it doesn't match our code style.

I checked blender's clang-format. It seems that there was a slight conflict in the settings of visual studio. I will make sure to check again with visual code.

> Please run make format when push and configure clang-format to your IDE. This file has several issues where it doesn't match our code style. I checked blender's clang-format. It seems that there was a slight conflict in the settings of visual studio. I will make sure to check again with visual code.
#include <cstdio> #include <cstdio>
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
#include <sstream>
vnapdv marked this conversation as resolved Outdated

System includes should use <>

System includes should use `<>`
/* Set to 0 to allow devices that do not have the required features. /* Set to 0 to allow devices that do not have the required features.
* This allows development on OSX until we really needs these features. */ * This allows development on OSX until we really needs these features. */
@ -81,18 +79,6 @@ static const char *vulkan_error_as_string(VkResult result)
return "Unknown Error"; return "Unknown Error";
} }
} }
static bool vklayer_config_exist(const char* vk_extension_config)
{
const char *ev_val = getenv("VK_LAYER_PATH");
if (ev_val == nullptr) {
return false;
}
std::stringstream filename;
filename << ev_val;
filename << "/" << vk_extension_config;
struct stat buffer;
return (stat(filename.str().c_str(), &buffer) == 0);
}
vnapdv marked this conversation as resolved Outdated

vklayer_config_exists might be a better name.

`vklayer_config_exists` might be a better name.
#define __STR(A) "" #A #define __STR(A) "" #A
#define VK_CHECK(__expression) \ #define VK_CHECK(__expression) \
@ -415,20 +401,16 @@ static bool checkLayerSupport(vector<VkLayerProperties> &layers_available, const
static void enableLayer(vector<VkLayerProperties> &layers_available, static void enableLayer(vector<VkLayerProperties> &layers_available,
vector<const char *> &layers_enabled, vector<const char *> &layers_enabled,
const char* layer_name, const char *layer_name,
const bool warning) const bool debug)
{ {
if (checkLayerSupport(layers_available, layer_name)) {
if (strcmp(layer_name, "VK_LAYER_KHRONOS_validation") == 0) { layers_enabled.push_back(layer_name);
if (checkLayerSupport(layers_available, layer_name) && }
vklayer_config_exist("VkLayer_khronos_validation.json")) { else if (debug) {
layers_enabled.push_back(layer_name); fprintf(
} stderr, "Warning: Layer requested, but not supported by the platform. [%s]\n", layer_name);
else if (warning) {
fprintf(stderr,"Warning: Layer requested, but not supported by the platform. [%s]\n",layer_name);
}
} }
} }
static bool device_extensions_support(VkPhysicalDevice device, vector<const char *> required_exts) static bool device_extensions_support(VkPhysicalDevice device, vector<const char *> required_exts)
@ -882,7 +864,7 @@ GHOST_TSuccess GHOST_ContextVK::initializeDrawingContext()
vector<const char *> layers_enabled; vector<const char *> layers_enabled;
if (m_debug) { if (m_debug) {
enableLayer(layers_available, layers_enabled, "VK_LAYER_KHRONOS_validation",true); enableLayer(layers_available, layers_enabled, "VK_LAYER_KHRONOS_validation", m_debug);
} }
vector<const char *> extensions_device; vector<const char *> extensions_device;