diff options
| author | 2022-01-30 22:26:01 +0100 | |
|---|---|---|
| committer | 2022-10-06 21:00:52 +0200 | |
| commit | 2931101e6f5aa755566ef40f6e6dc71909fd3e92 (patch) | |
| tree | 76e847786e355e24a136562d42177b895a03315e /src/video_core | |
| parent | VideoCore: Refactor syncing. (diff) | |
| download | yuzu-2931101e6f5aa755566ef40f6e6dc71909fd3e92.tar.gz yuzu-2931101e6f5aa755566ef40f6e6dc71909fd3e92.tar.xz yuzu-2931101e6f5aa755566ef40f6e6dc71909fd3e92.zip | |
NVDRV: Refactor Host1x
Diffstat (limited to 'src/video_core')
24 files changed, 138 insertions, 108 deletions
diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 723f9b67c..40e6d1ec4 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt | |||
| @@ -56,6 +56,8 @@ add_library(video_core STATIC | |||
| 56 | host1x/codecs/vp9_types.h | 56 | host1x/codecs/vp9_types.h |
| 57 | host1x/control.cpp | 57 | host1x/control.cpp |
| 58 | host1x/control.h | 58 | host1x/control.h |
| 59 | host1x/host1x.cpp | ||
| 60 | host1x/host1x.h | ||
| 59 | host1x/nvdec.cpp | 61 | host1x/nvdec.cpp |
| 60 | host1x/nvdec.h | 62 | host1x/nvdec.h |
| 61 | host1x/nvdec_common.h | 63 | host1x/nvdec_common.h |
diff --git a/src/video_core/cdma_pusher.cpp b/src/video_core/cdma_pusher.cpp index 148126347..28a2d2090 100644 --- a/src/video_core/cdma_pusher.cpp +++ b/src/video_core/cdma_pusher.cpp | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | #include <bit> | 4 | #include <bit> |
| 5 | #include "video_core/cdma_pusher.h" | 5 | #include "video_core/cdma_pusher.h" |
| 6 | #include "video_core/engines/maxwell_3d.h" | 6 | #include "video_core/engines/maxwell_3d.h" |
| 7 | #include "video_core/gpu.h" | ||
| 8 | #include "video_core/host1x/control.h" | 7 | #include "video_core/host1x/control.h" |
| 8 | #include "video_core/host1x/host1x.h" | ||
| 9 | #include "video_core/host1x/nvdec.h" | 9 | #include "video_core/host1x/nvdec.h" |
| 10 | #include "video_core/host1x/nvdec_common.h" | 10 | #include "video_core/host1x/nvdec_common.h" |
| 11 | #include "video_core/host1x/sync_manager.h" | 11 | #include "video_core/host1x/sync_manager.h" |
| @@ -13,11 +13,11 @@ | |||
| 13 | #include "video_core/memory_manager.h" | 13 | #include "video_core/memory_manager.h" |
| 14 | 14 | ||
| 15 | namespace Tegra { | 15 | namespace Tegra { |
| 16 | CDmaPusher::CDmaPusher(GPU& gpu_) | 16 | CDmaPusher::CDmaPusher(Host1x::Host1x& host1x_) |
| 17 | : gpu{gpu_}, nvdec_processor(std::make_shared<Host1x::Nvdec>(gpu)), | 17 | : host1x{host1x_}, nvdec_processor(std::make_shared<Host1x::Nvdec>(host1x)), |
| 18 | vic_processor(std::make_unique<Host1x::Vic>(gpu, nvdec_processor)), | 18 | vic_processor(std::make_unique<Host1x::Vic>(host1x, nvdec_processor)), |
| 19 | host1x_processor(std::make_unique<Host1x::Control>(gpu)), | 19 | host1x_processor(std::make_unique<Host1x::Control>(host1x)), |
| 20 | sync_manager(std::make_unique<Host1x::SyncptIncrManager>(gpu)) {} | 20 | sync_manager(std::make_unique<Host1x::SyncptIncrManager>(host1x)) {} |
| 21 | 21 | ||
| 22 | CDmaPusher::~CDmaPusher() = default; | 22 | CDmaPusher::~CDmaPusher() = default; |
| 23 | 23 | ||
diff --git a/src/video_core/cdma_pusher.h b/src/video_core/cdma_pusher.h index de17c2082..83112dfce 100644 --- a/src/video_core/cdma_pusher.h +++ b/src/video_core/cdma_pusher.h | |||
| @@ -12,10 +12,9 @@ | |||
| 12 | 12 | ||
| 13 | namespace Tegra { | 13 | namespace Tegra { |
| 14 | 14 | ||
| 15 | class GPU; | ||
| 16 | |||
| 17 | namespace Host1x { | 15 | namespace Host1x { |
| 18 | class Control; | 16 | class Control; |
| 17 | class Host1x; | ||
| 19 | class Nvdec; | 18 | class Nvdec; |
| 20 | class SyncptIncrManager; | 19 | class SyncptIncrManager; |
| 21 | class Vic; | 20 | class Vic; |
| @@ -91,7 +90,7 @@ enum class ThiMethod : u32 { | |||
| 91 | 90 | ||
| 92 | class CDmaPusher { | 91 | class CDmaPusher { |
| 93 | public: | 92 | public: |
| 94 | explicit CDmaPusher(GPU& gpu_); | 93 | explicit CDmaPusher(Host1x::Host1x& host1x); |
| 95 | ~CDmaPusher(); | 94 | ~CDmaPusher(); |
| 96 | 95 | ||
| 97 | /// Process the command entry | 96 | /// Process the command entry |
| @@ -104,7 +103,7 @@ private: | |||
| 104 | /// Write arguments value to the ThiRegisters member at the specified offset | 103 | /// Write arguments value to the ThiRegisters member at the specified offset |
| 105 | void ThiStateWrite(ThiRegisters& state, u32 offset, u32 argument); | 104 | void ThiStateWrite(ThiRegisters& state, u32 offset, u32 argument); |
| 106 | 105 | ||
| 107 | GPU& gpu; | 106 | Host1x::Host1x& host1x; |
| 108 | std::shared_ptr<Tegra::Host1x::Nvdec> nvdec_processor; | 107 | std::shared_ptr<Tegra::Host1x::Nvdec> nvdec_processor; |
| 109 | std::unique_ptr<Tegra::Host1x::Vic> vic_processor; | 108 | std::unique_ptr<Tegra::Host1x::Vic> vic_processor; |
| 110 | std::unique_ptr<Tegra::Host1x::Control> host1x_processor; | 109 | std::unique_ptr<Tegra::Host1x::Control> host1x_processor; |
diff --git a/src/video_core/gpu.cpp b/src/video_core/gpu.cpp index 1097db08a..e05c9a357 100644 --- a/src/video_core/gpu.cpp +++ b/src/video_core/gpu.cpp | |||
| @@ -83,19 +83,11 @@ struct GPU::Impl { | |||
| 83 | UNIMPLEMENTED(); | 83 | UNIMPLEMENTED(); |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | void CreateHost1xChannel() { | ||
| 87 | if (host1x_channel) { | ||
| 88 | return; | ||
| 89 | } | ||
| 90 | host1x_channel = CreateChannel(0); | ||
| 91 | host1x_channel->memory_manager = std::make_shared<Tegra::MemoryManager>(system); | ||
| 92 | InitChannel(*host1x_channel); | ||
| 93 | } | ||
| 94 | |||
| 95 | /// Binds a renderer to the GPU. | 86 | /// Binds a renderer to the GPU. |
| 96 | void BindRenderer(std::unique_ptr<VideoCore::RendererBase> renderer_) { | 87 | void BindRenderer(std::unique_ptr<VideoCore::RendererBase> renderer_) { |
| 97 | renderer = std::move(renderer_); | 88 | renderer = std::move(renderer_); |
| 98 | rasterizer = renderer->ReadRasterizer(); | 89 | rasterizer = renderer->ReadRasterizer(); |
| 90 | host1x.MemoryManager().BindRasterizer(rasterizer); | ||
| 99 | } | 91 | } |
| 100 | 92 | ||
| 101 | /// Flush all current written commands into the host GPU for execution. | 93 | /// Flush all current written commands into the host GPU for execution. |
| @@ -173,12 +165,6 @@ struct GPU::Impl { | |||
| 173 | return *current_channel->kepler_compute; | 165 | return *current_channel->kepler_compute; |
| 174 | } | 166 | } |
| 175 | 167 | ||
| 176 | /// Returns a reference to the GPU memory manager. | ||
| 177 | [[nodiscard]] Tegra::MemoryManager& MemoryManager() { | ||
| 178 | CreateHost1xChannel(); | ||
| 179 | return *host1x_channel->memory_manager; | ||
| 180 | } | ||
| 181 | |||
| 182 | /// Returns a reference to the GPU DMA pusher. | 168 | /// Returns a reference to the GPU DMA pusher. |
| 183 | [[nodiscard]] Tegra::DmaPusher& DmaPusher() { | 169 | [[nodiscard]] Tegra::DmaPusher& DmaPusher() { |
| 184 | ASSERT(current_channel); | 170 | ASSERT(current_channel); |
| @@ -299,7 +285,7 @@ struct GPU::Impl { | |||
| 299 | } | 285 | } |
| 300 | 286 | ||
| 301 | if (!cdma_pushers.contains(id)) { | 287 | if (!cdma_pushers.contains(id)) { |
| 302 | cdma_pushers.insert_or_assign(id, std::make_unique<Tegra::CDmaPusher>(gpu)); | 288 | cdma_pushers.insert_or_assign(id, std::make_unique<Tegra::CDmaPusher>(host1x)); |
| 303 | } | 289 | } |
| 304 | 290 | ||
| 305 | // SubmitCommandBuffer would make the nvdec operations async, this is not currently working | 291 | // SubmitCommandBuffer would make the nvdec operations async, this is not currently working |
| @@ -389,7 +375,6 @@ struct GPU::Impl { | |||
| 389 | VideoCore::RasterizerInterface* rasterizer = nullptr; | 375 | VideoCore::RasterizerInterface* rasterizer = nullptr; |
| 390 | const bool use_nvdec; | 376 | const bool use_nvdec; |
| 391 | 377 | ||
| 392 | std::shared_ptr<Control::ChannelState> host1x_channel; | ||
| 393 | s32 new_channel_id{1}; | 378 | s32 new_channel_id{1}; |
| 394 | /// Shader build notifier | 379 | /// Shader build notifier |
| 395 | std::unique_ptr<VideoCore::ShaderNotify> shader_notify; | 380 | std::unique_ptr<VideoCore::ShaderNotify> shader_notify; |
| @@ -510,14 +495,6 @@ const Engines::KeplerCompute& GPU::KeplerCompute() const { | |||
| 510 | return impl->KeplerCompute(); | 495 | return impl->KeplerCompute(); |
| 511 | } | 496 | } |
| 512 | 497 | ||
| 513 | Tegra::MemoryManager& GPU::MemoryManager() { | ||
| 514 | return impl->MemoryManager(); | ||
| 515 | } | ||
| 516 | |||
| 517 | const Tegra::MemoryManager& GPU::MemoryManager() const { | ||
| 518 | return impl->MemoryManager(); | ||
| 519 | } | ||
| 520 | |||
| 521 | Tegra::DmaPusher& GPU::DmaPusher() { | 498 | Tegra::DmaPusher& GPU::DmaPusher() { |
| 522 | return impl->DmaPusher(); | 499 | return impl->DmaPusher(); |
| 523 | } | 500 | } |
diff --git a/src/video_core/gpu.h b/src/video_core/gpu.h index c1a538257..f04edf5c4 100644 --- a/src/video_core/gpu.h +++ b/src/video_core/gpu.h | |||
| @@ -153,12 +153,6 @@ public: | |||
| 153 | /// Returns a reference to the KeplerCompute GPU engine. | 153 | /// Returns a reference to the KeplerCompute GPU engine. |
| 154 | [[nodiscard]] const Engines::KeplerCompute& KeplerCompute() const; | 154 | [[nodiscard]] const Engines::KeplerCompute& KeplerCompute() const; |
| 155 | 155 | ||
| 156 | /// Returns a reference to the GPU memory manager. | ||
| 157 | [[nodiscard]] Tegra::MemoryManager& MemoryManager(); | ||
| 158 | |||
| 159 | /// Returns a const reference to the GPU memory manager. | ||
| 160 | [[nodiscard]] const Tegra::MemoryManager& MemoryManager() const; | ||
| 161 | |||
| 162 | /// Returns a reference to the GPU DMA pusher. | 156 | /// Returns a reference to the GPU DMA pusher. |
| 163 | [[nodiscard]] Tegra::DmaPusher& DmaPusher(); | 157 | [[nodiscard]] Tegra::DmaPusher& DmaPusher(); |
| 164 | 158 | ||
diff --git a/src/video_core/host1x/codecs/codec.cpp b/src/video_core/host1x/codecs/codec.cpp index 70c47ae03..42e7d6e4f 100644 --- a/src/video_core/host1x/codecs/codec.cpp +++ b/src/video_core/host1x/codecs/codec.cpp | |||
| @@ -6,11 +6,11 @@ | |||
| 6 | #include <vector> | 6 | #include <vector> |
| 7 | #include "common/assert.h" | 7 | #include "common/assert.h" |
| 8 | #include "common/settings.h" | 8 | #include "common/settings.h" |
| 9 | #include "video_core/gpu.h" | ||
| 10 | #include "video_core/host1x/codecs/codec.h" | 9 | #include "video_core/host1x/codecs/codec.h" |
| 11 | #include "video_core/host1x/codecs/h264.h" | 10 | #include "video_core/host1x/codecs/h264.h" |
| 12 | #include "video_core/host1x/codecs/vp8.h" | 11 | #include "video_core/host1x/codecs/vp8.h" |
| 13 | #include "video_core/host1x/codecs/vp9.h" | 12 | #include "video_core/host1x/codecs/vp9.h" |
| 13 | #include "video_core/host1x/host1x.h" | ||
| 14 | #include "video_core/memory_manager.h" | 14 | #include "video_core/memory_manager.h" |
| 15 | 15 | ||
| 16 | extern "C" { | 16 | extern "C" { |
| @@ -73,10 +73,10 @@ void AVFrameDeleter(AVFrame* ptr) { | |||
| 73 | av_frame_free(&ptr); | 73 | av_frame_free(&ptr); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | Codec::Codec(GPU& gpu_, const Host1x::NvdecCommon::NvdecRegisters& regs) | 76 | Codec::Codec(Host1x::Host1x& host1x_, const Host1x::NvdecCommon::NvdecRegisters& regs) |
| 77 | : gpu(gpu_), state{regs}, h264_decoder(std::make_unique<Decoder::H264>(gpu)), | 77 | : host1x(host1x_), state{regs}, h264_decoder(std::make_unique<Decoder::H264>(host1x)), |
| 78 | vp8_decoder(std::make_unique<Decoder::VP8>(gpu)), | 78 | vp8_decoder(std::make_unique<Decoder::VP8>(host1x)), |
| 79 | vp9_decoder(std::make_unique<Decoder::VP9>(gpu)) {} | 79 | vp9_decoder(std::make_unique<Decoder::VP9>(host1x)) {} |
| 80 | 80 | ||
| 81 | Codec::~Codec() { | 81 | Codec::~Codec() { |
| 82 | if (!initialized) { | 82 | if (!initialized) { |
diff --git a/src/video_core/host1x/codecs/codec.h b/src/video_core/host1x/codecs/codec.h index 117cb3ccd..0d45fb7fe 100644 --- a/src/video_core/host1x/codecs/codec.h +++ b/src/video_core/host1x/codecs/codec.h | |||
| @@ -21,7 +21,6 @@ extern "C" { | |||
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | namespace Tegra { | 23 | namespace Tegra { |
| 24 | class GPU; | ||
| 25 | 24 | ||
| 26 | void AVFrameDeleter(AVFrame* ptr); | 25 | void AVFrameDeleter(AVFrame* ptr); |
| 27 | using AVFramePtr = std::unique_ptr<AVFrame, decltype(&AVFrameDeleter)>; | 26 | using AVFramePtr = std::unique_ptr<AVFrame, decltype(&AVFrameDeleter)>; |
| @@ -32,9 +31,13 @@ class VP8; | |||
| 32 | class VP9; | 31 | class VP9; |
| 33 | } // namespace Decoder | 32 | } // namespace Decoder |
| 34 | 33 | ||
| 34 | namespace Host1x { | ||
| 35 | class Host1x; | ||
| 36 | } // namespace Host1x | ||
| 37 | |||
| 35 | class Codec { | 38 | class Codec { |
| 36 | public: | 39 | public: |
| 37 | explicit Codec(GPU& gpu, const Host1x::NvdecCommon::NvdecRegisters& regs); | 40 | explicit Codec(Host1x::Host1x& host1x, const Host1x::NvdecCommon::NvdecRegisters& regs); |
| 38 | ~Codec(); | 41 | ~Codec(); |
| 39 | 42 | ||
| 40 | /// Initialize the codec, returning success or failure | 43 | /// Initialize the codec, returning success or failure |
| @@ -69,7 +72,7 @@ private: | |||
| 69 | AVCodecContext* av_codec_ctx{nullptr}; | 72 | AVCodecContext* av_codec_ctx{nullptr}; |
| 70 | AVBufferRef* av_gpu_decoder{nullptr}; | 73 | AVBufferRef* av_gpu_decoder{nullptr}; |
| 71 | 74 | ||
| 72 | GPU& gpu; | 75 | Host1x::Host1x& host1x; |
| 73 | const Host1x::NvdecCommon::NvdecRegisters& state; | 76 | const Host1x::NvdecCommon::NvdecRegisters& state; |
| 74 | std::unique_ptr<Decoder::H264> h264_decoder; | 77 | std::unique_ptr<Decoder::H264> h264_decoder; |
| 75 | std::unique_ptr<Decoder::VP8> vp8_decoder; | 78 | std::unique_ptr<Decoder::VP8> vp8_decoder; |
diff --git a/src/video_core/host1x/codecs/h264.cpp b/src/video_core/host1x/codecs/h264.cpp index 95534bc85..e87bd65fa 100644 --- a/src/video_core/host1x/codecs/h264.cpp +++ b/src/video_core/host1x/codecs/h264.cpp | |||
| @@ -5,8 +5,8 @@ | |||
| 5 | #include <bit> | 5 | #include <bit> |
| 6 | 6 | ||
| 7 | #include "common/settings.h" | 7 | #include "common/settings.h" |
| 8 | #include "video_core/gpu.h" | ||
| 9 | #include "video_core/host1x/codecs/h264.h" | 8 | #include "video_core/host1x/codecs/h264.h" |
| 9 | #include "video_core/host1x/host1x.h" | ||
| 10 | #include "video_core/memory_manager.h" | 10 | #include "video_core/memory_manager.h" |
| 11 | 11 | ||
| 12 | namespace Tegra::Decoder { | 12 | namespace Tegra::Decoder { |
| @@ -24,19 +24,20 @@ constexpr std::array<u8, 16> zig_zag_scan{ | |||
| 24 | }; | 24 | }; |
| 25 | } // Anonymous namespace | 25 | } // Anonymous namespace |
| 26 | 26 | ||
| 27 | H264::H264(GPU& gpu_) : gpu(gpu_) {} | 27 | H264::H264(Host1x::Host1x& host1x_) : host1x{host1x_} {} |
| 28 | 28 | ||
| 29 | H264::~H264() = default; | 29 | H264::~H264() = default; |
| 30 | 30 | ||
| 31 | const std::vector<u8>& H264::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state, | 31 | const std::vector<u8>& H264::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state, |
| 32 | bool is_first_frame) { | 32 | bool is_first_frame) { |
| 33 | H264DecoderContext context; | 33 | H264DecoderContext context; |
| 34 | gpu.MemoryManager().ReadBlock(state.picture_info_offset, &context, sizeof(H264DecoderContext)); | 34 | host1x.MemoryManager().ReadBlock(state.picture_info_offset, &context, |
| 35 | sizeof(H264DecoderContext)); | ||
| 35 | 36 | ||
| 36 | const s64 frame_number = context.h264_parameter_set.frame_number.Value(); | 37 | const s64 frame_number = context.h264_parameter_set.frame_number.Value(); |
| 37 | if (!is_first_frame && frame_number != 0) { | 38 | if (!is_first_frame && frame_number != 0) { |
| 38 | frame.resize(context.stream_len); | 39 | frame.resize(context.stream_len); |
| 39 | gpu.MemoryManager().ReadBlock(state.frame_bitstream_offset, frame.data(), frame.size()); | 40 | host1x.MemoryManager().ReadBlock(state.frame_bitstream_offset, frame.data(), frame.size()); |
| 40 | return frame; | 41 | return frame; |
| 41 | } | 42 | } |
| 42 | 43 | ||
| @@ -155,8 +156,8 @@ const std::vector<u8>& H264::ComposeFrame(const Host1x::NvdecCommon::NvdecRegist | |||
| 155 | frame.resize(encoded_header.size() + context.stream_len); | 156 | frame.resize(encoded_header.size() + context.stream_len); |
| 156 | std::memcpy(frame.data(), encoded_header.data(), encoded_header.size()); | 157 | std::memcpy(frame.data(), encoded_header.data(), encoded_header.size()); |
| 157 | 158 | ||
| 158 | gpu.MemoryManager().ReadBlock(state.frame_bitstream_offset, | 159 | host1x.MemoryManager().ReadBlock(state.frame_bitstream_offset, |
| 159 | frame.data() + encoded_header.size(), context.stream_len); | 160 | frame.data() + encoded_header.size(), context.stream_len); |
| 160 | 161 | ||
| 161 | return frame; | 162 | return frame; |
| 162 | } | 163 | } |
diff --git a/src/video_core/host1x/codecs/h264.h b/src/video_core/host1x/codecs/h264.h index a98730474..5cc86454e 100644 --- a/src/video_core/host1x/codecs/h264.h +++ b/src/video_core/host1x/codecs/h264.h | |||
| @@ -11,7 +11,11 @@ | |||
| 11 | #include "video_core/host1x/nvdec_common.h" | 11 | #include "video_core/host1x/nvdec_common.h" |
| 12 | 12 | ||
| 13 | namespace Tegra { | 13 | namespace Tegra { |
| 14 | class GPU; | 14 | |
| 15 | namespace Host1x { | ||
| 16 | class Host1x; | ||
| 17 | } // namespace Host1x | ||
| 18 | |||
| 15 | namespace Decoder { | 19 | namespace Decoder { |
| 16 | 20 | ||
| 17 | class H264BitWriter { | 21 | class H264BitWriter { |
| @@ -55,7 +59,7 @@ private: | |||
| 55 | 59 | ||
| 56 | class H264 { | 60 | class H264 { |
| 57 | public: | 61 | public: |
| 58 | explicit H264(GPU& gpu); | 62 | explicit H264(Host1x::Host1x& host1x); |
| 59 | ~H264(); | 63 | ~H264(); |
| 60 | 64 | ||
| 61 | /// Compose the H264 frame for FFmpeg decoding | 65 | /// Compose the H264 frame for FFmpeg decoding |
| @@ -64,7 +68,7 @@ public: | |||
| 64 | 68 | ||
| 65 | private: | 69 | private: |
| 66 | std::vector<u8> frame; | 70 | std::vector<u8> frame; |
| 67 | GPU& gpu; | 71 | Host1x::Host1x& host1x; |
| 68 | 72 | ||
| 69 | struct H264ParameterSet { | 73 | struct H264ParameterSet { |
| 70 | s32 log2_max_pic_order_cnt_lsb_minus4; ///< 0x00 | 74 | s32 log2_max_pic_order_cnt_lsb_minus4; ///< 0x00 |
diff --git a/src/video_core/host1x/codecs/vp8.cpp b/src/video_core/host1x/codecs/vp8.cpp index aac026e17..28fb12cb8 100644 --- a/src/video_core/host1x/codecs/vp8.cpp +++ b/src/video_core/host1x/codecs/vp8.cpp | |||
| @@ -3,18 +3,18 @@ | |||
| 3 | 3 | ||
| 4 | #include <vector> | 4 | #include <vector> |
| 5 | 5 | ||
| 6 | #include "video_core/gpu.h" | ||
| 7 | #include "video_core/host1x/codecs/vp8.h" | 6 | #include "video_core/host1x/codecs/vp8.h" |
| 7 | #include "video_core/host1x/host1x.h" | ||
| 8 | #include "video_core/memory_manager.h" | 8 | #include "video_core/memory_manager.h" |
| 9 | 9 | ||
| 10 | namespace Tegra::Decoder { | 10 | namespace Tegra::Decoder { |
| 11 | VP8::VP8(GPU& gpu_) : gpu(gpu_) {} | 11 | VP8::VP8(Host1x::Host1x& host1x_) : host1x{host1x_} {} |
| 12 | 12 | ||
| 13 | VP8::~VP8() = default; | 13 | VP8::~VP8() = default; |
| 14 | 14 | ||
| 15 | const std::vector<u8>& VP8::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state) { | 15 | const std::vector<u8>& VP8::ComposeFrame(const Host1x::NvdecCommon::NvdecRegisters& state) { |
| 16 | VP8PictureInfo info; | 16 | VP8PictureInfo info; |
| 17 | gpu.MemoryManager().ReadBlock(state.picture_info_offset, &info, sizeof(VP8PictureInfo)); | 17 | host1x.MemoryManager().ReadBlock(state.picture_info_offset, &info, sizeof(VP8PictureInfo)); |
| 18 | 18 | ||
| 19 | const bool is_key_frame = info.key_frame == 1u; | 19 | const bool is_key_frame = info.key_frame == 1u; |
| 20 | const auto bitstream_size = static_cast<size_t>(info.vld_buffer_size); | 20 | const auto bitstream_size = static_cast<size_t>(info.vld_buffer_size); |
| @@ -45,7 +45,7 @@ const std::vector<u8>& VP8::ComposeFrame(const Host1x::NvdecCommon::NvdecRegiste | |||
| 45 | frame[9] = static_cast<u8>(((info.frame_height >> 8) & 0x3f)); | 45 | frame[9] = static_cast<u8>(((info.frame_height >> 8) & 0x3f)); |
| 46 | } | 46 | } |
| 47 | const u64 bitstream_offset = state.frame_bitstream_offset; | 47 | const u64 bitstream_offset = state.frame_bitstream_offset; |
| 48 | gpu.MemoryManager().ReadBlock(bitstream_offset, frame.data() + header_size, bitstream_size); | 48 | host1x.MemoryManager().ReadBlock(bitstream_offset, frame.data() + header_size, bitstream_size); |
| 49 | 49 | ||
| 50 | return frame; | 50 | return frame; |
| 51 | } | 51 | } |
diff --git a/src/video_core/host1x/codecs/vp8.h b/src/video_core/host1x/codecs/vp8.h index a1dfa5f03..5bf07ecab 100644 --- a/src/video_core/host1x/codecs/vp8.h +++ b/src/video_core/host1x/codecs/vp8.h | |||
| @@ -11,12 +11,16 @@ | |||
| 11 | #include "video_core/host1x/nvdec_common.h" | 11 | #include "video_core/host1x/nvdec_common.h" |
| 12 | 12 | ||
| 13 | namespace Tegra { | 13 | namespace Tegra { |
| 14 | class GPU; | 14 | |
| 15 | namespace Host1x { | ||
| 16 | class Host1x; | ||
| 17 | } // namespace Host1x | ||
| 18 | |||
| 15 | namespace Decoder { | 19 | namespace Decoder { |
| 16 | 20 | ||
| 17 | class VP8 { | 21 | class VP8 { |
| 18 | public: | 22 | public: |
| 19 | explicit VP8(GPU& gpu); | 23 | explicit VP8(Host1x::Host1x& host1x); |
| 20 | ~VP8(); | 24 | ~VP8(); |
| 21 | 25 | ||
| 22 | /// Compose the VP8 frame for FFmpeg decoding | 26 | /// Compose the VP8 frame for FFmpeg decoding |
| @@ -25,7 +29,7 @@ public: | |||
| 25 | 29 | ||
| 26 | private: | 30 | private: |
| 27 | std::vector<u8> frame; | 31 | std::vector<u8> frame; |
| 28 | GPU& gpu; | 32 | Host1x::Host1x& host1x; |
| 29 | 33 | ||
| 30 | struct VP8PictureInfo { | 34 | struct VP8PictureInfo { |
| 31 | INSERT_PADDING_WORDS_NOINIT(14); | 35 | INSERT_PADDING_WORDS_NOINIT(14); |
diff --git a/src/video_core/host1x/codecs/vp9.cpp b/src/video_core/host1x/codecs/vp9.cpp index bc50c6ba4..667aadc6a 100644 --- a/src/video_core/host1x/codecs/vp9.cpp +++ b/src/video_core/host1x/codecs/vp9.cpp | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | #include <algorithm> // for std::copy | 4 | #include <algorithm> // for std::copy |
| 5 | #include <numeric> | 5 | #include <numeric> |
| 6 | #include "common/assert.h" | 6 | #include "common/assert.h" |
| 7 | #include "video_core/gpu.h" | ||
| 8 | #include "video_core/host1x/codecs/vp9.h" | 7 | #include "video_core/host1x/codecs/vp9.h" |
| 8 | #include "video_core/host1x/host1x.h" | ||
| 9 | #include "video_core/memory_manager.h" | 9 | #include "video_core/memory_manager.h" |
| 10 | 10 | ||
| 11 | namespace Tegra::Decoder { | 11 | namespace Tegra::Decoder { |
| @@ -236,7 +236,7 @@ constexpr std::array<u8, 254> map_lut{ | |||
| 236 | } | 236 | } |
| 237 | } // Anonymous namespace | 237 | } // Anonymous namespace |
| 238 | 238 | ||
| 239 | VP9::VP9(GPU& gpu_) : gpu{gpu_} {} | 239 | VP9::VP9(Host1x::Host1x& host1x_) : host1x{host1x_} {} |
| 240 | 240 | ||
| 241 | VP9::~VP9() = default; | 241 | VP9::~VP9() = default; |
| 242 | 242 | ||
| @@ -357,7 +357,7 @@ void VP9::WriteMvProbabilityUpdate(VpxRangeEncoder& writer, u8 new_prob, u8 old_ | |||
| 357 | 357 | ||
| 358 | Vp9PictureInfo VP9::GetVp9PictureInfo(const Host1x::NvdecCommon::NvdecRegisters& state) { | 358 | Vp9PictureInfo VP9::GetVp9PictureInfo(const Host1x::NvdecCommon::NvdecRegisters& state) { |
| 359 | PictureInfo picture_info; | 359 | PictureInfo picture_info; |
| 360 | gpu.MemoryManager().ReadBlock(state.picture_info_offset, &picture_info, sizeof(PictureInfo)); | 360 | host1x.MemoryManager().ReadBlock(state.picture_info_offset, &picture_info, sizeof(PictureInfo)); |
| 361 | Vp9PictureInfo vp9_info = picture_info.Convert(); | 361 | Vp9PictureInfo vp9_info = picture_info.Convert(); |
| 362 | 362 | ||
| 363 | InsertEntropy(state.vp9_entropy_probs_offset, vp9_info.entropy); | 363 | InsertEntropy(state.vp9_entropy_probs_offset, vp9_info.entropy); |
| @@ -372,17 +372,17 @@ Vp9PictureInfo VP9::GetVp9PictureInfo(const Host1x::NvdecCommon::NvdecRegisters& | |||
| 372 | 372 | ||
| 373 | void VP9::InsertEntropy(u64 offset, Vp9EntropyProbs& dst) { | 373 | void VP9::InsertEntropy(u64 offset, Vp9EntropyProbs& dst) { |
| 374 | EntropyProbs entropy; | 374 | EntropyProbs entropy; |
| 375 | gpu.MemoryManager().ReadBlock(offset, &entropy, sizeof(EntropyProbs)); | 375 | host1x.MemoryManager().ReadBlock(offset, &entropy, sizeof(EntropyProbs)); |
| 376 | entropy.Convert(dst); | 376 | entropy.Convert(dst); |
| 377 | } | 377 | } |
| 378 | 378 | ||
| 379 | Vp9FrameContainer VP9::GetCurrentFrame(const Host1x::NvdecCommon::NvdecRegisters& state) { | 379 | Vp9FrameContainer VP9::GetCurrentFrame(const Host1x::NvdecCommon::NvdecRegisters& state) { |
| 380 | Vp9FrameContainer current_frame{}; | 380 | Vp9FrameContainer current_frame{}; |
| 381 | { | 381 | { |
| 382 | gpu.SyncGuestHost(); | 382 | // gpu.SyncGuestHost(); epic, why? |
| 383 | current_frame.info = GetVp9PictureInfo(state); | 383 | current_frame.info = GetVp9PictureInfo(state); |
| 384 | current_frame.bit_stream.resize(current_frame.info.bitstream_size); | 384 | current_frame.bit_stream.resize(current_frame.info.bitstream_size); |
| 385 | gpu.MemoryManager().ReadBlock(state.frame_bitstream_offset, current_frame.bit_stream.data(), | 385 | host1x.MemoryManager().ReadBlock(state.frame_bitstream_offset, current_frame.bit_stream.data(), |
| 386 | current_frame.info.bitstream_size); | 386 | current_frame.info.bitstream_size); |
| 387 | } | 387 | } |
| 388 | if (!next_frame.bit_stream.empty()) { | 388 | if (!next_frame.bit_stream.empty()) { |
diff --git a/src/video_core/host1x/codecs/vp9.h b/src/video_core/host1x/codecs/vp9.h index a425c0fa4..d4083e8d3 100644 --- a/src/video_core/host1x/codecs/vp9.h +++ b/src/video_core/host1x/codecs/vp9.h | |||
| @@ -12,7 +12,11 @@ | |||
| 12 | #include "video_core/host1x/nvdec_common.h" | 12 | #include "video_core/host1x/nvdec_common.h" |
| 13 | 13 | ||
| 14 | namespace Tegra { | 14 | namespace Tegra { |
| 15 | class GPU; | 15 | |
| 16 | namespace Host1x { | ||
| 17 | class Host1x; | ||
| 18 | } // namespace Host1x | ||
| 19 | |||
| 16 | namespace Decoder { | 20 | namespace Decoder { |
| 17 | 21 | ||
| 18 | /// The VpxRangeEncoder, and VpxBitStreamWriter classes are used to compose the | 22 | /// The VpxRangeEncoder, and VpxBitStreamWriter classes are used to compose the |
| @@ -106,7 +110,7 @@ private: | |||
| 106 | 110 | ||
| 107 | class VP9 { | 111 | class VP9 { |
| 108 | public: | 112 | public: |
| 109 | explicit VP9(GPU& gpu_); | 113 | explicit VP9(Host1x::Host1x& host1x); |
| 110 | ~VP9(); | 114 | ~VP9(); |
| 111 | 115 | ||
| 112 | VP9(const VP9&) = delete; | 116 | VP9(const VP9&) = delete; |
| @@ -176,7 +180,7 @@ private: | |||
| 176 | [[nodiscard]] std::vector<u8> ComposeCompressedHeader(); | 180 | [[nodiscard]] std::vector<u8> ComposeCompressedHeader(); |
| 177 | [[nodiscard]] VpxBitStreamWriter ComposeUncompressedHeader(); | 181 | [[nodiscard]] VpxBitStreamWriter ComposeUncompressedHeader(); |
| 178 | 182 | ||
| 179 | GPU& gpu; | 183 | Host1x::Host1x& host1x; |
| 180 | std::vector<u8> frame; | 184 | std::vector<u8> frame; |
| 181 | 185 | ||
| 182 | std::array<s8, 4> loop_filter_ref_deltas{}; | 186 | std::array<s8, 4> loop_filter_ref_deltas{}; |
diff --git a/src/video_core/host1x/codecs/vp9_types.h b/src/video_core/host1x/codecs/vp9_types.h index bb3d8df6e..adad8ed7e 100644 --- a/src/video_core/host1x/codecs/vp9_types.h +++ b/src/video_core/host1x/codecs/vp9_types.h | |||
| @@ -9,7 +9,6 @@ | |||
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | 10 | ||
| 11 | namespace Tegra { | 11 | namespace Tegra { |
| 12 | class GPU; | ||
| 13 | 12 | ||
| 14 | namespace Decoder { | 13 | namespace Decoder { |
| 15 | struct Vp9FrameDimensions { | 14 | struct Vp9FrameDimensions { |
diff --git a/src/video_core/host1x/control.cpp b/src/video_core/host1x/control.cpp index b72b01aa3..a81c635ae 100644 --- a/src/video_core/host1x/control.cpp +++ b/src/video_core/host1x/control.cpp | |||
| @@ -3,13 +3,12 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include "common/assert.h" | 5 | #include "common/assert.h" |
| 6 | #include "video_core/gpu.h" | ||
| 7 | #include "video_core/host1x/control.h" | 6 | #include "video_core/host1x/control.h" |
| 8 | #include "video_core/host1x/host1x.h" | 7 | #include "video_core/host1x/host1x.h" |
| 9 | 8 | ||
| 10 | namespace Tegra::Host1x { | 9 | namespace Tegra::Host1x { |
| 11 | 10 | ||
| 12 | Control::Control(GPU& gpu_) : gpu(gpu_) {} | 11 | Control::Control(Host1x& host1x_) : host1x(host1x_) {} |
| 13 | 12 | ||
| 14 | Control::~Control() = default; | 13 | Control::~Control() = default; |
| 15 | 14 | ||
| @@ -29,7 +28,7 @@ void Control::ProcessMethod(Method method, u32 argument) { | |||
| 29 | } | 28 | } |
| 30 | 29 | ||
| 31 | void Control::Execute(u32 data) { | 30 | void Control::Execute(u32 data) { |
| 32 | gpu.Host1x().GetSyncpointManager().WaitHost(data, syncpoint_value); | 31 | host1x.GetSyncpointManager().WaitHost(data, syncpoint_value); |
| 33 | } | 32 | } |
| 34 | 33 | ||
| 35 | } // namespace Tegra::Host1x | 34 | } // namespace Tegra::Host1x |
diff --git a/src/video_core/host1x/control.h b/src/video_core/host1x/control.h index 04dac7d51..18a9b56c0 100644 --- a/src/video_core/host1x/control.h +++ b/src/video_core/host1x/control.h | |||
| @@ -8,10 +8,10 @@ | |||
| 8 | #include "common/common_types.h" | 8 | #include "common/common_types.h" |
| 9 | 9 | ||
| 10 | namespace Tegra { | 10 | namespace Tegra { |
| 11 | class GPU; | ||
| 12 | 11 | ||
| 13 | namespace Host1x { | 12 | namespace Host1x { |
| 14 | 13 | ||
| 14 | class Host1x; | ||
| 15 | class Nvdec; | 15 | class Nvdec; |
| 16 | 16 | ||
| 17 | class Control { | 17 | class Control { |
| @@ -22,7 +22,7 @@ public: | |||
| 22 | WaitSyncpt32 = 0x50, | 22 | WaitSyncpt32 = 0x50, |
| 23 | }; | 23 | }; |
| 24 | 24 | ||
| 25 | explicit Control(GPU& gpu); | 25 | explicit Control(Host1x& host1x); |
| 26 | ~Control(); | 26 | ~Control(); |
| 27 | 27 | ||
| 28 | /// Writes the method into the state, Invoke Execute() if encountered | 28 | /// Writes the method into the state, Invoke Execute() if encountered |
| @@ -33,7 +33,7 @@ private: | |||
| 33 | void Execute(u32 data); | 33 | void Execute(u32 data); |
| 34 | 34 | ||
| 35 | u32 syncpoint_value{}; | 35 | u32 syncpoint_value{}; |
| 36 | GPU& gpu; | 36 | Host1x& host1x; |
| 37 | }; | 37 | }; |
| 38 | 38 | ||
| 39 | } // namespace Host1x | 39 | } // namespace Host1x |
diff --git a/src/video_core/host1x/host1x.cpp b/src/video_core/host1x/host1x.cpp new file mode 100644 index 000000000..eb00f4855 --- /dev/null +++ b/src/video_core/host1x/host1x.cpp | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | // Copyright 2022 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv3 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "core/core.h" | ||
| 6 | #include "video_core/host1x/host1x.h" | ||
| 7 | |||
| 8 | namespace Tegra { | ||
| 9 | |||
| 10 | namespace Host1x { | ||
| 11 | |||
| 12 | Host1x::Host1x(Core::System& system_) | ||
| 13 | : system{system_}, syncpoint_manager{}, memory_manager{system, 32, 12}, | ||
| 14 | allocator{std::make_unique<Common::FlatAllocator<u32, 0, 32>>(1 << 12)} {} | ||
| 15 | |||
| 16 | } // namespace Host1x | ||
| 17 | |||
| 18 | } // namespace Tegra | ||
diff --git a/src/video_core/host1x/host1x.h b/src/video_core/host1x/host1x.h index 2971be286..e4b69d75a 100644 --- a/src/video_core/host1x/host1x.h +++ b/src/video_core/host1x/host1x.h | |||
| @@ -6,7 +6,13 @@ | |||
| 6 | 6 | ||
| 7 | #include "common/common_types.h" | 7 | #include "common/common_types.h" |
| 8 | 8 | ||
| 9 | #include "common/address_space.h" | ||
| 9 | #include "video_core/host1x/syncpoint_manager.h" | 10 | #include "video_core/host1x/syncpoint_manager.h" |
| 11 | #include "video_core/memory_manager.h" | ||
| 12 | |||
| 13 | namespace Core { | ||
| 14 | class System; | ||
| 15 | } // namespace Core | ||
| 10 | 16 | ||
| 11 | namespace Tegra { | 17 | namespace Tegra { |
| 12 | 18 | ||
| @@ -14,7 +20,7 @@ namespace Host1x { | |||
| 14 | 20 | ||
| 15 | class Host1x { | 21 | class Host1x { |
| 16 | public: | 22 | public: |
| 17 | Host1x() : syncpoint_manager{} {} | 23 | Host1x(Core::System& system); |
| 18 | 24 | ||
| 19 | SyncpointManager& GetSyncpointManager() { | 25 | SyncpointManager& GetSyncpointManager() { |
| 20 | return syncpoint_manager; | 26 | return syncpoint_manager; |
| @@ -24,8 +30,27 @@ public: | |||
| 24 | return syncpoint_manager; | 30 | return syncpoint_manager; |
| 25 | } | 31 | } |
| 26 | 32 | ||
| 33 | Tegra::MemoryManager& MemoryManager() { | ||
| 34 | return memory_manager; | ||
| 35 | } | ||
| 36 | |||
| 37 | const Tegra::MemoryManager& MemoryManager() const { | ||
| 38 | return memory_manager; | ||
| 39 | } | ||
| 40 | |||
| 41 | Common::FlatAllocator<u32, 0, 32>& Allocator() { | ||
| 42 | return *allocator; | ||
| 43 | } | ||
| 44 | |||
| 45 | const Common::FlatAllocator<u32, 0, 32>& Allocator() const { | ||
| 46 | return *allocator; | ||
| 47 | } | ||
| 48 | |||
| 27 | private: | 49 | private: |
| 50 | Core::System& system; | ||
| 28 | SyncpointManager syncpoint_manager; | 51 | SyncpointManager syncpoint_manager; |
| 52 | Tegra::MemoryManager memory_manager; | ||
| 53 | std::unique_ptr<Common::FlatAllocator<u32, 0, 32>> allocator; | ||
| 29 | }; | 54 | }; |
| 30 | 55 | ||
| 31 | } // namespace Host1x | 56 | } // namespace Host1x |
diff --git a/src/video_core/host1x/nvdec.cpp b/src/video_core/host1x/nvdec.cpp index 5f6decd0d..a4bd5b79f 100644 --- a/src/video_core/host1x/nvdec.cpp +++ b/src/video_core/host1x/nvdec.cpp | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "common/assert.h" | 4 | #include "common/assert.h" |
| 5 | #include "video_core/gpu.h" | 5 | #include "video_core/host1x/host1x.h" |
| 6 | #include "video_core/host1x/nvdec.h" | 6 | #include "video_core/host1x/nvdec.h" |
| 7 | 7 | ||
| 8 | namespace Tegra::Host1x { | 8 | namespace Tegra::Host1x { |
| @@ -10,7 +10,8 @@ namespace Tegra::Host1x { | |||
| 10 | #define NVDEC_REG_INDEX(field_name) \ | 10 | #define NVDEC_REG_INDEX(field_name) \ |
| 11 | (offsetof(NvdecCommon::NvdecRegisters, field_name) / sizeof(u64)) | 11 | (offsetof(NvdecCommon::NvdecRegisters, field_name) / sizeof(u64)) |
| 12 | 12 | ||
| 13 | Nvdec::Nvdec(GPU& gpu_) : gpu(gpu_), state{}, codec(std::make_unique<Codec>(gpu, state)) {} | 13 | Nvdec::Nvdec(Host1x& host1x_) |
| 14 | : host1x(host1x_), state{}, codec(std::make_unique<Codec>(host1x, state)) {} | ||
| 14 | 15 | ||
| 15 | Nvdec::~Nvdec() = default; | 16 | Nvdec::~Nvdec() = default; |
| 16 | 17 | ||
diff --git a/src/video_core/host1x/nvdec.h b/src/video_core/host1x/nvdec.h index 41ba1f7a0..3949d5181 100644 --- a/src/video_core/host1x/nvdec.h +++ b/src/video_core/host1x/nvdec.h | |||
| @@ -9,13 +9,14 @@ | |||
| 9 | #include "video_core/host1x/codecs/codec.h" | 9 | #include "video_core/host1x/codecs/codec.h" |
| 10 | 10 | ||
| 11 | namespace Tegra { | 11 | namespace Tegra { |
| 12 | class GPU; | ||
| 13 | 12 | ||
| 14 | namespace Host1x { | 13 | namespace Host1x { |
| 15 | 14 | ||
| 15 | class Host1x; | ||
| 16 | |||
| 16 | class Nvdec { | 17 | class Nvdec { |
| 17 | public: | 18 | public: |
| 18 | explicit Nvdec(GPU& gpu); | 19 | explicit Nvdec(Host1x& host1x); |
| 19 | ~Nvdec(); | 20 | ~Nvdec(); |
| 20 | 21 | ||
| 21 | /// Writes the method into the state, Invoke Execute() if encountered | 22 | /// Writes the method into the state, Invoke Execute() if encountered |
| @@ -28,7 +29,7 @@ private: | |||
| 28 | /// Invoke codec to decode a frame | 29 | /// Invoke codec to decode a frame |
| 29 | void Execute(); | 30 | void Execute(); |
| 30 | 31 | ||
| 31 | GPU& gpu; | 32 | Host1x& host1x; |
| 32 | NvdecCommon::NvdecRegisters state; | 33 | NvdecCommon::NvdecRegisters state; |
| 33 | std::unique_ptr<Codec> codec; | 34 | std::unique_ptr<Codec> codec; |
| 34 | }; | 35 | }; |
diff --git a/src/video_core/host1x/sync_manager.cpp b/src/video_core/host1x/sync_manager.cpp index 8694f77e2..5ef9ea217 100644 --- a/src/video_core/host1x/sync_manager.cpp +++ b/src/video_core/host1x/sync_manager.cpp | |||
| @@ -3,14 +3,13 @@ | |||
| 3 | 3 | ||
| 4 | #include <algorithm> | 4 | #include <algorithm> |
| 5 | #include "sync_manager.h" | 5 | #include "sync_manager.h" |
| 6 | #include "video_core/gpu.h" | ||
| 7 | #include "video_core/host1x/host1x.h" | 6 | #include "video_core/host1x/host1x.h" |
| 8 | #include "video_core/host1x/syncpoint_manager.h" | 7 | #include "video_core/host1x/syncpoint_manager.h" |
| 9 | 8 | ||
| 10 | namespace Tegra { | 9 | namespace Tegra { |
| 11 | namespace Host1x { | 10 | namespace Host1x { |
| 12 | 11 | ||
| 13 | SyncptIncrManager::SyncptIncrManager(GPU& gpu_) : gpu(gpu_) {} | 12 | SyncptIncrManager::SyncptIncrManager(Host1x& host1x_) : host1x(host1x_) {} |
| 14 | SyncptIncrManager::~SyncptIncrManager() = default; | 13 | SyncptIncrManager::~SyncptIncrManager() = default; |
| 15 | 14 | ||
| 16 | void SyncptIncrManager::Increment(u32 id) { | 15 | void SyncptIncrManager::Increment(u32 id) { |
| @@ -40,7 +39,7 @@ void SyncptIncrManager::IncrementAllDone() { | |||
| 40 | if (!increments[done_count].complete) { | 39 | if (!increments[done_count].complete) { |
| 41 | break; | 40 | break; |
| 42 | } | 41 | } |
| 43 | auto& syncpoint_manager = gpu.Host1x().GetSyncpointManager(); | 42 | auto& syncpoint_manager = host1x.GetSyncpointManager(); |
| 44 | syncpoint_manager.IncrementGuest(increments[done_count].syncpt_id); | 43 | syncpoint_manager.IncrementGuest(increments[done_count].syncpt_id); |
| 45 | syncpoint_manager.IncrementHost(increments[done_count].syncpt_id); | 44 | syncpoint_manager.IncrementHost(increments[done_count].syncpt_id); |
| 46 | } | 45 | } |
diff --git a/src/video_core/host1x/sync_manager.h b/src/video_core/host1x/sync_manager.h index aba72d5c5..7bb77fa27 100644 --- a/src/video_core/host1x/sync_manager.h +++ b/src/video_core/host1x/sync_manager.h | |||
| @@ -9,10 +9,10 @@ | |||
| 9 | 9 | ||
| 10 | namespace Tegra { | 10 | namespace Tegra { |
| 11 | 11 | ||
| 12 | class GPU; | ||
| 13 | |||
| 14 | namespace Host1x { | 12 | namespace Host1x { |
| 15 | 13 | ||
| 14 | class Host1x; | ||
| 15 | |||
| 16 | struct SyncptIncr { | 16 | struct SyncptIncr { |
| 17 | u32 id; | 17 | u32 id; |
| 18 | u32 class_id; | 18 | u32 class_id; |
| @@ -25,7 +25,7 @@ struct SyncptIncr { | |||
| 25 | 25 | ||
| 26 | class SyncptIncrManager { | 26 | class SyncptIncrManager { |
| 27 | public: | 27 | public: |
| 28 | explicit SyncptIncrManager(GPU& gpu); | 28 | explicit SyncptIncrManager(Host1x& host1x); |
| 29 | ~SyncptIncrManager(); | 29 | ~SyncptIncrManager(); |
| 30 | 30 | ||
| 31 | /// Add syncpoint id and increment all | 31 | /// Add syncpoint id and increment all |
| @@ -45,7 +45,7 @@ private: | |||
| 45 | std::mutex increment_lock; | 45 | std::mutex increment_lock; |
| 46 | u32 current_id{}; | 46 | u32 current_id{}; |
| 47 | 47 | ||
| 48 | GPU& gpu; | 48 | Host1x& host1x; |
| 49 | }; | 49 | }; |
| 50 | 50 | ||
| 51 | } // namespace Host1x | 51 | } // namespace Host1x |
diff --git a/src/video_core/host1x/vic.cpp b/src/video_core/host1x/vic.cpp index a9422670a..5d8039841 100644 --- a/src/video_core/host1x/vic.cpp +++ b/src/video_core/host1x/vic.cpp | |||
| @@ -19,7 +19,7 @@ extern "C" { | |||
| 19 | #include "common/logging/log.h" | 19 | #include "common/logging/log.h" |
| 20 | 20 | ||
| 21 | #include "video_core/engines/maxwell_3d.h" | 21 | #include "video_core/engines/maxwell_3d.h" |
| 22 | #include "video_core/gpu.h" | 22 | #include "video_core/host1x/host1x.h" |
| 23 | #include "video_core/host1x/nvdec.h" | 23 | #include "video_core/host1x/nvdec.h" |
| 24 | #include "video_core/host1x/vic.h" | 24 | #include "video_core/host1x/vic.h" |
| 25 | #include "video_core/memory_manager.h" | 25 | #include "video_core/memory_manager.h" |
| @@ -49,8 +49,8 @@ union VicConfig { | |||
| 49 | BitField<46, 14, u64_le> surface_height_minus1; | 49 | BitField<46, 14, u64_le> surface_height_minus1; |
| 50 | }; | 50 | }; |
| 51 | 51 | ||
| 52 | Vic::Vic(GPU& gpu_, std::shared_ptr<Nvdec> nvdec_processor_) | 52 | Vic::Vic(Host1x& host1x_, std::shared_ptr<Nvdec> nvdec_processor_) |
| 53 | : gpu(gpu_), | 53 | : host1x(host1x_), |
| 54 | nvdec_processor(std::move(nvdec_processor_)), converted_frame_buffer{nullptr, av_free} {} | 54 | nvdec_processor(std::move(nvdec_processor_)), converted_frame_buffer{nullptr, av_free} {} |
| 55 | 55 | ||
| 56 | Vic::~Vic() = default; | 56 | Vic::~Vic() = default; |
| @@ -81,7 +81,7 @@ void Vic::Execute() { | |||
| 81 | LOG_ERROR(Service_NVDRV, "VIC Luma address not set."); | 81 | LOG_ERROR(Service_NVDRV, "VIC Luma address not set."); |
| 82 | return; | 82 | return; |
| 83 | } | 83 | } |
| 84 | const VicConfig config{gpu.MemoryManager().Read<u64>(config_struct_address + 0x20)}; | 84 | const VicConfig config{host1x.MemoryManager().Read<u64>(config_struct_address + 0x20)}; |
| 85 | const AVFramePtr frame_ptr = nvdec_processor->GetFrame(); | 85 | const AVFramePtr frame_ptr = nvdec_processor->GetFrame(); |
| 86 | const auto* frame = frame_ptr.get(); | 86 | const auto* frame = frame_ptr.get(); |
| 87 | if (!frame) { | 87 | if (!frame) { |
| @@ -159,12 +159,12 @@ void Vic::WriteRGBFrame(const AVFrame* frame, const VicConfig& config) { | |||
| 159 | Texture::SwizzleSubrect(width, height, width * 4, width, 4, luma_buffer.data(), | 159 | Texture::SwizzleSubrect(width, height, width * 4, width, 4, luma_buffer.data(), |
| 160 | converted_frame_buf_addr, block_height, 0, 0); | 160 | converted_frame_buf_addr, block_height, 0, 0); |
| 161 | 161 | ||
| 162 | gpu.MemoryManager().WriteBlock(output_surface_luma_address, luma_buffer.data(), size); | 162 | host1x.MemoryManager().WriteBlock(output_surface_luma_address, luma_buffer.data(), size); |
| 163 | } else { | 163 | } else { |
| 164 | // send pitch linear frame | 164 | // send pitch linear frame |
| 165 | const size_t linear_size = width * height * 4; | 165 | const size_t linear_size = width * height * 4; |
| 166 | gpu.MemoryManager().WriteBlock(output_surface_luma_address, converted_frame_buf_addr, | 166 | host1x.MemoryManager().WriteBlock(output_surface_luma_address, converted_frame_buf_addr, |
| 167 | linear_size); | 167 | linear_size); |
| 168 | } | 168 | } |
| 169 | } | 169 | } |
| 170 | 170 | ||
| @@ -192,8 +192,8 @@ void Vic::WriteYUVFrame(const AVFrame* frame, const VicConfig& config) { | |||
| 192 | luma_buffer[dst + x] = luma_src[src + x]; | 192 | luma_buffer[dst + x] = luma_src[src + x]; |
| 193 | } | 193 | } |
| 194 | } | 194 | } |
| 195 | gpu.MemoryManager().WriteBlock(output_surface_luma_address, luma_buffer.data(), | 195 | host1x.MemoryManager().WriteBlock(output_surface_luma_address, luma_buffer.data(), |
| 196 | luma_buffer.size()); | 196 | luma_buffer.size()); |
| 197 | 197 | ||
| 198 | // Chroma | 198 | // Chroma |
| 199 | const std::size_t half_height = frame_height / 2; | 199 | const std::size_t half_height = frame_height / 2; |
| @@ -234,8 +234,8 @@ void Vic::WriteYUVFrame(const AVFrame* frame, const VicConfig& config) { | |||
| 234 | ASSERT(false); | 234 | ASSERT(false); |
| 235 | break; | 235 | break; |
| 236 | } | 236 | } |
| 237 | gpu.MemoryManager().WriteBlock(output_surface_chroma_address, chroma_buffer.data(), | 237 | host1x.MemoryManager().WriteBlock(output_surface_chroma_address, chroma_buffer.data(), |
| 238 | chroma_buffer.size()); | 238 | chroma_buffer.size()); |
| 239 | } | 239 | } |
| 240 | 240 | ||
| 241 | } // namespace Host1x | 241 | } // namespace Host1x |
diff --git a/src/video_core/host1x/vic.h b/src/video_core/host1x/vic.h index c51f8af7e..2b78786e8 100644 --- a/src/video_core/host1x/vic.h +++ b/src/video_core/host1x/vic.h | |||
| @@ -10,10 +10,10 @@ | |||
| 10 | struct SwsContext; | 10 | struct SwsContext; |
| 11 | 11 | ||
| 12 | namespace Tegra { | 12 | namespace Tegra { |
| 13 | class GPU; | ||
| 14 | 13 | ||
| 15 | namespace Host1x { | 14 | namespace Host1x { |
| 16 | 15 | ||
| 16 | class Host1x; | ||
| 17 | class Nvdec; | 17 | class Nvdec; |
| 18 | union VicConfig; | 18 | union VicConfig; |
| 19 | 19 | ||
| @@ -28,7 +28,7 @@ public: | |||
| 28 | SetOutputSurfaceChromaUnusedOffset = 0x1ca | 28 | SetOutputSurfaceChromaUnusedOffset = 0x1ca |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | explicit Vic(GPU& gpu, std::shared_ptr<Nvdec> nvdec_processor); | 31 | explicit Vic(Host1x& host1x, std::shared_ptr<Nvdec> nvdec_processor); |
| 32 | 32 | ||
| 33 | ~Vic(); | 33 | ~Vic(); |
| 34 | 34 | ||
| @@ -42,7 +42,7 @@ private: | |||
| 42 | 42 | ||
| 43 | void WriteYUVFrame(const AVFrame* frame, const VicConfig& config); | 43 | void WriteYUVFrame(const AVFrame* frame, const VicConfig& config); |
| 44 | 44 | ||
| 45 | GPU& gpu; | 45 | Host1x& host1x; |
| 46 | std::shared_ptr<Tegra::Host1x::Nvdec> nvdec_processor; | 46 | std::shared_ptr<Tegra::Host1x::Nvdec> nvdec_processor; |
| 47 | 47 | ||
| 48 | /// Avoid reallocation of the following buffers every frame, as their | 48 | /// Avoid reallocation of the following buffers every frame, as their |