3
0

SkinnedMeshComputePass.cpp 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 <SkinnedMesh/SkinnedMeshComputePass.h>
  9. #include <SkinnedMesh/SkinnedMeshFeatureProcessor.h>
  10. #include <Atom/Feature/SkinnedMesh/SkinnedMeshOutputStreamManagerInterface.h>
  11. #include <Atom/RPI.Public/Shader/Shader.h>
  12. #include <Atom/RHI/CommandList.h>
  13. namespace AZ
  14. {
  15. namespace Render
  16. {
  17. SkinnedMeshComputePass::SkinnedMeshComputePass(const RPI::PassDescriptor& descriptor)
  18. : RPI::ComputePass(descriptor)
  19. {
  20. }
  21. RPI::Ptr<SkinnedMeshComputePass> SkinnedMeshComputePass::Create(const RPI::PassDescriptor& descriptor)
  22. {
  23. RPI::Ptr<SkinnedMeshComputePass> pass = aznew SkinnedMeshComputePass(descriptor);
  24. return pass;
  25. }
  26. Data::Instance<RPI::Shader> SkinnedMeshComputePass::GetShader() const
  27. {
  28. return m_shader;
  29. }
  30. void SkinnedMeshComputePass::SetFeatureProcessor(SkinnedMeshFeatureProcessor* skinnedMeshFeatureProcessor)
  31. {
  32. m_skinnedMeshFeatureProcessor = skinnedMeshFeatureProcessor;
  33. }
  34. void SkinnedMeshComputePass::SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph)
  35. {
  36. if (m_skinnedMeshFeatureProcessor)
  37. {
  38. m_skinnedMeshFeatureProcessor->SetupSkinningScope(frameGraph);
  39. }
  40. ComputePass::SetupFrameGraphDependencies(frameGraph);
  41. }
  42. void SkinnedMeshComputePass::BuildCommandListInternal(const RHI::FrameGraphExecuteContext& context)
  43. {
  44. if (m_skinnedMeshFeatureProcessor)
  45. {
  46. RHI::CommandList* commandList = context.GetCommandList();
  47. SetSrgsForDispatch(commandList);
  48. m_skinnedMeshFeatureProcessor->SubmitSkinningDispatchItems(commandList, context.GetSubmitRange().m_startIndex, context.GetSubmitRange().m_endIndex);
  49. }
  50. }
  51. void SkinnedMeshComputePass::OnShaderReinitialized(const RPI::Shader& shader)
  52. {
  53. ComputePass::OnShaderReinitialized(shader);
  54. if (m_skinnedMeshFeatureProcessor)
  55. {
  56. m_skinnedMeshFeatureProcessor->OnSkinningShaderReinitialized(m_shader);
  57. }
  58. }
  59. void SkinnedMeshComputePass::OnShaderVariantReinitialized(const RPI::ShaderVariant& shaderVariant)
  60. {
  61. ComputePass::OnShaderVariantReinitialized(shaderVariant);
  62. if (m_skinnedMeshFeatureProcessor)
  63. {
  64. m_skinnedMeshFeatureProcessor->OnSkinningShaderReinitialized(m_shader);
  65. }
  66. }
  67. } // namespace Render
  68. } // namespace AZ