pica_state.h 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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 <array>
  6. #include "common/bit_field.h"
  7. #include "common/common_types.h"
  8. #include "video_core/pica.h"
  9. #include "video_core/primitive_assembly.h"
  10. #include "video_core/shader/shader.h"
  11. namespace Pica {
  12. /// Struct used to describe current Pica state
  13. struct State {
  14. void Reset();
  15. /// Pica registers
  16. Regs regs;
  17. Shader::ShaderSetup vs;
  18. Shader::ShaderSetup gs;
  19. std::array<Math::Vec4<float24>, 16> vs_default_attributes;
  20. struct {
  21. union LutEntry {
  22. // Used for raw access
  23. u32 raw;
  24. // LUT value, encoded as 12-bit fixed point, with 12 fraction bits
  25. BitField<0, 12, u32> value; // 0.0.12 fixed point
  26. // Used by HW for efficient interpolation, Citra does not use these
  27. BitField<12, 12, s32> difference; // 1.0.11 fixed point
  28. float ToFloat() {
  29. return static_cast<float>(value) / 4095.f;
  30. }
  31. };
  32. std::array<std::array<LutEntry, 256>, 24> luts;
  33. } lighting;
  34. struct {
  35. union LutEntry {
  36. // Used for raw access
  37. u32 raw;
  38. BitField<0, 13, s32> difference; // 1.1.11 fixed point
  39. BitField<13, 11, u32> value; // 0.0.11 fixed point
  40. };
  41. std::array<LutEntry, 128> lut;
  42. } fog;
  43. /// Current Pica command list
  44. struct {
  45. const u32* head_ptr;
  46. const u32* current_ptr;
  47. u32 length;
  48. } cmd_list;
  49. /// Struct used to describe immediate mode rendering state
  50. struct ImmediateModeState {
  51. // Used to buffer partial vertices for immediate-mode rendering.
  52. Shader::InputVertex input_vertex;
  53. // Index of the next attribute to be loaded into `input_vertex`.
  54. u32 current_attribute = 0;
  55. } immediate;
  56. // This is constructed with a dummy triangle topology
  57. PrimitiveAssembler<Shader::OutputVertex> primitive_assembler;
  58. };
  59. extern State g_state; ///< Current Pica state
  60. } // namespace