diff --git a/filament/src/Froxelizer.cpp b/filament/src/Froxelizer.cpp index 2c9605c635..9c3069754a 100644 --- a/filament/src/Froxelizer.cpp +++ b/filament/src/Froxelizer.cpp @@ -167,12 +167,12 @@ bool Froxelizer::prepare( // froxel buffer (~32 KiB) mFroxelBufferUser = { - driverApi.allocatePod(FROXEL_BUFFER_ENTRY_COUNT_MAX, CACHELINE_SIZE), + driverApi.allocatePod(FROXEL_BUFFER_ENTRY_COUNT_MAX), FROXEL_BUFFER_ENTRY_COUNT_MAX }; // record buffer (~64 KiB) mRecordBufferUser = { - driverApi.allocatePod(RECORD_BUFFER_ENTRY_COUNT, CACHELINE_SIZE), + driverApi.allocatePod(RECORD_BUFFER_ENTRY_COUNT), RECORD_BUFFER_ENTRY_COUNT }; /* diff --git a/libs/utils/include/utils/JobSystem.h b/libs/utils/include/utils/JobSystem.h index 50a0d30488..c0b1c429e5 100644 --- a/libs/utils/include/utils/JobSystem.h +++ b/libs/utils/include/utils/JobSystem.h @@ -46,29 +46,31 @@ public: using JobFunc = void(*)(void*, JobSystem&, Job*); - class alignas(CACHELINE_SIZE) Job { // NOLINT(cppcoreguidelines-pro-type-member-init) + class alignas(CACHELINE_SIZE) Job { public: - Job() noexcept {} // = default; + Job() noexcept {} /* = default; */ /* clang bug */ // NOLINT(modernize-use-equals-default,cppcoreguidelines-pro-type-member-init) Job(const Job&) = delete; Job(Job&&) = delete; - void* getData() { return storage; } - void const* getData() const { return storage; } private: friend class JobSystem; - // Size is chosen so that we can store at least std::function<>, the alignas() qualifier - // ensures we're multiple of a cache-line. - static constexpr size_t JOB_STORAGE_SIZE = (sizeof(std::function) + sizeof(void*) - 1) / sizeof(void*); + // Size is chosen so that we can store at least std::function<> + // the alignas() qualifier ensures we're multiple of a cache-line. + static constexpr size_t JOB_STORAGE_SIZE = // NOLINT(cert-err58-cpp) + (std::max(sizeof(std::function), size_t(48)) + sizeof(void*) - 1) + / sizeof(void*); // keep it first, so it's correctly aligned with all architectures - // this is were we store the job's data, typically a std::function - void* storage[JOB_STORAGE_SIZE]; - - JobFunc function; - uint16_t parent; - std::atomic runningJobCount = { 1 }; - mutable std::atomic refCount = { 1 }; + // this is were we store the job's data, typically a std::function<> + // v7 | v8 + void* storage[JOB_STORAGE_SIZE]; // 48 | 48 + JobFunc function; // 4 | 8 + uint16_t parent; // 2 | 2 + std::atomic runningJobCount = { 1 }; // 2 | 2 + mutable std::atomic refCount = { 1 }; // 2 | 2 + // 6 | 2 (padding) + // 64 | 64 }; explicit JobSystem(size_t threadCount = 0, size_t adoptableThreadsCount = 1) noexcept; diff --git a/libs/utils/include/utils/architecture.h b/libs/utils/include/utils/architecture.h index f9e029b866..83b1179406 100644 --- a/libs/utils/include/utils/architecture.h +++ b/libs/utils/include/utils/architecture.h @@ -21,13 +21,7 @@ namespace utils { -#ifdef __ARM_32BIT_STATE -// on ARM 32-bits, assume 32-bytes cache lines -constexpr size_t CACHELINE_SIZE = 32; -#else -// on ARM64 and x86 we assume 64-bytes cache lines constexpr size_t CACHELINE_SIZE = 64; -#endif } // namespace utils