mirror of
https://git.eden-emu.dev/eden-emu/eden
synced 2026-06-28 22:45:26 +02:00
[video_core] Remove redundant references in GPU engine structs
Signed-off-by: lizzie <lizzie@eden-emu.dev>
This commit is contained in:
parent
66141a2e7c
commit
871d3ffb20
7 changed files with 155 additions and 276 deletions
|
|
@ -40,30 +40,32 @@
|
|||
namespace Tegra {
|
||||
|
||||
struct GPU::Impl {
|
||||
explicit Impl(GPU& gpu_, Core::System& system_, bool is_async_, bool use_nvdec_)
|
||||
: gpu{gpu_}, system{system_}, host1x{system.Host1x()}, use_nvdec{use_nvdec_},
|
||||
shader_notify{std::make_unique<VideoCore::ShaderNotify>()}, is_async{is_async_},
|
||||
gpu_thread{system_, is_async_}, scheduler{std::make_unique<Control::Scheduler>(gpu)} {}
|
||||
explicit Impl(Core::System& system_, bool is_async_, bool use_nvdec_)
|
||||
: system{system_}
|
||||
, use_nvdec{use_nvdec_}
|
||||
, shader_notify()
|
||||
, is_async{is_async_}
|
||||
, gpu_thread{system_, is_async_}
|
||||
, scheduler(system_.GPU())
|
||||
{}
|
||||
|
||||
~Impl() = default;
|
||||
|
||||
std::shared_ptr<Control::ChannelState> CreateChannel(s32 channel_id) {
|
||||
auto channel_state = std::make_shared<Tegra::Control::ChannelState>(channel_id);
|
||||
channels.emplace(channel_id, channel_state);
|
||||
scheduler->DeclareChannel(channel_state);
|
||||
scheduler.DeclareChannel(channel_state);
|
||||
return channel_state;
|
||||
}
|
||||
|
||||
void BindChannel(s32 channel_id) {
|
||||
if (bound_channel == channel_id) {
|
||||
return;
|
||||
if (bound_channel != channel_id) {
|
||||
auto it = channels.find(channel_id);
|
||||
ASSERT(it != channels.end());
|
||||
bound_channel = channel_id;
|
||||
current_channel = it->second.get();
|
||||
renderer->ReadRasterizer()->BindChannel(*current_channel);
|
||||
}
|
||||
auto it = channels.find(channel_id);
|
||||
ASSERT(it != channels.end());
|
||||
bound_channel = channel_id;
|
||||
current_channel = it->second.get();
|
||||
|
||||
rasterizer->BindChannel(*current_channel);
|
||||
}
|
||||
|
||||
std::shared_ptr<Control::ChannelState> AllocateChannel() {
|
||||
|
|
@ -71,13 +73,13 @@ struct GPU::Impl {
|
|||
}
|
||||
|
||||
void InitChannel(Control::ChannelState& to_init, u64 program_id) {
|
||||
to_init.Init(system, gpu, program_id);
|
||||
to_init.BindRasterizer(rasterizer);
|
||||
rasterizer->InitializeChannel(to_init);
|
||||
to_init.Init(system, program_id);
|
||||
to_init.BindRasterizer(renderer->ReadRasterizer());
|
||||
renderer->ReadRasterizer()->InitializeChannel(to_init);
|
||||
}
|
||||
|
||||
void InitAddressSpace(Tegra::MemoryManager& memory_manager) {
|
||||
memory_manager.BindRasterizer(rasterizer);
|
||||
memory_manager.BindRasterizer(renderer->ReadRasterizer());
|
||||
}
|
||||
|
||||
void ReleaseChannel(Control::ChannelState& to_release) {
|
||||
|
|
@ -87,26 +89,26 @@ struct GPU::Impl {
|
|||
/// Binds a renderer to the GPU.
|
||||
void BindRenderer(std::unique_ptr<VideoCore::RendererBase> renderer_) {
|
||||
renderer = std::move(renderer_);
|
||||
rasterizer = renderer->ReadRasterizer();
|
||||
host1x.MemoryManager().BindInterface(rasterizer);
|
||||
host1x.gmmu_manager.BindRasterizer(rasterizer);
|
||||
system.Host1x().MemoryManager().BindInterface(renderer->ReadRasterizer());
|
||||
system.Host1x().GMMU().BindRasterizer(renderer->ReadRasterizer());
|
||||
}
|
||||
|
||||
/// Flush all current written commands into the host GPU for execution.
|
||||
void FlushCommands() {
|
||||
rasterizer->FlushCommands();
|
||||
renderer->ReadRasterizer()->FlushCommands();
|
||||
}
|
||||
|
||||
/// Synchronizes CPU writes with Host GPU memory.
|
||||
void InvalidateGPUCache() {
|
||||
std::function<void(PAddr, size_t)> callback_writes(
|
||||
[this](PAddr address, size_t size) { rasterizer->OnCacheInvalidation(address, size); });
|
||||
std::function<void(PAddr, size_t)> callback_writes([this](PAddr address, size_t size) {
|
||||
renderer->ReadRasterizer()->OnCacheInvalidation(address, size);
|
||||
});
|
||||
system.GatherGPUDirtyMemory(callback_writes);
|
||||
}
|
||||
|
||||
/// Signal the ending of command list.
|
||||
void OnCommandListEnd() {
|
||||
rasterizer->ReleaseFences(false);
|
||||
renderer->ReadRasterizer()->ReleaseFences(false);
|
||||
Settings::UpdateGPUAccuracy();
|
||||
}
|
||||
|
||||
|
|
@ -143,62 +145,6 @@ struct GPU::Impl {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns a reference to the Maxwell3D GPU engine.
|
||||
[[nodiscard]] Engines::Maxwell3D& Maxwell3D() {
|
||||
ASSERT(current_channel);
|
||||
return *current_channel->maxwell_3d;
|
||||
}
|
||||
|
||||
/// Returns a const reference to the Maxwell3D GPU engine.
|
||||
[[nodiscard]] const Engines::Maxwell3D& Maxwell3D() const {
|
||||
ASSERT(current_channel);
|
||||
return *current_channel->maxwell_3d;
|
||||
}
|
||||
|
||||
/// Returns a reference to the KeplerCompute GPU engine.
|
||||
[[nodiscard]] Engines::KeplerCompute& KeplerCompute() {
|
||||
ASSERT(current_channel);
|
||||
return *current_channel->kepler_compute;
|
||||
}
|
||||
|
||||
/// Returns a reference to the KeplerCompute GPU engine.
|
||||
[[nodiscard]] const Engines::KeplerCompute& KeplerCompute() const {
|
||||
ASSERT(current_channel);
|
||||
return *current_channel->kepler_compute;
|
||||
}
|
||||
|
||||
/// Returns a reference to the GPU DMA pusher.
|
||||
[[nodiscard]] Tegra::DmaPusher& DmaPusher() {
|
||||
ASSERT(current_channel);
|
||||
return *current_channel->dma_pusher;
|
||||
}
|
||||
|
||||
/// Returns a const reference to the GPU DMA pusher.
|
||||
[[nodiscard]] const Tegra::DmaPusher& DmaPusher() const {
|
||||
ASSERT(current_channel);
|
||||
return *current_channel->dma_pusher;
|
||||
}
|
||||
|
||||
/// Returns a reference to the underlying renderer.
|
||||
[[nodiscard]] VideoCore::RendererBase& Renderer() {
|
||||
return *renderer;
|
||||
}
|
||||
|
||||
/// Returns a const reference to the underlying renderer.
|
||||
[[nodiscard]] const VideoCore::RendererBase& Renderer() const {
|
||||
return *renderer;
|
||||
}
|
||||
|
||||
/// Returns a reference to the shader notifier.
|
||||
[[nodiscard]] VideoCore::ShaderNotify& ShaderNotify() {
|
||||
return *shader_notify;
|
||||
}
|
||||
|
||||
/// Returns a const reference to the shader notifier.
|
||||
[[nodiscard]] const VideoCore::ShaderNotify& ShaderNotify() const {
|
||||
return *shader_notify;
|
||||
}
|
||||
|
||||
[[nodiscard]] u64 GetTicks() const {
|
||||
u64 gpu_tick = system.CoreTiming().GetGPUTicks();
|
||||
Settings::GpuOverclock overclock = Settings::values.fast_gpu_time.GetValue();
|
||||
|
|
@ -210,14 +156,6 @@ struct GPU::Impl {
|
|||
return gpu_tick;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool IsAsync() const {
|
||||
return is_async;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool UseNvdec() const {
|
||||
return use_nvdec;
|
||||
}
|
||||
|
||||
void RendererFrameEndNotify() {
|
||||
system.GetPerfStats().EndGameFrame();
|
||||
}
|
||||
|
|
@ -227,7 +165,7 @@ struct GPU::Impl {
|
|||
/// core timing events.
|
||||
void Start() {
|
||||
Settings::UpdateGPUAccuracy();
|
||||
gpu_thread.StartThread(*renderer, renderer->Context(), *scheduler);
|
||||
gpu_thread.StartThread(*renderer, renderer->Context(), scheduler);
|
||||
}
|
||||
|
||||
void NotifyShutdown() {
|
||||
|
|
@ -260,14 +198,13 @@ struct GPU::Impl {
|
|||
}
|
||||
|
||||
VideoCore::RasterizerDownloadArea OnCPURead(DAddr addr, u64 size) {
|
||||
auto raster_area = rasterizer->GetFlushArea(addr, size);
|
||||
auto raster_area = renderer->ReadRasterizer()->GetFlushArea(addr, size);
|
||||
if (raster_area.preemtive) {
|
||||
return raster_area;
|
||||
}
|
||||
raster_area.preemtive = true;
|
||||
const u64 fence = RequestSyncOperation([this, &raster_area]() {
|
||||
rasterizer->FlushRegion(raster_area.start_address,
|
||||
raster_area.end_address - raster_area.start_address);
|
||||
renderer->ReadRasterizer()->FlushRegion(raster_area.start_address, raster_area.end_address - raster_area.start_address);
|
||||
});
|
||||
gpu_thread.TickGPU();
|
||||
WaitForSyncOperation(fence);
|
||||
|
|
@ -280,7 +217,7 @@ struct GPU::Impl {
|
|||
}
|
||||
|
||||
bool OnCPUWrite(DAddr addr, u64 size) {
|
||||
return rasterizer->OnCPUWrite(addr, size);
|
||||
return renderer->ReadRasterizer()->OnCPUWrite(addr, size);
|
||||
}
|
||||
|
||||
/// Notify rasterizer that any caches of the specified region should be flushed and invalidated
|
||||
|
|
@ -337,17 +274,14 @@ struct GPU::Impl {
|
|||
return out;
|
||||
}
|
||||
|
||||
GPU& gpu;
|
||||
Core::System& system;
|
||||
Host1x::Host1x& host1x;
|
||||
|
||||
std::unique_ptr<VideoCore::RendererBase> renderer;
|
||||
VideoCore::RasterizerInterface* rasterizer = nullptr;
|
||||
const bool use_nvdec;
|
||||
|
||||
s32 new_channel_id{1};
|
||||
/// Shader build notifier
|
||||
std::unique_ptr<VideoCore::ShaderNotify> shader_notify;
|
||||
VideoCore::ShaderNotify shader_notify;
|
||||
/// When true, we are about to shut down emulation session, so terminate outstanding tasks
|
||||
std::atomic_bool shutting_down{};
|
||||
|
||||
|
|
@ -371,7 +305,7 @@ struct GPU::Impl {
|
|||
VideoCommon::GPUThread::ThreadManager gpu_thread;
|
||||
std::unique_ptr<Core::Frontend::GraphicsContext> cpu_context;
|
||||
|
||||
std::unique_ptr<Tegra::Control::Scheduler> scheduler;
|
||||
Tegra::Control::Scheduler scheduler;
|
||||
ankerl::unordered_dense::map<s32, std::shared_ptr<Tegra::Control::ChannelState>> channels;
|
||||
Tegra::Control::ChannelState* current_channel;
|
||||
s32 bound_channel{-1};
|
||||
|
|
@ -382,7 +316,8 @@ struct GPU::Impl {
|
|||
};
|
||||
|
||||
GPU::GPU(Core::System& system, bool is_async, bool use_nvdec)
|
||||
: impl{std::make_unique<Impl>(*this, system, is_async, use_nvdec)} {}
|
||||
: impl{std::make_unique<Impl>(system, is_async, use_nvdec)}
|
||||
{}
|
||||
|
||||
GPU::~GPU() = default;
|
||||
|
||||
|
|
@ -423,8 +358,9 @@ void GPU::OnCommandListEnd() {
|
|||
}
|
||||
|
||||
u64 GPU::RequestFlush(DAddr addr, std::size_t size) {
|
||||
return impl->RequestSyncOperation(
|
||||
[this, addr, size]() { impl->rasterizer->FlushRegion(addr, size); });
|
||||
return impl->RequestSyncOperation([this, addr, size]() {
|
||||
impl->renderer->ReadRasterizer()->FlushRegion(addr, size);
|
||||
});
|
||||
}
|
||||
|
||||
u64 GPU::CurrentSyncRequestFence() const {
|
||||
|
|
@ -441,52 +377,52 @@ void GPU::TickWork() {
|
|||
|
||||
/// Gets a mutable reference to the Host1x interface
|
||||
Host1x::Host1x& GPU::Host1x() {
|
||||
return impl->host1x;
|
||||
return impl->system.Host1x();
|
||||
}
|
||||
|
||||
/// Gets an immutable reference to the Host1x interface.
|
||||
const Host1x::Host1x& GPU::Host1x() const {
|
||||
return impl->host1x;
|
||||
return impl->system.Host1x();
|
||||
}
|
||||
|
||||
Engines::Maxwell3D& GPU::Maxwell3D() {
|
||||
return impl->Maxwell3D();
|
||||
return *impl->current_channel->maxwell_3d;
|
||||
}
|
||||
|
||||
const Engines::Maxwell3D& GPU::Maxwell3D() const {
|
||||
return impl->Maxwell3D();
|
||||
return *impl->current_channel->maxwell_3d;
|
||||
}
|
||||
|
||||
Engines::KeplerCompute& GPU::KeplerCompute() {
|
||||
return impl->KeplerCompute();
|
||||
return *impl->current_channel->kepler_compute;
|
||||
}
|
||||
|
||||
const Engines::KeplerCompute& GPU::KeplerCompute() const {
|
||||
return impl->KeplerCompute();
|
||||
return *impl->current_channel->kepler_compute;
|
||||
}
|
||||
|
||||
Tegra::DmaPusher& GPU::DmaPusher() {
|
||||
return impl->DmaPusher();
|
||||
return *impl->current_channel->dma_pusher;
|
||||
}
|
||||
|
||||
const Tegra::DmaPusher& GPU::DmaPusher() const {
|
||||
return impl->DmaPusher();
|
||||
return *impl->current_channel->dma_pusher;
|
||||
}
|
||||
|
||||
VideoCore::RendererBase& GPU::Renderer() {
|
||||
return impl->Renderer();
|
||||
return *impl->renderer;
|
||||
}
|
||||
|
||||
const VideoCore::RendererBase& GPU::Renderer() const {
|
||||
return impl->Renderer();
|
||||
return *impl->renderer;
|
||||
}
|
||||
|
||||
VideoCore::ShaderNotify& GPU::ShaderNotify() {
|
||||
return impl->ShaderNotify();
|
||||
return impl->shader_notify;
|
||||
}
|
||||
|
||||
const VideoCore::ShaderNotify& GPU::ShaderNotify() const {
|
||||
return impl->ShaderNotify();
|
||||
return impl->shader_notify;
|
||||
}
|
||||
|
||||
void GPU::RequestComposite(std::vector<Tegra::FramebufferConfig>&& layers,
|
||||
|
|
@ -503,11 +439,11 @@ u64 GPU::GetTicks() const {
|
|||
}
|
||||
|
||||
bool GPU::IsAsync() const {
|
||||
return impl->IsAsync();
|
||||
return impl->is_async;
|
||||
}
|
||||
|
||||
bool GPU::UseNvdec() const {
|
||||
return impl->UseNvdec();
|
||||
return impl->use_nvdec;
|
||||
}
|
||||
|
||||
void GPU::RendererFrameEndNotify() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue