Skip to content

Commit b983f9f

Browse files
committed
Updated submodules.
Switch back to upstream ASTC repository since it's being maintained again. Support thread data for converters, which is used for ASTC compression to pre-allocate the temporary buffers, now that it's passed as a parameter instead of re-allocating each block.
1 parent 4a3c68f commit b983f9f

18 files changed

+131
-58
lines changed

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
url = https://github.com/google/etc2comp.git
1010
[submodule "lib/astc-encoder"]
1111
path = lib/astc-encoder
12-
url = https://github.com/akb825/astc-encoder.git
12+
url = https://github.com/ARM-software/astc-encoder.git
1313
[submodule "lib/glm"]
1414
path = lib/glm
1515
url = https://github.com/g-truc/glm

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ endif()
5656

5757
set(CUTTLEFISH_MAJOR_VERSION 2)
5858
set(CUTTLEFISH_MINOR_VERSION 0)
59-
set(CUTTLEFISH_PATCH_VERSION 1)
59+
set(CUTTLEFISH_PATCH_VERSION 2)
6060
set(CUTTLEFISH_VERSION ${CUTTLEFISH_MAJOR_VERSION}.${CUTTLEFISH_MINOR_VERSION}.${CUTTLEFISH_PATCH_VERSION})
6161

6262
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

lib/FreeImage

lib/glm

Submodule glm updated 158 files

lib/nvidia-texture-tools

lib/src/AstcConverter.cpp

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,50 @@ void astc_codec_internal_error(const char *filename, int linenum)
7272
namespace cuttlefish
7373
{
7474

75+
class AstcConverter::AstcThreadData : public Converter::ThreadData
76+
{
77+
public:
78+
AstcThreadData()
79+
{
80+
m_planes.ei1 = &m_ei1;
81+
m_planes.ei2 = &m_ei2;
82+
m_planes.eix1 = m_eix1;
83+
m_planes.eix2 = m_eix2;
84+
m_planes.decimated_quantized_weights = m_decimated_quantized_weights;
85+
m_planes.decimated_weights = m_decimated_weights;
86+
m_planes.flt_quantized_decimated_quantized_weights =
87+
m_flt_quantized_decimated_quantized_weights;
88+
m_planes.u8_quantized_decimated_quantized_weights =
89+
m_u8_quantized_decimated_quantized_weights;
90+
91+
tempBuffers.ewb = &m_ewb;
92+
tempBuffers.ewbo = &m_ewbo;
93+
tempBuffers.tempblocks = m_tempblocks;
94+
tempBuffers.temp = &m_temp;
95+
// Buffers for plane1 is smaller than planes2, so can re-use between them.
96+
tempBuffers.plane1 = &m_planes;
97+
tempBuffers.planes2 = &m_planes;
98+
}
99+
100+
compress_symbolic_block_buffers tempBuffers;
101+
102+
private:
103+
endpoints_and_weights m_ei1;
104+
endpoints_and_weights m_ei2;
105+
endpoints_and_weights m_eix1[MAX_DECIMATION_MODES];
106+
endpoints_and_weights m_eix2[MAX_DECIMATION_MODES];
107+
float m_decimated_quantized_weights[2*MAX_DECIMATION_MODES*MAX_WEIGHTS_PER_BLOCK];
108+
float m_decimated_weights[2*MAX_DECIMATION_MODES*MAX_WEIGHTS_PER_BLOCK];
109+
float m_flt_quantized_decimated_quantized_weights[2*MAX_WEIGHT_MODES*MAX_WEIGHTS_PER_BLOCK];
110+
uint8_t m_u8_quantized_decimated_quantized_weights[2*MAX_WEIGHT_MODES*MAX_WEIGHTS_PER_BLOCK];
111+
compress_fixed_partition_buffers m_planes;
112+
113+
error_weight_block m_ewb;
114+
error_weight_block_orig m_ewbo;
115+
symbolic_compressed_block m_tempblocks[4];
116+
imageblock m_temp;
117+
};
118+
75119
std::mutex AstcConverter::m_mutex;
76120

77121
static bool initialize()
@@ -160,7 +204,7 @@ AstcConverter::~AstcConverter()
160204
m_mutex.unlock();
161205
}
162206

163-
void AstcConverter::process(unsigned int x, unsigned int y)
207+
void AstcConverter::process(unsigned int x, unsigned int y, ThreadData* threadData)
164208
{
165209
imageblock astcBlock;
166210
astcBlock.xpos = x*m_blockX;
@@ -229,13 +273,19 @@ void AstcConverter::process(unsigned int x, unsigned int y)
229273

230274
symbolic_compressed_block symbolicBlock;
231275
compress_symbolic_block(&dummyImage, m_hdr ? DECODE_HDR : DECODE_LDR, m_blockX, m_blockY, 1,
232-
&errorParams, &astcBlock, &symbolicBlock);
276+
&errorParams, &astcBlock, &symbolicBlock,
277+
&reinterpret_cast<AstcThreadData*>(threadData)->tempBuffers);
233278

234279
auto block = reinterpret_cast<physical_compressed_block*>(
235280
data().data() + (y*m_jobsX + x)*blockSize);
236281
*block = symbolic_to_physical(m_blockX, m_blockY, 1, &symbolicBlock);
237282
}
238283

284+
std::unique_ptr<Converter::ThreadData> AstcConverter::createThreadData()
285+
{
286+
return std::unique_ptr<ThreadData>(new AstcThreadData);
287+
}
288+
239289
} // namespace cuttlefish
240290

241291
#endif // CUTTLEFISH_HAS_ASTC

lib/src/AstcConverter.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,12 @@ class AstcConverter : public Converter
3636

3737
unsigned int jobsX() const override {return m_jobsX;}
3838
unsigned int jobsY() const override {return m_jobsY;}
39-
void process(unsigned int x, unsigned int y) override;
39+
void process(unsigned int x, unsigned int y, ThreadData* threadData) override;
40+
std::unique_ptr<ThreadData> createThreadData() override;
4041

4142
private:
43+
class AstcThreadData;
44+
4245
unsigned int m_blockX;
4346
unsigned int m_blockY;
4447
unsigned int m_jobsX;

lib/src/Converter.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -540,8 +540,9 @@ bool Converter::convert(const Texture& texture, MipImageList& images, MipTexture
540540
unsigned int curThreads = std::min(jobsX*jobsY, threadCount);
541541
if (curThreads <= 1)
542542
{
543+
std::unique_ptr<ThreadData> threadData = converter->createThreadData();
543544
for (const std::pair<unsigned int, unsigned int>& job : jobs)
544-
converter->process(job.first, job.second);
545+
converter->process(job.first, job.second, threadData.get());
545546
}
546547
else
547548
{
@@ -550,13 +551,16 @@ bool Converter::convert(const Texture& texture, MipImageList& images, MipTexture
550551
{
551552
threads.emplace_back([&curJob, &jobs, &converter]()
552553
{
554+
std::unique_ptr<ThreadData> threadData =
555+
converter->createThreadData();
553556
do
554557
{
555558
unsigned int thisJob = curJob++;
556559
if (thisJob >= jobs.size())
557560
return;
558561

559-
converter->process(jobs[thisJob].first, jobs[thisJob].second);
562+
converter->process(jobs[thisJob].first, jobs[thisJob].second,
563+
threadData.get());
560564
} while (true);
561565
});
562566
}
@@ -575,4 +579,9 @@ bool Converter::convert(const Texture& texture, MipImageList& images, MipTexture
575579
return true;
576580
}
577581

582+
std::unique_ptr<Converter::ThreadData> Converter::createThreadData()
583+
{
584+
return nullptr;
585+
}
586+
578587
} // namespace cuttlefish

lib/src/Converter.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ class Converter
4040
using DepthTextureList = std::vector<FaceTextureList>;
4141
using MipTextureList = std::vector<DepthTextureList>;
4242

43+
class ThreadData
44+
{
45+
public:
46+
virtual ~ThreadData() = default;
47+
};
48+
4349
static bool convert(const Texture& texture, MipImageList& images, MipTextureList& textureData,
4450
Texture::Quality quality, unsigned int threadCount);
4551

@@ -58,7 +64,8 @@ class Converter
5864

5965
virtual unsigned int jobsX() const = 0;
6066
virtual unsigned int jobsY() const = 0;
61-
virtual void process(unsigned int x, unsigned int y) = 0;
67+
virtual void process(unsigned int x, unsigned int y, ThreadData* threadData) = 0;
68+
virtual std::unique_ptr<ThreadData> createThreadData();
6269

6370
private:
6471
const Image* m_image;

0 commit comments

Comments
 (0)