Sin descripción
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. namespace UnityEditor.ShaderGraph.Internal
  3. {
  4. // ------------------------------------------------------------------------------------------
  5. //
  6. // The general use of precision follows this data flow
  7. //
  8. // Precision -- user selectable precision setting on each node
  9. // == apply precision inherit rules based on node inputs ==>
  10. // GraphPrecision -- where "GraphPrecision.Graph" means use the graph default setting
  11. // == fallback to graph defaults ==>
  12. // GraphPrecision -- where "GraphPrecision.Graph" means it is switchable when in a subgraph
  13. // == shadergraph concretization ==>
  14. // ConcretePrecision -- the actual precision used by the node, half or single
  15. //
  16. // We could at some point separate the two GraphPrecision uses into separate enums,
  17. // but they're close enough we're using one enum for both uses at the moment
  18. //
  19. // ------------------------------------------------------------------------------------------
  20. // this is generally used for user-selectable precision
  21. [Serializable]
  22. enum Precision
  23. {
  24. Inherit, // automatically choose the precision based on the inputs
  25. Single, // force single precision (float)
  26. Half, // force half precision
  27. Graph, // use the graph default (for subgraphs this will properly switch based on the subgraph node setting)
  28. }
  29. // this is used when calculating precision within a graph
  30. // it basically represents the precision after applying the automatic inheritance rules
  31. // but before applying the fallback to the graph default
  32. // tracking this explicitly helps us build subgraph switchable precision behavior (any node using Graph can be switched)
  33. public enum GraphPrecision
  34. {
  35. Single = 0, // the ordering is different here so we can use the min function to resolve inherit/automatic behavior
  36. Graph = 1,
  37. Half = 2
  38. }
  39. // this is the actual set of precisions we have, a shadergraph must resolve every node to one of these
  40. // in subgraphs, this concrete precision is only used for preview, and may not represent the actual precision of those nodes
  41. // when used in a shader graph
  42. [Serializable]
  43. public enum ConcretePrecision
  44. {
  45. Single,
  46. Half,
  47. }
  48. // inherit(auto) rules for combining input types
  49. // half + half ==> half
  50. // single + single ==> single
  51. // single + half ==> single
  52. // single + graph ==> single
  53. // half + graph ==> graph
  54. // single + half + graph ==> single
  55. //
  56. // basically: take the min when arranged like so: single(0), graph(1), half(2)
  57. }