Skip to content

Commit b4ed248

Browse files
author
N3xoX1
committed
Get the OS calls to be able to push the display list to the video module
1 parent 75015e1 commit b4ed248

30 files changed

Lines changed: 628 additions & 154 deletions

src/nxemu-module-spec/base.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
enum
1818
{
1919
MODULE_LOADER_SPECS_VERSION = 0x0106,
20-
MODULE_VIDEO_SPECS_VERSION = 0x0102,
20+
MODULE_VIDEO_SPECS_VERSION = 0x0103,
2121
MODULE_CPU_SPECS_VERSION = 0x0102,
22-
MODULE_OPERATING_SYSTEM_SPECS_VERSION = 0x0104,
22+
MODULE_OPERATING_SYSTEM_SPECS_VERSION = 0x0105,
2323
};
2424

2525
enum MODULE_TYPE : uint16_t

src/nxemu-module-spec/operating_system.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ __interface IDeviceMemory
6363
const uint8_t * BackingBasePointer() const = 0;
6464
};
6565

66+
__interface ICacheInvalidator
67+
{
68+
virtual void OnCacheInvalidation(uint64_t address, uint32_t size) = 0;
69+
};
70+
6671
__interface IOperatingSystem
6772
{
6873
bool Initialize(void) = 0;
@@ -72,6 +77,7 @@ __interface IOperatingSystem
7277
IDeviceMemory & DeviceMemory(void) = 0;
7378
void KeyboardKeyPress(int modifier, int keyIndex, int keyCode) = 0;
7479
void KeyboardKeyRelease(int modifier, int keyIndex, int keyCode) = 0;
80+
void GatherGPUDirtyMemory(ICacheInvalidator * invalidator) = 0;
7581
};
7682

7783
EXPORT IOperatingSystem * CALL CreateOperatingSystem(ISwitchSystem & system);

src/nxemu-module-spec/video.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,28 @@ struct VideoNvFence
2626
uint32_t value;
2727
};
2828

29+
__interface IChannelState
30+
{
31+
bool Initialized() const = 0;
32+
int32_t BindId() const = 0;
33+
void Init(uint64_t programId) = 0;
34+
void SetMemoryManager(uint32_t id) = 0;
35+
void Release() = 0;
36+
};
37+
2938
__interface IVideo
3039
{
3140
bool Initialize(void) = 0;
41+
uint32_t AllocAsEx(uint64_t addressSpaceBits, uint64_t splitAddress, uint64_t bigPageBits, uint64_t pageBits) = 0;
42+
uint64_t MapBufferEx(uint64_t gpuAddr, uint64_t deviceAddr, uint64_t size, uint8_t kind, bool isBigPages) = 0;
3243
uint64_t MemoryAllocate(uint64_t size) = 0;
3344
void MemoryTrackContinuity(uint64_t address, uint64_t virtualAddress, uint64_t size, uint64_t asid) = 0;
3445
void MemoryMap(uint64_t address, uint64_t virtualAddress, uint64_t size, uint64_t asid, bool track) = 0;
3546
void RequestComposite(VideoFramebufferConfig * layers, uint32_t layerCount, VideoNvFence * fences, uint32_t fenceCount) = 0;
3647
uint64_t RegisterProcess(IMemory * memory) = 0;
3748
void UpdateFramebufferLayout(uint32_t width, uint32_t height) = 0;
49+
IChannelState * AllocateChannel() = 0;
50+
void PushGPUEntries(int32_t bindId, const uint64_t * commandList, uint32_t commandListSize, const uint32_t * prefetchCommandlist, uint32_t prefetchCommandlistSize) = 0;
3851
};
3952

4053
EXPORT IVideo * CALL CreateVideo(IRenderWindow & RenderWindow, ISwitchSystem & System);

src/nxemu-os/core/core.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,12 @@ std::span<GPUDirtyMemoryManager> System::GetGPUDirtyMemoryManager() {
259259
return impl->gpu_dirty_memory_managers;
260260
}
261261

262+
void System::GatherGPUDirtyMemory(ICacheInvalidator * invalidator) {
263+
for (auto& manager : impl->gpu_dirty_memory_managers) {
264+
manager.Gather(invalidator);
265+
}
266+
}
267+
262268
ISwitchSystem & System::GetSwitchSystem()
263269
{
264270
return impl->switchSystem;

src/nxemu-os/core/core.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <string>
1313
#include <vector>
1414

15+
#include <nxemu-module-spec/operating_system.h>
1516
#include "yuzu_common/common_types.h"
1617

1718
enum class StorageId : uint8_t;
@@ -219,18 +220,12 @@ class System {
219220
*/
220221
[[nodiscard]] bool IsPoweredOn() const;
221222

222-
/// Gets a reference to the telemetry session for this emulation session.
223-
[[nodiscard]] Core::TelemetrySession& TelemetrySession();
224-
225-
/// Gets a reference to the telemetry session for this emulation session.
226-
[[nodiscard]] const Core::TelemetrySession& TelemetrySession() const;
227-
228223
/// Prepare the core emulation for a reschedule
229224
void PrepareReschedule(u32 core_index);
230225

231226
std::span<GPUDirtyMemoryManager> GetGPUDirtyMemoryManager();
232227

233-
void GatherGPUDirtyMemory(std::function<void(PAddr, size_t)>& callback);
228+
void GatherGPUDirtyMemory(ICacheInvalidator * invalidator);
234229

235230
ISwitchSystem & GetSwitchSystem();
236231
IVideo & GetVideo();

src/nxemu-os/core/file_sys/filesystem_interfaces.cpp

Lines changed: 1 addition & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,88 +1,6 @@
11
#include "filesystem_interfaces.h"
22
#include <nxemu-module-spec/system_loader.h>
3-
4-
template<typename InterfaceType>
5-
InterfacePtr<InterfaceType>::InterfacePtr() :
6-
m_ptr(nullptr)
7-
{
8-
}
9-
10-
template<typename InterfaceType>
11-
InterfacePtr<InterfaceType>::InterfacePtr(InterfaceType* ptr) :
12-
m_ptr(ptr)
13-
{
14-
}
15-
16-
template<typename InterfaceType>
17-
InterfacePtr<InterfaceType>::InterfacePtr(InterfacePtr&& other) noexcept
18-
: m_ptr(other.m_ptr)
19-
{
20-
other.m_ptr = nullptr;
21-
}
22-
23-
template<typename InterfaceType>
24-
InterfacePtr<InterfaceType>::~InterfacePtr()
25-
{
26-
if (m_ptr)
27-
{
28-
m_ptr->Release();
29-
m_ptr = nullptr;
30-
}
31-
}
32-
33-
template<typename InterfaceType>
34-
InterfacePtr<InterfaceType> & InterfacePtr<InterfaceType>::operator=(InterfaceType * ptr)
35-
{
36-
if (m_ptr != ptr && m_ptr != nullptr)
37-
{
38-
m_ptr->Release();
39-
}
40-
m_ptr = ptr;
41-
return *this;
42-
}
43-
44-
template<typename InterfaceType>
45-
InterfacePtr<InterfaceType>& InterfacePtr<InterfaceType>::operator=(InterfacePtr&& other) noexcept
46-
{
47-
if (this != &other)
48-
{
49-
if (m_ptr) {
50-
m_ptr->Release();
51-
}
52-
m_ptr = other.m_ptr;
53-
other.m_ptr = nullptr;
54-
}
55-
return *this;
56-
}
57-
58-
template<typename InterfaceType>
59-
InterfaceType** InterfacePtr<InterfaceType>::GetAddressForSet()
60-
{
61-
if (m_ptr)
62-
{
63-
m_ptr->Release();
64-
m_ptr = nullptr;
65-
}
66-
return &m_ptr;
67-
}
68-
69-
template<typename InterfaceType>
70-
InterfaceType* InterfacePtr<InterfaceType>::operator->() const
71-
{
72-
return m_ptr;
73-
}
74-
75-
template<typename InterfaceType>
76-
InterfaceType& InterfacePtr<InterfaceType>::operator*() const
77-
{
78-
return *m_ptr;
79-
}
80-
81-
template<typename InterfaceType>
82-
InterfacePtr<InterfaceType>::operator bool() const
83-
{
84-
return m_ptr != nullptr;
85-
}
3+
#include <yuzu_common/interface_pointer_def.h>
864

875
std::vector<uint8_t> IVirtualFilePtr::ReadAllBytes() const
886
{

src/nxemu-os/core/file_sys/filesystem_interfaces.h

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,6 @@
11
#pragma once
22
#include <vector>
3-
4-
template<typename InterfaceType>
5-
class InterfacePtr
6-
{
7-
public:
8-
InterfacePtr();
9-
InterfacePtr(InterfaceType *);
10-
InterfacePtr(InterfacePtr && other) noexcept;
11-
~InterfacePtr();
12-
13-
InterfacePtr & operator=(InterfaceType * ptr);
14-
InterfacePtr & operator=(InterfacePtr && other) noexcept;
15-
InterfaceType ** GetAddressForSet();
16-
17-
InterfaceType * operator->() const;
18-
InterfaceType & operator*() const;
19-
operator bool() const;
20-
21-
protected:
22-
InterfacePtr(const InterfacePtr &) = delete;
23-
InterfacePtr & operator=(const InterfacePtr &) = delete;
24-
25-
InterfaceType * m_ptr;
26-
};
3+
#include "yuzu_common/interface_pointer.h"
274

285
__interface IVirtualDirectory;
296
__interface IVirtualFile;

src/nxemu-os/core/gpu_dirty_memory_manager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class GPUDirtyMemoryManager {
4545
std::memory_order_relaxed));
4646
}
4747

48-
void Gather(std::function<void(PAddr, size_t)>& callback) {
48+
void Gather(ICacheInvalidator * invalidator) {
4949
{
5050
std::scoped_lock lk(guard);
5151
TransformAddress t = current.exchange(default_transform, std::memory_order_relaxed);
@@ -63,7 +63,7 @@ class GPUDirtyMemoryManager {
6363
mask = mask >> empty_bits;
6464

6565
const size_t continuous_bits = std::countr_one(mask);
66-
callback((static_cast<PAddr>(transform.address) << page_bits) + offset,
66+
invalidator->OnCacheInvalidation((static_cast<PAddr>(transform.address) << page_bits) + offset,
6767
continuous_bits << align_bits);
6868
mask = continuous_bits < align_size ? (mask >> continuous_bits) : 0;
6969
offset += continuous_bits << align_bits;

src/nxemu-os/core/hle/service/nvdrv/devices/nvdisp_disp0.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void nvdisp_disp0::Composite(std::span<const Nvnflinger::HwcLayer> sorted_layers
8787
}
8888
}
8989

90-
system.GetVideo().RequestComposite(output_layers.data(), output_layers.size(), output_fences.data(), output_fences.size());
90+
system.GetVideo().RequestComposite(output_layers.data(), (uint32_t)output_layers.size(), output_fences.data(), (uint32_t)output_fences.size());
9191
system.SpeedLimiter().DoSpeedLimiting(system.CoreTiming().GetGlobalTimeUs());
9292
system.GetPerfStats().EndSystemFrame();
9393
system.GetPerfStats().BeginSystemFrame();

0 commit comments

Comments
 (0)