Skip to content

Commit

Permalink
vkconfig: Allow removing missing layers from configuration
Browse files Browse the repository at this point in the history
Change-Id: I0d6d0fe8cecef6f1e1a474a88dbf6c1ad6963998
  • Loading branch information
christophe-lunarg committed Feb 6, 2025
1 parent a15ec3f commit 4a6ec4d
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 7 deletions.
19 changes: 18 additions & 1 deletion vkconfig_core/configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,23 @@ bool Configuration::HasMissingLayer(const LayerManager& layers, std::vector<std:
return !missing_layers.empty();
}

void Configuration::RemoveParameter(const std::string& layer_key) {
std::vector<Parameter> updated_parameters;

for (std::size_t i = 0, n = parameters.size(); i < n; ++i) {
const Parameter& parameter = parameters[i];
assert(!parameter.key.empty());

if (parameter.key == layer_key) {
continue;
}

updated_parameters.push_back(parameter);
}

std::swap(this->parameters, updated_parameters);
}

void Configuration::SwitchLayerVersion(const LayerManager& layers, const std::string& layer_key, const Path& manifest_path) {
if (manifest_path.Empty()) {
this->SwitchLayerLatest(layers, layer_key);
Expand Down Expand Up @@ -512,7 +529,7 @@ void Configuration::GatherParameters(const LayerManager& layers) {

::OrderParameter(gathered_parameters, layers);

this->parameters = gathered_parameters;
std::swap(this->parameters, gathered_parameters);
}

void Configuration::Reorder(const std::vector<std::string>& layer_names) {
Expand Down
1 change: 1 addition & 0 deletions vkconfig_core/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class Configuration {
const Parameter* GetActiveParameter() const;

bool HasMissingLayer(const LayerManager& layers, std::vector<std::string>& missing_layers) const;
void RemoveParameter(const std::string& layer_key);
void SwitchLayerVersion(const LayerManager& layers, const std::string& layer_key, const Path& manifest_path);
void SwitchLayerLatest(const LayerManager& layers, const std::string& layer_key);
void GatherParameters(const LayerManager& layers);
Expand Down
3 changes: 3 additions & 0 deletions vkconfig_gui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

### Features:
- Add dark mode support, automatically matching the OS mode
- Add button to remove missing layers

---
## Vulkan Configurator 3.0.0 - February 2025
[Vulkan SDK 1.4.304.1](https://github.com/LunarG/VulkanTools/tree/vulkan-sdk-1.4.304.1)

Expand Down Expand Up @@ -38,6 +40,7 @@
### Deprecation:
- Requires Vulkan Loader 1.4.304 or newer

---
## Vulkan Configurator 2.6.3 - January 2025
[Vulkan SDK 1.4.304.0](https://github.com/LunarG/VulkanTools/tree/vulkan-sdk-1.4.304.0)
- Final build
Expand Down
49 changes: 43 additions & 6 deletions vkconfig_gui/widget_tab_configurations_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "widget_tab_configurations_layer.h"
#include "widget_setting.h"
#include "tab_configurations.h"
#include "widget_resize_button.h"
#include "combo_box.h"

#include "../vkconfig_core/configurator.h"
Expand All @@ -33,6 +34,12 @@ ConfigurationLayerWidget::ConfigurationLayerWidget(TabConfigurations *tab, const
const Layer *layer = configurator.layers.Find(parameter.key, parameter.api_version);

this->layer_state = new ComboBox(this);
this->layer_remove = new ResizeButton(this, 0);
this->layer_remove->setMaximumWidth(32);
this->layer_remove->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
this->layer_remove->adjustSize();
this->layer_remove->setText("X");
this->connect(this->layer_remove, SIGNAL(clicked()), this, SLOT(on_layer_remove_pressed()));

const int first = parameter.builtin == LAYER_BUILTIN_UNORDERED ? LAYER_CONTROL_UNORDERED_FIRST : LAYER_CONTROL_FIRST;
const int last = parameter.builtin == LAYER_BUILTIN_UNORDERED ? LAYER_CONTROL_UNORDERED_LAST : LAYER_CONTROL_LAST;
Expand Down Expand Up @@ -60,7 +67,7 @@ ConfigurationLayerWidget::ConfigurationLayerWidget(TabConfigurations *tab, const
this->connect(this->layer_state, SIGNAL(currentIndexChanged(int)), this, SLOT(on_layer_state_currentIndexChanged(int)));

const bool layer_found = layer != nullptr || parameter.builtin != LAYER_BUILTIN_NONE;
this->setEnabled(layer_found);
// this->setEnabled(layer_found);

std::string decorated_name = parameter.key;

Expand All @@ -70,9 +77,16 @@ ConfigurationLayerWidget::ConfigurationLayerWidget(TabConfigurations *tab, const
if (layer->status != STATUS_STABLE) {
decorated_name += format(" (%s)", GetToken(layer->status));
}
this->layer_remove->setVisible(false);
} else if (!layer_found) {
decorated_name += " - Missing";
this->layer_state->setVisible(false);
this->layer_state->setToolTip("Remove the layer from the configuration");
}
if (parameter.builtin == LAYER_BUILTIN_UNORDERED) {
this->layer_remove->setVisible(false);
}

/*
if (layer_versions.empty()) {
// A layers configuration may have excluded layer that are misssing because they are not available on this platform
Expand Down Expand Up @@ -112,16 +126,39 @@ void ConfigurationLayerWidget::resizeEvent(QResizeEvent *event) {
QSize size = event->size();

if (this->layer_state != nullptr) {
this->layer_state->adjustSize();
if (this->layer_state->isVisible()) {
this->layer_state->adjustSize();

const int width_state = this->layer_state->width();
const int height_state = this->layer_state->height();

const QRect state_button_rect = QRect(size.width() - width_state, 0, width_state, height_state);
this->layer_state->setGeometry(state_button_rect);
}
}

if (this->layer_remove != nullptr) {
if (this->layer_remove->isVisible()) {
this->layer_remove->adjustSize();

const int width_state = this->layer_state->width();
const int height_state = this->layer_state->height();
const int width_state = this->layer_remove->width();
const int height_state = this->layer_remove->height();

const QRect state_button_rect = QRect(size.width() - width_state, 0, width_state, height_state);
this->layer_state->setGeometry(state_button_rect);
const QRect state_button_rect = QRect(size.width() - width_state, 0, width_state, height_state);
this->layer_remove->setGeometry(state_button_rect);
}
}
}

void ConfigurationLayerWidget::on_layer_remove_pressed() {
Configurator &configurator = Configurator::Get();

Configuration *configuration = configurator.GetActiveConfiguration();
configuration->RemoveParameter(this->layer_name);

tab->UpdateUI(UPDATE_REBUILD_UI);
}

void ConfigurationLayerWidget::on_layer_state_currentIndexChanged(int index) {
assert(index >= 0);
const LayerControl control = static_cast<LayerControl>(index);
Expand Down
5 changes: 5 additions & 0 deletions vkconfig_gui/widget_tab_configurations_layer.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,14 @@ class ConfigurationLayerWidget : public QLabel {

public Q_SLOTS:
void on_layer_state_currentIndexChanged(int index);
void on_layer_remove_pressed();

Q_SIGNALS:
void itemChanged();

private:
TabConfigurations *tab;

QComboBox *layer_state = nullptr;
QPushButton *layer_remove = nullptr;
};

0 comments on commit 4a6ec4d

Please sign in to comment.