| 918 | } |
| 919 | |
| 920 | WGPUComputePassEncoder 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 | |
| 954 | void GPUContextWebGPU::EndRenderPass() |
| 955 | { |
nothing calls this directly
no test coverage detected