implementing webgpu pipeline, fixing vulkan compute pass

This commit is contained in:
2025-02-26 15:01:36 +01:00
parent 6029695155
commit bb7b6e716a
8 changed files with 65 additions and 7 deletions

View File

@@ -2,6 +2,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define CHECK_PULSE_HANDLE_RETVAL(handle, retval) \
if(handle == PULSE_NULL_HANDLE) \
@@ -23,6 +24,15 @@ 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)
{
}
);
int main(void)
{
PulseBackend backend = PulseLoadBackend(PULSE_BACKEND_WEBGPU, PULSE_SHADER_FORMAT_WGSL_BIT, PULSE_HIGH_DEBUG);
@@ -31,6 +41,17 @@ int main(void)
PulseDevice device = PulseCreateDevice(backend, NULL, 0);
CHECK_PULSE_HANDLE_RETVAL(device, 1);
PulseComputePipelineCreateInfo info = { 0 };
info.code_size = strlen(wgsl_source);
info.code = (const uint8_t*)wgsl_source;
info.entrypoint = "main";
info.format = PULSE_SHADER_FORMAT_WGSL_BIT;
PulseComputePipeline pipeline = PulseCreateComputePipeline(device, &info);
CHECK_PULSE_HANDLE_RETVAL(pipeline, 1);
PulseDestroyComputePipeline(device, pipeline);
PulseDestroyDevice(device);
PulseUnloadBackend(backend);
puts("Successfully executed Pulse example using WebGPU !");

View File

@@ -1,4 +0,0 @@
@compute @workgroup_size(32, 32, 1)
fn main(@builtin(global_invocation_id) grid: vec3u)
{
}