WebGPU wrapper wip: add compute pass encoder object
This commit is contained in:
parent
c0b485ae4b
commit
818db07676
4 changed files with 122 additions and 2 deletions
57
libs/wgpu/include/psemek/wgpu/compute_pass_encoder.hpp
Normal file
57
libs/wgpu/include/psemek/wgpu/compute_pass_encoder.hpp
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <psemek/wgpu/detail/object.hpp>
|
||||||
|
#include <psemek/wgpu/query_set.hpp>
|
||||||
|
#include <psemek/wgpu/buffer.hpp>
|
||||||
|
#include <psemek/wgpu/bind_group.hpp>
|
||||||
|
#include <psemek/wgpu/compute_pipeline.hpp>
|
||||||
|
#include <psemek/geom/vector.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
namespace psemek::wgpu
|
||||||
|
{
|
||||||
|
|
||||||
|
struct compute_pass_encoder
|
||||||
|
: detail::object<compute_pass_encoder>
|
||||||
|
{
|
||||||
|
using detail::object<compute_pass_encoder>::object;
|
||||||
|
|
||||||
|
struct timestamp_writes
|
||||||
|
{
|
||||||
|
struct query_set query_set;
|
||||||
|
uint32_t begin_index;
|
||||||
|
uint32_t end_index;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct descriptor
|
||||||
|
{
|
||||||
|
std::vector<chained_struct> chain = {};
|
||||||
|
std::string label = {};
|
||||||
|
std::optional<struct timestamp_writes> timestamp_writes = {};
|
||||||
|
};
|
||||||
|
|
||||||
|
void set_bind_group(std::uint32_t group_index, bind_group group, std::vector<std::uint32_t> dynamic_offsets);
|
||||||
|
void set_pipeline(compute_pipeline pipeline);
|
||||||
|
void dispatch_workgroups(geom::vector<std::uint32_t, 3> const & workgroup_count);
|
||||||
|
void dispatch_workgroups_indirect(buffer indirect_buffer, std::uint64_t offset);
|
||||||
|
void insert_debug_marker(std::string const & marker_label);
|
||||||
|
void push_debug_group(std::string const & group_label);
|
||||||
|
void pop_debug_group();
|
||||||
|
void end();
|
||||||
|
void set_label(std::string const & label);
|
||||||
|
|
||||||
|
static void reference(void * ptr);
|
||||||
|
static void release(void * ptr);
|
||||||
|
|
||||||
|
private:
|
||||||
|
explicit compute_pass_encoder(void * ptr)
|
||||||
|
: detail::object<compute_pass_encoder>(ptr)
|
||||||
|
{}
|
||||||
|
|
||||||
|
friend struct command_encoder;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -55,7 +55,8 @@ namespace psemek::wgpu
|
||||||
bool stencil_read_only;
|
bool stencil_read_only;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct timestamp_writes {
|
struct timestamp_writes
|
||||||
|
{
|
||||||
struct query_set query_set;
|
struct query_set query_set;
|
||||||
std::uint32_t begin_index;
|
std::uint32_t begin_index;
|
||||||
std::uint32_t end_index;
|
std::uint32_t end_index;
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
+ WGPUBuffer
|
+ WGPUBuffer
|
||||||
+ WGPUCommandBuffer
|
+ WGPUCommandBuffer
|
||||||
- WGPUCommandEncoder
|
- WGPUCommandEncoder
|
||||||
WGPUComputePassEncoder
|
+ WGPUComputePassEncoder
|
||||||
+ WGPUComputePipeline
|
+ WGPUComputePipeline
|
||||||
- WGPUDevice
|
- WGPUDevice
|
||||||
+ WGPUInstance
|
+ WGPUInstance
|
||||||
|
|
|
||||||
62
libs/wgpu/source/compute_pass_encoder.cpp
Normal file
62
libs/wgpu/source/compute_pass_encoder.cpp
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
#include <psemek/wgpu/compute_pass_encoder.hpp>
|
||||||
|
#include <psemek/wgpu/external/webgpu.h>
|
||||||
|
|
||||||
|
namespace psemek::wgpu
|
||||||
|
{
|
||||||
|
|
||||||
|
void compute_pass_encoder::set_bind_group(std::uint32_t group_index, bind_group group, std::vector<std::uint32_t> dynamic_offsets)
|
||||||
|
{
|
||||||
|
wgpuComputePassEncoderSetBindGroup((WGPUComputePassEncoder)get(), group_index, (WGPUBindGroup)group.get(), dynamic_offsets.size(), dynamic_offsets.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_pass_encoder::set_pipeline(compute_pipeline pipeline)
|
||||||
|
{
|
||||||
|
wgpuComputePassEncoderSetPipeline((WGPUComputePassEncoder)get(), (WGPUComputePipeline)pipeline.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_pass_encoder::dispatch_workgroups(geom::vector<std::uint32_t, 3> const & workgroup_count)
|
||||||
|
{
|
||||||
|
wgpuComputePassEncoderDispatchWorkgroups((WGPUComputePassEncoder)get(), workgroup_count[0], workgroup_count[1], workgroup_count[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_pass_encoder::dispatch_workgroups_indirect(buffer indirect_buffer, std::uint64_t offset)
|
||||||
|
{
|
||||||
|
wgpuComputePassEncoderDispatchWorkgroupsIndirect((WGPUComputePassEncoder)get(), (WGPUBuffer)indirect_buffer.get(), offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_pass_encoder::insert_debug_marker(std::string const & marker_label)
|
||||||
|
{
|
||||||
|
wgpuComputePassEncoderInsertDebugMarker((WGPUComputePassEncoder)get(), marker_label.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_pass_encoder::push_debug_group(std::string const & group_label)
|
||||||
|
{
|
||||||
|
wgpuComputePassEncoderPushDebugGroup((WGPUComputePassEncoder)get(), group_label.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_pass_encoder::pop_debug_group()
|
||||||
|
{
|
||||||
|
wgpuComputePassEncoderPopDebugGroup((WGPUComputePassEncoder)get());
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_pass_encoder::end()
|
||||||
|
{
|
||||||
|
wgpuComputePassEncoderEnd((WGPUComputePassEncoder)get());
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_pass_encoder::set_label(std::string const & label)
|
||||||
|
{
|
||||||
|
wgpuComputePassEncoderSetLabel((WGPUComputePassEncoder)get(), label.data());
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_pass_encoder::reference(void * ptr)
|
||||||
|
{
|
||||||
|
wgpuComputePassEncoderReference((WGPUComputePassEncoder)ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
void compute_pass_encoder::release(void * ptr)
|
||||||
|
{
|
||||||
|
wgpuComputePassEncoderRelease((WGPUComputePassEncoder)ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue