Graphics Reference
In-Depth Information
var viewProjection = Matrix.Multiply(viewMatrix,
projectionMatrix);
// Determine the meshes to render for this context
int batchSize = (int)Math.Floor((double)meshes.Count /
contextList.Length);
int startIndex = batchSize * contextIndex;
int endIndex = Math.Min(startIndex + batchSize,
meshes.Count - 1);
// If the last context include remaining meshes due to
// the rounding above.
if (contextIndex == contextList.Length - 1)
endIndex = meshes.Count - 1;
// Loop over the meshes for this context and render them
var perObject = new ConstantBuffers.PerObject();
for (var i = startIndex; i <= endIndex; i++)
{
// Simulate additional CPU load
for (var j = 0; j < additionalCPULoad; j++)
{
viewProjection = Matrix.Multiply(viewMatrix,
projectionMatrix);
}
var m = meshes[i];
// Update perObject constant buffer
perObject.World = m.World * worldMatrix;
perObject.WorldInverseTranspose = Matrix.Transpose(
Matrix.Invert(perObject.World));
perObject.WorldViewProjection = perObject.World *
viewProjection;
perObject.Transpose();
renderContext.UpdateSubresource(ref perObject,
perObjectBuffer);
// Provide the material and armature constant buffer
m.PerArmatureBuffer = perArmatureBuffer;
m.PerMaterialBuffer = perMaterialBuffer;
// Render the mesh using the provided DeviceContext
m.Render(renderContext);
}
 
Search WWH ::




Custom Search