Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Execute amp/mesh shaders using command list directly, this works fine on both - AMD and NVidia
- if (mRenderer->mMeshShaders && mRenderer->mGraphicsVendor == D3DRenderer::GraphicsVendor::AMD)
- {
- Engine::RenderNode* bufferData = renderNodes->GetBufferData();
- for (int i = 0; i < renderNodes->GetCount(); i++)
- {
- if (bufferData[i].mObject->Has<MeshComponent>())
- {
- MeshComponent* meshComponent = bufferData[i].mObject->Get<MeshComponent>();
- context->SetBufferSRV(0, *(meshComponent->GetMesh()->GetVertexBuffer()));
- context->SetBufferSRV(1, *(meshComponent->GetMesh()->GetIndexBuffer()));
- context->SetBufferSRV(2, *(meshComponent->GetMesh()->GetMeshletVertexBuffer()));
- context->SetBufferSRV(3, *(meshComponent->GetMesh()->GetMeshletPrimitiveBuffer()));
- context->SetBufferSRV(4, *(meshComponent->GetMesh()->GetMeshletBuffer()));
- context->SetConstants(5, Engine::DWParam(i), Engine::DWParam(meshComponent->GetMesh()->GetMeshletCount()));
- unsigned int amplificationShaderInvocations = meshComponent->GetMesh()->GetMeshletCount() / 32 + (meshComponent->GetMesh()->GetMeshletCount() % 32 == 0 ? 0 : 1);
- context->DispatchMesh(amplificationShaderInvocations, 1, 1);
- }
- }
- }
- // For multi-draw-indirect approach, use execute indirect as usual
- else
- {
- if (culling != nullptr)
- {
- context->ExecuteIndirect(*(renderNodes->GetCommandSignature(0)), *(culling->GetResultsArgsBuffer()), 0, renderNodes->GetIndirectDrawCount(), &(culling->GetResultsArgsBuffer()->GetCounterBuffer()), 0);
- }
- else
- {
- context->ExecuteIndirect(*(renderNodes->GetCommandSignature(0)), *(renderNodes->GetIndirectArgsBuffer()), 0, renderNodes->GetIndirectDrawCount());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement