| 647 | } |
| 648 | |
| 649 | gfx::IRenderCommandEncoder* RenderContext::drawCallCommon(GraphicsState* pState, ProgramVars* pVars) |
| 650 | { |
| 651 | // Insert barriers for bound resources. |
| 652 | pVars->prepareDescriptorSets(this); |
| 653 | |
| 654 | // Insert barriers for render targets. |
| 655 | ensureFboAttachmentResourceStates(this, pState->getFbo().get()); |
| 656 | |
| 657 | // Insert barriers for vertex/index buffers. |
| 658 | auto pGso = pState->getGSO(pVars).get(); |
| 659 | if (pGso != mpLastBoundGraphicsStateObject) |
| 660 | { |
| 661 | auto pVao = pState->getVao().get(); |
| 662 | for (uint32_t i = 0; i < pVao->getVertexBuffersCount(); i++) |
| 663 | { |
| 664 | auto vertexBuffer = pVao->getVertexBuffer(i).get(); |
| 665 | resourceBarrier(vertexBuffer, Resource::State::VertexBuffer); |
| 666 | } |
| 667 | if (pVao->getIndexBuffer()) |
| 668 | { |
| 669 | auto indexBuffer = pVao->getIndexBuffer().get(); |
| 670 | resourceBarrier(indexBuffer, Resource::State::IndexBuffer); |
| 671 | } |
| 672 | } |
| 673 | |
| 674 | bool isNewEncoder = false; |
| 675 | auto encoder = getLowLevelData()->getRenderCommandEncoder( |
| 676 | pGso->getGFXRenderPassLayout(), pState->getFbo() ? pState->getFbo()->getGfxFramebuffer() : nullptr, isNewEncoder |
| 677 | ); |
| 678 | |
| 679 | FALCOR_GFX_CALL(encoder->bindPipelineWithRootObject(pGso->getGfxPipelineState(), pVars->getShaderObject())); |
| 680 | |
| 681 | if (isNewEncoder || pGso != mpLastBoundGraphicsStateObject) |
| 682 | { |
| 683 | mpLastBoundGraphicsStateObject = pGso; |
| 684 | auto pVao = pState->getVao().get(); |
| 685 | auto pVertexLayout = pVao->getVertexLayout().get(); |
| 686 | for (uint32_t i = 0; i < pVao->getVertexBuffersCount(); i++) |
| 687 | { |
| 688 | auto bufferLayout = pVertexLayout->getBufferLayout(i); |
| 689 | auto vertexBuffer = pVao->getVertexBuffer(i).get(); |
| 690 | encoder->setVertexBuffer(i, pVao->getVertexBuffer(i)->getGfxBufferResource(), bufferLayout->getElementOffset(0)); |
| 691 | } |
| 692 | if (pVao->getIndexBuffer()) |
| 693 | { |
| 694 | auto indexBuffer = pVao->getIndexBuffer().get(); |
| 695 | encoder->setIndexBuffer(indexBuffer->getGfxBufferResource(), getGFXFormat(pVao->getIndexBufferFormat())); |
| 696 | } |
| 697 | encoder->setPrimitiveTopology(getGFXPrimitiveTopology(pVao->getPrimitiveTopology())); |
| 698 | encoder->setViewports( |
| 699 | (uint32_t)pState->getViewports().size(), reinterpret_cast<const gfx::Viewport*>(pState->getViewports().data()) |
| 700 | ); |
| 701 | encoder->setScissorRects( |
| 702 | (uint32_t)pState->getScissors().size(), reinterpret_cast<const gfx::ScissorRect*>(pState->getScissors().data()) |
| 703 | ); |
| 704 | } |
| 705 | |
| 706 | return encoder; |
nothing calls this directly
no test coverage detected