Skip to content

Commit

Permalink
Small compilation fixes (#7363)
Browse files Browse the repository at this point in the history
- gltfio: Enable -Wall -Werror for gltfio_core
 - gltfio: Fix various errors that were missed warnings
 - matdbg: switch from std::atomic_uint64_t to
   std::atomic<uint64_t> for older clang
  • Loading branch information
poweifeng committed Nov 14, 2023
1 parent 57aa99e commit 0d30439
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 18 deletions.
11 changes: 6 additions & 5 deletions libs/gltfio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ if (WEBGL_PTHREADS)
target_compile_definitions(gltfio_core PUBLIC -DFILAMENT_WASM_THREADS)
endif()

set(GLTFIO_WARNINGS -Wall -Werror)
if (NOT MSVC)
target_compile_options(gltfio_core PRIVATE ${GLTFIO_WARNINGS})
endif()

if (NOT WEBGL AND NOT ANDROID AND NOT IOS)

# ==================================================================================================
Expand All @@ -185,10 +190,6 @@ if (NOT WEBGL AND NOT ANDROID AND NOT IOS)
target_link_libraries(${TARGET} PUBLIC filamat gltfio_core)
target_include_directories(${TARGET} PUBLIC ${PUBLIC_HDR_DIR})
set_target_properties(${TARGET} PROPERTIES FOLDER Libs)

# ==================================================================================================
# Compiler flags
# ==================================================================================================
if (NOT MSVC)
target_compile_options(${TARGET} PRIVATE -Wno-deprecated-register)
endif()
Expand Down Expand Up @@ -229,7 +230,7 @@ if (TNT_DEV AND NOT WEBGL AND NOT ANDROID AND NOT IOS)

target_link_libraries(${TEST_TARGET} PRIVATE ${TARGET} gtest uberarchive)
if (NOT MSVC)
target_compile_options(${TEST_TARGET} PRIVATE -Wno-deprecated-register)
target_compile_options(${TEST_TARGET} PRIVATE ${GLTFIO_WARNINGS})
endif()
set_target_properties(${TEST_TARGET} PROPERTIES FOLDER Tests)
endif()
Expand Down
1 change: 0 additions & 1 deletion libs/gltfio/include/gltfio/ResourceLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ class UTILS_PUBLIC ResourceLoader {
private:
bool loadResources(FFilamentAsset* asset, bool async);
void normalizeSkinningWeights(FFilamentAsset* asset) const;
AssetPool* mPool;
struct Impl;
Impl* pImpl;
};
Expand Down
4 changes: 2 additions & 2 deletions libs/gltfio/src/AssetLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#include <math/vec3.h>
#include <math/vec4.h>

#include <utils/compiler.h>
#include <utils/EntityManager.h>
#include <utils/FixedCapacityVector.h>
#include <utils/Log.h>
Expand Down Expand Up @@ -768,7 +769,6 @@ void FAssetLoader::createRenderable(const cgltf_node* node, Entity entity, const

void FAssetLoader::createMaterialVariants(const cgltf_mesh* mesh, Entity entity,
FFilamentAsset* fAsset, FFilamentInstance* instance) {
const cgltf_data* srcAsset = fAsset->mSourceAsset->hierarchy;
UvMap uvmap {};
for (cgltf_size prim = 0, n = mesh->primitives_count; prim < n; ++prim) {
const cgltf_primitive& srcPrim = mesh->primitives[prim];
Expand Down Expand Up @@ -1076,7 +1076,7 @@ bool FAssetLoader::createPrimitive(const cgltf_primitive& inPrim, const char* na
.build(mEngine);
outPrim->targets = targets;
fAsset->mMorphTargetBuffers.push_back(targets);
const cgltf_accessor* previous = nullptr;
UTILS_UNUSED_IN_RELEASE cgltf_accessor const* previous = nullptr;
for (int tindex = 0; tindex < targetsCount; ++tindex) {
const cgltf_morph_target& inTarget = inPrim.targets[tindex];
for (cgltf_size aindex = 0; aindex < inTarget.attributes_count; ++aindex) {
Expand Down
3 changes: 2 additions & 1 deletion libs/gltfio/src/DracoCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include <draco/compression/decode.h>
#endif

#include <utils/compiler.h>
#include <utils/Log.h>

#if GLTFIO_DRACO_SUPPORTED
Expand Down Expand Up @@ -65,7 +66,7 @@ DracoMesh::~DracoMesh() {
}

// Gets the number of components in the given cgltf vector type, or -1 for matrices.
static int getNumComponents(cgltf_type ctype) {
UTILS_UNUSED_IN_RELEASE static int getNumComponents(cgltf_type ctype) {
return ((int) ctype) <= 4 ? ((int) ctype) : -1;
}

Expand Down
2 changes: 1 addition & 1 deletion libs/gltfio/src/FFilamentAsset.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace utils {

namespace filament::gltfio {

class Wireframe;
struct Wireframe;

// Encapsulates VertexBuffer::setBufferAt() or IndexBuffer::setBuffer().
struct BufferSlot {
Expand Down
2 changes: 1 addition & 1 deletion libs/gltfio/src/Ktx2Provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Texture* Ktx2Provider::pushTexture(const uint8_t* data, size_t byteCount,
}

JobSystem* js = &mEngine->getJobSystem();
item->job = jobs::createJob(*js, mDecoderRootJob, [this, item] {
item->job = jobs::createJob(*js, mDecoderRootJob, [item] {
using Result = ktxreader::Ktx2Reader::Result;
const bool success = Result::SUCCESS == item->async->doTranscoding();
item->transcoderState.store(success ? TranscoderState::SUCCESS : TranscoderState::ERROR);
Expand Down
3 changes: 2 additions & 1 deletion libs/gltfio/src/ResourceLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <geometry/Transcoder.h>

#include <utils/compiler.h>
#include <utils/JobSystem.h>
#include <utils/Log.h>
#include <utils/Systrace.h>
Expand Down Expand Up @@ -243,7 +244,7 @@ static void decodeMeshoptCompression(cgltf_data* data) {
void* destination = malloc(compression->count * compression->stride);
assert_invariant(destination);

int error = 0;
UTILS_UNUSED_IN_RELEASE int error = 0;
switch (compression->mode) {
case cgltf_meshopt_compression_mode_invalid:
break;
Expand Down
2 changes: 1 addition & 1 deletion libs/gltfio/src/StbProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ Texture* StbProvider::pushTexture(const uint8_t* data, size_t byteCount,
}

JobSystem* js = &mEngine->getJobSystem();
info->decoderJob = jobs::createJob(*js, mDecoderRootJob, [this, info] {
info->decoderJob = jobs::createJob(*js, mDecoderRootJob, [info] {
auto& source = info->sourceBuffer;
int width, height, comp;

Expand Down
4 changes: 0 additions & 4 deletions libs/gltfio/test/gltfio_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ using namespace backend;
using namespace gltfio;
using namespace utils;

constexpr uint32_t WIDTH = 64;
constexpr uint32_t HEIGHT = 64;

char const* ANIMATED_MORPH_CUBE_GLB = "AnimatedMorphCube.glb";

static std::ifstream::pos_type getFileSize(const char* filename) {
Expand Down Expand Up @@ -178,7 +175,6 @@ do { \
TEST_F(glTFIOTest, AnimatedMorphCubeTransforms) {
FilamentAsset const& morphCubeAsset = *mData[ANIMATED_MORPH_CUBE_GLB]->getAsset();
auto const& transformManager = mEngine->getTransformManager();
auto const& renderableManager = mEngine->getRenderableManager();
Entity const* renderables = morphCubeAsset.getRenderableEntities();

EXPECT_EQ(morphCubeAsset.getRenderableEntityCount(), 1u);
Expand Down
2 changes: 1 addition & 1 deletion libs/matdbg/src/ApiHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ApiHandler : public CivetHandler {
// This variable is to implement a *hanging* effect for /api/status. The call to /api/status
// will always block until statusMaterialId is updated again. The client is expected to keep
// calling /api/status (a constant "pull" to simulate a push).
std::atomic_uint64_t mCurrentStatus = 0;
std::atomic<uint64_t> mCurrentStatus = 0;
};

} // filament::matdbg
Expand Down

0 comments on commit 0d30439

Please sign in to comment.