ImageBinary.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // Copyright (C) 2009-2022, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. // WARNING: This file is auto generated.
  6. #pragma once
  7. #include <AnKi/Resource/Common.h>
  8. namespace anki {
  9. /// @addtogroup resource
  10. /// @{
  11. static constexpr const char* IMAGE_MAGIC = "ANKITEX1";
  12. /// Image type.
  13. /// @memberof ImageBinaryHeader
  14. enum class ImageBinaryType : U32
  15. {
  16. NONE,
  17. _2D,
  18. CUBE,
  19. _3D,
  20. _2D_ARRAY
  21. };
  22. /// The acceptable color types.
  23. /// @memberof ImageBinaryHeader
  24. enum class ImageBinaryColorFormat : U32
  25. {
  26. NONE,
  27. RGB8,
  28. RGBA8,
  29. SRGB8,
  30. RGBF32,
  31. RGBAF32
  32. };
  33. /// The available data compressions.
  34. /// @memberof ImageBinaryHeader
  35. enum class ImageBinaryDataCompression : U32
  36. {
  37. NONE,
  38. RAW = 1 << 0,
  39. S3TC = 1 << 1,
  40. ETC = 1 << 2,
  41. ASTC = 1 << 3
  42. };
  43. ANKI_ENUM_ALLOW_NUMERIC_OPERATIONS(ImageBinaryDataCompression)
  44. /// The 1st things that appears in a image binary.
  45. class ImageBinaryHeader
  46. {
  47. public:
  48. Array<U8, 8> m_magic;
  49. U32 m_width;
  50. U32 m_height;
  51. U32 m_depthOrLayerCount;
  52. ImageBinaryType m_type;
  53. ImageBinaryColorFormat m_colorFormat;
  54. ImageBinaryDataCompression m_compressionMask;
  55. U32 m_isNormal;
  56. U32 m_mipmapCount;
  57. U32 m_astcBlockSizeX;
  58. U32 m_astcBlockSizeY;
  59. Array<U8, 80> m_padding;
  60. template<typename TSerializer, typename TClass>
  61. static void serializeCommon(TSerializer& s, TClass self)
  62. {
  63. s.doArray("m_magic", offsetof(ImageBinaryHeader, m_magic), &self.m_magic[0], self.m_magic.getSize());
  64. s.doValue("m_width", offsetof(ImageBinaryHeader, m_width), self.m_width);
  65. s.doValue("m_height", offsetof(ImageBinaryHeader, m_height), self.m_height);
  66. s.doValue("m_depthOrLayerCount", offsetof(ImageBinaryHeader, m_depthOrLayerCount), self.m_depthOrLayerCount);
  67. s.doValue("m_type", offsetof(ImageBinaryHeader, m_type), self.m_type);
  68. s.doValue("m_colorFormat", offsetof(ImageBinaryHeader, m_colorFormat), self.m_colorFormat);
  69. s.doValue("m_compressionMask", offsetof(ImageBinaryHeader, m_compressionMask), self.m_compressionMask);
  70. s.doValue("m_isNormal", offsetof(ImageBinaryHeader, m_isNormal), self.m_isNormal);
  71. s.doValue("m_mipmapCount", offsetof(ImageBinaryHeader, m_mipmapCount), self.m_mipmapCount);
  72. s.doValue("m_astcBlockSizeX", offsetof(ImageBinaryHeader, m_astcBlockSizeX), self.m_astcBlockSizeX);
  73. s.doValue("m_astcBlockSizeY", offsetof(ImageBinaryHeader, m_astcBlockSizeY), self.m_astcBlockSizeY);
  74. s.doArray("m_padding", offsetof(ImageBinaryHeader, m_padding), &self.m_padding[0], self.m_padding.getSize());
  75. }
  76. template<typename TDeserializer>
  77. void deserialize(TDeserializer& deserializer)
  78. {
  79. serializeCommon<TDeserializer, ImageBinaryHeader&>(deserializer, *this);
  80. }
  81. template<typename TSerializer>
  82. void serialize(TSerializer& serializer) const
  83. {
  84. serializeCommon<TSerializer, const ImageBinaryHeader&>(serializer, *this);
  85. }
  86. };
  87. /// @}
  88. } // end namespace anki