mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-01-01 12:46:01 +00:00
Fix initialization of change_layers (#907)
This commit is contained in:
parent
c924457e28
commit
1ea6db6045
|
@ -21,7 +21,12 @@ static std::vector<ImGui::Layer*> layers;
|
||||||
// Update layers before rendering to allow layer changes to be applied during rendering.
|
// Update layers before rendering to allow layer changes to be applied during rendering.
|
||||||
// Using deque to keep the order of changes in case a Layer is removed then added again between
|
// Using deque to keep the order of changes in case a Layer is removed then added again between
|
||||||
// frames.
|
// frames.
|
||||||
static std::deque<std::pair<bool, ImGui::Layer*>> change_layers;
|
std::deque<std::pair<bool, ImGui::Layer*>>& GetChangeLayers() {
|
||||||
|
static std::deque<std::pair<bool, ImGui::Layer*>>* change_layers =
|
||||||
|
new std::deque<std::pair<bool, ImGui::Layer*>>;
|
||||||
|
return *change_layers;
|
||||||
|
}
|
||||||
|
|
||||||
static std::mutex change_layers_mutex{};
|
static std::mutex change_layers_mutex{};
|
||||||
|
|
||||||
namespace ImGui {
|
namespace ImGui {
|
||||||
|
@ -113,15 +118,15 @@ bool ProcessEvent(SDL_Event* event) {
|
||||||
void NewFrame() {
|
void NewFrame() {
|
||||||
{
|
{
|
||||||
std::scoped_lock lock{change_layers_mutex};
|
std::scoped_lock lock{change_layers_mutex};
|
||||||
while (!change_layers.empty()) {
|
while (!GetChangeLayers().empty()) {
|
||||||
const auto [to_be_added, layer] = change_layers.front();
|
const auto [to_be_added, layer] = GetChangeLayers().front();
|
||||||
if (to_be_added) {
|
if (to_be_added) {
|
||||||
layers.push_back(layer);
|
layers.push_back(layer);
|
||||||
} else {
|
} else {
|
||||||
const auto [begin, end] = std::ranges::remove(layers, layer);
|
const auto [begin, end] = std::ranges::remove(layers, layer);
|
||||||
layers.erase(begin, end);
|
layers.erase(begin, end);
|
||||||
}
|
}
|
||||||
change_layers.pop_front();
|
GetChangeLayers().pop_front();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,12 +189,12 @@ void Render(const vk::CommandBuffer& cmdbuf, ::Vulkan::Frame* frame) {
|
||||||
|
|
||||||
void Layer::AddLayer(Layer* layer) {
|
void Layer::AddLayer(Layer* layer) {
|
||||||
std::scoped_lock lock{change_layers_mutex};
|
std::scoped_lock lock{change_layers_mutex};
|
||||||
change_layers.emplace_back(true, layer);
|
GetChangeLayers().emplace_back(true, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Layer::RemoveLayer(Layer* layer) {
|
void Layer::RemoveLayer(Layer* layer) {
|
||||||
std::scoped_lock lock{change_layers_mutex};
|
std::scoped_lock lock{change_layers_mutex};
|
||||||
change_layers.emplace_back(false, layer);
|
GetChangeLayers().emplace_back(false, layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace ImGui
|
} // namespace ImGui
|
||||||
|
|
Loading…
Reference in a new issue