From 3cdbd4e87e2cf2177dd6ded35e705954dee29482 Mon Sep 17 00:00:00 2001 From: AzaezelX Date: Mon, 4 Aug 2025 14:11:00 -0500 Subject: [PATCH] don't let GFXD3D11TextureTarget::deactivate() try to generate mips if we haven't told that target to do so --- Engine/source/gfx/D3D11/gfxD3D11Target.cpp | 17 ++++++++++++----- .../source/gfx/D3D11/gfxD3D11TextureManager.cpp | 1 + Engine/source/postFx/postEffect.cpp | 4 +++- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Engine/source/gfx/D3D11/gfxD3D11Target.cpp b/Engine/source/gfx/D3D11/gfxD3D11Target.cpp index 63f910f05..989e086e2 100644 --- a/Engine/source/gfx/D3D11/gfxD3D11Target.cpp +++ b/Engine/source/gfx/D3D11/gfxD3D11Target.cpp @@ -276,11 +276,18 @@ void GFXD3D11TextureTarget::deactivate() //re-gen mip maps for (U32 i = 0; i < 6; i++) { - ID3D11ShaderResourceView* pSRView = mTargetSRViews[GFXTextureTarget::Color0 + i]; - if (pSRView) - D3D11DEVICECONTEXT->GenerateMips(pSRView); - } - + D3D11_TEXTURE2D_DESC desc; + if (mResolveTargets[GFXTextureTarget::Color0 + i]) + { + mResolveTargets[GFXTextureTarget::Color0 + i]->get2DTex()->GetDesc(&desc); + if (desc.MiscFlags & D3D11_RESOURCE_MISC_GENERATE_MIPS) + { + ID3D11ShaderResourceView* pSRView = mTargetSRViews[GFXTextureTarget::Color0 + i]; + if (pSRView) + D3D11DEVICECONTEXT->GenerateMips(pSRView); + } + } + } } void GFXD3D11TextureTarget::resolve() diff --git a/Engine/source/gfx/D3D11/gfxD3D11TextureManager.cpp b/Engine/source/gfx/D3D11/gfxD3D11TextureManager.cpp index e24a6f5dd..a8cf0a2fd 100644 --- a/Engine/source/gfx/D3D11/gfxD3D11TextureManager.cpp +++ b/Engine/source/gfx/D3D11/gfxD3D11TextureManager.cpp @@ -108,6 +108,7 @@ void GFXD3D11TextureManager::_innerCreateTexture( GFXD3D11TextureObject *retTex, (numMipLevels == 0 || numMipLevels > 1)&& !(depth > 0) ) { + if (numMipLevels == 5) Con::errorf("GFXD3D11TextureManager::_innerCreateTexture - numMipLevels == 5 found!"); miscFlags |= D3D11_RESOURCE_MISC_GENERATE_MIPS; bindFlags |= D3D11_BIND_RENDER_TARGET; // in order to automatically generate mips. Resource needs to be a rendertarget and shader resource } diff --git a/Engine/source/postFx/postEffect.cpp b/Engine/source/postFx/postEffect.cpp index fa5f1fa39..4e2fb1990 100644 --- a/Engine/source/postFx/postEffect.cpp +++ b/Engine/source/postFx/postEffect.cpp @@ -849,7 +849,9 @@ void PostEffect::_setupConstants( const SceneRenderState *state ) if (mMipCountSC[i]->isValid()) { - mShaderConsts->set(mMipCountSC[i], (S32)mActiveTextures[i]->getMipLevels()); + S32 mipLevels = (S32)mActiveTextures[i]->getMipLevels(); + mShaderConsts->set(mMipCountSC[i], mipLevels); + if (mipLevels == 5) Con::errorf("PostEffect::_setupConstants - mipLevels == 5 found!"); } }