Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

re-enabled cpu matrix caching in MOAIGfxDevice

  • Loading branch information...
commit 0a7c446f9f61c27d7029707d39d85c24416a79d8 1 parent b1b6e21
@patrickmeehan patrickmeehan authored
Showing with 25 additions and 38 deletions.
  1. +25 −38 src/moaicore/MOAIGfxDevice.cpp
View
63 src/moaicore/MOAIGfxDevice.cpp
@@ -1579,49 +1579,36 @@ void MOAIGfxDevice::UpdateFinalColor () {
//----------------------------------------------------------------//
void MOAIGfxDevice::UpdateCpuVertexMtx () {
-
- u32 start = this->mVertexMtxInput;
- u32 finish = this->mVertexMtxOutput;
-
- this->mCpuVertexTransformMtx.Ident ();
- for ( u32 i = start; i < finish; ++i ) {
- this->mCpuVertexTransformMtx.Append ( this->mVertexTransforms [ i ]);
- }
- this->mCpuVertexTransform = !this->mCpuVertexTransformMtx.IsIdent ();
+ // Used signed, so we can roll "under" to -1 without an extra range check
+ int start = this->mVertexMtxInput;
+ int finish = this->mVertexMtxOutput;
- #ifdef USE_VTX_MTX_CACHE
-
- // Used signed, so we can roll "under" to -1 without an extra range check
- int start = this->mVertexMtxInput;
- int finish = this->mVertexMtxOutput;
+ // The matrices are being multiplied A*B*C, but the common case is that
+ // B and C are static throughout all/most of a frame. Thus, we can
+ // capitalize on the associativity of matrix multiplication by caching
+ // (B*C) and save a matrix mult in the common case (assuming they haven't
+ // changed since the last update request).
- // The matrices are being multiplied A*B*C, but the common case is that
- // B and C are static throughout all/most of a frame. Thus, we can
- // capitalize on the associativity of matrix multiplication by caching
- // (B*C) and save a matrix mult in the common case (assuming they haven't
- // changed since the last update request).
-
- int i = finish - 1;
-
- if ( this->mCpuVertexTransformCache [ i ]) {
- while ( i >= start && this->mCpuVertexTransformCache [ i ]) {
- --i;
- }
- this->mCpuVertexTransformMtx = this->mCpuVertexTransformCacheMtx [ i + 1 ];
- }
- else {
- this->mCpuVertexTransformMtx.Ident();
- }
-
- for ( ; i >= start; --i ) {
- this->mCpuVertexTransformMtx.Prepend ( this->mVertexTransforms [ i ]);
- this->mCpuVertexTransformCacheMtx [ i ] = this->mCpuVertexTransformMtx;
- this->mCpuVertexTransformCache [ i ] = true;
+ int i = finish - 1;
+
+ if ( this->mCpuVertexTransformCache [ i ]) {
+ while ( i >= start && this->mCpuVertexTransformCache [ i ]) {
+ --i;
}
+ this->mCpuVertexTransformMtx = this->mCpuVertexTransformCacheMtx [ i + 1 ];
+ }
+ else {
+ this->mCpuVertexTransformMtx.Ident();
+ }
+
+ for ( ; i >= start; --i ) {
+ this->mCpuVertexTransformMtx.Prepend ( this->mVertexTransforms [ i ]);
+ this->mCpuVertexTransformCacheMtx [ i ] = this->mCpuVertexTransformMtx;
+ this->mCpuVertexTransformCache [ i ] = true;
+ }
- this->mCpuVertexTransform = !this->mCpuVertexTransformMtx.IsIdent ();
- #endif
+ this->mCpuVertexTransform = !this->mCpuVertexTransformMtx.IsIdent ();
}
//----------------------------------------------------------------//
Please sign in to comment.
Something went wrong with that request. Please try again.