commit
354cf46b51
|
@ -7,10 +7,10 @@ on:
|
||||||
branches: [ master ]
|
branches: [ master ]
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read # to fetch code (actions/checkout)
|
contents: write # to fetch code (actions/checkout),and release
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
job:
|
build:
|
||||||
name: ${{ matrix.name }}-build-and-test
|
name: ${{ matrix.name }}-build-and-test
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
|
@ -93,12 +93,12 @@ jobs:
|
||||||
- name: Set Windows specific CMake arguments
|
- name: Set Windows specific CMake arguments
|
||||||
if: contains(matrix.name, 'windows')
|
if: contains(matrix.name, 'windows')
|
||||||
id: windows_extra_cmake_args
|
id: windows_extra_cmake_args
|
||||||
run: echo "::set-output name=args::-DASSIMP_BUILD_ASSIMP_TOOLS=1 -DASSIMP_BUILD_ASSIMP_VIEW=1 -DASSIMP_BUILD_ZLIB=1"
|
run: echo ":set-output name=args::=-DASSIMP_BUILD_ASSIMP_TOOLS=1 -DASSIMP_BUILD_ASSIMP_VIEW=1" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Set Hunter specific CMake arguments
|
- name: Set Hunter specific CMake arguments
|
||||||
if: contains(matrix.name, 'hunter')
|
if: contains(matrix.name, 'hunter')
|
||||||
id: hunter_extra_cmake_args
|
id: hunter_extra_cmake_args
|
||||||
run: echo "::set-output name=args::-DBUILD_SHARED_LIBS=OFF -DASSIMP_HUNTER_ENABLED=ON -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/polly/${{ matrix.toolchain }}.cmake"
|
run: echo "args=-DBUILD_SHARED_LIBS=OFF -DASSIMP_HUNTER_ENABLED=ON -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/cmake/polly/${{ matrix.toolchain }}.cmake" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: configure and build
|
- name: configure and build
|
||||||
uses: lukka/run-cmake@v3
|
uses: lukka/run-cmake@v3
|
||||||
|
@ -115,14 +115,98 @@ jobs:
|
||||||
- name: Exclude certain tests in Hunter specific builds
|
- name: Exclude certain tests in Hunter specific builds
|
||||||
if: contains(matrix.name, 'hunter')
|
if: contains(matrix.name, 'hunter')
|
||||||
id: hunter_extra_test_args
|
id: hunter_extra_test_args
|
||||||
run: echo "::set-output name=args::--gtest_filter=-utOpenGEXImportExport.Importissue1340_EmptyCameraObject:utColladaZaeImportExport.importBlenFromFileTest"
|
run: echo "args=--gtest_filter=-utOpenGEXImportExport.Importissue1340_EmptyCameraObject:utColladaZaeImportExport.importBlenFromFileTest" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: test
|
- name: test
|
||||||
run: cd build/bin && ./unit ${{ steps.hunter_extra_test_args.outputs.args }}
|
run: cd build/bin && ./unit ${{ steps.hunter_extra_test_args.outputs.args }}
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
- uses: actions/upload-artifact@v3
|
- uses: actions/upload-artifact@v3
|
||||||
if: matrix.name == 'windows-msvc'
|
if: contains(matrix.name,'windows')
|
||||||
|
with:
|
||||||
|
name: 'assimp-bins-${{ matrix.name }}'
|
||||||
|
path: build/bin/assimp*.exe
|
||||||
|
|
||||||
|
- uses: marvinpinto/action-automatic-releases@latest
|
||||||
|
if: contains(matrix.name, 'windows-msvc-hunter')
|
||||||
|
with:
|
||||||
|
repo_token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
automatic_release_tag: "master"
|
||||||
|
prerelease: true
|
||||||
|
title: "AutoRelease"
|
||||||
|
files: |
|
||||||
|
build/bin/assimp*.exe
|
||||||
|
|
||||||
|
create-release:
|
||||||
|
needs: [build]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
steps:
|
||||||
|
- id: create-release
|
||||||
|
uses: actions/create-release@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: '${{secrets.GITHUB_TOKEN}}'
|
||||||
|
with:
|
||||||
|
tag_name: '${{github.ref}}'
|
||||||
|
release_name: 'Release ${{github.ref}}'
|
||||||
|
draft: false
|
||||||
|
prerelease: true
|
||||||
|
- run: |
|
||||||
|
echo '${{steps.create-release.outputs.upload_url}}' > release_upload_url.txt
|
||||||
|
- uses: actions/upload-artifact@v1
|
||||||
|
with:
|
||||||
|
name: create-release
|
||||||
|
path: release_upload_url.txt
|
||||||
|
|
||||||
|
upload-release:
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
name: [ubuntu-latest-g++, macos-latest-clang++, windows-latest-cl.exe, ubuntu-latest-clang++, ubuntu-gcc-hunter, macos-clang-hunter, windows-msvc-hunter]
|
||||||
|
# For Windows msvc, for Linux and macOS let's use the clang compiler, use gcc for Linux.
|
||||||
|
include:
|
||||||
|
- name: windows-latest-cl.exe
|
||||||
|
os: windows-latest
|
||||||
|
cxx: cl.exe
|
||||||
|
cc: cl.exe
|
||||||
|
- name: ubuntu-latest-clang++
|
||||||
|
os: ubuntu-latest
|
||||||
|
cxx: clang++
|
||||||
|
cc: clang
|
||||||
|
- name: macos-latest-clang++
|
||||||
|
os: macos-latest
|
||||||
|
cxx: clang++
|
||||||
|
cc: clang
|
||||||
|
- name: ubuntu-latest-g++
|
||||||
|
os: ubuntu-latest
|
||||||
|
cxx: g++
|
||||||
|
cc: gcc
|
||||||
|
- name: ubuntu-gcc-hunter
|
||||||
|
os: ubuntu-latest
|
||||||
|
toolchain: ninja-gcc-cxx17-fpic
|
||||||
|
- name: macos-clang-hunter
|
||||||
|
os: macos-latest
|
||||||
|
toolchain: ninja-clang-cxx17-fpic
|
||||||
|
- name: windows-msvc-hunter
|
||||||
|
os: windows-latest
|
||||||
|
toolchain: ninja-vs-win64-cxx17
|
||||||
|
|
||||||
|
needs: [create-release]
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
steps:
|
||||||
|
- uses: softprops/action-gh-release@v1
|
||||||
|
with:
|
||||||
|
name: create-release
|
||||||
|
- id: upload-url
|
||||||
|
run: |
|
||||||
|
echo "url=$(cat create-release/release_upload_url.txt)" >> $GITHUB_OUTPUT
|
||||||
|
- uses: actions/download-artifact@v1
|
||||||
with:
|
with:
|
||||||
name: 'assimp-bins-${{ matrix.name }}-${{ github.sha }}'
|
name: 'assimp-bins-${{ matrix.name }}-${{ github.sha }}'
|
||||||
path: build/bin
|
- uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: '${{secrets.GITHUB_TOKEN}}'
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
*.zip
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,7 @@
|
||||||
Open Asset Import Library (assimp)
|
Open Asset Import Library (assimp)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 2006-2022, assimp team
|
Copyright (c) 2006-2023, assimp team
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
|
@ -59,12 +57,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
|
|
||||||
using namespace Assimp;
|
namespace Assimp {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Constructor to be privately used by Importer
|
// Constructor to be privately used by Importer
|
||||||
ImproveCacheLocalityProcess::ImproveCacheLocalityProcess()
|
ImproveCacheLocalityProcess::ImproveCacheLocalityProcess() :
|
||||||
: mConfigCacheDepth(PP_ICL_PTCACHE_SIZE) {
|
mConfigCacheDepth(PP_ICL_PTCACHE_SIZE) {
|
||||||
// empty
|
// empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,36 +108,13 @@ void ImproveCacheLocalityProcess::Execute( aiScene* pScene) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------------------------
|
||||||
// Improves the cache coherency of a specific mesh
|
static ai_real calculateInputACMR(aiMesh *pMesh, const aiFace *const pcEnd,
|
||||||
ai_real ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int meshNum) {
|
unsigned int configCacheDepth, unsigned int meshNum) {
|
||||||
// TODO: rewrite this to use std::vector or boost::shared_array
|
ai_real fACMR = 0.0f;
|
||||||
ai_assert(nullptr != pMesh);
|
unsigned int *piFIFOStack = new unsigned int[configCacheDepth];
|
||||||
|
memset(piFIFOStack, 0xff, configCacheDepth * sizeof(unsigned int));
|
||||||
// Check whether the input data is valid
|
|
||||||
// - there must be vertices and faces
|
|
||||||
// - all faces must be triangulated or we can't operate on them
|
|
||||||
if (!pMesh->HasFaces() || !pMesh->HasPositions())
|
|
||||||
return static_cast<ai_real>(0.f);
|
|
||||||
|
|
||||||
if (pMesh->mPrimitiveTypes != aiPrimitiveType_TRIANGLE) {
|
|
||||||
ASSIMP_LOG_ERROR("This algorithm works on triangle meshes only");
|
|
||||||
return static_cast<ai_real>(0.f);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(pMesh->mNumVertices <= mConfigCacheDepth) {
|
|
||||||
return static_cast<ai_real>(0.f);
|
|
||||||
}
|
|
||||||
|
|
||||||
ai_real fACMR = 3.f;
|
|
||||||
const aiFace* const pcEnd = pMesh->mFaces+pMesh->mNumFaces;
|
|
||||||
|
|
||||||
// Input ACMR is for logging purposes only
|
|
||||||
if (!DefaultLogger::isNullLogger()) {
|
|
||||||
|
|
||||||
unsigned int* piFIFOStack = new unsigned int[mConfigCacheDepth];
|
|
||||||
memset(piFIFOStack,0xff,mConfigCacheDepth*sizeof(unsigned int));
|
|
||||||
unsigned int *piCur = piFIFOStack;
|
unsigned int *piCur = piFIFOStack;
|
||||||
const unsigned int* const piCurEnd = piFIFOStack + mConfigCacheDepth;
|
const unsigned int *const piCurEnd = piFIFOStack + configCacheDepth;
|
||||||
|
|
||||||
// count the number of cache misses
|
// count the number of cache misses
|
||||||
unsigned int iCacheMisses = 0;
|
unsigned int iCacheMisses = 0;
|
||||||
|
@ -174,21 +149,53 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int me
|
||||||
ASSIMP_LOG_WARN(szBuff);
|
ASSIMP_LOG_WARN(szBuff);
|
||||||
return static_cast<ai_real>(0.f);
|
return static_cast<ai_real>(0.f);
|
||||||
}
|
}
|
||||||
|
return fACMR;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------------------------------
|
||||||
|
// Improves the cache coherency of a specific mesh
|
||||||
|
ai_real ImproveCacheLocalityProcess::ProcessMesh(aiMesh *pMesh, unsigned int meshNum) {
|
||||||
|
// TODO: rewrite this to use std::vector or boost::shared_array
|
||||||
|
ai_assert(nullptr != pMesh);
|
||||||
|
|
||||||
|
// Check whether the input data is valid
|
||||||
|
// - there must be vertices and faces
|
||||||
|
// - all faces must be triangulated or we can't operate on them
|
||||||
|
if (!pMesh->HasFaces() || !pMesh->HasPositions())
|
||||||
|
return static_cast<ai_real>(0.f);
|
||||||
|
|
||||||
|
if (pMesh->mPrimitiveTypes != aiPrimitiveType_TRIANGLE) {
|
||||||
|
ASSIMP_LOG_ERROR("This algorithm works on triangle meshes only");
|
||||||
|
return static_cast<ai_real>(0.f);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pMesh->mNumVertices <= mConfigCacheDepth) {
|
||||||
|
return static_cast<ai_real>(0.f);
|
||||||
|
}
|
||||||
|
|
||||||
|
ai_real fACMR = 3.f;
|
||||||
|
const aiFace *const pcEnd = pMesh->mFaces + pMesh->mNumFaces;
|
||||||
|
|
||||||
|
// Input ACMR is for logging purposes only
|
||||||
|
if (!DefaultLogger::isNullLogger()) {
|
||||||
|
fACMR = calculateInputACMR(pMesh, pcEnd, mConfigCacheDepth, meshNum);
|
||||||
}
|
}
|
||||||
|
|
||||||
// first we need to build a vertex-triangle adjacency list
|
// first we need to build a vertex-triangle adjacency list
|
||||||
VertexTriangleAdjacency adj(pMesh->mFaces, pMesh->mNumFaces, pMesh->mNumVertices, true);
|
VertexTriangleAdjacency adj(pMesh->mFaces, pMesh->mNumFaces, pMesh->mNumVertices, true);
|
||||||
|
|
||||||
// build a list to store per-vertex caching time stamps
|
// build a list to store per-vertex caching time stamps
|
||||||
unsigned int* const piCachingStamps = new unsigned int[pMesh->mNumVertices];
|
std::vector<unsigned int> piCachingStamps;
|
||||||
memset(piCachingStamps,0x0,pMesh->mNumVertices*sizeof(unsigned int));
|
piCachingStamps.resize(pMesh->mNumVertices);
|
||||||
|
memset(&piCachingStamps[0], 0x0, pMesh->mNumVertices * sizeof(unsigned int));
|
||||||
|
|
||||||
// allocate an empty output index buffer. We store the output indices in one large array.
|
// allocate an empty output index buffer. We store the output indices in one large array.
|
||||||
// Since the number of triangles won't change the input faces can be reused. This is how
|
// Since the number of triangles won't change the input faces can be reused. This is how
|
||||||
// we save thousands of redundant mini allocations for aiFace::mIndices
|
// we save thousands of redundant mini allocations for aiFace::mIndices
|
||||||
const unsigned int iIdxCnt = pMesh->mNumFaces * 3;
|
const unsigned int iIdxCnt = pMesh->mNumFaces * 3;
|
||||||
unsigned int* const piIBOutput = new unsigned int[iIdxCnt];
|
std::vector<unsigned int> piIBOutput;
|
||||||
unsigned int* piCSIter = piIBOutput;
|
piIBOutput.resize(iIdxCnt);
|
||||||
|
std::vector<unsigned int>::iterator piCSIter = piIBOutput.begin();
|
||||||
|
|
||||||
// allocate the flag array to hold the information
|
// allocate the flag array to hold the information
|
||||||
// whether a face has already been emitted or not
|
// whether a face has already been emitted or not
|
||||||
|
@ -202,7 +209,8 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int me
|
||||||
const std::vector<unsigned int> piNumTriPtrNoModify(piNumTriPtr, piNumTriPtr + pMesh->mNumVertices);
|
const std::vector<unsigned int> piNumTriPtrNoModify(piNumTriPtr, piNumTriPtr + pMesh->mNumVertices);
|
||||||
|
|
||||||
// get the largest number of referenced triangles and allocate the "candidate buffer"
|
// get the largest number of referenced triangles and allocate the "candidate buffer"
|
||||||
unsigned int iMaxRefTris = 0; {
|
unsigned int iMaxRefTris = 0;
|
||||||
|
{
|
||||||
const unsigned int *piCur = adj.mLiveTriangles;
|
const unsigned int *piCur = adj.mLiveTriangles;
|
||||||
const unsigned int *const piCurEnd = adj.mLiveTriangles + pMesh->mNumVertices;
|
const unsigned int *const piCurEnd = adj.mLiveTriangles + pMesh->mNumVertices;
|
||||||
for (; piCur != piCurEnd; ++piCur) {
|
for (; piCur != piCurEnd; ++piCur) {
|
||||||
|
@ -210,7 +218,8 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int me
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ai_assert(iMaxRefTris > 0);
|
ai_assert(iMaxRefTris > 0);
|
||||||
unsigned int* piCandidates = new unsigned int[iMaxRefTris*3];
|
std::vector<unsigned int> piCandidates;
|
||||||
|
piCandidates.resize(iMaxRefTris * 3);
|
||||||
unsigned int iCacheMisses = 0;
|
unsigned int iCacheMisses = 0;
|
||||||
|
|
||||||
// ...................................................................................
|
// ...................................................................................
|
||||||
|
@ -250,7 +259,7 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int me
|
||||||
|
|
||||||
unsigned int icnt = piNumTriPtrNoModify[ivdx];
|
unsigned int icnt = piNumTriPtrNoModify[ivdx];
|
||||||
unsigned int *piList = adj.GetAdjacentTriangles(ivdx);
|
unsigned int *piList = adj.GetAdjacentTriangles(ivdx);
|
||||||
unsigned int* piCurCandidate = piCandidates;
|
std::vector<unsigned int>::iterator piCurCandidate = piCandidates.begin();
|
||||||
|
|
||||||
// get all triangles in the neighborhood
|
// get all triangles in the neighborhood
|
||||||
for (unsigned int tri = 0; tri < icnt; ++tri) {
|
for (unsigned int tri = 0; tri < icnt; ++tri) {
|
||||||
|
@ -261,7 +270,7 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int me
|
||||||
|
|
||||||
// so iterate through all vertices of the current triangle
|
// so iterate through all vertices of the current triangle
|
||||||
const aiFace *pcFace = &pMesh->mFaces[fidx];
|
const aiFace *pcFace = &pMesh->mFaces[fidx];
|
||||||
unsigned nind = pcFace->mNumIndices;
|
const unsigned nind = pcFace->mNumIndices;
|
||||||
for (unsigned ind = 0; ind < nind; ind++) {
|
for (unsigned ind = 0; ind < nind; ind++) {
|
||||||
unsigned dp = pcFace->mIndices[ind];
|
unsigned dp = pcFace->mIndices[ind];
|
||||||
|
|
||||||
|
@ -297,7 +306,7 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int me
|
||||||
// get next fanning vertex
|
// get next fanning vertex
|
||||||
ivdx = -1;
|
ivdx = -1;
|
||||||
int max_priority = -1;
|
int max_priority = -1;
|
||||||
for (unsigned int* piCur = piCandidates;piCur != piCurCandidate;++piCur) {
|
for (std::vector<unsigned int>::iterator piCur = piCandidates.begin(); piCur != piCurCandidate; ++piCur) {
|
||||||
const unsigned int dp = *piCur;
|
const unsigned int dp = *piCur;
|
||||||
|
|
||||||
// must have live triangles
|
// must have live triangles
|
||||||
|
@ -345,29 +354,29 @@ ai_real ImproveCacheLocalityProcess::ProcessMesh( aiMesh* pMesh, unsigned int me
|
||||||
}
|
}
|
||||||
ai_real fACMR2 = 0.0f;
|
ai_real fACMR2 = 0.0f;
|
||||||
if (!DefaultLogger::isNullLogger()) {
|
if (!DefaultLogger::isNullLogger()) {
|
||||||
fACMR2 = (float)iCacheMisses / pMesh->mNumFaces;
|
fACMR2 = static_cast<ai_real>(iCacheMisses / pMesh->mNumFaces);
|
||||||
|
const ai_real averageACMR = ((fACMR - fACMR2) / fACMR) * 100.f;
|
||||||
// very intense verbose logging ... prepare for much text if there are many meshes
|
// very intense verbose logging ... prepare for much text if there are many meshes
|
||||||
if (DefaultLogger::get()->getLogSeverity() == Logger::VERBOSE) {
|
if (DefaultLogger::get()->getLogSeverity() == Logger::VERBOSE) {
|
||||||
ASSIMP_LOG_VERBOSE_DEBUG("Mesh %u | ACMR in: ", meshNum, " out: ", fACMR, " | ~", fACMR2, ((fACMR - fACMR2) / fACMR) * 100.f);
|
ASSIMP_LOG_VERBOSE_DEBUG("Mesh ", meshNum, "| ACMR in: ", fACMR, " out: ", fACMR2, " | average ACMR ", averageACMR);
|
||||||
}
|
}
|
||||||
|
|
||||||
fACMR2 *= pMesh->mNumFaces;
|
fACMR2 *= pMesh->mNumFaces;
|
||||||
}
|
}
|
||||||
|
|
||||||
// sort the output index buffer back to the input array
|
// sort the output index buffer back to the input array
|
||||||
piCSIter = piIBOutput;
|
piCSIter = piIBOutput.begin();
|
||||||
for (aiFace *pcFace = pMesh->mFaces; pcFace != pcEnd; ++pcFace) {
|
for (aiFace *pcFace = pMesh->mFaces; pcFace != pcEnd; ++pcFace) {
|
||||||
unsigned nind = pcFace->mNumIndices;
|
unsigned nind = pcFace->mNumIndices;
|
||||||
unsigned *ind = pcFace->mIndices;
|
unsigned *ind = pcFace->mIndices;
|
||||||
if (nind > 0) ind[0] = *piCSIter++;
|
if (nind > 0)
|
||||||
if (nind > 1) ind[1] = *piCSIter++;
|
ind[0] = *piCSIter++;
|
||||||
if (nind > 2) ind[2] = *piCSIter++;
|
if (nind > 1)
|
||||||
|
ind[1] = *piCSIter++;
|
||||||
|
if (nind > 2)
|
||||||
|
ind[2] = *piCSIter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// delete temporary storage
|
|
||||||
delete[] piCachingStamps;
|
|
||||||
delete[] piIBOutput;
|
|
||||||
delete[] piCandidates;
|
|
||||||
|
|
||||||
return fACMR2;
|
return fACMR2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // namespace Assimp
|
||||||
|
|
Loading…
Reference in New Issue