ShaderProgramBinaryExtra.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Copyright (C) 2009-2019, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #include <anki/shader_compiler/Common.h>
  6. #include <anki/gr/utils/Functions.h>
  7. #include <anki/util/Serializer.h>
  8. namespace anki
  9. {
  10. /// Serialize/deserialize ShaderVariableBlockInfo
  11. template<typename TSerializer, typename TShaderVariableBlockInfo>
  12. void serializeShaderVariableBlockInfo(TShaderVariableBlockInfo x, TSerializer& s)
  13. {
  14. s.doValue("m_offset", offsetof(ShaderVariableBlockInfo, m_offset), x.m_offset);
  15. s.doValue("m_arraySize", offsetof(ShaderVariableBlockInfo, m_arraySize), x.m_arraySize);
  16. s.doValue("m_arrayStride", offsetof(ShaderVariableBlockInfo, m_arrayStride), x.m_arrayStride);
  17. s.doValue("m_matrixStride", offsetof(ShaderVariableBlockInfo, m_matrixStride), x.m_matrixStride);
  18. }
  19. /// Serialize ShaderVariableBlockInfo
  20. template<>
  21. class SerializeFunctor<ShaderVariableBlockInfo>
  22. {
  23. public:
  24. template<typename TSerializer>
  25. void operator()(const ShaderVariableBlockInfo& x, TSerializer& serializer)
  26. {
  27. serializeShaderVariableBlockInfo<TSerializer, const ShaderVariableBlockInfo&>(x, serializer);
  28. }
  29. };
  30. /// Deserialize ShaderVariableBlockInfo
  31. template<>
  32. class DeserializeFunctor<ShaderVariableBlockInfo>
  33. {
  34. public:
  35. template<typename TDeserializer>
  36. void operator()(ShaderVariableBlockInfo& x, TDeserializer& deserialize)
  37. {
  38. serializeShaderVariableBlockInfo<TDeserializer, ShaderVariableBlockInfo&>(x, deserialize);
  39. }
  40. };
  41. /// Serialize ActiveProgramInputVariableMask
  42. template<typename TSerializer, typename T>
  43. void serializeActiveProgramInputVariableMask(T x, TSerializer& s)
  44. {
  45. s.doArray("bitset", 0, &x.getData()[0], x.getData().getSize());
  46. }
  47. /// Serialize ActiveProgramInputVariableMask
  48. template<>
  49. class SerializeFunctor<ActiveProgramInputVariableMask>
  50. {
  51. public:
  52. template<typename TSerializer>
  53. void operator()(const ActiveProgramInputVariableMask& x, TSerializer& serializer)
  54. {
  55. serializeActiveProgramInputVariableMask<TSerializer, const ActiveProgramInputVariableMask&>(x, serializer);
  56. }
  57. };
  58. /// Deserialize ActiveProgramInputVariableMask
  59. template<>
  60. class DeserializeFunctor<ActiveProgramInputVariableMask>
  61. {
  62. public:
  63. template<typename TDeserializer>
  64. void operator()(ActiveProgramInputVariableMask& x, TDeserializer& deserialize)
  65. {
  66. serializeShaderVariableBlockInfo<TDeserializer, ActiveProgramInputVariableMask&>(x, deserialize);
  67. }
  68. };
  69. } // end namespace anki