2018-02-11 21:34:20 -05:00
|
|
|
// Copyright 2018 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2019-03-05 20:25:01 -05:00
|
|
|
#include "common/assert.h"
|
|
|
|
#include "common/logging/log.h"
|
2018-02-11 21:34:20 -05:00
|
|
|
#include "video_core/engines/fermi_2d.h"
|
2019-04-05 18:21:15 -04:00
|
|
|
#include "video_core/memory_manager.h"
|
2018-10-05 23:46:40 -04:00
|
|
|
#include "video_core/rasterizer_interface.h"
|
2018-02-11 21:34:20 -05:00
|
|
|
|
2018-07-20 18:14:17 -04:00
|
|
|
namespace Tegra::Engines {
|
2018-02-11 21:34:20 -05:00
|
|
|
|
2020-12-30 00:25:23 -05:00
|
|
|
Fermi2D::Fermi2D() {
|
|
|
|
// Nvidia's OpenGL driver seems to assume these values
|
|
|
|
regs.src.depth = 1;
|
|
|
|
regs.dst.depth = 1;
|
|
|
|
}
|
2020-06-10 23:58:57 -04:00
|
|
|
|
|
|
|
Fermi2D::~Fermi2D() = default;
|
|
|
|
|
|
|
|
void Fermi2D::BindRasterizer(VideoCore::RasterizerInterface& rasterizer_) {
|
|
|
|
rasterizer = &rasterizer_;
|
|
|
|
}
|
2018-04-23 21:12:40 -04:00
|
|
|
|
2020-04-27 21:47:58 -04:00
|
|
|
void Fermi2D::CallMethod(u32 method, u32 method_argument, bool is_last_call) {
|
|
|
|
ASSERT_MSG(method < Regs::NUM_REGS,
|
2018-04-23 21:12:40 -04:00
|
|
|
"Invalid Fermi2D register, increase the size of the Regs structure");
|
2020-04-27 21:47:58 -04:00
|
|
|
regs.reg_array[method] = method_argument;
|
2018-04-24 23:00:40 -04:00
|
|
|
|
2020-12-30 00:25:23 -05:00
|
|
|
if (method == FERMI2D_REG_INDEX(pixels_from_memory.src_y0) + 1) {
|
|
|
|
Blit();
|
2018-04-24 23:00:40 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-20 02:16:56 -04:00
|
|
|
void Fermi2D::CallMultiMethod(u32 method, const u32* base_start, u32 amount, u32 methods_pending) {
|
2020-12-30 00:25:23 -05:00
|
|
|
for (u32 i = 0; i < amount; ++i) {
|
|
|
|
CallMethod(method, base_start[i], methods_pending - i <= 1);
|
2020-04-20 02:16:56 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-30 00:25:23 -05:00
|
|
|
void Fermi2D::Blit() {
|
|
|
|
LOG_DEBUG(HW_GPU, "called. source address=0x{:x}, destination address=0x{:x}",
|
|
|
|
regs.src.Address(), regs.dst.Address());
|
2018-04-24 23:00:40 -04:00
|
|
|
|
2020-12-30 00:25:23 -05:00
|
|
|
UNIMPLEMENTED_IF_MSG(regs.operation != Operation::SrcCopy, "Operation is not copy");
|
|
|
|
UNIMPLEMENTED_IF_MSG(regs.src.layer != 0, "Source layer is not zero");
|
|
|
|
UNIMPLEMENTED_IF_MSG(regs.dst.layer != 0, "Destination layer is not zero");
|
|
|
|
UNIMPLEMENTED_IF_MSG(regs.src.depth != 1, "Source depth is not one");
|
|
|
|
UNIMPLEMENTED_IF_MSG(regs.clip_enable != 0, "Clipped blit enabled");
|
2018-04-24 23:00:40 -04:00
|
|
|
|
2020-12-30 00:25:23 -05:00
|
|
|
const auto& args = regs.pixels_from_memory;
|
|
|
|
const Config config{
|
2020-09-18 13:55:18 -04:00
|
|
|
.operation = regs.operation,
|
2020-12-30 00:25:23 -05:00
|
|
|
.filter = args.sample_mode.filter,
|
|
|
|
.dst_x0 = args.dst_x0,
|
|
|
|
.dst_y0 = args.dst_y0,
|
|
|
|
.dst_x1 = args.dst_x0 + args.dst_width,
|
|
|
|
.dst_y1 = args.dst_y0 + args.dst_height,
|
|
|
|
.src_x0 = static_cast<s32>(args.src_x0 >> 32),
|
|
|
|
.src_y0 = static_cast<s32>(args.src_y0 >> 32),
|
|
|
|
.src_x1 = static_cast<s32>((args.du_dx * args.dst_width + args.src_x0) >> 32),
|
|
|
|
.src_y1 = static_cast<s32>((args.dv_dy * args.dst_height + args.src_y0) >> 32),
|
2020-09-18 13:55:18 -04:00
|
|
|
};
|
2020-12-30 00:25:23 -05:00
|
|
|
if (!rasterizer->AccelerateSurfaceCopy(regs.src, regs.dst, config)) {
|
2018-12-15 00:20:00 -05:00
|
|
|
UNIMPLEMENTED();
|
2018-04-24 23:00:40 -04:00
|
|
|
}
|
2018-04-23 21:12:40 -04:00
|
|
|
}
|
2018-02-11 21:34:20 -05:00
|
|
|
|
2018-07-20 18:14:17 -04:00
|
|
|
} // namespace Tegra::Engines
|