diff options
Diffstat (limited to 'src/core/hle')
-rw-r--r-- | src/core/hle/service/audio/audren_u.cpp | 2 | ||||
-rw-r--r-- | src/core/hle/service/filesystem/filesystem.h | 7 | ||||
-rw-r--r-- | src/core/hle/service/filesystem/fsp_srv.cpp | 18 | ||||
-rw-r--r-- | src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp | 35 | ||||
-rw-r--r-- | src/core/hle/service/nvnflinger/buffer_queue_core.cpp | 4 | ||||
-rw-r--r-- | src/core/hle/service/nvnflinger/buffer_slot.h | 1 |
6 files changed, 55 insertions, 12 deletions
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 2f09cade5..23e56c77a 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp @@ -359,7 +359,7 @@ private: void GetActiveChannelCount(HLERequestContext& ctx) { const auto& sink{system.AudioCore().GetOutputSink()}; - u32 channel_count{sink.GetDeviceChannels()}; + u32 channel_count{sink.GetSystemChannels()}; LOG_DEBUG(Service_Audio, "(STUBBED) called. Channels={}", channel_count); diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h index e7e7c4c28..276d264e1 100644 --- a/src/core/hle/service/filesystem/filesystem.h +++ b/src/core/hle/service/filesystem/filesystem.h @@ -54,6 +54,13 @@ enum class ImageDirectoryId : u32 { SdCard, }; +enum class OpenDirectoryMode : u64 { + Directory = (1 << 0), + File = (1 << 1), + All = Directory | File +}; +DECLARE_ENUM_FLAG_OPERATORS(OpenDirectoryMode); + class FileSystemController { public: explicit FileSystemController(Core::System& system_); diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index b1310d6e4..82ecc1b90 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp @@ -259,7 +259,7 @@ static void BuildEntryIndex(std::vector<FileSys::Entry>& entries, const std::vec class IDirectory final : public ServiceFramework<IDirectory> { public: - explicit IDirectory(Core::System& system_, FileSys::VirtualDir backend_) + explicit IDirectory(Core::System& system_, FileSys::VirtualDir backend_, OpenDirectoryMode mode) : ServiceFramework{system_, "IDirectory"}, backend(std::move(backend_)) { static const FunctionInfo functions[] = { {0, &IDirectory::Read, "Read"}, @@ -269,8 +269,12 @@ public: // TODO(DarkLordZach): Verify that this is the correct behavior. // Build entry index now to save time later. - BuildEntryIndex(entries, backend->GetFiles(), FileSys::EntryType::File); - BuildEntryIndex(entries, backend->GetSubdirectories(), FileSys::EntryType::Directory); + if (True(mode & OpenDirectoryMode::Directory)) { + BuildEntryIndex(entries, backend->GetSubdirectories(), FileSys::EntryType::Directory); + } + if (True(mode & OpenDirectoryMode::File)) { + BuildEntryIndex(entries, backend->GetFiles(), FileSys::EntryType::File); + } } private: @@ -446,11 +450,9 @@ public: const auto file_buffer = ctx.ReadBuffer(); const std::string name = Common::StringFromBuffer(file_buffer); + const auto mode = rp.PopRaw<OpenDirectoryMode>(); - // TODO(Subv): Implement this filter. - const u32 filter_flags = rp.Pop<u32>(); - - LOG_DEBUG(Service_FS, "called. directory={}, filter={}", name, filter_flags); + LOG_DEBUG(Service_FS, "called. directory={}, mode={}", name, mode); FileSys::VirtualDir vfs_dir{}; auto result = backend.OpenDirectory(&vfs_dir, name); @@ -460,7 +462,7 @@ public: return; } - auto directory = std::make_shared<IDirectory>(system, vfs_dir); + auto directory = std::make_shared<IDirectory>(system, vfs_dir, mode); IPC::ResponseBuilder rb{ctx, 2, 0, 1}; rb.Push(ResultSuccess); diff --git a/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp b/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp index d91886bed..bbe8e06d4 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_consumer.cpp @@ -90,6 +90,18 @@ Status BufferQueueConsumer::AcquireBuffer(BufferItem* out_buffer, LOG_DEBUG(Service_Nvnflinger, "acquiring slot={}", slot); + // If the front buffer is still being tracked, update its slot state + if (core->StillTracking(*front)) { + slots[slot].acquire_called = true; + slots[slot].needs_cleanup_on_release = false; + slots[slot].buffer_state = BufferState::Acquired; + + // TODO: for now, avoid resetting the fence, so that when we next return this + // slot to the producer, it will wait for the fence to pass. We should fix this + // by properly waiting for the fence in the BufferItemConsumer. + // slots[slot].fence = Fence::NoFence(); + } + // If the buffer has previously been acquired by the consumer, set graphic_buffer to nullptr to // avoid unnecessarily remapping this buffer on the consumer side. if (out_buffer->acquire_called) { @@ -132,11 +144,28 @@ Status BufferQueueConsumer::ReleaseBuffer(s32 slot, u64 frame_number, const Fenc ++current; } - slots[slot].buffer_state = BufferState::Free; + if (slots[slot].buffer_state == BufferState::Acquired) { + // TODO: for now, avoid resetting the fence, so that when we next return this + // slot to the producer, it can wait for its own fence to pass. We should fix this + // by properly waiting for the fence in the BufferItemConsumer. + // slots[slot].fence = release_fence; + slots[slot].buffer_state = BufferState::Free; - listener = core->connected_producer_listener; + listener = core->connected_producer_listener; - LOG_DEBUG(Service_Nvnflinger, "releasing slot {}", slot); + LOG_DEBUG(Service_Nvnflinger, "releasing slot {}", slot); + } else if (slots[slot].needs_cleanup_on_release) { + LOG_DEBUG(Service_Nvnflinger, "releasing a stale buffer slot {} (state = {})", slot, + slots[slot].buffer_state); + slots[slot].needs_cleanup_on_release = false; + return Status::StaleBufferSlot; + } else { + LOG_ERROR(Service_Nvnflinger, + "attempted to release buffer slot {} but its state was {}", slot, + slots[slot].buffer_state); + + return Status::BadValue; + } core->SignalDequeueCondition(); } diff --git a/src/core/hle/service/nvnflinger/buffer_queue_core.cpp b/src/core/hle/service/nvnflinger/buffer_queue_core.cpp index 4ed5e5978..5d8c861fa 100644 --- a/src/core/hle/service/nvnflinger/buffer_queue_core.cpp +++ b/src/core/hle/service/nvnflinger/buffer_queue_core.cpp @@ -74,6 +74,10 @@ void BufferQueueCore::FreeBufferLocked(s32 slot) { slots[slot].graphic_buffer.reset(); + if (slots[slot].buffer_state == BufferState::Acquired) { + slots[slot].needs_cleanup_on_release = true; + } + slots[slot].buffer_state = BufferState::Free; slots[slot].frame_number = UINT32_MAX; slots[slot].acquire_called = false; diff --git a/src/core/hle/service/nvnflinger/buffer_slot.h b/src/core/hle/service/nvnflinger/buffer_slot.h index d25bca049..37daca78b 100644 --- a/src/core/hle/service/nvnflinger/buffer_slot.h +++ b/src/core/hle/service/nvnflinger/buffer_slot.h @@ -31,6 +31,7 @@ struct BufferSlot final { u64 frame_number{}; Fence fence; bool acquire_called{}; + bool needs_cleanup_on_release{}; bool attached_by_consumer{}; bool is_preallocated{}; }; |