From 39794a27d92d3ea28e1ac432db14235fb58c177e Mon Sep 17 00:00:00 2001 From: Kbz-8 Date: Wed, 26 Feb 2025 17:48:24 +0100 Subject: [PATCH] yes --- Examples/WebGPU/main.c | 14 ++++++++++++-- Sources/Backends/WebGPU/WebGPUCommandList.c | 3 +++ Sources/Backends/WebGPU/WebGPUComputePass.c | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Examples/WebGPU/main.c b/Examples/WebGPU/main.c index 33b16b2..c212218 100644 --- a/Examples/WebGPU/main.c +++ b/Examples/WebGPU/main.c @@ -4,6 +4,7 @@ #include #include +#define WGSL_SOURCE(...) #__VA_ARGS__ #define CHECK_PULSE_HANDLE_RETVAL(handle, retval) \ if(handle == PULSE_NULL_HANDLE) \ { \ @@ -24,8 +25,6 @@ void DebugCallBack(PulseDebugMessageSeverity severity, const char* message) printf("Pulse: %s\n", message); } -#define WGSL_SOURCE(...) #__VA_ARGS__ - const char* wgsl_source = WGSL_SOURCE( @compute @workgroup_size(32, 32, 1) fn main(@builtin(global_invocation_id) grid: vec3u) @@ -50,6 +49,17 @@ int main(void) PulseComputePipeline pipeline = PulseCreateComputePipeline(device, &info); CHECK_PULSE_HANDLE_RETVAL(pipeline, 1); + PulseCommandList cmd = PulseRequestCommandList(device, PULSE_COMMAND_LIST_GENERAL); + CHECK_PULSE_HANDLE_RETVAL(cmd, 1); + + PulseComputePass pass = PulseBeginComputePass(cmd); + CHECK_PULSE_HANDLE_RETVAL(pass, 1); + PulseBindComputePipeline(pass, pipeline); + PulseDispatchComputations(pass, 32, 32, 1); + PulseEndComputePass(pass); + + PulseReleaseCommandList(device, cmd); + PulseDestroyComputePipeline(device, pipeline); PulseDestroyDevice(device); diff --git a/Sources/Backends/WebGPU/WebGPUCommandList.c b/Sources/Backends/WebGPU/WebGPUCommandList.c index e275589..f324c42 100644 --- a/Sources/Backends/WebGPU/WebGPUCommandList.c +++ b/Sources/Backends/WebGPU/WebGPUCommandList.c @@ -57,9 +57,12 @@ void WebGPUReleaseCommandList(PulseDevice device, PulseCommandList cmd) PULSE_CHECK_HANDLE(device); WebGPUCommandList* webgpu_cmd = WEBGPU_RETRIEVE_DRIVER_DATA_AS(cmd, WebGPUCommandList*); + WebGPUComputePass* webgpu_pass = WEBGPU_RETRIEVE_DRIVER_DATA_AS(cmd->pass, WebGPUComputePass*); wgpuCommandEncoderRelease(webgpu_cmd->encoder); + free(webgpu_pass); + free(cmd->pass); free(webgpu_cmd); free(cmd); } diff --git a/Sources/Backends/WebGPU/WebGPUComputePass.c b/Sources/Backends/WebGPU/WebGPUComputePass.c index a16adcb..c06309b 100644 --- a/Sources/Backends/WebGPU/WebGPUComputePass.c +++ b/Sources/Backends/WebGPU/WebGPUComputePass.c @@ -43,6 +43,7 @@ void WebGPUEndComputePass(PulseComputePass pass) { WebGPUComputePass* webgpu_pass = WEBGPU_RETRIEVE_DRIVER_DATA_AS(pass, WebGPUComputePass*); wgpuComputePassEncoderEnd(webgpu_pass->encoder); + wgpuComputePassEncoderRelease(webgpu_pass->encoder); } void WebGPUBindStorageBuffers(PulseComputePass pass, const PulseBuffer* buffers, uint32_t num_buffers)