HairDispatchItem.cpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 <Code/src/TressFX/TressFXCommon.h>
  9. #include <Rendering/HairDispatchItem.h>
  10. #include <Rendering/HairRenderObject.h>
  11. #include <Passes/HairSkinningComputePass.h>
  12. #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
  13. #include <Atom/RPI.Public/Shader/Shader.h>
  14. #include <Atom/RPI.Public/Buffer/Buffer.h>
  15. #include <Atom/RHI/Factory.h>
  16. #include <Atom/RHI/DeviceBufferView.h>
  17. #include <limits>
  18. namespace AZ
  19. {
  20. namespace Render
  21. {
  22. namespace Hair
  23. {
  24. HairDispatchItem::~HairDispatchItem()
  25. {
  26. }
  27. // Reference in the code above that tackles handling of the different dispatches possible
  28. // This one is targeting the per vertex dispatches for now.
  29. void HairDispatchItem::InitSkinningDispatch(
  30. RPI::Shader* shader,
  31. RPI::ShaderResourceGroup* hairGenerationSrg,
  32. RPI::ShaderResourceGroup* hairSimSrg,
  33. uint32_t elementsAmount )
  34. {
  35. m_shader = shader;
  36. RHI::DispatchDirect dispatchArgs(
  37. elementsAmount, 1, 1,
  38. TRESSFX_SIM_THREAD_GROUP_SIZE, 1, 1
  39. );
  40. m_dispatchItem.SetArguments(dispatchArgs);
  41. RHI::PipelineStateDescriptorForDispatch pipelineDesc;
  42. m_shader->GetVariant(RPI::ShaderAsset::RootShaderVariantStableId).ConfigurePipelineState(pipelineDesc);
  43. m_dispatchItem.SetPipelineState(m_shader->AcquirePipelineState(pipelineDesc));
  44. AZStd::array<const RHI::ShaderResourceGroup*, 2> srgs{
  45. hairGenerationSrg->GetRHIShaderResourceGroup(), // Static generation data
  46. hairSimSrg->GetRHIShaderResourceGroup() // Dynamic data changed between passes
  47. };
  48. m_dispatchItem.SetShaderResourceGroups(srgs);
  49. }
  50. } // namespace Hair
  51. } // namespace Render
  52. } // namespace AZ