dirty_flags.cpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // Copyright 2019 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <array>
  5. #include <cstddef>
  6. #include "common/common_types.h"
  7. #include "video_core/dirty_flags.h"
  8. #define OFF(field_name) MAXWELL3D_REG_INDEX(field_name)
  9. #define NUM(field_name) (sizeof(::Tegra::Engines::Maxwell3D::Regs::field_name) / sizeof(u32))
  10. namespace VideoCommon::Dirty {
  11. using Tegra::Engines::Maxwell3D;
  12. void SetupDirtyRenderTargets(Tegra::Engines::Maxwell3D::DirtyState::Tables& tables) {
  13. static constexpr std::size_t num_per_rt = NUM(rt[0]);
  14. static constexpr std::size_t begin = OFF(rt);
  15. static constexpr std::size_t num = num_per_rt * Maxwell3D::Regs::NumRenderTargets;
  16. for (std::size_t rt = 0; rt < Maxwell3D::Regs::NumRenderTargets; ++rt) {
  17. FillBlock(tables[0], begin + rt * num_per_rt, num_per_rt, ColorBuffer0 + rt);
  18. }
  19. FillBlock(tables[1], begin, num, RenderTargets);
  20. static constexpr std::array zeta_flags{ZetaBuffer, RenderTargets};
  21. for (std::size_t i = 0; i < std::size(zeta_flags); ++i) {
  22. const u8 flag = zeta_flags[i];
  23. auto& table = tables[i];
  24. table[OFF(zeta_enable)] = flag;
  25. table[OFF(zeta_width)] = flag;
  26. table[OFF(zeta_height)] = flag;
  27. FillBlock(table, OFF(zeta), NUM(zeta), flag);
  28. }
  29. }
  30. } // namespace VideoCommon::Dirty