2010-11-12 03:35:28 +00:00
|
|
|
/* -----------------------------------------------------------------------------
|
|
|
|
|
2011-01-19 07:27:04 +00:00
|
|
|
Copyright (c) 2006 Simon Brown si@sjbrown.co.uk
|
|
|
|
Copyright (c) 2006 Ignacio Castano icastano@nvidia.com
|
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
a copy of this software and associated documentation files (the
|
|
|
|
"Software"), to deal in the Software without restriction, including
|
|
|
|
without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included
|
|
|
|
in all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|
|
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
|
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
|
|
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
|
|
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
|
|
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
2010-11-12 03:35:28 +00:00
|
|
|
|
|
|
|
-------------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
#ifndef NVTT_CLUSTERFIT_H
|
|
|
|
#define NVTT_CLUSTERFIT_H
|
|
|
|
|
|
|
|
#include "nvmath/SimdVector.h"
|
|
|
|
#include "nvmath/Vector.h"
|
|
|
|
|
2012-01-01 21:29:27 +00:00
|
|
|
// Use SIMD version if altivec or SSE are available.
|
2012-01-12 16:54:10 +00:00
|
|
|
#define NVTT_USE_SIMD (NV_USE_ALTIVEC || NV_USE_SSE)
|
|
|
|
//#define NVTT_USE_SIMD 0
|
2012-01-01 21:29:27 +00:00
|
|
|
|
2010-11-12 03:35:28 +00:00
|
|
|
namespace nv {
|
|
|
|
|
|
|
|
struct ColorSet;
|
|
|
|
|
|
|
|
class ClusterFit
|
|
|
|
{
|
|
|
|
public:
|
2011-01-19 07:27:04 +00:00
|
|
|
ClusterFit();
|
|
|
|
|
|
|
|
void setColourSet(const ColorSet * set);
|
2010-11-12 03:35:28 +00:00
|
|
|
|
2012-01-04 02:25:28 +00:00
|
|
|
void setMetric(const Vector4 & w);
|
2011-01-19 07:27:04 +00:00
|
|
|
float bestError() const;
|
2010-11-12 03:35:28 +00:00
|
|
|
|
2011-01-19 07:27:04 +00:00
|
|
|
bool compress3(Vector3 * start, Vector3 * end);
|
|
|
|
bool compress4(Vector3 * start, Vector3 * end);
|
2010-11-12 03:35:28 +00:00
|
|
|
|
2011-01-19 07:27:04 +00:00
|
|
|
private:
|
2010-11-12 03:35:28 +00:00
|
|
|
|
2011-01-19 07:27:04 +00:00
|
|
|
uint m_count;
|
2010-11-12 03:35:28 +00:00
|
|
|
|
|
|
|
#if NVTT_USE_SIMD
|
2012-01-12 16:54:10 +00:00
|
|
|
NV_ALIGN_16 SimdVector m_weighted[16]; // color | weight
|
2011-01-19 07:27:04 +00:00
|
|
|
SimdVector m_metric; // vec3
|
|
|
|
SimdVector m_metricSqr; // vec3
|
|
|
|
SimdVector m_xxsum; // color | weight
|
|
|
|
SimdVector m_xsum; // color | weight (wsum)
|
|
|
|
SimdVector m_besterror; // scalar
|
2010-11-12 03:35:28 +00:00
|
|
|
#else
|
2011-01-19 07:27:04 +00:00
|
|
|
Vector3 m_weighted[16];
|
|
|
|
float m_weights[16];
|
|
|
|
Vector3 m_metric;
|
|
|
|
Vector3 m_metricSqr;
|
|
|
|
Vector3 m_xxsum;
|
|
|
|
Vector3 m_xsum;
|
|
|
|
float m_wsum;
|
|
|
|
float m_besterror;
|
2010-11-12 03:35:28 +00:00
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
} // nv namespace
|
|
|
|
|
|
|
|
#endif // NVTT_CLUSTERFIT_H
|