fermi_2d.cpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2018 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "core/core.h"
  5. #include "core/memory.h"
  6. #include "video_core/engines/fermi_2d.h"
  7. #include "video_core/engines/maxwell_3d.h"
  8. #include "video_core/rasterizer_interface.h"
  9. #include "video_core/textures/decoders.h"
  10. namespace Tegra::Engines {
  11. Fermi2D::Fermi2D(VideoCore::RasterizerInterface& rasterizer, MemoryManager& memory_manager)
  12. : memory_manager(memory_manager), rasterizer{rasterizer} {}
  13. void Fermi2D::CallMethod(const GPU::MethodCall& method_call) {
  14. ASSERT_MSG(method_call.method < Regs::NUM_REGS,
  15. "Invalid Fermi2D register, increase the size of the Regs structure");
  16. regs.reg_array[method_call.method] = method_call.argument;
  17. switch (method_call.method) {
  18. // Trigger the surface copy on the last register write. This is blit_src_y, but this is 64-bit,
  19. // so trigger on the second 32-bit write.
  20. case FERMI2D_REG_INDEX(blit_src_y) + 1: {
  21. HandleSurfaceCopy();
  22. break;
  23. }
  24. }
  25. }
  26. void Fermi2D::HandleSurfaceCopy() {
  27. LOG_WARNING(HW_GPU, "Requested a surface copy with operation {}",
  28. static_cast<u32>(regs.operation));
  29. // TODO(Subv): Only raw copies are implemented.
  30. ASSERT(regs.operation == Regs::Operation::SrcCopy);
  31. const u32 src_blit_x1{static_cast<u32>(regs.blit_src_x >> 32)};
  32. const u32 src_blit_y1{static_cast<u32>(regs.blit_src_y >> 32)};
  33. const u32 src_blit_x2{
  34. static_cast<u32>((regs.blit_src_x + (regs.blit_dst_width * regs.blit_du_dx)) >> 32)};
  35. const u32 src_blit_y2{
  36. static_cast<u32>((regs.blit_src_y + (regs.blit_dst_height * regs.blit_dv_dy)) >> 32)};
  37. const Common::Rectangle<u32> src_rect{src_blit_x1, src_blit_y1, src_blit_x2, src_blit_y2};
  38. const Common::Rectangle<u32> dst_rect{regs.blit_dst_x, regs.blit_dst_y,
  39. regs.blit_dst_x + regs.blit_dst_width,
  40. regs.blit_dst_y + regs.blit_dst_height};
  41. if (!rasterizer.AccelerateSurfaceCopy(regs.src, regs.dst, src_rect, dst_rect)) {
  42. UNIMPLEMENTED();
  43. }
  44. }
  45. } // namespace Tegra::Engines