yuzu/src/video_core/host1x/vic.h

67 lines
1.5 KiB
C++
Raw Normal View History

// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <memory>
#include <vector>
#include "common/common_types.h"
struct SwsContext;
namespace Tegra {
class GPU;
2022-01-30 12:31:13 +03:00
namespace Host1x {
class Nvdec;
2021-10-07 18:14:05 +03:00
union VicConfig;
class Vic {
public:
enum class Method : u32 {
Execute = 0xc0,
SetControlParams = 0x1c1,
SetConfigStructOffset = 0x1c2,
SetOutputSurfaceLumaOffset = 0x1c8,
SetOutputSurfaceChromaOffset = 0x1c9,
SetOutputSurfaceChromaUnusedOffset = 0x1ca
};
explicit Vic(GPU& gpu, std::shared_ptr<Nvdec> nvdec_processor);
2021-10-07 18:14:05 +03:00
~Vic();
/// Write to the device state.
2020-11-23 23:01:40 +03:00
void ProcessMethod(Method method, u32 argument);
private:
void Execute();
2021-10-07 18:14:05 +03:00
void WriteRGBFrame(const AVFrame* frame, const VicConfig& config);
2021-10-07 18:14:05 +03:00
void WriteYUVFrame(const AVFrame* frame, const VicConfig& config);
GPU& gpu;
2022-01-30 12:31:13 +03:00
std::shared_ptr<Tegra::Host1x::Nvdec> nvdec_processor;
2020-11-23 21:25:01 +03:00
/// Avoid reallocation of the following buffers every frame, as their
/// size does not change during a stream
using AVMallocPtr = std::unique_ptr<u8, decltype(&av_free)>;
AVMallocPtr converted_frame_buffer;
std::vector<u8> luma_buffer;
std::vector<u8> chroma_buffer;
GPUVAddr config_struct_address{};
GPUVAddr output_surface_luma_address{};
GPUVAddr output_surface_chroma_address{};
SwsContext* scaler_ctx{};
s32 scaler_width{};
s32 scaler_height{};
};
2022-01-30 12:31:13 +03:00
} // namespace Host1x
} // namespace Tegra