environment.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 ReadViewportTransformState() = 0;
  17. [[nodiscard]] virtual u32 TextureBoundBuffer() const = 0;
  18. [[nodiscard]] virtual u32 LocalMemorySize() const = 0;
  19. [[nodiscard]] virtual u32 SharedMemorySize() const = 0;
  20. [[nodiscard]] virtual std::array<u32, 3> WorkgroupSize() const = 0;
  21. virtual void Dump(u64 hash) = 0;
  22. [[nodiscard]] const ProgramHeader& SPH() const noexcept {
  23. return sph;
  24. }
  25. [[nodiscard]] const std::array<u32, 8>& GpPassthroughMask() const noexcept {
  26. return gp_passthrough_mask;
  27. }
  28. [[nodiscard]] Stage ShaderStage() const noexcept {
  29. return stage;
  30. }
  31. [[nodiscard]] u32 StartAddress() const noexcept {
  32. return start_address;
  33. }
  34. protected:
  35. ProgramHeader sph{};
  36. std::array<u32, 8> gp_passthrough_mask{};
  37. Stage stage{};
  38. u32 start_address{};
  39. };
  40. } // namespace Shader