MCPcopy Create free account
hub / github.com/AnswerDotAI/gpu.cpp / resetCommandBuffer

Function resetCommandBuffer

gpu.hpp:1145–1160  ·  view source on GitHub ↗

* @brief Resets the command buffer in preparation for a kernel dispatch. * Since command buffers are consumed upon submission, this function is used * both in the initial kernel creation and every time the kernel is to be * reused for a dispatch. * @param[in] device WGPUDevice instance to manage the operation * @param[in] op Kernel instance representing the kernel to reset * * @code * rese

Source from the content-addressed store, hash-verified

1143 * @endcode
1144 */
1145inline void resetCommandBuffer(WGPUDevice &device, Kernel &op) {
1146 {
1147 WGPUCommandEncoder commandEncoder =
1148 wgpuDeviceCreateCommandEncoder(device, nullptr);
1149 WGPUComputePassEncoder computePassEncoder =
1150 wgpuCommandEncoderBeginComputePass(commandEncoder, nullptr);
1151 wgpuComputePassEncoderSetPipeline(computePassEncoder, op.computePipeline);
1152 wgpuComputePassEncoderSetBindGroup(computePassEncoder, 0, op.bindGroup, 0,
1153 nullptr);
1154 wgpuComputePassEncoderDispatchWorkgroups(
1155 computePassEncoder, op.totalWorkgroups[0], op.totalWorkgroups[1],
1156 op.totalWorkgroups[2]);
1157 wgpuComputePassEncoderEnd(computePassEncoder);
1158 op.commandBuffer = wgpuCommandEncoderFinish(commandEncoder, nullptr);
1159 }
1160}
1161
1162/**
1163 * @brief NoParam is a no-op type used to indicate that a kernel does not have

Callers 5

createKernelFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
runTestFunction · 0.85
mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected