mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-01-19 20:24:49 +00:00
added checks for valid pointers after locking
This commit is contained in:
parent
95ef5ec226
commit
53abbe066d
|
|
@ -190,7 +190,8 @@ void CameraSpline::renderTimeMap()
|
|||
// Build vertex buffer
|
||||
GFXVertexBufferHandle<GFXVertexPC> vb;
|
||||
vb.set(GFX, mTimeMap.size(), GFXBufferTypeVolatile);
|
||||
vb.lock();
|
||||
void *ptr = vb.lock();
|
||||
if(!ptr) return;
|
||||
|
||||
MRandomLCG random(1376312589 * (U32)this);
|
||||
int index = 0;
|
||||
|
|
|
|||
|
|
@ -1727,6 +1727,7 @@ void Precipitation::renderObject(ObjectRenderInst *ri, SceneRenderState *state,
|
|||
// Do we need to relock the buffer?
|
||||
if ( !vertPtr )
|
||||
vertPtr = mRainVB.lock();
|
||||
if(!vertPtr) return;
|
||||
|
||||
// Set the proper texture coords... (it's fun!)
|
||||
tc = &mTexCoords[4*curr->texCoordIndex];
|
||||
|
|
@ -1817,6 +1818,7 @@ void Precipitation::renderObject(ObjectRenderInst *ri, SceneRenderState *state,
|
|||
// Do we need to relock the buffer?
|
||||
if ( !vertPtr )
|
||||
vertPtr = mRainVB.lock();
|
||||
if(!vertPtr) return;
|
||||
|
||||
vertPtr->point = pos + leftUp;
|
||||
vertPtr->texCoord = *tc;
|
||||
|
|
|
|||
|
|
@ -400,6 +400,7 @@ void CloudLayer::_initBuffers()
|
|||
|
||||
mVB.set( GFX, smVertCount, GFXBufferTypeStatic );
|
||||
GFXCloudVertex *pVert = mVB.lock();
|
||||
if(!pVert) return;
|
||||
|
||||
for ( U32 y = 0; y < smVertStride; y++ )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1452,7 +1452,8 @@ void DecalRoad::_captureVerts()
|
|||
mPB.set( GFX, mTriangleCount * 3, 0, GFXBufferTypeStatic );
|
||||
|
||||
// Lock the VertexBuffer
|
||||
GFXVertexPNTBT *vertPtr = mVB.lock();
|
||||
GFXVertexPNTBT *vertPtr = mVB.lock();
|
||||
if(!vertPtr) return;
|
||||
U32 vertIdx = 0;
|
||||
|
||||
//
|
||||
|
|
|
|||
|
|
@ -748,6 +748,7 @@ void ScatterSky::_initVBIB()
|
|||
|
||||
mVB.set( GFX, mVertCount, GFXBufferTypeStatic );
|
||||
ScatterSkyVertex *pVert = mVB.lock();
|
||||
if(!pVert) return;
|
||||
|
||||
for ( U32 y = 0; y < vertStride; y++ )
|
||||
{
|
||||
|
|
@ -1072,6 +1073,7 @@ void ScatterSky::_renderMoon( ObjectRenderInst *ri, SceneRenderState *state, Bas
|
|||
GFXVertexBufferHandle< GFXVertexPCT > vb;
|
||||
vb.set( GFX, 4, GFXBufferTypeVolatile );
|
||||
GFXVertexPCT *pVert = vb.lock();
|
||||
if(!pVert) return;
|
||||
|
||||
for ( S32 i = 0; i < 4; i++ )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -400,6 +400,7 @@ void SkyBox::_initRender()
|
|||
}
|
||||
|
||||
GFXVertexPNTT *vertPtr = mVB.lock();
|
||||
if(!vertPtr) return;
|
||||
|
||||
dMemcpy( vertPtr, tmpVerts, sizeof ( GFXVertexPNTT ) * vertCount );
|
||||
|
||||
|
|
@ -412,6 +413,7 @@ void SkyBox::_initRender()
|
|||
mFogBandVB.set( GFX, 48, GFXBufferTypeStatic );
|
||||
|
||||
GFXVertexPC *bandVertPtr = mFogBandVB.lock();
|
||||
if(!bandVertPtr) return;
|
||||
|
||||
// Grab the fog color.
|
||||
ColorI fogColor( mLastFogColor.red * 255, mLastFogColor.green * 255, mLastFogColor.blue * 255 );
|
||||
|
|
|
|||
|
|
@ -487,6 +487,7 @@ void Sun::_renderCorona( ObjectRenderInst *ri, SceneRenderState *state, BaseMatI
|
|||
GFXVertexBufferHandle< GFXVertexPCT > vb;
|
||||
vb.set( GFX, 4, GFXBufferTypeVolatile );
|
||||
GFXVertexPCT *pVert = vb.lock();
|
||||
if(!pVert) return;
|
||||
|
||||
for ( S32 i = 0; i < 4; i++ )
|
||||
{
|
||||
|
|
|
|||
|
|
@ -76,6 +76,8 @@ void TSForestCellBatch::_rebuildBatch()
|
|||
|
||||
// Fill this puppy!
|
||||
ImposterState *vertPtr = mVB.lock();
|
||||
if(!vertPtr) return;
|
||||
|
||||
Vector<ForestItem>::const_iterator item = mItems.begin();
|
||||
|
||||
const F32 radius = mDetail->getRadius();
|
||||
|
|
|
|||
|
|
@ -1505,7 +1505,8 @@ void WorldEditor::renderSplinePath(SimPath::Path *path)
|
|||
|
||||
GFXVertexBufferHandle<GFXVertexPC> vb;
|
||||
vb.set(GFX, 3*batchSize, GFXBufferTypeVolatile);
|
||||
vb.lock();
|
||||
void *lockPtr = vb.lock();
|
||||
if(!lockPtr) return;
|
||||
|
||||
U32 vIdx=0;
|
||||
|
||||
|
|
@ -1542,7 +1543,8 @@ void WorldEditor::renderSplinePath(SimPath::Path *path)
|
|||
|
||||
// Reset for next pass...
|
||||
vIdx = 0;
|
||||
vb.lock();
|
||||
void *lockPtr = vb.lock();
|
||||
if(!lockPtr) return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1198,6 +1198,7 @@ void ProcessedShaderMaterial::setBuffers( GFXVertexBufferHandleBase *vertBuffer,
|
|||
GFXVertexBufferDataHandle instVB;
|
||||
instVB.set( GFX, instFormat->getSizeInBytes(), instFormat, instCount, GFXBufferTypeVolatile );
|
||||
U8 *dest = instVB.lock();
|
||||
if(!dest) return;
|
||||
dMemcpy( dest, mInstancingState->getBuffer(), instFormat->getSizeInBytes() * instCount );
|
||||
instVB.unlock();
|
||||
|
||||
|
|
|
|||
|
|
@ -288,8 +288,12 @@ void RenderImposterMgr::_innerRender( const SceneRenderState *state, RenderPrePa
|
|||
smBatches++;
|
||||
|
||||
vb.set( GFX, stateCount*4, GFXBufferTypeVolatile );
|
||||
dMemcpy( vb.lock(), mBuffer, stateCount * 4 * sizeof( ImposterState ) );
|
||||
vb.unlock();
|
||||
ImposterState *buf = vb.lock();
|
||||
if(buf)
|
||||
{
|
||||
dMemcpy( buf, mBuffer, stateCount * 4 * sizeof( ImposterState ) );
|
||||
vb.unlock();
|
||||
}
|
||||
|
||||
//GFX->setVertexBuffer( mCornerVB, 0, stateCount * 4 );
|
||||
GFX->setVertexBuffer( vb );
|
||||
|
|
@ -327,8 +331,12 @@ void RenderImposterMgr::_innerRender( const SceneRenderState *state, RenderPrePa
|
|||
smBatches++;
|
||||
|
||||
vb.set( GFX, stateCount*4, GFXBufferTypeVolatile );
|
||||
dMemcpy( vb.lock(), mBuffer, stateCount * 4 * sizeof( ImposterState ) );
|
||||
vb.unlock();
|
||||
ImposterState *buf = vb.lock();
|
||||
if(buf)
|
||||
{
|
||||
dMemcpy( buf, mBuffer, stateCount * 4 * sizeof( ImposterState ) );
|
||||
vb.unlock();
|
||||
}
|
||||
|
||||
//GFX->setVertexBuffer( mCornerVB, 0, stateCount * 4 );
|
||||
GFX->setVertexBuffer( vb );
|
||||
|
|
|
|||
|
|
@ -219,8 +219,12 @@ void TerrainBlock::_updateBaseTexture( bool writeToCache )
|
|||
points[3].texCoord = Point2F( 1.0, needsYFlip ? 0.0f : 1.0f );
|
||||
|
||||
vb.set( GFX, 4, GFXBufferTypeVolatile );
|
||||
dMemcpy( vb.lock(), points, sizeof(GFXVertexPT) * 4 );
|
||||
vb.unlock();
|
||||
GFXVertexPT *ptr = vb.lock();
|
||||
if(ptr)
|
||||
{
|
||||
dMemcpy( ptr, points, sizeof(GFXVertexPT) * 4 );
|
||||
vb.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
GFXTexHandle blendTex;
|
||||
|
|
|
|||
|
|
@ -1254,6 +1254,7 @@ void TSSkinMesh::updateSkin( const Vector<MatrixF> &transforms, TSVertexBufferHa
|
|||
|
||||
// Lock, and skin directly into the final memory destination
|
||||
outPtr = (U8 *)instanceVB.lock();
|
||||
if(!outPtr) return;
|
||||
#endif
|
||||
// Set position/normal to zero so we can accumulate
|
||||
zero_vert_normal_bulk(mNumVerts, outPtr, outStride);
|
||||
|
|
@ -2379,6 +2380,7 @@ void TSMesh::_createVBIB( TSVertexBufferHandle &vb, GFXPrimitiveBufferHandle &pb
|
|||
|
||||
// Copy from aligned memory right into GPU memory
|
||||
U8 *vertData = (U8*)vb.lock();
|
||||
if(!vertData) return;
|
||||
#if defined(TORQUE_OS_XENON)
|
||||
XMemCpyStreaming_WriteCombined( vertData, mVertexData.address(), mVertexData.mem_size() );
|
||||
#else
|
||||
|
|
|
|||
Loading…
Reference in a new issue