Skip to content

Commit

Permalink
Print warning instead of failing out if the max sampler anisotropy ex…
Browse files Browse the repository at this point in the history
…ceeds the device limit
  • Loading branch information
TheMostDiligent committed Jan 12, 2024
1 parent e94b369 commit b75adfc
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
9 changes: 6 additions & 3 deletions Graphics/GraphicsEngine/src/SamplerBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,12 @@ void ValidateSamplerDesc(const SamplerDesc& Desc, const IRenderDevice* pDevice)
}
if (IsAnisotropicFilter(Desc.MinFilter))
{
VERIFY_SAMPLER(AdapterInfo.Sampler.MaxAnisotropy >= Desc.MaxAnisotropy,
"MaxAnisotropy (", Uint32{Desc.MaxAnisotropy}, ") exceeds the maximum supported anisotropy (", Uint32{AdapterInfo.Sampler.MaxAnisotropy},
"). Check the value of AdapterInfo.Sampler.MaxAnisotropy to make sure it is correct.");
if (Desc.MaxAnisotropy > AdapterInfo.Sampler.MaxAnisotropy)
{
LOG_WARNING_MESSAGE("MaxAnisotropy (", Uint32{Desc.MaxAnisotropy}, ") requested for sampler '", Desc.Name,
"' exceeds the maximum supported anisotropy (", Uint32{AdapterInfo.Sampler.MaxAnisotropy},
"). Check the value of AdapterInfo.Sampler.MaxAnisotropy.");
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions Graphics/GraphicsEngineD3D11/src/SamplerD3D11Impl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Diligent Graphics LLC
* Copyright 2019-2024 Diligent Graphics LLC
* Copyright 2015-2019 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -52,7 +52,7 @@ SamplerD3D11Impl::SamplerD3D11Impl(IReferenceCounters* pRefCounters,
TexAddressModeToD3D11AddressMode(SamplerDesc.AddressV),
TexAddressModeToD3D11AddressMode(SamplerDesc.AddressW),
SamplerDesc.MipLODBias,
SamplerDesc.MaxAnisotropy,
std::min<UINT>(SamplerDesc.MaxAnisotropy, D3D11_DEFAULT_MAX_ANISOTROPY),
ComparisonFuncToD3D11ComparisonFunc(SamplerDesc.ComparisonFunc),
{SamplerDesc.BorderColor[0], SamplerDesc.BorderColor[1], SamplerDesc.BorderColor[2], SamplerDesc.BorderColor[3]},
SamplerDesc.MinLOD,
Expand Down
4 changes: 2 additions & 2 deletions Graphics/GraphicsEngineD3D12/src/SamplerD3D12Impl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Diligent Graphics LLC
* Copyright 2019-2024 Diligent Graphics LLC
* Copyright 2015-2019 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -48,7 +48,7 @@ SamplerD3D12Impl::SamplerD3D12Impl(IReferenceCounters* pRefCounters,
TexAddressModeToD3D12AddressMode(SamplerDesc.AddressV),
TexAddressModeToD3D12AddressMode(SamplerDesc.AddressW),
SamplerDesc.MipLODBias,
SamplerDesc.MaxAnisotropy,
std::min<UINT>(SamplerDesc.MaxAnisotropy, D3D12_DEFAULT_MAX_ANISOTROPY),
ComparisonFuncToD3D12ComparisonFunc(SamplerDesc.ComparisonFunc),
{SamplerDesc.BorderColor[0], SamplerDesc.BorderColor[1], SamplerDesc.BorderColor[2], SamplerDesc.BorderColor[3]},
SamplerDesc.MinLOD,
Expand Down
6 changes: 2 additions & 4 deletions Graphics/GraphicsEngineVulkan/src/SamplerVkImpl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Diligent Graphics LLC
* Copyright 2019-2024 Diligent Graphics LLC
* Copyright 2015-2019 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -61,9 +61,7 @@ SamplerVkImpl::SamplerVkImpl(IReferenceCounters* pRefCounters, RenderDeviceVkImp
SamplerCI.mipLodBias = m_Desc.MipLODBias;

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

Expand Down

0 comments on commit b75adfc

Please sign in to comment.