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

Method OnDispatch

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

Source from the content-addressed store, hash-verified

918}
919
920WGPUComputePassEncoder GPUContextWebGPU::OnDispatch(GPUShaderProgramCS* shader)
921{
922 // End existing render pass (if any)
923 if (_renderPass)
924 EndRenderPass();
925
926 // Flush pending clears
927 FlushState();
928
929 // Start a new compute pass
930 WGPUComputePassDescriptor computePassDesc = WGPU_COMPUTE_PASS_DESCRIPTOR_INIT;
931 FlushTimestamps(1);
932 if (_pendingTimestampWrites.HasItems())
933 computePassDesc.timestampWrites = &_pendingTimestampWrites.Last();
934 _pendingTimestampWrites.Clear();
935 auto computePass = wgpuCommandEncoderBeginComputePass(Encoder, &computePassDesc);
936 ASSERT(computePass);
937
938 // Set pipeline
939 GPUPipelineStateWebGPU::BindGroupKey key;
940 auto shaderWebGPU = (GPUShaderProgramCSWebGPU*)shader;
941 WGPUComputePipeline pipeline = shaderWebGPU->GetPipeline(_device->Device, { _shaderResources }, key.Layout);
942 wgpuComputePassEncoderSetPipeline(computePass, pipeline);
943
944 // Set bind group
945 uint32 dynamicOffsets[DynamicOffsetsMax];
946 uint32 dynamicOffsetsCount = 0;
947 BuildBindGroup(0, shaderWebGPU->DescriptorInfo, key, dynamicOffsets, dynamicOffsetsCount);
948 WGPUBindGroup bindGroup = shaderWebGPU->GetBindGroup(_device->Device, key);
949 wgpuComputePassEncoderSetBindGroup(computePass, 0, bindGroup, dynamicOffsetsCount, dynamicOffsets);
950
951 return computePass;
952}
953
954void GPUContextWebGPU::EndRenderPass()
955{

Callers

nothing calls this directly

Calls 5

GetPipelineMethod · 0.80
HasItemsMethod · 0.45
LastMethod · 0.45
ClearMethod · 0.45
GetBindGroupMethod · 0.45

Tested by

no test coverage detected