Format all C++ and Java code via clang-format

Signed-off-by: Konstantin Pastbin <konstantin.pastbin@gmail.com>
This commit is contained in:
Konstantin Pastbin
2025-08-17 14:32:37 +07:00
parent 9f0290c0ec
commit bfffa1fff4
2169 changed files with 56441 additions and 64188 deletions

View File

@@ -27,13 +27,13 @@ bool IsEnoughMemory(uint32_t avVertex, uint32_t existVertex, uint32_t avIndex, u
return avVertex >= existVertex && avIndex >= existIndex;
}
template<typename TGenerator>
template <typename TGenerator>
void GenerateIndices(void * indexStorage, uint32_t count, uint32_t startIndex)
{
GenerateIndices<TGenerator>(indexStorage, count, TGenerator(startIndex));
}
template<typename TGenerator>
template <typename TGenerator>
void GenerateIndices(void * indexStorage, uint32_t count, TGenerator const & generator)
{
if (dp::IndexStorage::IsSupported32bit())
@@ -51,10 +51,7 @@ void GenerateIndices(void * indexStorage, uint32_t count, TGenerator const & gen
class IndexGenerator
{
public:
explicit IndexGenerator(uint32_t startIndex)
: m_startIndex(startIndex)
, m_counter(0)
, m_minStripCounter(0) {}
explicit IndexGenerator(uint32_t startIndex) : m_startIndex(startIndex), m_counter(0), m_minStripCounter(0) {}
protected:
uint32_t GetCounter() { return m_counter++; }
@@ -73,9 +70,9 @@ protected:
m_minStripCounter = static_cast<uint8_t>(CyclicClamp(m_minStripCounter + 1, 0, 5));
switch (tmp)
{
case 4: return 1;
case 5: return -1;
default: return 0;
case 4: return 1;
case 5: return -1;
default: return 0;
}
}
@@ -87,18 +84,14 @@ private:
class ListIndexGenerator : public IndexGenerator
{
public:
explicit ListIndexGenerator(uint32_t startIndex)
: IndexGenerator(startIndex)
{}
explicit ListIndexGenerator(uint32_t startIndex) : IndexGenerator(startIndex) {}
uint32_t operator()() { return m_startIndex + GetCounter(); }
};
class StripIndexGenerator : public IndexGenerator
{
public:
explicit StripIndexGenerator(uint32_t startIndex)
: IndexGenerator(startIndex)
{}
explicit StripIndexGenerator(uint32_t startIndex) : IndexGenerator(startIndex) {}
uint32_t operator()()
{
@@ -110,9 +103,7 @@ public:
class LineStripIndexGenerator : public IndexGenerator
{
public:
explicit LineStripIndexGenerator(uint32_t startIndex)
: IndexGenerator(startIndex)
{}
explicit LineStripIndexGenerator(uint32_t startIndex) : IndexGenerator(startIndex) {}
uint32_t operator()()
{
@@ -150,9 +141,7 @@ private:
class FanIndexGenerator : public IndexGenerator
{
public:
explicit FanIndexGenerator(uint32_t startIndex)
: IndexGenerator(startIndex)
{}
explicit FanIndexGenerator(uint32_t startIndex) : IndexGenerator(startIndex) {}
uint32_t operator()()
{
@@ -193,8 +182,7 @@ private:
};
} // namespace
UniversalBatch::UniversalBatch(BatchCallbacks & callbacks, uint8_t minVerticesCount,
uint8_t minIndicesCount)
UniversalBatch::UniversalBatch(BatchCallbacks & callbacks, uint8_t minVerticesCount, uint8_t minIndicesCount)
: m_callbacks(callbacks)
, m_canDivideStreams(true)
, m_minVerticesCount(minVerticesCount)
@@ -223,8 +211,8 @@ void UniversalBatch::FlushData(ref_ptr<GraphicsContext> context, ref_ptr<Attribu
FlushData(context, streams->GetBindingInfo(i), streams->GetRawPointer(i), vertexCount);
}
void UniversalBatch::FlushData(ref_ptr<GraphicsContext> context, BindingInfo const & info,
void const * data, uint32_t elementCount) const
void UniversalBatch::FlushData(ref_ptr<GraphicsContext> context, BindingInfo const & info, void const * data,
uint32_t elementCount) const
{
m_callbacks.FlushData(context, info, data, elementCount);
}
@@ -259,20 +247,16 @@ uint8_t UniversalBatch::GetVertexStride() const
return m_vertexStride;
}
bool UniversalBatch::IsBufferFilled(uint32_t availableVerticesCount,
uint32_t availableIndicesCount) const
bool UniversalBatch::IsBufferFilled(uint32_t availableVerticesCount, uint32_t availableIndicesCount) const
{
return availableVerticesCount < m_minVerticesCount ||
availableIndicesCount < m_minIndicesCount;
return availableVerticesCount < m_minVerticesCount || availableIndicesCount < m_minIndicesCount;
}
TriangleListBatch::TriangleListBatch(BatchCallbacks & callbacks)
: TBase(callbacks, 3 /* minVerticesCount */, 3 /* minIndicesCount */)
{}
void TriangleListBatch::BatchData(ref_ptr<GraphicsContext> context,
ref_ptr<AttributeProvider> streams)
void TriangleListBatch::BatchData(ref_ptr<GraphicsContext> context, ref_ptr<AttributeProvider> streams)
{
while (streams->IsDataExists())
{
@@ -280,7 +264,7 @@ void TriangleListBatch::BatchData(ref_ptr<GraphicsContext> context,
ChangeBuffer(context);
uint32_t avVertex = GetAvailableVertexCount();
uint32_t avIndex = GetAvailableIndexCount();
uint32_t avIndex = GetAvailableIndexCount();
uint32_t vertexCount = streams->GetVertexCount();
if (CanDivideStreams())
@@ -294,7 +278,7 @@ void TriangleListBatch::BatchData(ref_ptr<GraphicsContext> context,
{
ChangeBuffer(context);
avVertex = GetAvailableVertexCount();
avIndex = GetAvailableIndexCount();
avIndex = GetAvailableIndexCount();
ASSERT(IsEnoughMemory(avVertex, vertexCount, avIndex, vertexCount), ());
ASSERT(vertexCount % 3 == 0, ());
}
@@ -313,8 +297,7 @@ LineStripBatch::LineStripBatch(BatchCallbacks & callbacks)
: TBase(callbacks, 2 /* minVerticesCount */, 2 /* minIndicesCount */)
{}
void LineStripBatch::BatchData(ref_ptr<GraphicsContext> context,
ref_ptr<AttributeProvider> streams)
void LineStripBatch::BatchData(ref_ptr<GraphicsContext> context, ref_ptr<AttributeProvider> streams)
{
while (streams->IsDataExists())
{
@@ -368,8 +351,7 @@ void LineRawBatch::BatchData(ref_ptr<GraphicsContext> context, ref_ptr<Attribute
ChangeBuffer(context);
avVertex = GetAvailableVertexCount();
avIndex = GetAvailableIndexCount();
CHECK(IsEnoughMemory(avVertex, vertexCount, avIndex, indexCount),
(avVertex, vertexCount, avIndex, indexCount));
CHECK(IsEnoughMemory(avVertex, vertexCount, avIndex, indexCount), (avVertex, vertexCount, avIndex, indexCount));
}
uint32_t startIndex = 0;
@@ -391,7 +373,7 @@ FanStripHelper::FanStripHelper(BatchCallbacks & callbacks)
uint32_t FanStripHelper::BatchIndexes(ref_ptr<GraphicsContext> context, uint32_t vertexCount)
{
uint32_t avVertex = GetAvailableVertexCount();
uint32_t avIndex = GetAvailableIndexCount();
uint32_t avIndex = GetAvailableIndexCount();
uint32_t batchVertexCount = 0;
uint32_t batchIndexCount = 0;
@@ -401,7 +383,7 @@ uint32_t FanStripHelper::BatchIndexes(ref_ptr<GraphicsContext> context, uint32_t
{
ChangeBuffer(context);
avVertex = GetAvailableVertexCount();
avIndex = GetAvailableIndexCount();
avIndex = GetAvailableIndexCount();
CalcBatchPortion(vertexCount, avVertex, avIndex, batchVertexCount, batchIndexCount);
ASSERT(IsFullUploaded(), ());
}
@@ -466,12 +448,9 @@ uint32_t FanStripHelper::AlignICount(uint32_t iCount) const
return iCount - iCount % 3;
}
TriangleStripBatch::TriangleStripBatch(BatchCallbacks & callbacks)
: TBase(callbacks)
{}
TriangleStripBatch::TriangleStripBatch(BatchCallbacks & callbacks) : TBase(callbacks) {}
void TriangleStripBatch::BatchData(ref_ptr<GraphicsContext> context,
ref_ptr<AttributeProvider> streams)
void TriangleStripBatch::BatchData(ref_ptr<GraphicsContext> context, ref_ptr<AttributeProvider> streams)
{
while (streams->IsDataExists())
{
@@ -483,7 +462,6 @@ void TriangleStripBatch::BatchData(ref_ptr<GraphicsContext> context,
uint32_t const advanceCount = IsFullUploaded() ? batchVertexCount : (batchVertexCount - 2);
streams->Advance(advanceCount);
}
}
@@ -512,8 +490,7 @@ TriangleFanBatch::TriangleFanBatch(BatchCallbacks & callbacks) : TBase(callbacks
* second part of data. But to avoid 2 separate call of glBufferSubData we at first do a copy of
* data from params to cpuBuffer and than copy continuous block of memory from cpuBuffer
*/
void TriangleFanBatch::BatchData(ref_ptr<GraphicsContext> context,
ref_ptr<AttributeProvider> streams)
void TriangleFanBatch::BatchData(ref_ptr<GraphicsContext> context, ref_ptr<AttributeProvider> streams)
{
std::vector<CPUBuffer> cpuBuffers;
while (streams->IsDataExists())
@@ -554,8 +531,7 @@ void TriangleFanBatch::BatchData(ref_ptr<GraphicsContext> context,
streams->Advance(advanceCount);
}
else // if m_cpuBuffer empty than it's first iteration
{
else // if m_cpuBuffer empty than it's first iteration
if (IsFullUploaded())
{
// We can upload all input data as one peace. For upload we need only one iteration
@@ -570,8 +546,8 @@ void TriangleFanBatch::BatchData(ref_ptr<GraphicsContext> context,
cpuBuffers.reserve(streams->GetStreamCount());
for (size_t i = 0; i < streams->GetStreamCount(); ++i)
{
const BindingInfo & binding = streams->GetBindingInfo(i);
const void * rawDataPointer = streams->GetRawPointer(i);
BindingInfo const & binding = streams->GetBindingInfo(i);
void const * rawDataPointer = streams->GetRawPointer(i);
FlushData(context, binding, rawDataPointer, batchVertexCount);
// "(vertexCount + 1) - batchVertexCount" we allocate CPUBuffer on all remaining data
@@ -590,7 +566,6 @@ void TriangleFanBatch::BatchData(ref_ptr<GraphicsContext> context,
// first vertex of data from CPUBuffers
streams->Advance(batchVertexCount - 1);
}
}
}
}
@@ -599,12 +574,9 @@ void TriangleFanBatch::GenerateIndexes(void * indexStorage, uint32_t count, uint
GenerateIndices<FanIndexGenerator>(indexStorage, count, startIndex);
}
TriangleListOfStripBatch::TriangleListOfStripBatch(BatchCallbacks & callbacks)
: TBase(callbacks)
{}
TriangleListOfStripBatch::TriangleListOfStripBatch(BatchCallbacks & callbacks) : TBase(callbacks) {}
void TriangleListOfStripBatch::BatchData(ref_ptr<GraphicsContext> context,
ref_ptr<AttributeProvider> streams)
void TriangleListOfStripBatch::BatchData(ref_ptr<GraphicsContext> context, ref_ptr<AttributeProvider> streams)
{
while (streams->IsDataExists())
{
@@ -617,8 +589,7 @@ void TriangleListOfStripBatch::BatchData(ref_ptr<GraphicsContext> context,
}
}
bool TriangleListOfStripBatch::IsBufferFilled(uint32_t availableVerticesCount,
uint32_t availableIndicesCount) const
bool TriangleListOfStripBatch::IsBufferFilled(uint32_t availableVerticesCount, uint32_t availableIndicesCount) const
{
uint8_t const vertexStride = GetVertexStride();
ASSERT_GREATER_OR_EQUAL(vertexStride, 4, ());