engine_upload.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <span>
  5. #include "common/bit_field.h"
  6. #include "common/common_types.h"
  7. #include "common/scratch_buffer.h"
  8. namespace Tegra {
  9. class MemoryManager;
  10. }
  11. namespace VideoCore {
  12. class RasterizerInterface;
  13. }
  14. namespace Tegra::Engines::Upload {
  15. struct Registers {
  16. u32 line_length_in;
  17. u32 line_count;
  18. struct {
  19. u32 address_high;
  20. u32 address_low;
  21. u32 pitch;
  22. union {
  23. BitField<0, 4, u32> block_width;
  24. BitField<4, 4, u32> block_height;
  25. BitField<8, 4, u32> block_depth;
  26. };
  27. u32 width;
  28. u32 height;
  29. u32 depth;
  30. u32 layer;
  31. u32 x;
  32. u32 y;
  33. GPUVAddr Address() const {
  34. return (GPUVAddr{address_high} << 32) | GPUVAddr{address_low};
  35. }
  36. u32 BlockWidth() const {
  37. return block_width.Value();
  38. }
  39. u32 BlockHeight() const {
  40. return block_height.Value();
  41. }
  42. u32 BlockDepth() const {
  43. return block_depth.Value();
  44. }
  45. } dest;
  46. };
  47. class State {
  48. public:
  49. explicit State(MemoryManager& memory_manager_, Registers& regs_);
  50. ~State();
  51. void ProcessExec(bool is_linear_);
  52. void ProcessData(u32 data, bool is_last_call);
  53. void ProcessData(const u32* data, size_t num_data);
  54. /// Binds a rasterizer to this engine.
  55. void BindRasterizer(VideoCore::RasterizerInterface* rasterizer);
  56. GPUVAddr ExecTargetAddress() const {
  57. return regs.dest.Address();
  58. }
  59. u32 GetUploadSize() const {
  60. return copy_size;
  61. }
  62. private:
  63. void ProcessData(std::span<const u8> read_buffer);
  64. u32 write_offset = 0;
  65. u32 copy_size = 0;
  66. Common::ScratchBuffer<u8> inner_buffer;
  67. Common::ScratchBuffer<u8> tmp_buffer;
  68. bool is_linear = false;
  69. Registers& regs;
  70. MemoryManager& memory_manager;
  71. VideoCore::RasterizerInterface* rasterizer = nullptr;
  72. };
  73. } // namespace Tegra::Engines::Upload