2018-02-12 02:34:20 +00:00
|
|
|
// Copyright 2018 yuzu Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2019-03-06 01:25:01 +00:00
|
|
|
#include "common/assert.h"
|
|
|
|
#include "common/logging/log.h"
|
|
|
|
#include "common/math_util.h"
|
2018-02-12 02:34:20 +00:00
|
|
|
#include "video_core/engines/fermi_2d.h"
|
2018-10-06 03:46:40 +00:00
|
|
|
#include "video_core/rasterizer_interface.h"
|
2018-02-12 02:34:20 +00:00
|
|
|
|
2018-07-20 22:14:17 +00:00
|
|
|
namespace Tegra::Engines {
|
2018-02-12 02:34:20 +00:00
|
|
|
|
2018-10-06 03:46:40 +00:00
|
|
|
Fermi2D::Fermi2D(VideoCore::RasterizerInterface& rasterizer, MemoryManager& memory_manager)
|
|
|
|
: memory_manager(memory_manager), rasterizer{rasterizer} {}
|
2018-04-24 01:12:40 +00:00
|
|
|
|
2018-11-24 04:20:56 +00:00
|
|
|
void Fermi2D::CallMethod(const GPU::MethodCall& method_call) {
|
|
|
|
ASSERT_MSG(method_call.method < Regs::NUM_REGS,
|
2018-04-24 01:12:40 +00:00
|
|
|
"Invalid Fermi2D register, increase the size of the Regs structure");
|
2018-04-25 03:00:40 +00:00
|
|
|
|
2018-11-24 04:20:56 +00:00
|
|
|
regs.reg_array[method_call.method] = method_call.argument;
|
2018-04-25 03:00:40 +00:00
|
|
|
|
2018-11-24 04:20:56 +00:00
|
|
|
switch (method_call.method) {
|
2018-12-15 05:20:00 +00:00
|
|
|
// Trigger the surface copy on the last register write. This is blit_src_y, but this is 64-bit,
|
|
|
|
// so trigger on the second 32-bit write.
|
|
|
|
case FERMI2D_REG_INDEX(blit_src_y) + 1: {
|
2018-04-25 03:00:40 +00:00
|
|
|
HandleSurfaceCopy();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Fermi2D::HandleSurfaceCopy() {
|
2018-07-02 16:13:26 +00:00
|
|
|
LOG_WARNING(HW_GPU, "Requested a surface copy with operation {}",
|
2018-07-02 16:20:50 +00:00
|
|
|
static_cast<u32>(regs.operation));
|
2018-04-25 03:00:40 +00:00
|
|
|
|
|
|
|
// TODO(Subv): Only raw copies are implemented.
|
|
|
|
ASSERT(regs.operation == Regs::Operation::SrcCopy);
|
|
|
|
|
2018-12-15 05:20:00 +00:00
|
|
|
const u32 src_blit_x1{static_cast<u32>(regs.blit_src_x >> 32)};
|
|
|
|
const u32 src_blit_y1{static_cast<u32>(regs.blit_src_y >> 32)};
|
|
|
|
const u32 src_blit_x2{
|
|
|
|
static_cast<u32>((regs.blit_src_x + (regs.blit_dst_width * regs.blit_du_dx)) >> 32)};
|
|
|
|
const u32 src_blit_y2{
|
|
|
|
static_cast<u32>((regs.blit_src_y + (regs.blit_dst_height * regs.blit_dv_dy)) >> 32)};
|
2018-11-06 20:26:27 +00:00
|
|
|
|
2019-02-27 03:47:49 +00:00
|
|
|
const Common::Rectangle<u32> src_rect{src_blit_x1, src_blit_y1, src_blit_x2, src_blit_y2};
|
|
|
|
const Common::Rectangle<u32> dst_rect{regs.blit_dst_x, regs.blit_dst_y,
|
|
|
|
regs.blit_dst_x + regs.blit_dst_width,
|
|
|
|
regs.blit_dst_y + regs.blit_dst_height};
|
2018-10-06 03:46:40 +00:00
|
|
|
|
2018-12-15 05:20:00 +00:00
|
|
|
if (!rasterizer.AccelerateSurfaceCopy(regs.src, regs.dst, src_rect, dst_rect)) {
|
|
|
|
UNIMPLEMENTED();
|
2018-04-25 03:00:40 +00:00
|
|
|
}
|
2018-04-24 01:12:40 +00:00
|
|
|
}
|
2018-02-12 02:34:20 +00:00
|
|
|
|
2018-07-20 22:14:17 +00:00
|
|
|
} // namespace Tegra::Engines
|