environment.h 1.8 KB

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