fermi_2d.cpp 2.5 KB

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