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

Method OnDrawCall

Source/Engine/GraphicsDevice/WebGPU/GPUContextWebGPU.cpp:853–918  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

851}
852
853void GPUContextWebGPU::OnDrawCall()
854{
855 // Clear textures that are not bind to the render pass
856 auto renderTargets = ToSpan(_renderTargets, _renderTargetCount);
857 for (int32 i = _pendingClears.Count() - 1; i >= 0; i--)
858 {
859 auto clear = _pendingClears[i];
860 if (clear.View != _depthStencil && !SpanContains(renderTargets, clear.View))
861 {
862 ManualClear(clear);
863 _pendingClears.RemoveAt(i);
864 }
865 }
866
867 // Check if need to start a new render pass
868 if (_renderPassDirty || !_renderPass)
869 {
870 FlushRenderPass();
871 }
872
873 // Flush rendering states
874 if (_pipelineDirty)
875 {
876 _pipelineDirty = false;
877 WGPURenderPipeline pipeline = _pipelineState ? _pipelineState->GetPipeline(_pipelineKey, { _shaderResources }) : nullptr;
878 wgpuRenderPassEncoderSetPipeline(_renderPass, pipeline);
879 RENDER_STAT_PS_STATE_CHANGE();
880
881 // Invalidate bind groups (layout might change)
882 _bindGroupDirty = true;
883 }
884 if (_scissorRectDirty)
885 {
886 _scissorRectDirty = false;
887 wgpuRenderPassEncoderSetScissorRect(_renderPass, (uint32_t)_scissorRect.GetX(), (uint32_t)_scissorRect.GetY(), (uint32_t)_scissorRect.GetWidth(), (uint32_t)_scissorRect.GetHeight());
888 }
889 if (_viewportDirty)
890 {
891 _viewportDirty = false;
892 wgpuRenderPassEncoderSetViewport(_renderPass, _viewport.X, _viewport.Y, _viewport.Width, _viewport.Height, _viewport.MinDepth, _viewport.MaxDepth);
893 }
894 if (_indexBufferDirty && _indexBuffer.Buffer)
895 {
896 _indexBufferDirty = false;
897 wgpuRenderPassEncoderSetIndexBuffer(_renderPass, _indexBuffer.Buffer, _indexBuffer32Bit ? WGPUIndexFormat_Uint32 : WGPUIndexFormat_Uint16, _indexBuffer.Offset, _indexBuffer.Size);
898 }
899 if (_vertexBufferDirty)
900 {
901 _vertexBufferDirty = false;
902 for (int32 i = 0; i < _vertexBufferCount; i++)
903 {
904 auto vb = _vertexBuffers[i];
905 wgpuRenderPassEncoderSetVertexBuffer(_renderPass, i, vb.Buffer, vb.Offset, vb.Size);
906 }
907 }
908 if (_blendFactorDirty)
909 {
910 _blendFactorDirty = false;

Callers

nothing calls this directly

Calls 9

SpanContainsFunction · 0.85
GetPipelineMethod · 0.80
GetXMethod · 0.80
GetYMethod · 0.80
GetWidthMethod · 0.80
ToSpanFunction · 0.50
CountMethod · 0.45
RemoveAtMethod · 0.45
GetHeightMethod · 0.45

Tested by

no test coverage detected