From c5ec484d9a2417ef3fef2e9f2d9439aeba3704f4 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Tue, 25 Oct 2022 20:55:50 +0100 Subject: [PATCH] Avoid redundantly passing executor in ctors when it's already in ChannelCtx --- .../cpp/skyline/gpu/interconnect/fermi_2d.cpp | 5 ++++- .../main/cpp/skyline/gpu/interconnect/fermi_2d.h | 2 +- .../gpu/interconnect/maxwell_3d/maxwell_3d.cpp | 9 ++++----- .../gpu/interconnect/maxwell_3d/maxwell_3d.h | 1 - app/src/main/cpp/skyline/soc/gm20b/channel.cpp | 16 ++++++++-------- .../cpp/skyline/soc/gm20b/engines/fermi_2d.cpp | 10 +++++----- .../cpp/skyline/soc/gm20b/engines/fermi_2d.h | 2 +- .../cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp | 8 ++++---- .../cpp/skyline/soc/gm20b/engines/maxwell_3d.h | 2 +- 9 files changed, 28 insertions(+), 27 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/fermi_2d.cpp b/app/src/main/cpp/skyline/gpu/interconnect/fermi_2d.cpp index dbeb257f..e097ae44 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/fermi_2d.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/fermi_2d.cpp @@ -106,7 +106,10 @@ namespace skyline::gpu::interconnect { return texture; } - Fermi2D::Fermi2D(GPU &gpu, soc::gm20b::ChannelContext &channelCtx, gpu::interconnect::CommandExecutor &executor) : gpu(gpu), channelCtx(channelCtx), executor(executor) {} + Fermi2D::Fermi2D(GPU &gpu, soc::gm20b::ChannelContext &channelCtx) + : gpu{gpu}, + channelCtx{channelCtx}, + executor{channelCtx.executor} {} void Fermi2D::Blit(const Surface &srcSurface, const Surface &dstSurface, float srcRectX, float srcRectY, u32 dstRectWidth, u32 dstRectHeight, u32 dstRectX, u32 dstRectY, float duDx, float dvDy, SampleModeOrigin sampleOrigin, bool resolve, SampleModeFilter filter) { // TODO: When we support MSAA perform a resolve operation rather than blit when the `resolve` flag is set. diff --git a/app/src/main/cpp/skyline/gpu/interconnect/fermi_2d.h b/app/src/main/cpp/skyline/gpu/interconnect/fermi_2d.h index 3aaf4260..a870cc3b 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/fermi_2d.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/fermi_2d.h @@ -36,7 +36,7 @@ namespace skyline::gpu::interconnect { gpu::GuestTexture GetGuestTexture(const Surface &surface); public: - Fermi2D(GPU &gpu, soc::gm20b::ChannelContext &channelCtx, gpu::interconnect::CommandExecutor &executor); + Fermi2D(GPU &gpu, soc::gm20b::ChannelContext &channelCtx); void Blit(const Surface &srcSurface, const Surface &dstSurface, float srcRectX, float srcRectY, u32 dstRectWidth, u32 dstRectHeight, u32 dstRectX, u32 dstRectY, float duDx, float dvDy, SampleModeOrigin sampleOrigin, bool resolve, SampleModeFilter filter); }; diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp index ed70d1df..05f4908b 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp @@ -4,7 +4,7 @@ #include #include -#include +#include #include "common/utils.h" #include "maxwell_3d.h" #include "common.h" @@ -13,19 +13,18 @@ namespace skyline::gpu::interconnect::maxwell3d { Maxwell3D::Maxwell3D(GPU &gpu, soc::gm20b::ChannelContext &channelCtx, - gpu::interconnect::CommandExecutor &executor, nce::NCE &nce, skyline::kernel::MemoryManager &memoryManager, DirtyManager &manager, const EngineRegisterBundle ®isterBundle) - : ctx{channelCtx, executor, gpu, nce, memoryManager}, + : ctx{channelCtx, channelCtx.executor, gpu, nce, memoryManager}, activeState{manager, registerBundle.activeStateRegisters}, clearEngineRegisters{registerBundle.clearRegisters}, constantBuffers{manager, registerBundle.constantBufferSelectorRegisters}, samplers{manager, registerBundle.samplerPoolRegisters}, textures{manager, registerBundle.texturePoolRegisters}, directState{activeState.directState} { - executor.AddFlushCallback([this] { + ctx.executor.AddFlushCallback([this] { if (attachedDescriptorSets) { ctx.executor.AttachDependency(attachedDescriptorSets); attachedDescriptorSets = nullptr; @@ -40,7 +39,7 @@ namespace skyline::gpu::interconnect::maxwell3d { constantBuffers.DisableQuickBind(); }); - executor.AddPipelineChangeCallback([this] { + ctx.executor.AddPipelineChangeCallback([this] { activeState.MarkAllDirty(); activeDescriptorSet = nullptr; }); diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.h b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.h index 64909003..d1984466 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.h @@ -61,7 +61,6 @@ namespace skyline::gpu::interconnect::maxwell3d { Maxwell3D(GPU &gpu, soc::gm20b::ChannelContext &channelCtx, - gpu::interconnect::CommandExecutor &executor, nce::NCE &nce, kernel::MemoryManager &memoryManager, DirtyManager &manager, diff --git a/app/src/main/cpp/skyline/soc/gm20b/channel.cpp b/app/src/main/cpp/skyline/soc/gm20b/channel.cpp index c6372acc..848c10d5 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/channel.cpp +++ b/app/src/main/cpp/skyline/soc/gm20b/channel.cpp @@ -5,13 +5,13 @@ namespace skyline::soc::gm20b { ChannelContext::ChannelContext(const DeviceState &state, std::shared_ptr pAsCtx, size_t numEntries) - : asCtx(std::move(pAsCtx)), - executor(state), - maxwell3D(state, *this, macroState, executor), - fermi2D(state, *this, macroState, executor), - maxwellDma(state, *this, executor), - keplerCompute(state, *this), - inline2Memory(*this), - gpfifo(state, *this, numEntries), + : asCtx{std::move(pAsCtx)}, + executor{state}, + maxwell3D{state, *this, macroState}, + fermi2D{state, *this, macroState}, + maxwellDma{state, *this}, + keplerCompute{state, *this}, + inline2Memory{state, *this}, + gpfifo{state, *this, numEntries}, globalChannelLock{state.gpu->channelLock} {} } diff --git a/app/src/main/cpp/skyline/soc/gm20b/engines/fermi_2d.cpp b/app/src/main/cpp/skyline/soc/gm20b/engines/fermi_2d.cpp index 69edceb9..ed07400e 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/engines/fermi_2d.cpp +++ b/app/src/main/cpp/skyline/soc/gm20b/engines/fermi_2d.cpp @@ -6,11 +6,11 @@ #include "fermi_2d.h" namespace skyline::soc::gm20b::engine::fermi2d { - Fermi2D::Fermi2D(const DeviceState &state, ChannelContext &channelCtx, MacroState ¯oState, gpu::interconnect::CommandExecutor &executor) - : MacroEngineBase(macroState), - syncpoints(state.soc->host1x.syncpoints), - interconnect(*state.gpu, channelCtx, executor), - channelCtx(channelCtx) {} + Fermi2D::Fermi2D(const DeviceState &state, ChannelContext &channelCtx, MacroState ¯oState) + : MacroEngineBase{macroState}, + syncpoints{state.soc->host1x.syncpoints}, + interconnect{*state.gpu, channelCtx}, + channelCtx{channelCtx} {} void Fermi2D::HandleMethod(u32 method, u32 argument) { registers.raw[method] = argument; diff --git a/app/src/main/cpp/skyline/soc/gm20b/engines/fermi_2d.h b/app/src/main/cpp/skyline/soc/gm20b/engines/fermi_2d.h index 14b8c94c..26842d37 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/engines/fermi_2d.h +++ b/app/src/main/cpp/skyline/soc/gm20b/engines/fermi_2d.h @@ -86,7 +86,7 @@ namespace skyline::soc::gm20b::engine::fermi2d { Registers registers{}; - Fermi2D(const DeviceState &state, ChannelContext &channelCtx, MacroState ¯oState, gpu::interconnect::CommandExecutor &executor); + Fermi2D(const DeviceState &state, ChannelContext &channelCtx, MacroState ¯oState); void CallMethodFromMacro(u32 method, u32 argument) override; diff --git a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp index c47fb27c..1a311752 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp +++ b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.cpp @@ -61,14 +61,14 @@ namespace skyline::soc::gm20b::engine::maxwell3d { registers.begin->op : type::ConvertPrimitiveTopologyToDrawTopology(*registers.primitiveTopology); } - Maxwell3D::Maxwell3D(const DeviceState &state, ChannelContext &channelCtx, MacroState ¯oState, gpu::interconnect::CommandExecutor &executor) + Maxwell3D::Maxwell3D(const DeviceState &state, ChannelContext &channelCtx, MacroState ¯oState) : MacroEngineBase{macroState}, syncpoints{state.soc->host1x.syncpoints}, - i2m{channelCtx}, + i2m{state, channelCtx}, dirtyManager{registers}, - interconnect{*state.gpu, channelCtx, executor, *state.nce, state.process->memory, dirtyManager, MakeEngineRegisters(registers)}, + interconnect{*state.gpu, channelCtx, *state.nce, state.process->memory, dirtyManager, MakeEngineRegisters(registers)}, channelCtx{channelCtx} { - executor.AddFlushCallback([this]() { FlushEngineState(); }); + channelCtx.executor.AddFlushCallback([this]() { FlushEngineState(); }); InitializeRegisters(); } diff --git a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.h b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.h index 318839b3..cd7a9ed8 100644 --- a/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.h +++ b/app/src/main/cpp/skyline/soc/gm20b/engines/maxwell_3d.h @@ -364,7 +364,7 @@ namespace skyline::soc::gm20b::engine::maxwell3d { ChannelContext &channelCtx; - Maxwell3D(const DeviceState &state, ChannelContext &channelCtx, MacroState ¯oState, gpu::interconnect::CommandExecutor &executor); + Maxwell3D(const DeviceState &state, ChannelContext &channelCtx, MacroState ¯oState); /** * @brief Initializes Maxwell 3D registers to their default values