From c22dcdbaa3de0e2da250c800eb48e8c31bfa44b1 Mon Sep 17 00:00:00 2001 From: Joshua Ashton Date: Thu, 11 Nov 2021 23:52:35 +0000 Subject: [PATCH] [d3d9] Clamp LOD in calls to SetLOD MSDN says this is clamped and returns the clamped value. Closes: #1869 --- src/d3d9/d3d9_texture.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/d3d9/d3d9_texture.h b/src/d3d9/d3d9_texture.h index cfe6ecc2..c484c015 100644 --- a/src/d3d9/d3d9_texture.h +++ b/src/d3d9/d3d9_texture.h @@ -56,11 +56,13 @@ namespace dxvk { DWORD STDMETHODCALLTYPE SetLOD(DWORD LODNew) final { DWORD oldLod = m_lod; - m_lod = LODNew; + m_lod = std::min(LODNew, m_texture.Desc()->MipLevels - 1); - m_texture.CreateSampleView(LODNew); - if (this->GetPrivateRefCount() > 0) - this->m_parent->MarkTextureBindingDirty(this); + if (m_lod != oldLod) { + m_texture.CreateSampleView(LODNew); + if (this->GetPrivateRefCount() > 0) + this->m_parent->MarkTextureBindingDirty(this); + } return oldLod; }