Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 12 additions & 13 deletions vkconfig_cmd/main_layers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,22 +87,21 @@ static int RunLayersSurrender(Configurator& configurator, const CommandLine& com
}

static int RunLayersPath(Configurator& configurator, const CommandLine& command_line) {
printf("vkconfig: [INFO] Paths to find Vulkan Layers\n");
printf("vkconfig: [INFO] Vulkan Layers paths:\n");

for (int layers_paths_index = 0, layers_paths_count = LAYERS_PATHS_COUNT; layers_paths_index < layers_paths_count;
++layers_paths_index) {
const std::vector<LayersPathInfo>& paths = configurator.layers.paths[layers_paths_index];
printf("\n%s:\n", GetLabel(static_cast<LayersPaths>(layers_paths_index)));
const std::set<LayerDisplay>& layer_display_list = configurator.layers.BuildLayerDisplayList();

if (paths.empty()) {
printf(" - None\n");
} else {
for (std::size_t i = 0, n = paths.size(); i < n; ++i) {
if (paths[i].enabled) {
printf(" - %s\n", paths[i].path.AbsolutePath().c_str());
}
}
for (auto it = layer_display_list.begin(), end = layer_display_list.end(); it != end; ++it) {
const Layer* layer = configurator.layers.FindFromManifest(it->manifest_path, true);
if (layer == nullptr) {
continue;
}

const std::string status = layer->status == STATUS_STABLE ? "" : format(" (%s)", ::GetToken(layer->status));
const std::string text = format("%s - %s%s, %s layer", layer->key.c_str(), layer->api_version.str().c_str(), status.c_str(),
::GetToken(layer->type));

printf(" - %s\n", text.c_str());
}

return 0;
Expand Down
2 changes: 1 addition & 1 deletion vkconfig_core/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ bool Configuration::Load(const Path& full_path, const LayerManager& layers) {

if (layer != nullptr) {
parameter.manifest = layer->manifest_path;
parameter.type = layer->type;
// parameter.type = layer->type;
}

if (parameter.api_version != Version::LATEST) {
Expand Down
10 changes: 5 additions & 5 deletions vkconfig_core/json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@

#include <cassert>

QJsonDocument ParseJsonFile(const char* file) {
QFile file_schema(file);
const bool result = file_schema.open(QIODevice::ReadOnly | QIODevice::Text);
QJsonDocument ParseJsonFile(const char* path) {
QFile file(path);
const bool result = file.open(QIODevice::ReadOnly | QIODevice::Text);
if (result) {
const QString& data = file_schema.readAll();
file_schema.close();
const QString& data = file.readAll();
file.close();

QJsonParseError json_parse_error;
const QJsonDocument& json_document = QJsonDocument::fromJson(data.toUtf8(), &json_parse_error);
Expand Down
32 changes: 13 additions & 19 deletions vkconfig_core/layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,9 @@
#include <string>
#include <algorithm>

bool operator<(const LayersPathInfo& a, const LayersPathInfo& b) { return a.path.RelativePath() < b.path.RelativePath(); }

bool Found(const std::vector<LayersPathInfo>& data, const Path& path) {
bool Found(const std::vector<Path>& data, const Path& path) {
for (std::size_t i = 0, n = data.size(); i < n; ++i) {
if (data[i].path == path) {
if (data[i] == path) {
return true;
}
}
Expand Down Expand Up @@ -179,7 +177,7 @@ void Layer::FillPresetSettings(SettingDataSet& settings_data, const std::vector<
}

LayerLoadStatus Layer::Load(const Path& full_path_to_file, LayerType type, bool request_validate_manifest,
const std::map<Path, LayerStatus>& layers_found, ConfiguratorMode configurator_mode) {
ConfiguratorMode configurator_mode) {
this->type = type; // Set layer type, no way to know this from the json file

if (full_path_to_file.Empty()) {
Expand All @@ -197,13 +195,6 @@ LayerLoadStatus Layer::Load(const Path& full_path_to_file, LayerType type, bool
this->manifest_path = full_path_to_file;
this->last_modified = full_path_to_file.LastModified();

auto it = layers_found.find(full_path_to_file.AbsolutePath().c_str());
if (it != layers_found.end()) {
if (it->second.disabled && it->second.last_modified == this->last_modified) {
return LAYER_LOAD_FAILED;
}
}

// Convert the text to a JSON document & validate it.
// It does need to be a valid json formatted file.
QJsonParseError json_parse_error;
Expand Down Expand Up @@ -252,20 +243,15 @@ LayerLoadStatus Layer::Load(const Path& full_path_to_file, LayerType type, bool

this->key = ReadStringValue(json_layer_object, "name");

if (this->key == "VK_LAYER_LUNARG_override") {
if (this->key == "VK_LAYER_LUNARG_override" || !(this->key.rfind("VK_", 0) == 0)) {
return LAYER_LOAD_IGNORED;
}

this->api_version = ReadVersionValue(json_layer_object, "api_version");

JsonValidator validator;

std::string cached_last_modified;
if (it != layers_found.end()) {
cached_last_modified = it->second.last_modified;
}
const bool should_validate = request_validate_manifest && ((last_modified != cached_last_modified) || !it->second.validated);
const bool is_valid = should_validate ? validator.Check(json_text) : true;
const bool is_valid = request_validate_manifest ? validator.Check(json_text) : true;

if (!is_valid) {
switch (configurator_mode) {
Expand Down Expand Up @@ -407,6 +393,14 @@ LayerLoadStatus Layer::Load(const Path& full_path_to_file, LayerType type, bool
return this->IsValid() ? LAYER_LOAD_ADDED : LAYER_LOAD_INVALID; // Not all JSON file are layer JSON valid
}

bool operator<(const Layer& layer_a, const Layer& layer_b) {
if (layer_a.key == layer_b.key) {
return layer_a.api_version < layer_b.api_version;
} else {
return layer_a.key < layer_b.key;
}
}

void CollectDefaultSettingData(const SettingMetaSet& meta_set, SettingDataSet& data_set) {
for (std::size_t i = 0, n = meta_set.size(); i < n; ++i) {
SettingMeta* setting_meta = meta_set[i];
Expand Down
23 changes: 9 additions & 14 deletions vkconfig_core/layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,15 @@
#include <vector>
#include <string>

struct LayerStatus {
struct LayerDescriptor {
LayerType type = LAYER_TYPE_EXPLICIT;
std::string last_modified;
bool validated = false;
bool disabled = false;
};

struct LayersPathInfo {
Path path;
LayerType type = LAYER_TYPE_EXPLICIT;
bool enabled = true;
bool added = false;
};

bool operator<(const LayersPathInfo& a, const LayersPathInfo& b);

bool Found(const std::vector<LayersPathInfo>& data, const Path& path);
bool Found(const std::vector<Path>& data, const Path& path);

enum LayerLoadStatus {
LAYER_LOAD_ADDED = 0,
Expand All @@ -64,8 +58,8 @@ enum LayerLoadStatus {
LAYER_LOAD_LAST = LAYER_LOAD_IGNORED,
};

inline bool IsDisabled(LayerLoadStatus status) {
return status == LAYER_LOAD_FAILED || status == LAYER_LOAD_INVALID || status == LAYER_LOAD_IGNORED;
inline bool IsEnabled(LayerLoadStatus status) {
return !(status == LAYER_LOAD_FAILED || status == LAYER_LOAD_INVALID || status == LAYER_LOAD_IGNORED);
}

enum { LAYER_LOAD_COUNT = LAYER_LOAD_LAST - LAYER_LOAD_FIRST + 1 };
Expand Down Expand Up @@ -115,18 +109,19 @@ class Layer {
std::string enable_env;
std::string enable_value;
bool is_32bits = false;
bool enabled = true;

std::vector<SettingMeta*> settings;
std::vector<LayerPreset> presets;

LayerLoadStatus Load(const Path& full_path_to_file, LayerType type, bool request_validate_manifest,
const std::map<Path, LayerStatus>& layers_found, ConfiguratorMode configurator_mode);
ConfiguratorMode configurator_mode);

private:
Layer& operator=(const Layer&) = delete;

std::vector<std::shared_ptr<SettingMeta> > memory; // Settings are deleted when all layers instances are deleted.
};

bool operator<(const Layer& layer_a, const Layer& layer_b);

void CollectDefaultSettingData(const SettingMetaSet& meta_set, SettingDataSet& data_set);
Loading
Loading