Skip to content

Commit 05e0917

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

File tree

16 files changed

+66
-70
lines changed

16 files changed

+66
-70
lines changed

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
}();

Tests/Graphics/RHI/ComputeContextTest.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -314,12 +314,12 @@ TEST_CASE("RHI Compute Context Factory", "[rhi][compute][context][factory]")
314314

315315
SECTION("Can Create Sampler")
316316
{
317-
const Rhi::SamplerSettings sampler_settings{
318-
rhi::SamplerFilter { rhi::SamplerFilter::MinMag::Linear },
319-
rhi::SamplerAddress { rhi::SamplerAddress::Mode::ClampToEdge }
320-
};
321317
Rhi::Sampler sampler;
322-
REQUIRE_NOTHROW(sampler = compute_context.CreateSampler(sampler_settings));
318+
REQUIRE_NOTHROW(sampler = compute_context.CreateSampler(
319+
Rhi::SamplerSettings{
320+
.filter = rhi::SamplerFilter { rhi::SamplerFilter::MinMag::Linear },
321+
.address = rhi::SamplerAddress { rhi::SamplerAddress::Mode::ClampToEdge }
322+
}));
323323
REQUIRE(sampler.IsInitialized());
324324
CHECK(sampler.GetSettings().filter.min == Rhi::SamplerFilter::MinMag::Linear);
325325
CHECK(sampler.GetSettings().filter.mag == Rhi::SamplerFilter::MinMag::Linear);

Tests/Graphics/RHI/ParallelRenderCommandListTest.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,13 @@ TEST_CASE("RHI Parallel Render Command List Functions", "[rhi][list][render]")
203203
SECTION("Set Program Bindings is Not Implemented")
204204
{
205205
const Rhi::Texture texture = render_context.CreateTexture(
206-
Rhi::TextureSettings::ForImage(Dimensions(640, 480), {}, PixelFormat::RGBA8, false));
207-
const Rhi::Sampler sampler = render_context.CreateSampler({
206+
Rhi::TextureSettings::ForImage(Dimensions(640, 480), {}, PixelFormat::RGBA8, false));
207+
const Rhi::Sampler sampler = render_context.CreateSampler(
208+
Rhi::SamplerSettings
209+
{
208210
rhi::SamplerFilter { rhi::SamplerFilter::MinMag::Linear },
209211
rhi::SamplerAddress { rhi::SamplerAddress::Mode::ClampToEdge }
210-
});
212+
});
211213
const Rhi::Buffer buffer = render_context.CreateBuffer(
212214
Rhi::BufferSettings::ForConstantBuffer(42000, false, true));
213215

Tests/Graphics/RHI/ProgramBindingsTest.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,12 @@ TEST_CASE("RHI Program Bindings Functions", "[rhi][program][bindings]")
116116

117117
const Rhi::Sampler sampler = [&compute_context]()
118118
{
119-
const Rhi::Sampler sampler = compute_context.CreateSampler({
120-
rhi::SamplerFilter { rhi::SamplerFilter::MinMag::Linear },
121-
rhi::SamplerAddress { rhi::SamplerAddress::Mode::ClampToEdge }
122-
});
119+
const Rhi::Sampler sampler = compute_context.CreateSampler(
120+
rhi::SamplerSettings
121+
{
122+
.filter = rhi::SamplerFilter { rhi::SamplerFilter::MinMag::Linear },
123+
.address = rhi::SamplerAddress { rhi::SamplerAddress::Mode::ClampToEdge }
124+
});
123125
CHECK(sampler.SetName("S"));
124126
return sampler;
125127
}();

Tests/Graphics/RHI/RenderCommandListsTest.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -244,10 +244,12 @@ TEST_CASE("RHI Render Command List Functions", "[rhi][list][render]")
244244

245245
const Rhi::Sampler sampler = [&render_context]()
246246
{
247-
const Rhi::Sampler sampler = render_context.CreateSampler({
248-
rhi::SamplerFilter { rhi::SamplerFilter::MinMag::Linear },
249-
rhi::SamplerAddress { rhi::SamplerAddress::Mode::ClampToEdge }
250-
});
247+
const Rhi::Sampler sampler = render_context.CreateSampler(
248+
rhi::SamplerSettings
249+
{
250+
.filter = rhi::SamplerFilter { rhi::SamplerFilter::MinMag::Linear },
251+
.address = rhi::SamplerAddress { rhi::SamplerAddress::Mode::ClampToEdge }
252+
});
251253
sampler.SetName("S");
252254
return sampler;
253255
}();

Tests/Graphics/RHI/RenderContextTest.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,12 +439,13 @@ TEST_CASE("RHI Render Context Factory", "[rhi][render][context][factory]")
439439

440440
SECTION("Can Create Sampler")
441441
{
442-
const Rhi::SamplerSettings sampler_settings{
443-
rhi::SamplerFilter { rhi::SamplerFilter::MinMag::Linear },
444-
rhi::SamplerAddress { rhi::SamplerAddress::Mode::ClampToEdge }
445-
};
446442
Rhi::Sampler sampler;
447-
REQUIRE_NOTHROW(sampler = render_context.CreateSampler(sampler_settings));
443+
REQUIRE_NOTHROW(sampler = render_context.CreateSampler(
444+
Rhi::SamplerSettings
445+
{
446+
.filter = rhi::SamplerFilter { rhi::SamplerFilter::MinMag::Linear },
447+
.address = rhi::SamplerAddress { rhi::SamplerAddress::Mode::ClampToEdge }
448+
}));
448449
REQUIRE(sampler.IsInitialized());
449450
CHECK(sampler.GetSettings().filter.min == Rhi::SamplerFilter::MinMag::Linear);
450451
CHECK(sampler.GetSettings().filter.mag == Rhi::SamplerFilter::MinMag::Linear);

Tests/Graphics/RHI/SamplerTest.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ TEST_CASE("RHI Sampler Functions", "[rhi][sampler][resource]")
4444
{
4545
const Rhi::ComputeContext compute_context = Rhi::ComputeContext(GetTestDevice(), g_parallel_executor, {});
4646
const Rhi::SamplerSettings sampler_settings{
47-
rhi::SamplerFilter { rhi::SamplerFilter::MinMag::Linear },
48-
rhi::SamplerAddress { rhi::SamplerAddress::Mode::ClampToEdge },
49-
rhi::SamplerLevelOfDetail{ 0.5f, 0.f, 1.f },
50-
2U, rhi::SamplerBorderColor::OpaqueBlack,
51-
Compare::GreaterEqual
47+
.filter = rhi::SamplerFilter { rhi::SamplerFilter::MinMag::Linear },
48+
.address = rhi::SamplerAddress { rhi::SamplerAddress::Mode::ClampToEdge },
49+
.lod = rhi::SamplerLevelOfDetail{ 0.5f, 0.f, 1.f },
50+
.max_anisotropy = 2U,
51+
.border_color = rhi::SamplerBorderColor::OpaqueBlack,
52+
.compare_function = Compare::GreaterEqual
5253
};
5354

5455
SECTION("Constant Sampler Construction")

0 commit comments

Comments
 (0)