WebGPU wrapper wip: add sampler object
This commit is contained in:
parent
260d584df8
commit
e52ab0d731
3 changed files with 101 additions and 1 deletions
78
libs/wgpu/include/psemek/wgpu/sampler.hpp
Normal file
78
libs/wgpu/include/psemek/wgpu/sampler.hpp
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#pragma once
|
||||
|
||||
#include <psemek/wgpu/detail/object.hpp>
|
||||
#include <psemek/wgpu/chained_struct.hpp>
|
||||
#include <psemek/geom/interval.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace psemek::wgpu
|
||||
{
|
||||
|
||||
enum class address_mode : std::uint32_t
|
||||
{
|
||||
repeat = 0x00000000,
|
||||
mirror_repeat = 0x00000001,
|
||||
clamp_to_edge = 0x00000002,
|
||||
};
|
||||
|
||||
enum class filter_mode : std::uint32_t
|
||||
{
|
||||
nearest = 0x00000000,
|
||||
linear = 0x00000001,
|
||||
};
|
||||
|
||||
enum class mipmap_filter_mode : std::uint32_t
|
||||
{
|
||||
nearest = 0x00000000,
|
||||
linear = 0x00000001,
|
||||
};
|
||||
|
||||
enum class compare_function : std::uint32_t
|
||||
{
|
||||
undefined = 0x00000000,
|
||||
never = 0x00000001,
|
||||
less = 0x00000002,
|
||||
less_equal = 0x00000003,
|
||||
greater = 0x00000004,
|
||||
greater_equal = 0x00000005,
|
||||
equal = 0x00000006,
|
||||
not_equal = 0x00000007,
|
||||
always = 0x00000008,
|
||||
};
|
||||
|
||||
struct sampler
|
||||
: detail::object<sampler>
|
||||
{
|
||||
using detail::object<sampler>::object;
|
||||
|
||||
struct descriptor {
|
||||
std::vector<chained_struct> chain = {};
|
||||
std::string label = {};
|
||||
address_mode address_mode_u;
|
||||
address_mode address_mode_v;
|
||||
address_mode address_mode_w;
|
||||
filter_mode mag_filter;
|
||||
filter_mode min_filter;
|
||||
mipmap_filter_mode mipmap_filter;
|
||||
geom::interval<float> lod_clamp;
|
||||
compare_function compare;
|
||||
std::uint16_t maxAnisotropy;
|
||||
};
|
||||
|
||||
void set_label(std::string const & label);
|
||||
|
||||
static void reference(void * ptr);
|
||||
static void release(void * ptr);
|
||||
|
||||
private:
|
||||
explicit sampler(void * ptr)
|
||||
: detail::object<sampler>(ptr)
|
||||
{}
|
||||
|
||||
friend struct device;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
WGPURenderBundleEncoder
|
||||
- WGPURenderPassEncoder
|
||||
WGPURenderPipeline
|
||||
WGPUSampler
|
||||
+ WGPUSampler
|
||||
+ WGPUShaderModule
|
||||
+ WGPUSurface
|
||||
+ WGPUTexture
|
||||
|
|
|
|||
22
libs/wgpu/source/sampler.cpp
Normal file
22
libs/wgpu/source/sampler.cpp
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#include <psemek/wgpu/sampler.hpp>
|
||||
#include <psemek/wgpu/external/webgpu.h>
|
||||
|
||||
namespace psemek::wgpu
|
||||
{
|
||||
|
||||
void sampler::set_label(std::string const & label)
|
||||
{
|
||||
wgpuSamplerSetLabel((WGPUSampler)get(), label.data());
|
||||
}
|
||||
|
||||
void sampler::reference(void * ptr)
|
||||
{
|
||||
wgpuSamplerReference((WGPUSampler)ptr);
|
||||
}
|
||||
|
||||
void sampler::release(void * ptr)
|
||||
{
|
||||
wgpuSamplerRelease((WGPUSampler)ptr);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue