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
|
|
|
|
2019-08-30 14:08:00 -04:00
|
|
|
Fermi2D::Fermi2D(VideoCore::RasterizerInterface& rasterizer) : rasterizer{rasterizer} {}
|
2018-04-23 21:12:40 -04:00
|
|
|
|
2018-11-23 23:20:56 -05:00
|
|
|
void Fermi2D::CallMethod(const GPU::MethodCall& method_call) {
|
|
|
|
ASSERT_MSG(method_call.method < Regs::NUM_REGS,
|
2018-04-23 21:12:40 -04:00
|
|
|
"Invalid Fermi2D register, increase the size of the Regs structure");
|
2018-04-24 23:00:40 -04:00
|
|
|
|
2018-11-23 23:20:56 -05:00
|
|
|
regs.reg_array[method_call.method] = method_call.argument;
|
2018-04-24 23:00:40 -04:00
|
|
|
|
2018-11-23 23:20:56 -05:00
|
|
|
switch (method_call.method) {
|
2018-12-15 00:20:00 -05: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-24 23:00:40 -04:00
|
|
|
HandleSurfaceCopy();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Fermi2D::HandleSurfaceCopy() {
|
2019-09-21 20:18:57 -04:00
|
|
|
LOG_DEBUG(HW_GPU, "Requested a surface copy with operation {}",
|
2019-09-21 20:21:56 -04:00
|
|
|
static_cast<u32>(regs.operation));
|
2018-04-24 23:00:40 -04:00
|
|
|
|
|
|
|
// TODO(Subv): Only raw copies are implemented.
|
2019-05-18 04:57:49 -04:00
|
|
|
ASSERT(regs.operation == Operation::SrcCopy);
|
2018-04-24 23:00:40 -04:00
|
|
|
|
2018-12-15 00:20:00 -05: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)};
|
2019-06-12 16:20:20 -04:00
|
|
|
u32 src_blit_x2, src_blit_y2;
|
|
|
|
if (regs.blit_control.origin == Origin::Corner) {
|
|
|
|
src_blit_x2 =
|
|
|
|
static_cast<u32>((regs.blit_src_x + (regs.blit_du_dx * regs.blit_dst_width)) >> 32);
|
|
|
|
src_blit_y2 =
|
|
|
|
static_cast<u32>((regs.blit_src_y + (regs.blit_dv_dy * regs.blit_dst_height)) >> 32);
|
|
|
|
} else {
|
|
|
|
src_blit_x2 = static_cast<u32>((regs.blit_src_x >> 32) + regs.blit_dst_width);
|
|
|
|
src_blit_y2 = static_cast<u32>((regs.blit_src_y >> 32) + regs.blit_dst_height);
|
|
|
|
}
|
2019-02-26 22:47:49 -05: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};
|
2019-05-18 04:57:49 -04:00
|
|
|
Config copy_config;
|
|
|
|
copy_config.operation = regs.operation;
|
|
|
|
copy_config.filter = regs.blit_control.filter;
|
|
|
|
copy_config.src_rect = src_rect;
|
|
|
|
copy_config.dst_rect = dst_rect;
|
2018-10-05 23:46:40 -04:00
|
|
|
|
2019-05-18 04:57:49 -04:00
|
|
|
if (!rasterizer.AccelerateSurfaceCopy(regs.src, regs.dst, copy_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
|