Skip to content

Commit b75adfc

Browse files
Print warning instead of failing out if the max sampler anisotropy exceeds the device limit
1 parent e94b369 commit b75adfc

4 files changed

Lines changed: 12 additions & 11 deletions

File tree

Graphics/GraphicsEngine/src/SamplerBase.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,12 @@ void ValidateSamplerDesc(const SamplerDesc& Desc, const IRenderDevice* pDevice)
6262
}
6363
if (IsAnisotropicFilter(Desc.MinFilter))
6464
{
65-
VERIFY_SAMPLER(AdapterInfo.Sampler.MaxAnisotropy >= Desc.MaxAnisotropy,
66-
"MaxAnisotropy (", Uint32{Desc.MaxAnisotropy}, ") exceeds the maximum supported anisotropy (", Uint32{AdapterInfo.Sampler.MaxAnisotropy},
67-
"). Check the value of AdapterInfo.Sampler.MaxAnisotropy to make sure it is correct.");
65+
if (Desc.MaxAnisotropy > AdapterInfo.Sampler.MaxAnisotropy)
66+
{
67+
LOG_WARNING_MESSAGE("MaxAnisotropy (", Uint32{Desc.MaxAnisotropy}, ") requested for sampler '", Desc.Name,
68+
"' exceeds the maximum supported anisotropy (", Uint32{AdapterInfo.Sampler.MaxAnisotropy},
69+
"). Check the value of AdapterInfo.Sampler.MaxAnisotropy.");
70+
}
6871
}
6972
}
7073

Graphics/GraphicsEngineD3D11/src/SamplerD3D11Impl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 Diligent Graphics LLC
2+
* Copyright 2019-2024 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -52,7 +52,7 @@ SamplerD3D11Impl::SamplerD3D11Impl(IReferenceCounters* pRefCounters,
5252
TexAddressModeToD3D11AddressMode(SamplerDesc.AddressV),
5353
TexAddressModeToD3D11AddressMode(SamplerDesc.AddressW),
5454
SamplerDesc.MipLODBias,
55-
SamplerDesc.MaxAnisotropy,
55+
std::min<UINT>(SamplerDesc.MaxAnisotropy, D3D11_DEFAULT_MAX_ANISOTROPY),
5656
ComparisonFuncToD3D11ComparisonFunc(SamplerDesc.ComparisonFunc),
5757
{SamplerDesc.BorderColor[0], SamplerDesc.BorderColor[1], SamplerDesc.BorderColor[2], SamplerDesc.BorderColor[3]},
5858
SamplerDesc.MinLOD,

Graphics/GraphicsEngineD3D12/src/SamplerD3D12Impl.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 Diligent Graphics LLC
2+
* Copyright 2019-2024 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -48,7 +48,7 @@ SamplerD3D12Impl::SamplerD3D12Impl(IReferenceCounters* pRefCounters,
4848
TexAddressModeToD3D12AddressMode(SamplerDesc.AddressV),
4949
TexAddressModeToD3D12AddressMode(SamplerDesc.AddressW),
5050
SamplerDesc.MipLODBias,
51-
SamplerDesc.MaxAnisotropy,
51+
std::min<UINT>(SamplerDesc.MaxAnisotropy, D3D12_DEFAULT_MAX_ANISOTROPY),
5252
ComparisonFuncToD3D12ComparisonFunc(SamplerDesc.ComparisonFunc),
5353
{SamplerDesc.BorderColor[0], SamplerDesc.BorderColor[1], SamplerDesc.BorderColor[2], SamplerDesc.BorderColor[3]},
5454
SamplerDesc.MinLOD,

Graphics/GraphicsEngineVulkan/src/SamplerVkImpl.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2022 Diligent Graphics LLC
2+
* Copyright 2019-2024 Diligent Graphics LLC
33
* Copyright 2015-2019 Egor Yusov
44
*
55
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -61,9 +61,7 @@ SamplerVkImpl::SamplerVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImp
6161
SamplerCI.mipLodBias = m_Desc.MipLODBias;
6262

6363
SamplerCI.anisotropyEnable = IsAnisotropicFilter(m_Desc.MinFilter);
64-
DEV_CHECK_ERR(!SamplerCI.anisotropyEnable || (m_Desc.MaxAnisotropy >= 1 && static_cast<float>(m_Desc.MaxAnisotropy) <= Limits.maxSamplerAnisotropy),
65-
"MaxAnisotropy (", m_Desc.MaxAnisotropy, ") must be in range 1 .. ", Limits.maxSamplerAnisotropy, ".");
66-
SamplerCI.maxAnisotropy = SamplerCI.anisotropyEnable ? clamp(static_cast<float>(m_Desc.MaxAnisotropy), 1.f, Limits.maxSamplerAnisotropy) : 0.f;
64+
SamplerCI.maxAnisotropy = SamplerCI.anisotropyEnable ? clamp(static_cast<float>(m_Desc.MaxAnisotropy), 1.f, Limits.maxSamplerAnisotropy) : 0.f;
6765
DEV_CHECK_ERR((SamplerCI.anisotropyEnable != VK_FALSE) == IsAnisotropicFilter(m_Desc.MagFilter),
6866
"Min and mag filters must both be either anisotropic filters or non-anisotropic ones");
6967

0 commit comments

Comments
 (0)