environment.h 2.0 KB

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