MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / OnDrawCall

Method OnDrawCall

Source/Engine/GraphicsDevice/Vulkan/GPUContextVulkan.cpp:657–747  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

655}
656
657void GPUContextVulkan::OnDrawCall()
658{
659 GPUPipelineStateVulkan* pipelineState = _currentState;
660 ASSERT(pipelineState && pipelineState->IsValid());
661 const auto cmdBuffer = _cmdBufferManager->GetCmdBuffer();
662
663 // End previous render pass if render targets layout was modified
664 if (_rtDirtyFlag && cmdBuffer->IsInsideRenderPass())
665 EndRenderPass();
666
667 if (pipelineState->HasDescriptorsPerStageMask)
668 {
669 // Get descriptor pools set
670 bool needsWrite = pipelineState->AcquirePoolSet(cmdBuffer);
671
672 // Update descriptors for every used shader stage
673 uint32 remainingHasDescriptorsPerStageMask = pipelineState->HasDescriptorsPerStageMask;
674 for (int32 stage = 0; stage < DescriptorSet::GraphicsStagesCount && remainingHasDescriptorsPerStageMask; stage++)
675 {
676 if (remainingHasDescriptorsPerStageMask & 1)
677 UpdateDescriptorSets(*pipelineState->DescriptorInfoPerStage[stage], pipelineState->DSWriter[stage], needsWrite);
678 remainingHasDescriptorsPerStageMask >>= 1;
679 }
680
681 // Allocate sets if need to
682 //if (needsWrite) // TODO: write on change only?
683 {
684 if (!pipelineState->CurrentTypedDescriptorPoolSet->AllocateDescriptorSets(*pipelineState->DescriptorSetsLayout, pipelineState->DescriptorSetHandles.Get()))
685 return;
686 uint32 remainingStagesMask = pipelineState->HasDescriptorsPerStageMask;
687 uint32 stage = 0;
688 while (remainingStagesMask)
689 {
690 if (remainingStagesMask & 1)
691 pipelineState->DSWriter[stage].SetDescriptorSet(pipelineState->DescriptorSetHandles[stage]);
692 remainingStagesMask >>= 1;
693 stage++;
694 }
695
696 vkUpdateDescriptorSets(_device->Device, pipelineState->DSWriteContainer.DescriptorWrites.Count(), pipelineState->DSWriteContainer.DescriptorWrites.Get(), 0, nullptr);
697 }
698 }
699
700#if GPU_ENABLE_ASSERTION_LOW_LAYERS
701 // Check for missing vertex buffers layout
702 GPUVertexLayoutVulkan* vertexLayout = _vertexLayout ? _vertexLayout : pipelineState->VertexBufferLayout;
703 if (!vertexLayout && pipelineState && !pipelineState->VertexBufferLayout && (pipelineState->UsedStagesMask & (1 << (int32)DescriptorSet::Vertex)) != 0 && !_vertexLayout && _vbCount)
704 {
705 LOG(Error, "Missing Vertex Layout (not assigned to GPUBuffer). Vertex Shader won't read valid data resulting incorrect visuals.");
706 }
707#endif
708
709 // Start render pass if not during one
710 if (cmdBuffer->IsOutsideRenderPass())
711 BeginRenderPass();
712 else if (_barriers.HasBarrier())
713 {
714 // TODO: implement better image/buffer barriers - and remove this renderPass split to flush barriers

Callers

nothing calls this directly

Calls 13

GetCmdBufferMethod · 0.80
IsInsideRenderPassMethod · 0.80
SetDescriptorSetMethod · 0.80
IsOutsideRenderPassMethod · 0.80
HasBarrierMethod · 0.80
IsValidMethod · 0.45
AcquirePoolSetMethod · 0.45
GetMethod · 0.45
CountMethod · 0.45
GetHandleMethod · 0.45
GetStateMethod · 0.45

Tested by

no test coverage detected