tsMeshIntrinsics.cpp
Engine/source/ts/tsMeshIntrinsics.cpp
Public Variables
void(*
zero_vert_normal_bulk )(const dsize_t count, U8 *__restrict const outPtr, const dsize_t outStride)
Set the vertex position and normal to (0, 0, 0)
Public Functions
Detailed Description
Public Variables
MODULE_END
MODULE_INIT
void(* zero_vert_normal_bulk )(const dsize_t count, U8 *__restrict const outPtr, const dsize_t outStride)
Set the vertex position and normal to (0, 0, 0)
Parameters:
count | Number of elements |
outPtr | Pointer to a TSMesh aligned vertex buffer |
outStride | Size, in bytes, of one entry in the vertex buffer |
Public Functions
if(Platform::SystemInfo.processor.properties & CPU_PROP_SSE)
zero_vert_normal_bulk_C(const dsize_t count, U8 *__restrict const outPtr, const dsize_t outStride)
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23#include "ts/tsMesh.h" 24#include "ts/tsMeshIntrinsics.h" 25#include "ts/arch/tsMeshIntrinsics.arch.h" 26#include "core/module.h" 27 28 29void (*zero_vert_normal_bulk)(const dsize_t count, U8 * __restrict const outPtr, const dsize_t outStride) = NULL; 30 31//------------------------------------------------------------------------------ 32// Default C++ Implementations (pretty slow) 33//------------------------------------------------------------------------------ 34 35void zero_vert_normal_bulk_C(const dsize_t count, U8 * __restrict const outPtr, const dsize_t outStride) 36{ 37 char *outData = reinterpret_cast<char *>(outPtr); 38 39 // TODO: Try prefetch w/ ptr de-reference 40 41 for(S32 i = 0; i < count; i++) 42 { 43 TSMesh::__TSMeshVertexBase *outElem = reinterpret_cast<TSMesh::__TSMeshVertexBase *>(outData); 44 outElem->_vert.zero(); 45 outElem->_normal.zero(); 46 outData += outStride; 47 } 48} 49 50//------------------------------------------------------------------------------ 51// Initializer. 52//------------------------------------------------------------------------------ 53 54MODULE_BEGIN( TSMeshIntrinsics ) 55 56 MODULE_INIT_AFTER( 3D ) 57 58 MODULE_INIT 59 { 60 // Assign defaults (C++ versions) 61 zero_vert_normal_bulk = zero_vert_normal_bulk_C; 62 63 // Find the best implementation for the current CPU 64 if(Platform::SystemInfo.processor.properties & CPU_PROP_SSE) 65 { 66 #if (defined( TORQUE_CPU_X86 ) || defined( TORQUE_CPU_X64 )) 67 zero_vert_normal_bulk = zero_vert_normal_bulk_SSE; 68 #endif 69 } 70 } 71 72MODULE_END; 73