mirror of
https://github.com/Kbz-8/Pulse.git
synced 2026-01-11 15:33:34 +00:00
implementing webgpu pipeline, fixing vulkan compute pass
This commit is contained in:
@@ -134,4 +134,11 @@ PulseComputePass VulkanBeginComputePass(PulseCommandList cmd)
|
||||
|
||||
void VulkanEndComputePass(PulseComputePass pass)
|
||||
{
|
||||
VulkanComputePass* vulkan_pass = VULKAN_RETRIEVE_DRIVER_DATA_AS(pass, VulkanComputePass*);
|
||||
VulkanReturnDescriptorSetToPool(vulkan_pass->read_only_descriptor_set->pool, vulkan_pass->read_only_descriptor_set);
|
||||
VulkanReturnDescriptorSetToPool(vulkan_pass->read_write_descriptor_set->pool, vulkan_pass->read_write_descriptor_set);
|
||||
VulkanReturnDescriptorSetToPool(vulkan_pass->uniform_descriptor_set->pool, vulkan_pass->uniform_descriptor_set);
|
||||
vulkan_pass->read_only_descriptor_set = VK_NULL_HANDLE;
|
||||
vulkan_pass->read_write_descriptor_set = VK_NULL_HANDLE;
|
||||
vulkan_pass->uniform_descriptor_set = VK_NULL_HANDLE;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "WebGPU.h"
|
||||
#include "WebGPUDevice.h"
|
||||
#include "WebGPUComputePass.h"
|
||||
#include "WebGPUComputePipeline.h"
|
||||
|
||||
PulseComputePass WebGPUCreateComputePass(PulseDevice device, PulseCommandList cmd)
|
||||
{
|
||||
@@ -58,6 +59,9 @@ void WebGPUBindStorageImages(PulseComputePass pass, const PulseImage* images, ui
|
||||
|
||||
void WebGPUBindComputePipeline(PulseComputePass pass, PulseComputePipeline pipeline)
|
||||
{
|
||||
WebGPUComputePass* webgpu_pass = WEBGPU_RETRIEVE_DRIVER_DATA_AS(pass, WebGPUComputePass*);
|
||||
WebGPUComputePipeline* webgpu_pipeline = WEBGPU_RETRIEVE_DRIVER_DATA_AS(pipeline, WebGPUComputePipeline*);
|
||||
wgpuComputePassEncoderSetPipeline(webgpu_pass->encoder, webgpu_pipeline->pipeline);
|
||||
}
|
||||
|
||||
void WebGPUDispatchComputations(PulseComputePass pass, uint32_t groupcount_x, uint32_t groupcount_y, uint32_t groupcount_z)
|
||||
|
||||
@@ -44,8 +44,8 @@ PulseComputePipeline WebGPUCreateComputePipeline(PulseDevice device, const Pulse
|
||||
webgpu_pipeline->shader = wgpuDeviceCreateShaderModule(webgpu_device->device, &shader_descriptor);
|
||||
|
||||
WGPUStringView entrypoint = { 0 };
|
||||
code.length = WGPU_STRLEN;
|
||||
code.data = info->entrypoint;
|
||||
entrypoint.length = WGPU_STRLEN;
|
||||
entrypoint.data = info->entrypoint;
|
||||
WGPUProgrammableStageDescriptor state = { 0 };
|
||||
state.module = webgpu_pipeline->shader;
|
||||
state.entryPoint = entrypoint;
|
||||
@@ -53,9 +53,29 @@ PulseComputePipeline WebGPUCreateComputePipeline(PulseDevice device, const Pulse
|
||||
pipeline_descriptor.compute = state;
|
||||
webgpu_pipeline->pipeline = wgpuDeviceCreateComputePipeline(webgpu_device->device, &pipeline_descriptor);
|
||||
|
||||
if(PULSE_IS_BACKEND_HIGH_LEVEL_DEBUG(device->backend))
|
||||
PulseLogInfoFmt(device->backend, "(WebGPU) created new compute pipeline %p", pipeline);
|
||||
|
||||
return pipeline;
|
||||
}
|
||||
|
||||
void WebGPUDestroyComputePipeline(PulseDevice device, PulseComputePipeline pipeline)
|
||||
{
|
||||
if(pipeline == PULSE_NULL_HANDLE)
|
||||
{
|
||||
if(PULSE_IS_BACKEND_LOW_LEVEL_DEBUG(device->backend))
|
||||
PulseLogWarning(device->backend, "compute pipeline is NULL, this may be a bug in your application");
|
||||
return;
|
||||
}
|
||||
|
||||
PULSE_UNUSED(device);
|
||||
WebGPUComputePipeline* webgpu_pipeline = WEBGPU_RETRIEVE_DRIVER_DATA_AS(pipeline, WebGPUComputePipeline*);
|
||||
wgpuComputePipelineRelease(webgpu_pipeline->pipeline);
|
||||
wgpuShaderModuleRelease(webgpu_pipeline->shader);
|
||||
free(webgpu_pipeline);
|
||||
|
||||
if(PULSE_IS_BACKEND_HIGH_LEVEL_DEBUG(device->backend))
|
||||
PulseLogInfoFmt(device->backend, "(WebGPU) destroyed compute pipeline %p", pipeline);
|
||||
|
||||
free(pipeline);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user