From 39ed87570bdb2f86969d4be821c94b722dc71179 Mon Sep 17 00:00:00 2001 From: Joe Ludwig Date: Wed, 26 Jun 2013 15:22:04 -0700 Subject: First version of the SOurce SDK 2013 --- mp/src/mathlib/simdvectormatrix.cpp | 112 ++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 mp/src/mathlib/simdvectormatrix.cpp (limited to 'mp/src/mathlib/simdvectormatrix.cpp') diff --git a/mp/src/mathlib/simdvectormatrix.cpp b/mp/src/mathlib/simdvectormatrix.cpp new file mode 100644 index 00000000..7b200c2e --- /dev/null +++ b/mp/src/mathlib/simdvectormatrix.cpp @@ -0,0 +1,112 @@ +//========= Copyright Valve Corporation, All rights reserved. ============// +// +// Purpose: Provide a class (SSE/SIMD only) holding a 2d matrix of class FourVectors, +// for high speed processing in tools. +// +// $NoKeywords: $ +// +//=============================================================================// + + + +#include "basetypes.h" +#include "mathlib/mathlib.h" +#include "mathlib/simdvectormatrix.h" +#include "mathlib/ssemath.h" +#include "tier0/dbg.h" + +void CSIMDVectorMatrix::CreateFromRGBA_FloatImageData(int srcwidth, int srcheight, + float const *srcdata ) +{ + Assert( srcwidth && srcheight && srcdata ); + SetSize( srcwidth, srcheight ); + + FourVectors *p_write_ptr=m_pData; + int n_vectors_per_source_line=(srcwidth >> 2); + int ntrailing_pixels_per_source_line=(srcwidth & 3); + for(int y=0;y( p_write_ptr ); + // copy full input blocks + for(int x=0;xx=Pow_FixedPoint_Exponent_SIMD( src->x, fixed_point_exp ); + src->y=Pow_FixedPoint_Exponent_SIMD( src->y, fixed_point_exp ); + src->z=Pow_FixedPoint_Exponent_SIMD( src->z, fixed_point_exp ); + src++; + } while (--nv); + } +} + +CSIMDVectorMatrix & CSIMDVectorMatrix::operator+=( CSIMDVectorMatrix const &src ) +{ + Assert( m_nWidth == src.m_nWidth ); + Assert( m_nHeight == src.m_nHeight ); + int nv=NVectors(); + if ( nv ) + { + FourVectors *srcv=src.m_pData; + FourVectors *destv=m_pData; + do // !! speed !! inline more iters + { + *( destv++ ) += *( srcv++ ); + } while ( --nv ); + } + return *this; +} + +CSIMDVectorMatrix & CSIMDVectorMatrix::operator*=( Vector const &src ) +{ + int nv=NVectors(); + if ( nv ) + { + FourVectors scalevalue; + scalevalue.DuplicateVector( src ); + FourVectors *destv=m_pData; + do // !! speed !! inline more iters + { + destv->VProduct( scalevalue ); + destv++; + } while ( --nv ); + } + return *this; +} + -- cgit v1.2.3