pica_state.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2016 Citra Emulator Project
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "video_core/pica.h"
  6. #include "video_core/primitive_assembly.h"
  7. #include "video_core/shader/shader.h"
  8. namespace Pica {
  9. /// Struct used to describe current Pica state
  10. struct State {
  11. void Reset();
  12. /// Pica registers
  13. Regs regs;
  14. Shader::ShaderSetup vs;
  15. Shader::ShaderSetup gs;
  16. struct {
  17. union LutEntry {
  18. // Used for raw access
  19. u32 raw;
  20. // LUT value, encoded as 12-bit fixed point, with 12 fraction bits
  21. BitField< 0, 12, u32> value;
  22. // Used by HW for efficient interpolation, Citra does not use these
  23. BitField<12, 12, u32> difference;
  24. float ToFloat() {
  25. return static_cast<float>(value) / 4095.f;
  26. }
  27. };
  28. std::array<std::array<LutEntry, 256>, 24> luts;
  29. } lighting;
  30. /// Current Pica command list
  31. struct {
  32. const u32* head_ptr;
  33. const u32* current_ptr;
  34. u32 length;
  35. } cmd_list;
  36. /// Struct used to describe immediate mode rendering state
  37. struct ImmediateModeState {
  38. // Used to buffer partial vertices for immediate-mode rendering.
  39. Shader::InputVertex input_vertex;
  40. // Index of the next attribute to be loaded into `input_vertex`.
  41. int current_attribute = 0;
  42. } immediate;
  43. // This is constructed with a dummy triangle topology
  44. PrimitiveAssembler<Shader::OutputVertex> primitive_assembler;
  45. };
  46. extern State g_state; ///< Current Pica state
  47. } // namespace