mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-11-24 04:45:42 +01:00
Fix some more compiler errors
This commit is contained in:
parent
08c919d965
commit
c7a2e24b07
@ -84,8 +84,8 @@ static const int kPBits[4][2] = {
|
|||||||
class BC7CompressionMode {
|
class BC7CompressionMode {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static const int kMaxNumSubsets = 3;
|
static const uint32 kMaxNumSubsets = 3;
|
||||||
static const int kNumModes = 8;
|
static const uint32 kNumModes = 8;
|
||||||
|
|
||||||
explicit BC7CompressionMode(int mode, bool opaque = true) : m_IsOpaque(opaque), m_Attributes(&(kModeAttributes[mode])), m_RotateMode(0), m_IndexMode(0) { }
|
explicit BC7CompressionMode(int mode, bool opaque = true) : m_IsOpaque(opaque), m_Attributes(&(kModeAttributes[mode])), m_RotateMode(0), m_IndexMode(0) { }
|
||||||
~BC7CompressionMode() { }
|
~BC7CompressionMode() { }
|
||||||
|
@ -718,7 +718,7 @@ double BC7CompressionMode::CompressCluster(const RGBACluster &cluster, RGBAVecto
|
|||||||
double bestErr = CompressSingleColor(p, p1, p2, dummyPbit);
|
double bestErr = CompressSingleColor(p, p1, p2, dummyPbit);
|
||||||
|
|
||||||
// We're assuming all indices will be index 1...
|
// We're assuming all indices will be index 1...
|
||||||
for(int i = 0; i < cluster.GetNumPoints(); i++) {
|
for(uint32 i = 0; i < cluster.GetNumPoints(); i++) {
|
||||||
bestIndices[i] = 1;
|
bestIndices[i] = 1;
|
||||||
alphaIndices[i] = 1;
|
alphaIndices[i] = 1;
|
||||||
}
|
}
|
||||||
@ -730,7 +730,7 @@ double BC7CompressionMode::CompressCluster(const RGBACluster &cluster, RGBAVecto
|
|||||||
float alphaVals[kMaxNumDataPoints];
|
float alphaVals[kMaxNumDataPoints];
|
||||||
|
|
||||||
float alphaMin = FLT_MAX, alphaMax = -FLT_MAX;
|
float alphaMin = FLT_MAX, alphaMax = -FLT_MAX;
|
||||||
for(int i = 0; i < cluster.GetNumPoints(); i++) {
|
for(uint32 i = 0; i < cluster.GetNumPoints(); i++) {
|
||||||
|
|
||||||
RGBAVector v = cluster.GetPoint(i);
|
RGBAVector v = cluster.GetPoint(i);
|
||||||
switch(GetRotationMode()) {
|
switch(GetRotationMode()) {
|
||||||
@ -783,10 +783,6 @@ double BC7CompressionMode::CompressCluster(const RGBACluster &cluster, RGBAVecto
|
|||||||
|
|
||||||
// Mode 5 has 8 bits of precision for alpha.
|
// Mode 5 has 8 bits of precision for alpha.
|
||||||
if(GetModeNumber() == 5) {
|
if(GetModeNumber() == 5) {
|
||||||
|
|
||||||
assert(a1 == float(a1b));
|
|
||||||
assert(a2 == float(a2b));
|
|
||||||
|
|
||||||
for(uint32 i = 0; i < kMaxNumDataPoints; i++)
|
for(uint32 i = 0; i < kMaxNumDataPoints; i++)
|
||||||
alphaIndices[i] = 0;
|
alphaIndices[i] = 0;
|
||||||
|
|
||||||
@ -971,14 +967,14 @@ double BC7CompressionMode::CompressCluster(const RGBACluster &cluster, RGBAVecto
|
|||||||
double bestErr = CompressSingleColor(p, p1, p2, bestPbitCombo);
|
double bestErr = CompressSingleColor(p, p1, p2, bestPbitCombo);
|
||||||
|
|
||||||
// We're assuming all indices will be index 1...
|
// We're assuming all indices will be index 1...
|
||||||
for(int i = 0; i < cluster.GetNumPoints(); i++) {
|
for(uint32 i = 0; i < cluster.GetNumPoints(); i++) {
|
||||||
bestIndices[i] = 1;
|
bestIndices[i] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return bestErr;
|
return bestErr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const int nBuckets = (1 << GetNumberOfBitsPerIndex());
|
const uint32 nBuckets = (1 << GetNumberOfBitsPerIndex());
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
RGBAVector avg = cluster.GetTotal() / float(cluster.GetNumPoints());
|
RGBAVector avg = cluster.GetTotal() / float(cluster.GetNumPoints());
|
||||||
@ -987,7 +983,7 @@ double BC7CompressionMode::CompressCluster(const RGBACluster &cluster, RGBAVecto
|
|||||||
::GetPrincipalAxis(cluster.GetNumPoints(), cluster.GetPoints(), axis, eigOne, NULL);
|
::GetPrincipalAxis(cluster.GetNumPoints(), cluster.GetPoints(), axis, eigOne, NULL);
|
||||||
|
|
||||||
float mindp = FLT_MAX, maxdp = -FLT_MAX;
|
float mindp = FLT_MAX, maxdp = -FLT_MAX;
|
||||||
for(int i = 0 ; i < cluster.GetNumPoints(); i++) {
|
for(uint32 i = 0 ; i < cluster.GetNumPoints(); i++) {
|
||||||
float dp = (cluster.GetPoint(i) - avg) * axis;
|
float dp = (cluster.GetPoint(i) - avg) * axis;
|
||||||
if(dp < mindp) mindp = dp;
|
if(dp < mindp) mindp = dp;
|
||||||
if(dp > maxdp) maxdp = dp;
|
if(dp > maxdp) maxdp = dp;
|
||||||
@ -1002,10 +998,10 @@ double BC7CompressionMode::CompressCluster(const RGBACluster &cluster, RGBAVecto
|
|||||||
ClampEndpoints(p1, p2);
|
ClampEndpoints(p1, p2);
|
||||||
|
|
||||||
RGBAVector pts[1 << 4]; // At most 4 bits per index.
|
RGBAVector pts[1 << 4]; // At most 4 bits per index.
|
||||||
int numPts[1<<4];
|
uint32 numPts[1<<4];
|
||||||
assert(nBuckets <= 1 << 4);
|
assert(nBuckets <= 1 << 4);
|
||||||
|
|
||||||
for(int i = 0; i < nBuckets; i++) {
|
for(uint32 i = 0; i < nBuckets; i++) {
|
||||||
float s = (float(i) / float(nBuckets - 1));
|
float s = (float(i) / float(nBuckets - 1));
|
||||||
pts[i] = (1.0f - s) * p1 + s * p2;
|
pts[i] = (1.0f - s) * p1 + s * p2;
|
||||||
}
|
}
|
||||||
@ -1014,7 +1010,7 @@ double BC7CompressionMode::CompressCluster(const RGBACluster &cluster, RGBAVecto
|
|||||||
assert(pts[nBuckets - 1] == p2);
|
assert(pts[nBuckets - 1] == p2);
|
||||||
|
|
||||||
// Do k-means clustering...
|
// Do k-means clustering...
|
||||||
int bucketIdx[kMaxNumDataPoints];
|
uint32 bucketIdx[kMaxNumDataPoints];
|
||||||
|
|
||||||
bool fixed = false;
|
bool fixed = false;
|
||||||
while(!fixed) {
|
while(!fixed) {
|
||||||
@ -1022,11 +1018,11 @@ double BC7CompressionMode::CompressCluster(const RGBACluster &cluster, RGBAVecto
|
|||||||
RGBAVector newPts[1 << 4];
|
RGBAVector newPts[1 << 4];
|
||||||
|
|
||||||
// Assign each of the existing points to one of the buckets...
|
// Assign each of the existing points to one of the buckets...
|
||||||
for(int i = 0; i < cluster.GetNumPoints(); i++) {
|
for(uint32 i = 0; i < cluster.GetNumPoints(); i++) {
|
||||||
|
|
||||||
int minBucket = -1;
|
int minBucket = -1;
|
||||||
float minDist = FLT_MAX;
|
float minDist = FLT_MAX;
|
||||||
for(int j = 0; j < nBuckets; j++) {
|
for(uint32 j = 0; j < nBuckets; j++) {
|
||||||
RGBAVector v = cluster.GetPoint(i) - pts[j];
|
RGBAVector v = cluster.GetPoint(i) - pts[j];
|
||||||
float distSq = v * v;
|
float distSq = v * v;
|
||||||
if(distSq < minDist)
|
if(distSq < minDist)
|
||||||
@ -1041,11 +1037,11 @@ double BC7CompressionMode::CompressCluster(const RGBACluster &cluster, RGBAVecto
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate new buckets based on centroids of clusters...
|
// Calculate new buckets based on centroids of clusters...
|
||||||
for(int i = 0; i < nBuckets; i++) {
|
for(uint32 i = 0; i < nBuckets; i++) {
|
||||||
|
|
||||||
numPts[i] = 0;
|
numPts[i] = 0;
|
||||||
newPts[i] = RGBAVector(0.0f);
|
newPts[i] = RGBAVector(0.0f);
|
||||||
for(int j = 0; j < cluster.GetNumPoints(); j++) {
|
for(uint32 j = 0; j < cluster.GetNumPoints(); j++) {
|
||||||
if(bucketIdx[j] == i) {
|
if(bucketIdx[j] == i) {
|
||||||
numPts[i]++;
|
numPts[i]++;
|
||||||
newPts[i] += cluster.GetPoint(j);
|
newPts[i] += cluster.GetPoint(j);
|
||||||
@ -1060,20 +1056,20 @@ double BC7CompressionMode::CompressCluster(const RGBACluster &cluster, RGBAVecto
|
|||||||
|
|
||||||
// If we haven't changed, then we're done.
|
// If we haven't changed, then we're done.
|
||||||
fixed = true;
|
fixed = true;
|
||||||
for(int i = 0; i < nBuckets; i++) {
|
for(uint32 i = 0; i < nBuckets; i++) {
|
||||||
if(pts[i] != newPts[i])
|
if(pts[i] != newPts[i])
|
||||||
fixed = false;
|
fixed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign the new points to be the old points.
|
// Assign the new points to be the old points.
|
||||||
for(int i = 0; i < nBuckets; i++) {
|
for(uint32 i = 0; i < nBuckets; i++) {
|
||||||
pts[i] = newPts[i];
|
pts[i] = newPts[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there's only one bucket filled, then just compress for that single color...
|
// If there's only one bucket filled, then just compress for that single color...
|
||||||
int numBucketsFilled = 0, lastFilledBucket = -1;
|
int numBucketsFilled = 0, lastFilledBucket = -1;
|
||||||
for(int i = 0; i < nBuckets; i++) {
|
for(uint32 i = 0; i < nBuckets; i++) {
|
||||||
if(numPts[i] > 0) {
|
if(numPts[i] > 0) {
|
||||||
numBucketsFilled++;
|
numBucketsFilled++;
|
||||||
lastFilledBucket = i;
|
lastFilledBucket = i;
|
||||||
@ -1086,7 +1082,7 @@ double BC7CompressionMode::CompressCluster(const RGBACluster &cluster, RGBAVecto
|
|||||||
double bestErr = CompressSingleColor(p, p1, p2, bestPbitCombo);
|
double bestErr = CompressSingleColor(p, p1, p2, bestPbitCombo);
|
||||||
|
|
||||||
// We're assuming all indices will be index 1...
|
// We're assuming all indices will be index 1...
|
||||||
for(int i = 0; i < cluster.GetNumPoints(); i++) {
|
for(uint32 i = 0; i < cluster.GetNumPoints(); i++) {
|
||||||
bestIndices[i] = 1;
|
bestIndices[i] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1098,7 +1094,7 @@ double BC7CompressionMode::CompressCluster(const RGBACluster &cluster, RGBAVecto
|
|||||||
// http://developer.download.nvidia.com/compute/cuda/1.1-Beta/x86_website/projects/dxtc/doc/cuda_dxtc.pdf
|
// http://developer.download.nvidia.com/compute/cuda/1.1-Beta/x86_website/projects/dxtc/doc/cuda_dxtc.pdf
|
||||||
float asq = 0.0, bsq = 0.0, ab = 0.0;
|
float asq = 0.0, bsq = 0.0, ab = 0.0;
|
||||||
RGBAVector ax(0.0), bx(0.0);
|
RGBAVector ax(0.0), bx(0.0);
|
||||||
for(int i = 0; i < nBuckets; i++) {
|
for(uint32 i = 0; i < nBuckets; i++) {
|
||||||
float a = float(nBuckets - 1 - i) / float(nBuckets - 1);
|
float a = float(nBuckets - 1 - i) / float(nBuckets - 1);
|
||||||
float b = float(i) / float(nBuckets - 1);
|
float b = float(i) / float(nBuckets - 1);
|
||||||
|
|
||||||
@ -2004,7 +2000,7 @@ namespace BC7C
|
|||||||
BlockStat s (kBlockStatString[eBlockStat_Mode], *m_ModePtr);
|
BlockStat s (kBlockStatString[eBlockStat_Mode], *m_ModePtr);
|
||||||
m_BSM.AddStat(m_BlockIdx, s);
|
m_BSM.AddStat(m_BlockIdx, s);
|
||||||
|
|
||||||
for(int i = 0; i < BC7CompressionMode::kNumModes; i++) {
|
for(uint32 i = 0; i < BC7CompressionMode::kNumModes; i++) {
|
||||||
s = BlockStat(kBlockStatString[eBlockStat_ModeZeroEstimate + i], m_Estimates[i]);
|
s = BlockStat(kBlockStatString[eBlockStat_ModeZeroEstimate + i], m_Estimates[i]);
|
||||||
m_BSM.AddStat(m_BlockIdx, s);
|
m_BSM.AddStat(m_BlockIdx, s);
|
||||||
|
|
||||||
@ -2020,7 +2016,7 @@ namespace BC7C
|
|||||||
|
|
||||||
// reset global variables...
|
// reset global variables...
|
||||||
bestMode = 0;
|
bestMode = 0;
|
||||||
for(int i = 0; i < BC7CompressionMode::kNumModes; i++){
|
for(uint32 i = 0; i < BC7CompressionMode::kNumModes; i++){
|
||||||
modeError[i] = modeEstimate[i] = -1.0;
|
modeError[i] = modeEstimate[i] = -1.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,7 +333,7 @@ bool RGBAMatrix::Identity() {
|
|||||||
|
|
||||||
RGBACluster::RGBACluster(const RGBACluster &left, const RGBACluster &right) {
|
RGBACluster::RGBACluster(const RGBACluster &left, const RGBACluster &right) {
|
||||||
*this = left;
|
*this = left;
|
||||||
for(int i = 0; i < right.m_NumPoints; i++) {
|
for(uint32 i = 0; i < right.m_NumPoints; i++) {
|
||||||
const RGBAVector &p = right.m_DataPoints[i];
|
const RGBAVector &p = right.m_DataPoints[i];
|
||||||
AddPoint(p);
|
AddPoint(p);
|
||||||
}
|
}
|
||||||
@ -436,7 +436,7 @@ double RGBACluster::QuantizedError(const RGBAVector &p1, const RGBAVector &p2, u
|
|||||||
const RGBAVector metric = errorMetricVec;
|
const RGBAVector metric = errorMetricVec;
|
||||||
|
|
||||||
float totalError = 0.0;
|
float totalError = 0.0;
|
||||||
for(int i = 0; i < m_NumPoints; i++) {
|
for(uint32 i = 0; i < m_NumPoints; i++) {
|
||||||
|
|
||||||
const uint32 pixel = m_DataPoints[i].ToPixel();
|
const uint32 pixel = m_DataPoints[i].ToPixel();
|
||||||
const uint8 *pb = (const uint8 *)(&pixel);
|
const uint8 *pb = (const uint8 *)(&pixel);
|
||||||
|
@ -377,7 +377,7 @@ public:
|
|||||||
|
|
||||||
RGBAVector GetTotal() const { return m_Total; }
|
RGBAVector GetTotal() const { return m_Total; }
|
||||||
const RGBAVector &GetPoint(int idx) const { return m_DataPoints[idx]; }
|
const RGBAVector &GetPoint(int idx) const { return m_DataPoints[idx]; }
|
||||||
int GetNumPoints() const { return m_NumPoints; }
|
uint32 GetNumPoints() const { return m_NumPoints; }
|
||||||
RGBAVector GetAvg() const { return m_Total / float(m_NumPoints); }
|
RGBAVector GetAvg() const { return m_Total / float(m_NumPoints); }
|
||||||
const RGBAVector *GetPoints() const { return m_DataPoints; }
|
const RGBAVector *GetPoints() const { return m_DataPoints; }
|
||||||
|
|
||||||
@ -402,7 +402,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
// The number of points in the cluster.
|
// The number of points in the cluster.
|
||||||
int m_NumPoints;
|
uint32 m_NumPoints;
|
||||||
|
|
||||||
RGBAVector m_Total;
|
RGBAVector m_Total;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user