IR.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * Copyright (c) 2022, Stephan Unverwerth <s.unverwerth@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/String.h>
  8. #include <AK/Vector.h>
  9. namespace GPU::IR {
  10. enum class Opcode {
  11. Move,
  12. };
  13. enum class StorageLocation {
  14. Constant,
  15. Uniform,
  16. Input,
  17. Output,
  18. Temporary,
  19. };
  20. enum class StorageType {
  21. Float,
  22. Vector2,
  23. Vector3,
  24. Vector4,
  25. Matrix3x3,
  26. Matrix4x4,
  27. };
  28. struct StorageReference final {
  29. StorageLocation location;
  30. size_t index;
  31. };
  32. struct Instruction final {
  33. Opcode operation;
  34. Vector<StorageReference> arguments;
  35. StorageReference result;
  36. };
  37. struct Constant final {
  38. StorageType type;
  39. union {
  40. float float_values[16];
  41. };
  42. };
  43. struct Uniform final {
  44. String name;
  45. StorageType type;
  46. };
  47. struct Input final {
  48. String name;
  49. StorageType type;
  50. };
  51. struct Output final {
  52. String name;
  53. StorageType type;
  54. };
  55. struct Temporary final {
  56. StorageType type;
  57. };
  58. struct Shader final {
  59. Vector<Constant> constants;
  60. Vector<Uniform> uniforms;
  61. Vector<Input> inputs;
  62. Vector<Output> outputs;
  63. Vector<Temporary> temporaries;
  64. Vector<Instruction> instructions;
  65. };
  66. }