mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-11 22:54:34 +00:00
Added immutable vertex and index buffers.
This commit is contained in:
parent
d08c0df85d
commit
28d303c5ea
13 changed files with 98 additions and 32 deletions
|
|
@ -731,7 +731,8 @@ void GFXD3D9Device::setShader( GFXShader *shader, bool force )
|
|||
//-----------------------------------------------------------------------------
|
||||
GFXPrimitiveBuffer * GFXD3D9Device::allocPrimitiveBuffer( U32 numIndices,
|
||||
U32 numPrimitives,
|
||||
GFXBufferType bufferType )
|
||||
GFXBufferType bufferType,
|
||||
void* data )
|
||||
{
|
||||
// Allocate a buffer to return
|
||||
GFXD3D9PrimitiveBuffer * res = new GFXD3D9PrimitiveBuffer(this, numIndices, numPrimitives, bufferType);
|
||||
|
|
@ -741,12 +742,13 @@ GFXPrimitiveBuffer * GFXD3D9Device::allocPrimitiveBuffer( U32 numIndices,
|
|||
D3DPOOL pool = D3DPOOL_DEFAULT;
|
||||
|
||||
// Assumptions:
|
||||
// - static buffers are write once, use many
|
||||
// - static buffers are write rarely, use many
|
||||
// - dynamic buffers are write many, use many
|
||||
// - volatile buffers are write once, use once
|
||||
// You may never read from a buffer.
|
||||
switch(bufferType)
|
||||
{
|
||||
case GFXBufferTypeImmutable:
|
||||
case GFXBufferTypeStatic:
|
||||
pool = isD3D9Ex() ? D3DPOOL_DEFAULT : D3DPOOL_MANAGED;
|
||||
break;
|
||||
|
|
@ -781,6 +783,14 @@ GFXPrimitiveBuffer * GFXD3D9Device::allocPrimitiveBuffer( U32 numIndices,
|
|||
D3D9Assert(mD3DDevice->CreateIndexBuffer( sizeof(U16) * numIndices , usage, GFXD3D9IndexFormat[GFXIndexFormat16], pool, &res->ib, 0),
|
||||
"Failed to allocate an index buffer.");
|
||||
}
|
||||
|
||||
if(data)
|
||||
{
|
||||
void* dest;
|
||||
res->lock(0, numIndices, &dest);
|
||||
dMemcpy(dest, data, sizeof(U16) * numIndices);
|
||||
res->unlock();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
@ -791,7 +801,8 @@ GFXPrimitiveBuffer * GFXD3D9Device::allocPrimitiveBuffer( U32 numIndices,
|
|||
GFXVertexBuffer * GFXD3D9Device::allocVertexBuffer( U32 numVerts,
|
||||
const GFXVertexFormat *vertexFormat,
|
||||
U32 vertSize,
|
||||
GFXBufferType bufferType )
|
||||
GFXBufferType bufferType,
|
||||
void* data)
|
||||
{
|
||||
PROFILE_SCOPE( GFXD3D9Device_allocVertexBuffer );
|
||||
|
||||
|
|
@ -808,7 +819,7 @@ GFXVertexBuffer * GFXD3D9Device::allocVertexBuffer( U32 numVerts,
|
|||
res->mNumVerts = 0;
|
||||
|
||||
// Assumptions:
|
||||
// - static buffers are write once, use many
|
||||
// - static buffers are write rarely, use many
|
||||
// - dynamic buffers are write many, use many
|
||||
// - volatile buffers are write once, use once
|
||||
// You may never read from a buffer.
|
||||
|
|
@ -850,6 +861,15 @@ GFXVertexBuffer * GFXD3D9Device::allocVertexBuffer( U32 numVerts,
|
|||
}
|
||||
|
||||
res->mNumVerts = numVerts;
|
||||
|
||||
if(data)
|
||||
{
|
||||
void* dest;
|
||||
res->lock(0, numVerts, &dest);
|
||||
dMemcpy(dest, data, vertSize * numVerts);
|
||||
res->unlock();
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue