XFStateManager.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // Copyright 2023 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <array>
  5. #include "Common/BitSet.h"
  6. class PointerWrap;
  7. // This class manages how XF state changes over
  8. // a period of time (typically a single draw call)
  9. class XFStateManager
  10. {
  11. public:
  12. void Init();
  13. void DoState(PointerWrap& p);
  14. void InvalidateXFRange(int start, int end);
  15. void SetTexMatrixChangedA(u32 value);
  16. bool DidTexMatrixAChange() const { return m_tex_matrices_changed[0]; }
  17. void ResetTexMatrixAChange();
  18. void SetTexMatrixChangedB(u32 value);
  19. bool DidTexMatrixBChange() const { return m_tex_matrices_changed[1]; }
  20. void ResetTexMatrixBChange();
  21. bool DidPosNormalChange() const { return m_pos_normal_matrix_changed; }
  22. void ResetPosNormalChange();
  23. void SetProjectionChanged();
  24. bool DidProjectionChange() const { return m_projection_changed; }
  25. void ResetProjection();
  26. void SetViewportChanged();
  27. bool DidViewportChange() const { return m_viewport_changed; }
  28. void ResetViewportChange();
  29. void SetTexMatrixInfoChanged(int index);
  30. bool DidTexMatrixInfoChange() const { return m_tex_mtx_info_changed; }
  31. void ResetTexMatrixInfoChange();
  32. void SetLightingConfigChanged();
  33. bool DidLightingConfigChange() const { return m_lighting_config_changed; }
  34. void ResetLightingConfigChange();
  35. const std::array<int, 2>& GetLightsChanged() const { return m_minmax_lights_changed; }
  36. void ResetLightsChanged();
  37. void SetMaterialColorChanged(int index);
  38. const BitSet32& GetMaterialChanges() const { return m_materials_changed; }
  39. void ResetMaterialChanges();
  40. const std::array<int, 2>& GetPerVertexTransformMatrixChanges() const
  41. {
  42. return m_minmax_transform_matrices_changed;
  43. }
  44. void ResetPerVertexTransformMatrixChanges();
  45. const std::array<int, 2>& GetPerVertexNormalMatrixChanges() const
  46. {
  47. return m_minmax_normal_matrices_changed;
  48. }
  49. void ResetPerVertexNormalMatrixChanges();
  50. const std::array<int, 2>& GetPostTransformMatrixChanges() const
  51. {
  52. return m_minmax_post_transform_matrices_changed;
  53. }
  54. void ResetPostTransformMatrixChanges();
  55. private:
  56. // track changes
  57. std::array<bool, 2> m_tex_matrices_changed{};
  58. bool m_pos_normal_matrix_changed = false;
  59. bool m_projection_changed = false;
  60. bool m_viewport_changed = false;
  61. bool m_tex_mtx_info_changed = false;
  62. bool m_lighting_config_changed = false;
  63. BitSet32 m_materials_changed;
  64. std::array<int, 2> m_minmax_transform_matrices_changed{};
  65. std::array<int, 2> m_minmax_normal_matrices_changed{};
  66. std::array<int, 2> m_minmax_post_transform_matrices_changed{};
  67. std::array<int, 2> m_minmax_lights_changed{};
  68. };