Skip to content

Commit

Permalink
[D3D11] Fix crash on FL11 cards
Browse files Browse the repository at this point in the history
mReadOnlyIsTexBuffer does not imply FL 11.1
FL 11.0 supports structured buffers, but it does not support
NO_OVERWRITE on SRVs.

This was causing crashes on Win7, NVidia GTX 750Ti, feature level 11.0
See https://forums.ogre3d.org/viewtopic.php?f=25&t=96206
  • Loading branch information
darksylinc committed Feb 19, 2021
1 parent b0ed722 commit be01ddf
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions RenderSystems/Direct3D11/src/Vao/OgreD3D11VaoManager.cpp
Expand Up @@ -1321,11 +1321,20 @@ namespace Ogre
"D3D11VaoManager::createShaderBufferInterface" );
}

D3D11DynamicBuffer *dynamicBuffer = 0;
if( bufferType >= BT_DYNAMIC_DEFAULT )
dynamicBuffer = new D3D11DynamicBuffer( vboName.Get(), internalSizeBytes, mDevice );
if( mD3D11RenderSystem->_getFeatureLevel() > D3D_FEATURE_LEVEL_11_0 )
{
D3D11DynamicBuffer *dynamicBuffer = 0;
if( bufferType >= BT_DYNAMIC_DEFAULT )
dynamicBuffer = new D3D11DynamicBuffer( vboName.Get(), internalSizeBytes, mDevice );

bufferInterface = new D3D11BufferInterface( 0, vboName.Get(), dynamicBuffer );
bufferInterface = new D3D11BufferInterface( 0, vboName.Get(), dynamicBuffer );
}
else
{
// D3D11.0 doesn't support NO_OVERWRITE on shader buffers.
// Use the basic interface. But it does support structured buffers
bufferInterface = new D3D11CompatBufferInterface( 0, vboName.Get(), mDevice );
}
}
else
{
Expand All @@ -1343,8 +1352,10 @@ namespace Ogre
//-----------------------------------------------------------------------------------
void D3D11VaoManager::destroyReadOnlyBufferImpl( ReadOnlyBufferPacked *readOnlyBuffer )
{
if( !mReadOnlyIsTexBuffer )
if( !mReadOnlyIsTexBuffer && mD3D11RenderSystem->_getFeatureLevel() > D3D_FEATURE_LEVEL_11_0 )
{
OGRE_ASSERT_HIGH(
dynamic_cast<D3D11BufferInterface *>( readOnlyBuffer->getBufferInterface() ) );
D3D11BufferInterface *bufferInterface =
static_cast<D3D11BufferInterface *>( readOnlyBuffer->getBufferInterface() );

Expand All @@ -1360,6 +1371,7 @@ namespace Ogre

readOnlyBuffer->unmap( UO_UNMAP_ALL );
}

delete bufferInterface->getDynamicBuffer();
bufferInterface->_setNullDynamicBuffer();
}
Expand Down

0 comments on commit be01ddf

Please sign in to comment.