mirror of
https://git.h3cjp.net/H3cJP/yuzu.git
synced 2024-11-15 13:22:48 +00:00
Merge pull request #6284 from ameerj/shantae-fix
nvflinger: Create layers when they are queried but not found
This commit is contained in:
commit
d5131805ce
|
@ -139,11 +139,15 @@ std::optional<u64> NVFlinger::CreateLayer(u64 display_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const u64 layer_id = next_layer_id++;
|
const u64 layer_id = next_layer_id++;
|
||||||
|
CreateLayerAtId(*display, layer_id);
|
||||||
|
return layer_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NVFlinger::CreateLayerAtId(VI::Display& display, u64 layer_id) {
|
||||||
const u32 buffer_queue_id = next_buffer_queue_id++;
|
const u32 buffer_queue_id = next_buffer_queue_id++;
|
||||||
buffer_queues.emplace_back(
|
buffer_queues.emplace_back(
|
||||||
std::make_unique<BufferQueue>(system.Kernel(), buffer_queue_id, layer_id));
|
std::make_unique<BufferQueue>(system.Kernel(), buffer_queue_id, layer_id));
|
||||||
display->CreateLayer(layer_id, *buffer_queues.back());
|
display.CreateLayer(layer_id, *buffer_queues.back());
|
||||||
return layer_id;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void NVFlinger::CloseLayer(u64 layer_id) {
|
void NVFlinger::CloseLayer(u64 layer_id) {
|
||||||
|
@ -154,9 +158,9 @@ void NVFlinger::CloseLayer(u64 layer_id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) const {
|
std::optional<u32> NVFlinger::FindBufferQueueId(u64 display_id, u64 layer_id) {
|
||||||
const auto lock_guard = Lock();
|
const auto lock_guard = Lock();
|
||||||
const auto* const layer = FindLayer(display_id, layer_id);
|
const auto* const layer = FindOrCreateLayer(display_id, layer_id);
|
||||||
|
|
||||||
if (layer == nullptr) {
|
if (layer == nullptr) {
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
|
@ -232,6 +236,24 @@ const VI::Layer* NVFlinger::FindLayer(u64 display_id, u64 layer_id) const {
|
||||||
return display->FindLayer(layer_id);
|
return display->FindLayer(layer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VI::Layer* NVFlinger::FindOrCreateLayer(u64 display_id, u64 layer_id) {
|
||||||
|
auto* const display = FindDisplay(display_id);
|
||||||
|
|
||||||
|
if (display == nullptr) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto* layer = display->FindLayer(layer_id);
|
||||||
|
|
||||||
|
if (layer == nullptr) {
|
||||||
|
LOG_DEBUG(Service, "Layer at id {} not found. Trying to create it.", layer_id);
|
||||||
|
CreateLayerAtId(*display, layer_id);
|
||||||
|
return display->FindLayer(layer_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
return layer;
|
||||||
|
}
|
||||||
|
|
||||||
void NVFlinger::Compose() {
|
void NVFlinger::Compose() {
|
||||||
for (auto& display : displays) {
|
for (auto& display : displays) {
|
||||||
// Trigger vsync for this display at the end of drawing
|
// Trigger vsync for this display at the end of drawing
|
||||||
|
|
|
@ -67,7 +67,7 @@ public:
|
||||||
/// Finds the buffer queue ID of the specified layer in the specified display.
|
/// Finds the buffer queue ID of the specified layer in the specified display.
|
||||||
///
|
///
|
||||||
/// If an invalid display ID or layer ID is provided, then an empty optional is returned.
|
/// If an invalid display ID or layer ID is provided, then an empty optional is returned.
|
||||||
[[nodiscard]] std::optional<u32> FindBufferQueueId(u64 display_id, u64 layer_id) const;
|
[[nodiscard]] std::optional<u32> FindBufferQueueId(u64 display_id, u64 layer_id);
|
||||||
|
|
||||||
/// Gets the vsync event for the specified display.
|
/// Gets the vsync event for the specified display.
|
||||||
///
|
///
|
||||||
|
@ -100,6 +100,14 @@ private:
|
||||||
/// Finds the layer identified by the specified ID in the desired display.
|
/// Finds the layer identified by the specified ID in the desired display.
|
||||||
[[nodiscard]] const VI::Layer* FindLayer(u64 display_id, u64 layer_id) const;
|
[[nodiscard]] const VI::Layer* FindLayer(u64 display_id, u64 layer_id) const;
|
||||||
|
|
||||||
|
/// Finds the layer identified by the specified ID in the desired display,
|
||||||
|
/// or creates the layer if it is not found.
|
||||||
|
/// To be used when the system expects the specified ID to already exist.
|
||||||
|
[[nodiscard]] VI::Layer* FindOrCreateLayer(u64 display_id, u64 layer_id);
|
||||||
|
|
||||||
|
/// Creates a layer with the specified layer ID in the desired display.
|
||||||
|
void CreateLayerAtId(VI::Display& display, u64 layer_id);
|
||||||
|
|
||||||
static void VSyncThread(NVFlinger& nv_flinger);
|
static void VSyncThread(NVFlinger& nv_flinger);
|
||||||
|
|
||||||
void SplitVSync();
|
void SplitVSync();
|
||||||
|
|
Loading…
Reference in a new issue