mirror of
https://github.com/Kbz-8/Pulse.git
synced 2026-01-11 15:33:34 +00:00
adding base webgpu compute pass and compute pipeline
This commit is contained in:
@@ -4,21 +4,44 @@
|
||||
|
||||
#include <Pulse.h>
|
||||
#include "WebGPU.h"
|
||||
#include "WebGPUDevice.h"
|
||||
#include "WebGPUComputePass.h"
|
||||
|
||||
PulseComputePass WebGPUCreateComputePass(PulseDevice device, PulseCommandList cmd)
|
||||
{
|
||||
PULSE_UNUSED(device);
|
||||
PulseComputePass pass = (PulseComputePass)calloc(1, sizeof(PulseComputePassHandler));
|
||||
PULSE_CHECK_ALLOCATION_RETVAL(pass, PULSE_NULL_HANDLE);
|
||||
|
||||
WebGPUComputePass* webgpu_pass = (WebGPUComputePass*)calloc(1, sizeof(WebGPUComputePass));
|
||||
PULSE_CHECK_ALLOCATION_RETVAL(webgpu_pass, PULSE_NULL_HANDLE);
|
||||
|
||||
pass->cmd = cmd;
|
||||
pass->driver_data = webgpu_pass;
|
||||
|
||||
return pass;
|
||||
}
|
||||
|
||||
void WebGPUDestroyComputePass(PulseDevice device, PulseComputePass pass)
|
||||
{
|
||||
PULSE_UNUSED(device);
|
||||
free(pass->driver_data);
|
||||
free(pass);
|
||||
}
|
||||
|
||||
PulseComputePass WebGPUBeginComputePass(PulseCommandList cmd)
|
||||
{
|
||||
WebGPUCommandList* webgpu_cmd = WEBGPU_RETRIEVE_DRIVER_DATA_AS(cmd, WebGPUCommandList*);
|
||||
WebGPUComputePass* webgpu_pass = WEBGPU_RETRIEVE_DRIVER_DATA_AS(cmd->pass, WebGPUComputePass*);
|
||||
WGPUComputePassDescriptor descriptor = { 0 };
|
||||
webgpu_pass->encoder = wgpuCommandEncoderBeginComputePass(webgpu_cmd->encoder, &descriptor);
|
||||
return cmd->pass;
|
||||
}
|
||||
|
||||
void WebGPUEndComputePass(PulseComputePass pass)
|
||||
{
|
||||
WebGPUComputePass* webgpu_pass = WEBGPU_RETRIEVE_DRIVER_DATA_AS(pass, WebGPUComputePass*);
|
||||
wgpuComputePassEncoderEnd(webgpu_pass->encoder);
|
||||
}
|
||||
|
||||
void WebGPUBindStorageBuffers(PulseComputePass pass, const PulseBuffer* buffers, uint32_t num_buffers)
|
||||
@@ -39,4 +62,6 @@ void WebGPUBindComputePipeline(PulseComputePass pass, PulseComputePipeline pipel
|
||||
|
||||
void WebGPUDispatchComputations(PulseComputePass pass, uint32_t groupcount_x, uint32_t groupcount_y, uint32_t groupcount_z)
|
||||
{
|
||||
WebGPUComputePass* webgpu_pass = WEBGPU_RETRIEVE_DRIVER_DATA_AS(pass, WebGPUComputePass*);
|
||||
wgpuComputePassEncoderDispatchWorkgroups(webgpu_pass->encoder, groupcount_x, groupcount_y, groupcount_z);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user