draw_manager.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. // SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include "common/common_types.h"
  5. #include "video_core/engines/maxwell_3d.h"
  6. namespace VideoCore {
  7. class RasterizerInterface;
  8. }
  9. namespace Tegra::Engines {
  10. using PrimitiveTopologyControl = Maxwell3D::Regs::PrimitiveTopologyControl;
  11. using PrimitiveTopology = Maxwell3D::Regs::PrimitiveTopology;
  12. using PrimitiveTopologyOverride = Maxwell3D::Regs::PrimitiveTopologyOverride;
  13. using IndexBuffer = Maxwell3D::Regs::IndexBuffer;
  14. using VertexBuffer = Maxwell3D::Regs::VertexBuffer;
  15. using IndexBufferSmall = Maxwell3D::Regs::IndexBufferSmall;
  16. class DrawManager {
  17. public:
  18. enum class DrawMode : u32 { General = 0, Instance, InlineIndex };
  19. struct State {
  20. PrimitiveTopology topology{};
  21. DrawMode draw_mode{};
  22. bool draw_indexed{};
  23. u32 base_index{};
  24. VertexBuffer vertex_buffer;
  25. IndexBuffer index_buffer;
  26. u32 base_instance{};
  27. u32 instance_count{};
  28. std::vector<u8> inline_index_draw_indexes;
  29. };
  30. explicit DrawManager(Maxwell3D* maxwell_3d);
  31. void ProcessMethodCall(u32 method, u32 argument);
  32. void Clear(u32 layer_count);
  33. void DrawDeferred();
  34. void DrawArray(PrimitiveTopology topology, u32 vertex_first, u32 vertex_count,
  35. u32 base_instance, u32 num_instances);
  36. void DrawIndex(PrimitiveTopology topology, u32 index_first, u32 index_count, u32 base_index,
  37. u32 base_instance, u32 num_instances);
  38. const State& GetDrawState() const {
  39. return draw_state;
  40. }
  41. private:
  42. void SetInlineIndexBuffer(u32 index);
  43. void DrawBegin();
  44. void DrawEnd(u32 instance_count = 1, bool force_draw = false);
  45. void DrawIndexSmall(u32 argument);
  46. void UpdateTopology();
  47. void ProcessDraw(bool draw_indexed, u32 instance_count);
  48. Maxwell3D* maxwell3d{};
  49. State draw_state{};
  50. };
  51. } // namespace Tegra::Engines