ShaderInputContract.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <Atom/RPI.Reflect/Shader/ShaderInputContract.h>
  9. #include <AzCore/Utils/TypeHash.h>
  10. #include <AzCore/Serialization/SerializeContext.h>
  11. namespace AZ
  12. {
  13. namespace RPI
  14. {
  15. void ShaderInputContract::Reflect(ReflectContext* context)
  16. {
  17. if (auto* serializeContext = azrtti_cast<SerializeContext*>(context))
  18. {
  19. serializeContext->Class<ShaderInputContract>()
  20. ->Version(1)
  21. ->Field("streamChannels", &ShaderInputContract::m_streamChannels)
  22. ;
  23. serializeContext->Class<StreamChannelInfo>()
  24. ->Version(1)
  25. ->Field("semantic", &StreamChannelInfo::m_semantic)
  26. ->Field("componentCount", &StreamChannelInfo::m_componentCount)
  27. ->Field("isOptional", &StreamChannelInfo::m_isOptional)
  28. ->Field("streamBoundIndicatorIndex", &StreamChannelInfo::m_streamBoundIndicatorIndex)
  29. ;
  30. }
  31. }
  32. HashValue64 ShaderInputContract::GetHash() const
  33. {
  34. HashValue64 hash = HashValue64{ 0 };
  35. for (const StreamChannelInfo& info : m_streamChannels)
  36. {
  37. hash = info.m_semantic.GetHash(hash);
  38. hash = TypeHash64(info.m_componentCount, hash);
  39. }
  40. return hash;
  41. }
  42. } // namespace RPI
  43. } // namespace AZ