environment.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2021 yuzu Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include <array>
  6. #include "common/common_types.h"
  7. #include "shader_recompiler/program_header.h"
  8. #include "shader_recompiler/shader_info.h"
  9. #include "shader_recompiler/stage.h"
  10. namespace Shader {
  11. class Environment {
  12. public:
  13. virtual ~Environment() = default;
  14. [[nodiscard]] virtual u64 ReadInstruction(u32 address) = 0;
  15. [[nodiscard]] virtual u32 ReadCbufValue(u32 cbuf_index, u32 cbuf_offset) = 0;
  16. [[nodiscard]] virtual TextureType ReadTextureType(u32 raw_handle) = 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