2
0

XRPassRegisterSystemComponent.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 <XR/XRPassRegisterSystemComponent.h>
  9. #include <Atom/RPI.Public/Pass/PassSystemInterface.h>
  10. #include <Passes/FoveatedImagePass.h>
  11. #include <AzCore/Serialization/SerializeContext.h>
  12. namespace XR
  13. {
  14. void PassRegisterSystemComponent::GetDependentServices(AZ::ComponentDescriptor::DependencyArrayType& required)
  15. {
  16. // This module uses the PassSystem that is part of the RPI System Module.
  17. required.push_back(AZ_CRC_CE("RPISystem"));
  18. }
  19. void PassRegisterSystemComponent::Reflect(AZ::ReflectContext* context)
  20. {
  21. if (AZ::SerializeContext* serializeContext = azrtti_cast<AZ::SerializeContext*>(context))
  22. {
  23. serializeContext->Class<PassRegisterSystemComponent, AZ::Component>()->Version(1);
  24. }
  25. }
  26. void PassRegisterSystemComponent::Activate()
  27. {
  28. auto* passSystem = AZ::RPI::PassSystemInterface::Get();
  29. AZ_Assert(passSystem, "Cannot get the pass system.");
  30. passSystem->AddPassCreator(AZ::Name(FoveatedImagePassClassName), &FoveatedImagePass::Create);
  31. // Setup handler for load pass template mappings
  32. m_loadTemplatesHandler = AZ::RPI::PassSystemInterface::OnReadyLoadTemplatesEvent::Handler([this]() { this->LoadPassTemplateMappings(); });
  33. passSystem->ConnectEvent(m_loadTemplatesHandler);
  34. }
  35. void PassRegisterSystemComponent::Deactivate()
  36. {
  37. m_loadTemplatesHandler.Disconnect();
  38. }
  39. void PassRegisterSystemComponent::LoadPassTemplateMappings() const
  40. {
  41. const char* passTemplatesFile = "Passes/OpenXRPassTemplates.azasset";
  42. AZ::RPI::PassSystemInterface::Get()->LoadPassTemplateMappings(passTemplatesFile);
  43. }
  44. }