Advertisement
Zgragselus

AMD epicness

Dec 31st, 2024
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.73 KB | None | 0 0
  1.         // Execute amp/mesh shaders using command list directly, this works fine on both - AMD and NVidia
  2.         if (mRenderer->mMeshShaders && mRenderer->mGraphicsVendor == D3DRenderer::GraphicsVendor::AMD)
  3.         {
  4.             Engine::RenderNode* bufferData = renderNodes->GetBufferData();
  5.  
  6.             for (int i = 0; i < renderNodes->GetCount(); i++)
  7.             {
  8.                 if (bufferData[i].mObject->Has<MeshComponent>())
  9.                 {
  10.                     MeshComponent* meshComponent = bufferData[i].mObject->Get<MeshComponent>();
  11.  
  12.                     context->SetBufferSRV(0, *(meshComponent->GetMesh()->GetVertexBuffer()));
  13.                     context->SetBufferSRV(1, *(meshComponent->GetMesh()->GetIndexBuffer()));
  14.                     context->SetBufferSRV(2, *(meshComponent->GetMesh()->GetMeshletVertexBuffer()));
  15.                     context->SetBufferSRV(3, *(meshComponent->GetMesh()->GetMeshletPrimitiveBuffer()));
  16.                     context->SetBufferSRV(4, *(meshComponent->GetMesh()->GetMeshletBuffer()));
  17.                     context->SetConstants(5, Engine::DWParam(i), Engine::DWParam(meshComponent->GetMesh()->GetMeshletCount()));
  18.  
  19.                     unsigned int amplificationShaderInvocations = meshComponent->GetMesh()->GetMeshletCount() / 32 + (meshComponent->GetMesh()->GetMeshletCount() % 32 == 0 ? 0 : 1);
  20.  
  21.                     context->DispatchMesh(amplificationShaderInvocations, 1, 1);
  22.                 }
  23.             }
  24.         }
  25.         // For multi-draw-indirect approach, use execute indirect as usual
  26.         else
  27.         {
  28.             if (culling != nullptr)
  29.             {
  30.                 context->ExecuteIndirect(*(renderNodes->GetCommandSignature(0)), *(culling->GetResultsArgsBuffer()), 0, renderNodes->GetIndirectDrawCount(), &(culling->GetResultsArgsBuffer()->GetCounterBuffer()), 0);
  31.             }
  32.             else
  33.             {
  34.                 context->ExecuteIndirect(*(renderNodes->GetCommandSignature(0)), *(renderNodes->GetIndirectArgsBuffer()), 0, renderNodes->GetIndirectDrawCount());
  35.             }
  36.         }
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement