In the original implementation, all Model vertex buffers and index buffers are allocated by GraphicsMemory. This means that they are in a upload heap which is accessible to both the CPU and GPU, equivalent to the Direct3D 11 version of USAGE_DYNAMIC. This is simple and easy to use, but has performance impacts--which on Xbox One can be quite noticeable due to the caching behavior.
This change adds an optional call to LoadStaticBuffers which uses a ResourceUploadBatch to create static VB/IBs for rendering copying the data from the loaded GraphicsMemory resources. This is equivalent to USAGE_DEFAULT in Direct3D 11.
The ModelMeshPart now contains four new members:
staticVertexBuffer: If set, then this vertex buffer is used for rendering as the VB in the view. Otherwise it uses vertexBuffer.
staticIndexBuffer: If set, then this index buffer is used for rendering as the IB in the view. Otherwise it uses indexBuffer.
vertexBufferSize: The size of the VB for rendering set in the view.
indexBufferSize: The size of the IB for rendering set in the view.
There is a small breaking change here in that all custom Model loaders must populate the new vertexBufferSize and indexBufferSize members of ModelMeshPart.
Custom Model renderers should be updated for all four new member variables.
To support this I added a new Upload method overload for ResourceUploadBatch. The existing Upload method copies the data into a staging upload heap resource for use in the copy to the GPU, but here the data is already in an upload heap managed by GraphicsMemory which we can use directly.
Also did a little SAL annotation cleanup in a few places, and added comparison operators for SharedGraphicsResource
In the original implementation, all Model vertex buffers and index buffers are allocated by
GraphicsMemory
. This means that they are in a upload heap which is accessible to both the CPU and GPU, equivalent to the Direct3D 11 version ofUSAGE_DYNAMIC
. This is simple and easy to use, but has performance impacts--which on Xbox One can be quite noticeable due to the caching behavior.This change adds an optional call to
LoadStaticBuffers
which uses aResourceUploadBatch
to create static VB/IBs for rendering copying the data from the loadedGraphicsMemory
resources. This is equivalent toUSAGE_DEFAULT
in Direct3D 11.The
ModelMeshPart
now contains four new members:staticVertexBuffer
: If set, then this vertex buffer is used for rendering as the VB in the view. Otherwise it usesvertexBuffer
.staticIndexBuffer
: If set, then this index buffer is used for rendering as the IB in the view. Otherwise it usesindexBuffer
.vertexBufferSize
: The size of the VB for rendering set in the view.indexBufferSize
: The size of the IB for rendering set in the view.There is a small breaking change here in that all custom Model loaders must populate the new
vertexBufferSize
andindexBufferSize
members ofModelMeshPart
.Custom Model renderers should be updated for all four new member variables.
To support this I added a new
Upload
method overload forResourceUploadBatch
. The existingUpload
method copies the data into a staging upload heap resource for use in the copy to the GPU, but here the data is already in an upload heap managed byGraphicsMemory
which we can use directly.