diff --git a/libs/wgpu/include/psemek/wgpu/sampler.hpp b/libs/wgpu/include/psemek/wgpu/sampler.hpp new file mode 100644 index 00000000..8c4d4b62 --- /dev/null +++ b/libs/wgpu/include/psemek/wgpu/sampler.hpp @@ -0,0 +1,78 @@ +#pragma once + +#include +#include +#include + +#include +#include +#include + +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 + { + using detail::object::object; + + struct descriptor { + std::vector 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 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(ptr) + {} + + friend struct device; + }; + +} diff --git a/libs/wgpu/objects-todo b/libs/wgpu/objects-todo index d630809c..e512434f 100644 --- a/libs/wgpu/objects-todo +++ b/libs/wgpu/objects-todo @@ -15,7 +15,7 @@ WGPURenderBundleEncoder - WGPURenderPassEncoder WGPURenderPipeline - WGPUSampler ++ WGPUSampler + WGPUShaderModule + WGPUSurface + WGPUTexture diff --git a/libs/wgpu/source/sampler.cpp b/libs/wgpu/source/sampler.cpp new file mode 100644 index 00000000..f8fc0870 --- /dev/null +++ b/libs/wgpu/source/sampler.cpp @@ -0,0 +1,22 @@ +#include +#include + +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); + } + +}