mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-11-24 09:45:48 +01:00
Actually use the simulated annealing setting.
This commit is contained in:
parent
220a736a36
commit
5bd306d09b
@ -105,10 +105,11 @@ class CompressionMode {
|
|||||||
// This initializes the compression variables used in order to compress a list
|
// This initializes the compression variables used in order to compress a list
|
||||||
// of clusters. We can increase the speed a tad by specifying whether or not
|
// of clusters. We can increase the speed a tad by specifying whether or not
|
||||||
// the block is opaque or not.
|
// the block is opaque or not.
|
||||||
explicit CompressionMode(int mode, ErrorMetric metric)
|
explicit CompressionMode(int mode, const CompressionSettings &settings)
|
||||||
: m_IsOpaque(mode < 4)
|
: m_IsOpaque(mode < 4)
|
||||||
, m_Attributes(&(kModeAttributes[mode]))
|
, m_Attributes(&(kModeAttributes[mode]))
|
||||||
, m_ErrorMetric(metric)
|
, m_SASteps(settings.m_NumSimulatedAnnealingSteps)
|
||||||
|
, m_ErrorMetric(settings.m_ErrorMetric)
|
||||||
, m_RotateMode(0)
|
, m_RotateMode(0)
|
||||||
, m_IndexMode(0)
|
, m_IndexMode(0)
|
||||||
{ }
|
{ }
|
||||||
@ -185,6 +186,7 @@ class CompressionMode {
|
|||||||
const double m_IsOpaque;
|
const double m_IsOpaque;
|
||||||
const Attributes *const m_Attributes;
|
const Attributes *const m_Attributes;
|
||||||
|
|
||||||
|
int m_SASteps;
|
||||||
ErrorMetric m_ErrorMetric;
|
ErrorMetric m_ErrorMetric;
|
||||||
int m_RotateMode;
|
int m_RotateMode;
|
||||||
int m_IndexMode;
|
int m_IndexMode;
|
||||||
|
@ -260,8 +260,6 @@ const uint32 kInterpolationValues[4][16][2] = {
|
|||||||
{30, 34}, {26, 38}, {21, 43}, {17, 47}, {13, 51}, {9, 55}, {4, 60}, {0, 64}}
|
{30, 34}, {26, 38}, {21, 43}, {17, 47}, {13, 51}, {9, 55}, {4, 60}, {0, 64}}
|
||||||
};
|
};
|
||||||
|
|
||||||
int CompressionMode::MaxAnnealingIterations = 50; // This is a setting.
|
|
||||||
|
|
||||||
CompressionMode::Attributes
|
CompressionMode::Attributes
|
||||||
CompressionMode::kModeAttributes[kNumModes] = {
|
CompressionMode::kModeAttributes[kNumModes] = {
|
||||||
// Mode 0
|
// Mode 0
|
||||||
@ -666,7 +664,7 @@ double CompressionMode::OptimizeEndpointsForCluster(
|
|||||||
visitedStates[lastVisitedState].pBitCombo = curPbitCombo;
|
visitedStates[lastVisitedState].pBitCombo = curPbitCombo;
|
||||||
lastVisitedState++;
|
lastVisitedState++;
|
||||||
|
|
||||||
const int maxEnergy = MaxAnnealingIterations;
|
const int maxEnergy = this->m_SASteps;
|
||||||
|
|
||||||
for(int energy = 0; bestError > 0 && energy < maxEnergy; energy++) {
|
for(int energy = 0; bestError > 0 && energy < maxEnergy; energy++) {
|
||||||
|
|
||||||
@ -1842,8 +1840,8 @@ static ShapeSelection BoxSelection(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void CompressClusters(ShapeSelection selection, const uint32 pixels[16],
|
static void CompressClusters(const ShapeSelection &selection, const uint32 pixels[16],
|
||||||
ErrorMetric metric, uint8 *outBuf,
|
const CompressionSettings &settings, uint8 *outBuf,
|
||||||
double *errors, int *modeChosen) {
|
double *errors, int *modeChosen) {
|
||||||
RGBACluster cluster(pixels);
|
RGBACluster cluster(pixels);
|
||||||
uint8 tmpBuf[16];
|
uint8 tmpBuf[16];
|
||||||
@ -1853,14 +1851,15 @@ static void CompressClusters(ShapeSelection selection, const uint32 pixels[16],
|
|||||||
// Block mode zero only has four bits for the partition index,
|
// Block mode zero only has four bits for the partition index,
|
||||||
// so if the chosen three-partition shape is not within this range,
|
// so if the chosen three-partition shape is not within this range,
|
||||||
// then we shouldn't consider using this block mode...
|
// then we shouldn't consider using this block mode...
|
||||||
|
uint32 selectedModes = selection.m_SelectedModes;
|
||||||
if(selection.m_ThreeShapeIndex >= 16) {
|
if(selection.m_ThreeShapeIndex >= 16) {
|
||||||
selection.m_SelectedModes &= ~(static_cast<uint32>(eBlockMode_Zero));
|
selectedModes &= ~(static_cast<uint32>(eBlockMode_Zero));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uint32 modeIdx = 0; modeIdx < 8; modeIdx++) {
|
for(uint32 modeIdx = 0; modeIdx < 8; modeIdx++) {
|
||||||
|
|
||||||
uint32 mode = modes[modeIdx];
|
uint32 mode = modes[modeIdx];
|
||||||
if((selection.m_SelectedModes & (1 << mode)) == 0) {
|
if((selectedModes & (1 << mode)) == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1875,7 +1874,7 @@ static void CompressClusters(ShapeSelection selection, const uint32 pixels[16],
|
|||||||
shape, CompressionMode::GetAttributesForMode(mode)->numSubsets);
|
shape, CompressionMode::GetAttributesForMode(mode)->numSubsets);
|
||||||
|
|
||||||
BitStream tmpStream(tmpBuf, 128, 0);
|
BitStream tmpStream(tmpBuf, 128, 0);
|
||||||
double error = CompressionMode(mode, metric).Compress(tmpStream, shape, cluster);
|
double error = CompressionMode(mode, settings).Compress(tmpStream, shape, cluster);
|
||||||
|
|
||||||
if(errors)
|
if(errors)
|
||||||
errors[mode] = error;
|
errors[mode] = error;
|
||||||
@ -1928,7 +1927,7 @@ static void CompressBC7Block(const uint32 x, const uint32 y,
|
|||||||
selectionFn(x, y, block, userData);
|
selectionFn(x, y, block, userData);
|
||||||
selection.m_SelectedModes &= settings.m_BlockModes;
|
selection.m_SelectedModes &= settings.m_BlockModes;
|
||||||
assert(selection.m_SelectedModes);
|
assert(selection.m_SelectedModes);
|
||||||
CompressClusters(selection, block, settings.m_ErrorMetric, outBuf, NULL, NULL);
|
CompressClusters(selection, block, settings, outBuf, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static double EstimateTwoClusterErrorStats(
|
static double EstimateTwoClusterErrorStats(
|
||||||
@ -2247,8 +2246,7 @@ static void CompressBC7Block(
|
|||||||
|
|
||||||
selection.m_SelectedModes &= settings.m_BlockModes;
|
selection.m_SelectedModes &= settings.m_BlockModes;
|
||||||
assert(selection.m_SelectedModes);
|
assert(selection.m_SelectedModes);
|
||||||
ErrorMetric metric = settings.m_ErrorMetric;
|
CompressClusters(selection, block, settings, outBuf, modeError, &bestMode);
|
||||||
CompressClusters(selection, block, metric, outBuf, modeError, &bestMode);
|
|
||||||
|
|
||||||
PrintStat(logStream, kBlockStatString[eBlockStat_Path], path);
|
PrintStat(logStream, kBlockStatString[eBlockStat_Path], path);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user