memory_util.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // Copyright 2020 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <cstddef>
  6. #include <vector>
  7. #include "common/common_types.h"
  8. #include "video_core/engines/maxwell_3d.h"
  9. #include "video_core/engines/shader_type.h"
  10. namespace Tegra {
  11. class MemoryManager;
  12. }
  13. namespace VideoCommon::Shader {
  14. using ProgramCode = std::vector<u64>;
  15. constexpr u32 STAGE_MAIN_OFFSET = 10;
  16. constexpr u32 KERNEL_MAIN_OFFSET = 0;
  17. /// Gets the address for the specified shader stage program
  18. GPUVAddr GetShaderAddress(Tegra::Engines::Maxwell3D& maxwell3d,
  19. Tegra::Engines::Maxwell3D::Regs::ShaderProgram program);
  20. /// Gets if the current instruction offset is a scheduler instruction
  21. bool IsSchedInstruction(std::size_t offset, std::size_t main_offset);
  22. /// Calculates the size of a program stream
  23. std::size_t CalculateProgramSize(const ProgramCode& program, bool is_compute);
  24. /// Gets the shader program code from memory for the specified address
  25. ProgramCode GetShaderCode(Tegra::MemoryManager& memory_manager, GPUVAddr gpu_addr,
  26. const u8* host_ptr, bool is_compute);
  27. /// Hashes one (or two) program streams
  28. u64 GetUniqueIdentifier(Tegra::Engines::ShaderType shader_type, bool is_a, const ProgramCode& code,
  29. const ProgramCode& code_b = {});
  30. } // namespace VideoCommon::Shader