Skip to content

Commit 05e0917

Browse files
committed
Use designated initializers for Rhi::SamplerSettings
1 parent 4ab1eed commit 05e0917

16 files changed

Lines changed: 66 additions & 70 deletions

File tree

Apps/03-TexturedCube/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ void TexturedCubeApp::Init()
283283
m_texture_sampler = GetRenderContext().CreateSampler(
284284
rhi::Sampler::Settings
285285
{
286-
rhi::Sampler::Filter { rhi::Sampler::Filter::MinMag::Linear },
287-
rhi::Sampler::Address { rhi::Sampler::Address::Mode::ClampToEdge }
286+
.filter = rhi::Sampler::Filter { rhi::Sampler::Filter::MinMag::Linear },
287+
.address = rhi::Sampler::Address { rhi::Sampler::Address::Mode::ClampToEdge }
288288
}
289289
);
290290

Apps/03-TexturedCube/TexturedCubeApp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ void TexturedCubeApp::Init()
148148
m_texture_sampler = GetRenderContext().CreateSampler(
149149
rhi::Sampler::Settings
150150
{
151-
rhi::Sampler::Filter { rhi::Sampler::Filter::MinMag::Linear },
152-
rhi::Sampler::Address { rhi::Sampler::Address::Mode::ClampToEdge }
151+
.filter = rhi::Sampler::Filter { rhi::Sampler::Filter::MinMag::Linear },
152+
.address = rhi::Sampler::Address { rhi::Sampler::Address::Mode::ClampToEdge }
153153
}
154154
);
155155

Apps/04-ShadowCube/ShadowCubeApp.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ void ShadowCubeApp::Init()
107107
m_texture_sampler = render_context.CreateSampler(
108108
rhi::Sampler::Settings
109109
{
110-
rhi::Sampler::Filter { rhi::Sampler::Filter::MinMag::Linear },
111-
rhi::Sampler::Address { rhi::Sampler::Address::Mode::ClampToEdge }
110+
.filter = rhi::Sampler::Filter { rhi::Sampler::Filter::MinMag::Linear },
111+
.address = rhi::Sampler::Address { rhi::Sampler::Address::Mode::ClampToEdge }
112112
}
113113
);
114114
m_texture_sampler.SetName("Texture Sampler");
@@ -117,8 +117,8 @@ void ShadowCubeApp::Init()
117117
m_shadow_sampler = render_context.CreateSampler(
118118
rhi::Sampler::Settings
119119
{
120-
rhi::Sampler::Filter { rhi::Sampler::Filter::MinMag::Linear },
121-
rhi::Sampler::Address { rhi::Sampler::Address::Mode::ClampToEdge }
120+
.filter = rhi::Sampler::Filter { rhi::Sampler::Filter::MinMag::Linear },
121+
.address = rhi::Sampler::Address { rhi::Sampler::Address::Mode::ClampToEdge }
122122
}
123123
);
124124
m_shadow_sampler.SetName("Shadow Map Sampler");

Apps/06-CubeMapArray/CubeMapArrayApp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,8 @@ void CubeMapArrayApp::Init()
138138
m_texture_sampler = GetRenderContext().CreateSampler(
139139
rhi::Sampler::Settings
140140
{
141-
rhi::Sampler::Filter { rhi::Sampler::Filter::MinMag::Linear },
142-
rhi::Sampler::Address { rhi::Sampler::Address::Mode::ClampToEdge }
141+
.filter = rhi::Sampler::Filter { rhi::Sampler::Filter::MinMag::Linear },
142+
.address = rhi::Sampler::Address { rhi::Sampler::Address::Mode::ClampToEdge }
143143
}
144144
);
145145

Apps/07-ParallelRendering/ParallelRenderingApp.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ void ParallelRenderingApp::Init()
188188
m_texture_sampler = GetRenderContext().CreateSampler(
189189
rhi::Sampler::Settings
190190
{
191-
rhi::Sampler::Filter { rhi::Sampler::Filter::MinMag::Linear },
192-
rhi::Sampler::Address { rhi::Sampler::Address::Mode::ClampToEdge }
191+
.filter = rhi::Sampler::Filter { rhi::Sampler::Filter::MinMag::Linear },
192+
.address = rhi::Sampler::Address { rhi::Sampler::Address::Mode::ClampToEdge }
193193
}
194194
);
195195

Modules/Graphics/Primitives/Sources/Methane/Graphics/ScreenQuad.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,12 @@ class ScreenQuad::Impl
187187
m_texture_sampler = render_context.GetObjectRegistry().GetGraphicsObject<Rhi::Sampler>(s_sampler_name);
188188
if (!m_texture_sampler.IsInitialized())
189189
{
190-
m_texture_sampler = render_context.CreateSampler({
191-
Rhi::ISampler::Filter(Rhi::ISampler::Filter::MinMag::Linear),
192-
Rhi::ISampler::Address(Rhi::ISampler::Address::Mode::ClampToZero),
193-
});
190+
m_texture_sampler = render_context.CreateSampler(
191+
Rhi::SamplerSettings
192+
{
193+
.filter = Rhi::ISampler::Filter(Rhi::ISampler::Filter::MinMag::Linear),
194+
.address = Rhi::ISampler::Address(Rhi::ISampler::Address::Mode::ClampToZero),
195+
});
194196
m_texture_sampler.SetName(s_sampler_name);
195197
render_context.GetObjectRegistry().AddGraphicsObject(m_texture_sampler);
196198
}

Modules/Graphics/RHI/Interface/Include/Methane/Graphics/RHI/ISampler.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,21 +117,14 @@ enum class SamplerBorderColor : uint32_t
117117

118118
struct SamplerSettings
119119
{
120-
SamplerSettings(const SamplerFilter& filter,
121-
const SamplerAddress& address,
122-
const SamplerLevelOfDetail& lod = {},
123-
uint32_t max_anisotropy = 1,
124-
SamplerBorderColor border_color = SamplerBorderColor::TransparentBlack,
125-
Compare compare_function = Compare::Never);
126-
127-
[[nodiscard]] friend bool operator==(const SamplerSettings& left, const SamplerSettings& right) = default;
128-
129120
SamplerFilter filter;
130121
SamplerAddress address;
131122
SamplerLevelOfDetail lod;
132123
uint32_t max_anisotropy = 1;
133124
SamplerBorderColor border_color = SamplerBorderColor::TransparentBlack;
134125
Compare compare_function = Compare::Never;
126+
127+
[[nodiscard]] friend bool operator==(const SamplerSettings& left, const SamplerSettings& right) = default;
135128
};
136129

137130
struct IContext;

Modules/Graphics/RHI/Interface/Sources/Methane/Graphics/RHI/ISampler.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,6 @@ Methane sampler interface: GPU resource for texture sampling.
2727
namespace Methane::Graphics::Rhi
2828
{
2929

30-
SamplerSettings::SamplerSettings(const SamplerFilter& filter, const SamplerAddress& address,
31-
const SamplerLevelOfDetail& lod, uint32_t max_anisotropy,
32-
SamplerBorderColor border_color, Compare compare_function)
33-
: filter(filter)
34-
, address(address)
35-
, lod(lod)
36-
, max_anisotropy(max_anisotropy)
37-
, border_color(border_color)
38-
, compare_function(compare_function)
39-
{ }
40-
4130
SamplerLevelOfDetail::SamplerLevelOfDetail(float bias, float min, float max)
4231
: min(min)
4332
, max(max)

Modules/UserInterface/Typography/Sources/Methane/UserInterface/Text.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,12 @@ class Text::Impl // NOSONAR - class destructor is required
396396
m_atlas_sampler = gfx_objects_registry.GetGraphicsObject<rhi::Sampler>(s_sampler_name);
397397
if (!m_atlas_sampler.IsInitialized())
398398
{
399-
m_atlas_sampler = m_ui_context.GetRenderContext().CreateSampler({
400-
rhi::ISampler::Filter(rhi::ISampler::Filter::MinMag::Linear),
401-
rhi::ISampler::Address(rhi::ISampler::Address::Mode::ClampToZero),
402-
});
399+
m_atlas_sampler = m_ui_context.GetRenderContext().CreateSampler(
400+
rhi::SamplerSettings
401+
{
402+
.filter = rhi::ISampler::Filter(rhi::ISampler::Filter::MinMag::Linear),
403+
.address = rhi::ISampler::Address(rhi::ISampler::Address::Mode::ClampToZero),
404+
});
403405
m_atlas_sampler.SetName(s_sampler_name);
404406

405407
gfx_objects_registry.AddGraphicsObject(m_atlas_sampler);

Tests/Graphics/RHI/ComputeCommandListTest.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,12 @@ TEST_CASE("RHI Compute Command List Functions", "[rhi][list][compute]")
204204

205205
const Rhi::Sampler sampler = [&compute_context]()
206206
{
207-
const Rhi::Sampler sampler = compute_context.CreateSampler({
208-
rhi::SamplerFilter { rhi::SamplerFilter::MinMag::Linear },
209-
rhi::SamplerAddress { rhi::SamplerAddress::Mode::ClampToEdge }
210-
});
207+
const Rhi::Sampler sampler = compute_context.CreateSampler(
208+
rhi::SamplerSettings
209+
{
210+
.filter = rhi::SamplerFilter { rhi::SamplerFilter::MinMag::Linear },
211+
.address = rhi::SamplerAddress { rhi::SamplerAddress::Mode::ClampToEdge }
212+
});
211213
sampler.SetName("S");
212214
return sampler;
213215
}();

0 commit comments

Comments
 (0)