environment.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <array>
  5. #include "common/common_types.h"
  6. #include "shader_recompiler/program_header.h"
  7. #include "shader_recompiler/shader_info.h"
  8. #include "shader_recompiler/stage.h"
  9. namespace Shader {
  10. class Environment {
  11. public:
  12. virtual ~Environment() = default;
  13. [[nodiscard]] virtual u64 ReadInstruction(u32 address) = 0;
  14. [[nodiscard]] virtual u32 ReadCbufValue(u32 cbuf_index, u32 cbuf_offset) = 0;
  15. [[nodiscard]] virtual TextureType ReadTextureType(u32 raw_handle) = 0;
  16. [[nodiscard]] virtual u32 TextureBoundBuffer() const = 0;
  17. [[nodiscard]] virtual u32 LocalMemorySize() const = 0;
  18. [[nodiscard]] virtual u32 SharedMemorySize() const = 0;
  19. [[nodiscard]] virtual std::array<u32, 3> WorkgroupSize() const = 0;
  20. virtual void Dump(u64 hash) = 0;
  21. [[nodiscard]] const ProgramHeader& SPH() const noexcept {
  22. return sph;
  23. }
  24. [[nodiscard]] const std::array<u32, 8>& GpPassthroughMask() const noexcept {
  25. return gp_passthrough_mask;
  26. }
  27. [[nodiscard]] Stage ShaderStage() const noexcept {
  28. return stage;
  29. }
  30. [[nodiscard]] u32 StartAddress() const noexcept {
  31. return start_address;
  32. }
  33. protected:
  34. ProgramHeader sph{};
  35. std::array<u32, 8> gp_passthrough_mask{};
  36. Stage stage{};
  37. u32 start_address{};
  38. };
  39. } // namespace Shader