An LRU cache for blocks of vertices in an IVertexBuffer.
sealed class
|
VertexBufferCache
|
extends
|
Disposable
|
||
implements
|
IBeginEnd
|
||||
ICapacity
|
|||||
IResource
|
|||||
IVertexElements
|
Returns the block count.
public
property
|
BlockCount
{
get
}
|
||
type
|
int32
|
||
value
|
|
The block count. |
Returns the block size.
public
property
|
BlockSize
{
get
}
|
||
type
|
int32
|
||
value
|
|
The block size, in vertices. |
Returns the capacity of this object.
public
property
|
Capacity
{
get
}
|
||
type
|
int32
|
||
value
|
|
The capacity, in elements. | |
implements
|
ICapacity.Capacity
|
Returns the lifecycle state of this object.
public
virtual
property
|
LifecycleState
{
get
}
|
||
type
|
LifecycleState
|
||
value
|
The lifecycle state. | ||
inherited
|
Disposable.LifecycleState
|
Returns the estimated memory consumption of this object.
public
property
|
MemoryConsumption
{
get
}
|
||
type
|
int64
|
||
value
|
|
The estimated memory consumption, in bytes. | |
implements
|
IMemoryConsumption.MemoryConsumption
|
public
property
|
VertexBuffer
{
get
}
|
||
type
|
IVertexBuffer
|
||
value
|
Returns the vertex declaration elements.
public
property
|
VertexElements
{
get
}
|
||
type
|
VertexElements
|
||
value
|
|
The vertex declaration elements. | |
implements
|
IVertexElements.VertexElements
|
Creates a new instance of VertexBufferCache.
public
constructor
|
VertexBufferCache
([Owner]
IVertexBuffer buffer,
int32 blockSize = 1024)
|
||
params
|
buffer
|
[not-null]
|
The vertex buffer to use for caching data. |
blockSize
|
[>0]
|
The
block
size,
in
vertices.
Defaults
to
1024 . |
Acquires a strong reference to this disposable object.
[OwnerReturn, ThreadSafe]
|
||||
public
method
|
AcquireTry
()
|
|||
type
|
IDisposable
|
|||
returns
|
this
if
a
new
strong
reference
has
been
acquired,
null
if
this
object
is
already
being
disposed.
|
|||
inherited
|
Disposable.AcquireTry
|
Remarks:
The object will not be actually disposed by calls to Dispose when there is at least one strong reference left. Code that calls the AcquireTry method is responsible for calling the Dispose method accordingly.
This method is not intended to be used in performance-critical code. It should only be used to high-level resource management.
Begins an access to this object.
public
method
|
Begin
()
|
||
implements
|
IBeginEnd.Begin
|
Remarks:
See the documentation of the class which implements this interface for details on the operations that must be wrapped in Begin and End calls.
See also:
BeginEnd
public
method
|
BlockId
(int32 blockIndex)
|
||
type
|
int64
|
||
params
|
blockIndex
|
Fetches a block from the cache.
public
method
|
BlockIndex
(int64 blockId,
bool loadIfNecessary)
|
||
type
|
int32
|
||
params
|
blockId
|
The user-defined block ID. | |
loadIfNecessary
|
Load the block into the cache, if necessary? | ||
returns
|
The
return
value
R
can
be
interpreted
as
follows:
>=
0 :
The
block
is
present
in
the
cache,
R
is
the
block
index.
=
-1 :
The
block
is
not
present
in
the
cache
and
loadIfNecessary
is
false .
<=-2 :
The
block
is
not
present
in
the
cache
and
-2-R
is
the
block
index
to
use
for
loading
its
data.
|
Returns the write buffer for loading a block.
public
method
|
Buffer
(int32 index,
int32 count = 0)
|
||
type
|
ByteBuffer
|
||
params
|
index
|
The block index, see return value of BlockIndex. | |
count
|
[0..BlockSize]
|
Optional
buffer
limit,
in
vertices.
If
0 ,
the
block
size
will
be
used.
Defaults
to
0 .
|
|
returns
|
|
The write buffer. |
Clears all blocks from the cache.
public
method
|
Clear
()
|
Clears the given block from the cache.
public
method
|
Clear
(int64 blockId)
|
||
params
|
blockId
|
The user-defined block ID. |
Releases all resources held by this object if there are no more strong references to it, decrements the reference counter by one otherwise.
[Dispose, OwnerThis, ThreadSafe]
|
||||
public
method
|
Dispose
()
|
|||
inherited
|
Disposable.Dispose
|
Remarks:
The Dispose method silently returns if the object has already been disposed.
Ends the current access to this object.
public
method
|
End
()
|
||
implements
|
IBeginEnd.End
|
Remarks:
See the documentation of the class which implements this interface for details on the operations that must be wrapped in Begin and End calls.
See also:
BeginEnd