| 655 | } |
| 656 | |
| 657 | void 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 |
nothing calls this directly
no test coverage detected