载入中...
搜索中...
未找到
SamplerBuilder.h
浏览该文件的文档.
1#pragma once
2
5
6#include <cstdint>
7
8namespace eve::graphics::webgpu {
9
20public:
22 SamplerBuilder() = default;
23
25 static SamplerBuilder fromEngine(const eve::graphics::TextureSampler &s, uint32_t mipLevels,
26 float maxDeviceAnisotropy);
27
29 SamplerBuilder &label(const char *l) {
30 label_ = l;
31 return *this;
32 }
34 SamplerBuilder &address(wgpu::AddressMode u, wgpu::AddressMode v,
35 wgpu::AddressMode w = wgpu::AddressMode::ClampToEdge) {
36 addrU_ = u;
37 addrV_ = v;
38 addrW_ = w;
39 return *this;
40 }
42 SamplerBuilder &filter(wgpu::FilterMode mag, wgpu::FilterMode min) {
43 mag_ = mag;
44 min_ = min;
45 return *this;
46 }
48 SamplerBuilder &mipmap(wgpu::MipmapFilterMode mip, float lodMin = 0.f, float lodMax = 1000.f) {
49 mip_ = mip;
50 lodMin_ = lodMin;
51 lodMax_ = lodMax;
52 return *this;
53 }
55 SamplerBuilder &compare(wgpu::CompareFunction cmp) {
56 compare_ = cmp;
57 hasCompare_ = true;
58 return *this;
59 }
61 SamplerBuilder &anisotropy(float maxAniso) {
62 aniso_ = maxAniso > 1.f ? maxAniso : 1.f;
63 return *this;
64 }
65
67 wgpu::Sampler build(const wgpu::Device &device) const;
68
69private:
70 const char *label_ = "eve_sampler";
71 wgpu::AddressMode addrU_ = wgpu::AddressMode::ClampToEdge;
72 wgpu::AddressMode addrV_ = wgpu::AddressMode::ClampToEdge;
73 wgpu::AddressMode addrW_ = wgpu::AddressMode::ClampToEdge;
74 wgpu::FilterMode mag_ = wgpu::FilterMode::Linear;
75 wgpu::FilterMode min_ = wgpu::FilterMode::Linear;
76 wgpu::MipmapFilterMode mip_ = wgpu::MipmapFilterMode::Nearest;
77 float lodMin_ = 0.f;
78 float lodMax_ = 0.f;
79 float aniso_ = 1.f;
80 bool hasCompare_ = false;
81 wgpu::CompareFunction compare_ = wgpu::CompareFunction::Always;
82};
83
84} // namespace eve::graphics::webgpu
float w
Definition AnimClip.cpp:738
const std::string & s
vkb::Device & device
float u
Definition Grass.cpp:233
float v
Fluent builder for wgpu::Sampler.
SamplerBuilder & anisotropy(float maxAniso)
Anisotropy.
wgpu::Sampler build(const wgpu::Device &device) const
Create the sampler. Throws eve::graphics::Exception on null device.
SamplerBuilder & compare(wgpu::CompareFunction cmp)
Compare.
SamplerBuilder()=default
Defaults: clamp-to-edge, linear mag/min, no mip sampling, aniso 1.
static SamplerBuilder fromEngine(const eve::graphics::TextureSampler &s, uint32_t mipLevels, float maxDeviceAnisotropy)
Start from an engine TextureSampler (mirrors Graphics::makeSampler).
SamplerBuilder & address(wgpu::AddressMode u, wgpu::AddressMode v, wgpu::AddressMode w=wgpu::AddressMode::ClampToEdge)
Address.
SamplerBuilder & mipmap(wgpu::MipmapFilterMode mip, float lodMin=0.f, float lodMax=1000.f)
Mipmap.
SamplerBuilder & label(const char *l)
Label.
SamplerBuilder & filter(wgpu::FilterMode mag, wgpu::FilterMode min)
Filter.
Sampler state for a Texture (filter, wrap, mip LOD, anisotropy). Defaults match historical engine beh...