mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-12 23:24:41 +00:00
fix directx rendertarget crash
asset brower previews were asserting due to a cornercase rt assignment also ditch mipgen for rts targetting a texture profile that's marked as nomip, and adjust hdr uopsampling shader to compensate for overdarks
This commit is contained in:
parent
0404b743f6
commit
00ee42e2a8
4 changed files with 18 additions and 17 deletions
|
|
@ -106,9 +106,9 @@ void GFXD3D11TextureTarget::attachTexture( RenderSlot slot, GFXTextureObject *te
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Cast the texture object to D3D...
|
// Cast the texture object to D3D...
|
||||||
AssertFatal(static_cast<GFXD3D11TextureObject*>(tex), "GFXD3D11TextureTarget::attachTexture - invalid texture object.");
|
AssertFatal(dynamic_cast<GFXD3D11TextureObject*>(tex), "GFXD3D11TextureTarget::attachTexture - invalid texture object.");
|
||||||
|
|
||||||
GFXD3D11TextureObject *d3dto = static_cast<GFXD3D11TextureObject*>(tex);
|
GFXD3D11TextureObject *d3dto = dynamic_cast<GFXD3D11TextureObject*>(tex);
|
||||||
|
|
||||||
// Grab the surface level.
|
// Grab the surface level.
|
||||||
if( slot == DepthStencil )
|
if( slot == DepthStencil )
|
||||||
|
|
@ -134,7 +134,6 @@ void GFXD3D11TextureTarget::attachTexture( RenderSlot slot, GFXTextureObject *te
|
||||||
mTargets[slot]->AddRef();
|
mTargets[slot]->AddRef();
|
||||||
mTargetViews[slot] = d3dto->getRTView();
|
mTargetViews[slot] = d3dto->getRTView();
|
||||||
mTargetViews[slot]->AddRef();
|
mTargetViews[slot]->AddRef();
|
||||||
mResolveTargets[slot] = d3dto;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -271,17 +270,21 @@ void GFXD3D11TextureTarget::deactivate()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//re-gen mip maps
|
//re-gen mip maps
|
||||||
for (U32 i = 0; i < 6; i++)
|
for (U32 i = GFXTextureTarget::Color0; i < GFXTextureTarget::MaxRenderSlotId; i++)
|
||||||
{
|
{
|
||||||
D3D11_TEXTURE2D_DESC desc;
|
GFXD3D11TextureObject* targ = mResolveTargets[i];
|
||||||
if (mResolveTargets[GFXTextureTarget::Color0 + i])
|
ID3D11ShaderResourceView* pSRView = mTargetSRViews[i];
|
||||||
|
if (targ && targ->getSurface() && pSRView)
|
||||||
{
|
{
|
||||||
mResolveTargets[GFXTextureTarget::Color0 + i]->get2DTex()->GetDesc(&desc);
|
ID3D11Texture2D* tex = dynamic_cast<ID3D11Texture2D*>(targ->getResource());
|
||||||
if (desc.MiscFlags & D3D11_RESOURCE_MISC_GENERATE_MIPS)
|
if (tex)
|
||||||
{
|
{
|
||||||
ID3D11ShaderResourceView* pSRView = mTargetSRViews[GFXTextureTarget::Color0 + i];
|
D3D11_TEXTURE2D_DESC desc;
|
||||||
if (pSRView)
|
tex->GetDesc(&desc);
|
||||||
|
if (desc.MiscFlags & D3D11_RESOURCE_MISC_GENERATE_MIPS)
|
||||||
|
{
|
||||||
D3D11DEVICECONTEXT->GenerateMips(pSRView);
|
D3D11DEVICECONTEXT->GenerateMips(pSRView);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -341,8 +344,8 @@ GFXD3D11WindowTarget::GFXD3D11WindowTarget()
|
||||||
|
|
||||||
GFXD3D11WindowTarget::~GFXD3D11WindowTarget()
|
GFXD3D11WindowTarget::~GFXD3D11WindowTarget()
|
||||||
{
|
{
|
||||||
SAFE_RELEASE(mDepthStencilView)
|
SAFE_RELEASE(mDepthStencilView);
|
||||||
SAFE_RELEASE(mDepthStencil);
|
SAFE_RELEASE(mDepthStencil);
|
||||||
SAFE_RELEASE(mBackBufferView);
|
SAFE_RELEASE(mBackBufferView);
|
||||||
SAFE_RELEASE(mBackBuffer);
|
SAFE_RELEASE(mBackBuffer);
|
||||||
SAFE_RELEASE(mSwapChain);
|
SAFE_RELEASE(mSwapChain);
|
||||||
|
|
|
||||||
|
|
@ -1418,7 +1418,7 @@ void GFXTextureManager::_validateTexParams( const U32 width, const U32 height,
|
||||||
{
|
{
|
||||||
// If a texture is not power-of-2 in size for both dimensions, it must
|
// If a texture is not power-of-2 in size for both dimensions, it must
|
||||||
// have only 1 mip level.
|
// have only 1 mip level.
|
||||||
if (profile->isRenderTarget())
|
if (profile->isRenderTarget() && !profile->noMip())
|
||||||
{
|
{
|
||||||
if (inOutNumMips == 0) //auto
|
if (inOutNumMips == 0) //auto
|
||||||
inOutNumMips = mFloor(mLog2(mMax(width, height))) + 1;
|
inOutNumMips = mFloor(mLog2(mMax(width, height))) + 1;
|
||||||
|
|
|
||||||
|
|
@ -55,11 +55,10 @@ void main()
|
||||||
|
|
||||||
upSample.rgb = e*4.0;
|
upSample.rgb = e*4.0;
|
||||||
upSample.rgb += (b+d+f+h)*2.0;
|
upSample.rgb += (b+d+f+h)*2.0;
|
||||||
upSample.rgb += (a+c+g+i);
|
upSample.rgb += (a+c+g+i);
|
||||||
upSample.rgb *= 1.0 / 16.0;
|
|
||||||
finalOut += upSample;
|
finalOut += upSample;
|
||||||
}
|
}
|
||||||
finalOut /= mipCount0;
|
finalOut /= pow(mipCount0,3);
|
||||||
finalOut.a = 1.0;
|
finalOut.a = 1.0;
|
||||||
|
|
||||||
OUT_col = finalOut;
|
OUT_col = finalOut;
|
||||||
|
|
|
||||||
|
|
@ -51,7 +51,6 @@ float4 main(PFXVertToPix IN) : TORQUE_TARGET0
|
||||||
upSample.rgb = e*4.0;
|
upSample.rgb = e*4.0;
|
||||||
upSample.rgb += (b+d+f+h)*2.0;
|
upSample.rgb += (b+d+f+h)*2.0;
|
||||||
upSample.rgb += (a+c+g+i);
|
upSample.rgb += (a+c+g+i);
|
||||||
upSample.rgb *= 1.0 / 16.0;
|
|
||||||
finalOut += upSample;
|
finalOut += upSample;
|
||||||
}
|
}
|
||||||
finalOut /= mipCount0;
|
finalOut /= mipCount0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue