Skip to content

Commit 95f4f39

Browse files
vkconfig: Refactor layers tab and improve UI consistency
1 parent 02acf73 commit 95f4f39

37 files changed

Lines changed: 2205 additions & 2034 deletions

vkconfig_cmd/main_layers.cpp

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -87,22 +87,21 @@ static int RunLayersSurrender(Configurator& configurator, const CommandLine& com
8787
}
8888

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

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

97-
if (paths.empty()) {
98-
printf(" - None\n");
99-
} else {
100-
for (std::size_t i = 0, n = paths.size(); i < n; ++i) {
101-
if (paths[i].enabled) {
102-
printf(" - %s\n", paths[i].path.AbsolutePath().c_str());
103-
}
104-
}
94+
for (auto it = layer_display_list.begin(), end = layer_display_list.end(); it != end; ++it) {
95+
const Layer* layer = configurator.layers.FindFromManifest(it->manifest_path, true);
96+
if (layer == nullptr) {
97+
continue;
10598
}
99+
100+
const std::string status = layer->status == STATUS_STABLE ? "" : format(" (%s)", ::GetToken(layer->status));
101+
const std::string text = format("%s - %s%s, %s layer", layer->key.c_str(), layer->api_version.str().c_str(), status.c_str(),
102+
::GetToken(layer->type));
103+
104+
printf(" - %s\n", text.c_str());
106105
}
107106

108107
return 0;

vkconfig_core/configuration.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ bool Configuration::Load(const Path& full_path, const LayerManager& layers) {
173173

174174
if (layer != nullptr) {
175175
parameter.manifest = layer->manifest_path;
176-
parameter.type = layer->type;
176+
// parameter.type = layer->type;
177177
}
178178

179179
if (parameter.api_version != Version::LATEST) {

vkconfig_core/json.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@
2525

2626
#include <cassert>
2727

28-
QJsonDocument ParseJsonFile(const char* file) {
29-
QFile file_schema(file);
30-
const bool result = file_schema.open(QIODevice::ReadOnly | QIODevice::Text);
28+
QJsonDocument ParseJsonFile(const char* path) {
29+
QFile file(path);
30+
const bool result = file.open(QIODevice::ReadOnly | QIODevice::Text);
3131
if (result) {
32-
const QString& data = file_schema.readAll();
33-
file_schema.close();
32+
const QString& data = file.readAll();
33+
file.close();
3434

3535
QJsonParseError json_parse_error;
3636
const QJsonDocument& json_document = QJsonDocument::fromJson(data.toUtf8(), &json_parse_error);

vkconfig_core/layer.cpp

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,9 @@
4949
#include <string>
5050
#include <algorithm>
5151

52-
bool operator<(const LayersPathInfo& a, const LayersPathInfo& b) { return a.path.RelativePath() < b.path.RelativePath(); }
53-
54-
bool Found(const std::vector<LayersPathInfo>& data, const Path& path) {
52+
bool Found(const std::vector<Path>& data, const Path& path) {
5553
for (std::size_t i = 0, n = data.size(); i < n; ++i) {
56-
if (data[i].path == path) {
54+
if (data[i] == path) {
5755
return true;
5856
}
5957
}
@@ -179,7 +177,7 @@ void Layer::FillPresetSettings(SettingDataSet& settings_data, const std::vector<
179177
}
180178

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

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

200-
auto it = layers_found.find(full_path_to_file.AbsolutePath().c_str());
201-
if (it != layers_found.end()) {
202-
if (it->second.disabled && it->second.last_modified == this->last_modified) {
203-
return LAYER_LOAD_FAILED;
204-
}
205-
}
206-
207198
// Convert the text to a JSON document & validate it.
208199
// It does need to be a valid json formatted file.
209200
QJsonParseError json_parse_error;
@@ -252,20 +243,15 @@ LayerLoadStatus Layer::Load(const Path& full_path_to_file, LayerType type, bool
252243

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

255-
if (this->key == "VK_LAYER_LUNARG_override") {
246+
if (this->key == "VK_LAYER_LUNARG_override" || !(this->key.rfind("VK_", 0) == 0)) {
256247
return LAYER_LOAD_IGNORED;
257248
}
258249

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

261252
JsonValidator validator;
262253

263-
std::string cached_last_modified;
264-
if (it != layers_found.end()) {
265-
cached_last_modified = it->second.last_modified;
266-
}
267-
const bool should_validate = request_validate_manifest && ((last_modified != cached_last_modified) || !it->second.validated);
268-
const bool is_valid = should_validate ? validator.Check(json_text) : true;
254+
const bool is_valid = request_validate_manifest ? validator.Check(json_text) : true;
269255

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

396+
bool operator<(const Layer& layer_a, const Layer& layer_b) {
397+
if (layer_a.key == layer_b.key) {
398+
return layer_a.api_version < layer_b.api_version;
399+
} else {
400+
return layer_a.key < layer_b.key;
401+
}
402+
}
403+
410404
void CollectDefaultSettingData(const SettingMetaSet& meta_set, SettingDataSet& data_set) {
411405
for (std::size_t i = 0, n = meta_set.size(); i < n; ++i) {
412406
SettingMeta* setting_meta = meta_set[i];

vkconfig_core/layer.h

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,15 @@
3636
#include <vector>
3737
#include <string>
3838

39-
struct LayerStatus {
39+
struct LayerDescriptor {
40+
LayerType type = LAYER_TYPE_EXPLICIT;
4041
std::string last_modified;
4142
bool validated = false;
42-
bool disabled = false;
43-
};
44-
45-
struct LayersPathInfo {
46-
Path path;
47-
LayerType type = LAYER_TYPE_EXPLICIT;
4843
bool enabled = true;
44+
bool added = false;
4945
};
5046

51-
bool operator<(const LayersPathInfo& a, const LayersPathInfo& b);
52-
53-
bool Found(const std::vector<LayersPathInfo>& data, const Path& path);
47+
bool Found(const std::vector<Path>& data, const Path& path);
5448

5549
enum LayerLoadStatus {
5650
LAYER_LOAD_ADDED = 0,
@@ -64,8 +58,8 @@ enum LayerLoadStatus {
6458
LAYER_LOAD_LAST = LAYER_LOAD_IGNORED,
6559
};
6660

67-
inline bool IsDisabled(LayerLoadStatus status) {
68-
return status == LAYER_LOAD_FAILED || status == LAYER_LOAD_INVALID || status == LAYER_LOAD_IGNORED;
61+
inline bool IsEnabled(LayerLoadStatus status) {
62+
return !(status == LAYER_LOAD_FAILED || status == LAYER_LOAD_INVALID || status == LAYER_LOAD_IGNORED);
6963
}
7064

7165
enum { LAYER_LOAD_COUNT = LAYER_LOAD_LAST - LAYER_LOAD_FIRST + 1 };
@@ -115,18 +109,19 @@ class Layer {
115109
std::string enable_env;
116110
std::string enable_value;
117111
bool is_32bits = false;
118-
bool enabled = true;
119112

120113
std::vector<SettingMeta*> settings;
121114
std::vector<LayerPreset> presets;
122115

123116
LayerLoadStatus Load(const Path& full_path_to_file, LayerType type, bool request_validate_manifest,
124-
const std::map<Path, LayerStatus>& layers_found, ConfiguratorMode configurator_mode);
117+
ConfiguratorMode configurator_mode);
125118

126119
private:
127120
Layer& operator=(const Layer&) = delete;
128121

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

125+
bool operator<(const Layer& layer_a, const Layer& layer_b);
126+
132127
void CollectDefaultSettingData(const SettingMetaSet& meta_set, SettingDataSet& data_set);

0 commit comments

Comments
 (0)