Skip to content

Commit

Permalink
Fix warnings in the compilation and tests (#2223)
Browse files Browse the repository at this point in the history
* Fix warnings in the compilation and tests

* Fix more warnings

* Attempt to fix darwin warnings
  • Loading branch information
sebastienblor authored Feb 5, 2025
1 parent b6233d7 commit 7bb1bb9
Show file tree
Hide file tree
Showing 37 changed files with 67 additions and 91 deletions.
9 changes: 8 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,14 @@ elif is_windows:
if env['BOOST_ALL_NO_LIB']:
env.Append(CPPDEFINES = Split('BOOST_ALL_NO_LIB HBOOST_ALL_NO_LIB'))

env.Append(CPPDEFINES = Split('TBB_SUPPRESS_DEPRECATED_MESSAGES'))

# This definition allows to re-enable deprecated function when using c++17 headers, this fixes the compilation issue
# error: no template named 'unary_function' in namespace 'std'
if env['_COMPILER'] == 'clang':
env.Append(CPPDEFINES = Split('_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION'))
env.Append(CCFLAGS = Split('-Wno-deprecated -Wno-deprecated-declarations -Wno-deprecated-builtins'))


# If USD is built in static, we need to define PXR_STATIC in order to hide the symbols
if env['USD_BUILD_MODE'] == 'static':
Expand Down Expand Up @@ -426,7 +430,7 @@ elif env['_COMPILER'] == 'msvc':
env.Append(LINKFLAGS=Split('/ignore:4099'))
env.Append(LINKFLAGS=Split('/ignore:4217'))

env.Append(CCFLAGS=Split('/D "NOMINMAX" /D "TBB_SUPPRESS_DEPRECATED_MESSAGES" /Zc:inline-'))
env.Append(CCFLAGS=Split('/D "NOMINMAX" /Zc:inline-'))
# Optimization/profile/debug flags
if env['MODE'] == 'opt':
env.Append(CCFLAGS=Split('/O2 /Oi /Ob2 /MD'))
Expand All @@ -437,6 +441,9 @@ elif env['_COMPILER'] == 'msvc':
env.Append(CCFLAGS=Split('/Od /Zi /MD'))
env.Append(LINKFLAGS=Split('/DEBUG'))

if env['WARN_LEVEL'] == 'strict':
env.Append(CCFLAGS=Split('/WX'))


if not env['SHOW_CMDS']:
# Hide long compile lines from the user
Expand Down
2 changes: 0 additions & 2 deletions libs/common/materials_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ ShaderReadFunc ReadPreviewSurface = [](const std::string& nodeName,
// Create a subtract shader that will be connected to the transmission
AtNode *subtractNode = materialReader.CreateArnoldNode("subtract", subtractNodeName.c_str());
AiNodeSetRGB(subtractNode, str::input1, 1.f, 1.f, 1.f);
float opacity;
const InputAttribute& attr = opacityAttr->second;
if (!attr.connection.IsEmpty()) {
materialReader.ConnectShader(subtractNode, "input2", attr.connection, ArnoldAPIAdapter::CONNECTION_LINK);
Expand Down Expand Up @@ -271,7 +270,6 @@ ShaderReadFunc ReadPrimvarFloat2 = [](const std::string& nodeName,
// means that we should be looking at the builtin uv coordinates.

std::string varName;
GfVec2f fallback(0.f);
AtNode* node = nullptr;
const auto varnameAttr = inputAttrs.find(str::t_varname);
if (varnameAttr != inputAttrs.end()) {
Expand Down
2 changes: 1 addition & 1 deletion libs/common/parameters_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ uint32_t DeclareAndAssignParameter(
// - If the value has more than one element, and the scope is "constant", we want a constant array
// - If the attribute name is "displayColor" and has a single element, we want a constant user data
bool isConstant = !isArray ||
(scope == str::t_constant || name == str::t_displayColor) && arraySize <= 1;
((scope == str::t_constant || name == str::t_displayColor) && arraySize <= 1);

uint8_t type = GetArnoldTypeFromValue(value, !isArray , isArray);

Expand Down
2 changes: 1 addition & 1 deletion libs/common/procedural_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ bool ProceduralReader::Read(long int cacheId, const std::string &path)

UsdStageRefPtr stage = (id.IsValid()) ? stageCache.Find(id) : nullptr;
if (!stage) {
AiMsgWarning("[usd] Cache ID not valid %d", cacheId);
AiMsgWarning("[usd] Cache ID not valid %ld", cacheId);
_cacheId = 0;
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions libs/common/rendersettings_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ AtNode * ReadDriverFromRenderProduct(const UsdRenderProduct &renderProduct, Arno
const std::string attrName = attr.GetName().GetString();
if (TfStringStartsWith(attrName, driverParamPrefix)) {
const std::string driverParamName = attrName.substr(driverParamPrefix.size());
const AtParamEntry *paramEntry = AiNodeEntryLookUpParameter(AiNodeGetNodeEntry(driver), driverParamName.c_str());
const AtParamEntry *paramEntry = AiNodeEntryLookUpParameter(AiNodeGetNodeEntry(driver), AtString(driverParamName.c_str()));
if (!paramEntry) {
continue;
}
Expand Down Expand Up @@ -304,7 +304,7 @@ AtNode * DeduceDriverFromFilename(const UsdRenderProduct &renderProduct, ArnoldA
const std::string attrName = attr.GetName().GetString();
if (TfStringStartsWith(attrName, arnoldPrefix)) {
const std::string driverParamName = attrName.substr(arnoldPrefix.size());
const AtParamEntry *paramEntry = AiNodeEntryLookUpParameter(AiNodeGetNodeEntry(driver), driverParamName.c_str());
const AtParamEntry *paramEntry = AiNodeEntryLookUpParameter(AiNodeGetNodeEntry(driver), AtString(driverParamName.c_str()));
if (!paramEntry) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion libs/common/shape_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ void ArnoldUsdCurvesData::SetOrientationFromValue(AtNode* node, const VtValue& v

const VtVec3fArray& values = value.UncheckedGet<VtVec3fArray>();
// Arnold requires the amount of orientation values to be the same as the amount of points
if (values.size() == _numPoints) {
if (values.size() == (size_t)_numPoints) {
AiNodeSetArray(node, str::orientations, AiArrayConvert(values.size(), 1, AI_TYPE_VECTOR, values.data()));
// If orientation is set on the arnold curves, then the mode needs to be "oriented"
AiNodeSetStr(node, str::mode, str::oriented);
Expand Down
4 changes: 2 additions & 2 deletions libs/render_delegate/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void _RemapNormalKeys(size_t inputCount, size_t requiredCount, T &sample)
remappedInput *= inputCount;
int floorIndex = (int) remappedInput;
float remappedDelta = remappedInput - floorIndex;
if (remappedDelta < AI_EPSILON || floorIndex + 1 >= origValues.size()) {
if (remappedDelta < AI_EPSILON || size_t(floorIndex + 1) >= origValues.size()) {
// If there's no need to interpolate, we copy the input VtValue for this key
sample.values.push_back(origValues[std::min(floorIndex, (int)inputCount - 1)]);
} else {
Expand Down Expand Up @@ -258,7 +258,7 @@ void HdArnoldMesh::Sync(
if (isLeftHanded || hasNegativeValues) {
VtIntArray vertexCountsTmp = topology.GetFaceVertexCounts();
VtIntArray vertexIndicesTmp = topology.GetFaceVertexIndices();
assert(vertexCountsTmp.size() == numFaces);
assert(vertexCountsTmp.size() == (size_t)numFaces);
if (Ai_unlikely(hasNegativeValues)) {
std::transform(vertexCountsTmp.cbegin(), vertexCountsTmp.cend(), vertexCountsTmp.begin(), [] (const int i){return i < 0 ? 0 : i;});
}
Expand Down
5 changes: 3 additions & 2 deletions libs/render_delegate/node_graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ class MaterialHydraReader : public MaterialReader
MaterialHydraReader(HdArnoldNodeGraph& nodeGraph,
const HdMaterialNetwork& network,
HydraArnoldAPI& context) :
MaterialReader(),
_nodeGraph(nodeGraph),
_network(network),
_context(context),
MaterialReader() {}
_context(context)
{}


AtNode* CreateArnoldNode(const char* nodeType, const char* nodeName) override
Expand Down
8 changes: 2 additions & 6 deletions libs/render_delegate/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ TF_DEFINE_PRIVATE_TOKENS(_tokens,
((hydraProcCamera, "/ArnoldHydraProceduralCamera"))
);

static int s_anonymousOverrideCounter = 0;
static AtMutex s_globalReaderMutex;

// check pxr/imaging/hd/testenv/testHdRenderIndex.cpp
class HdArnoldSyncPass : public HdRenderPass
{
Expand Down Expand Up @@ -149,7 +146,7 @@ HydraArnoldReader::~HydraArnoldReader() {
// }
}

HydraArnoldReader::HydraArnoldReader(AtUniverse *universe) : _universe(universe), _purpose(UsdGeomTokens->render) {
HydraArnoldReader::HydraArnoldReader(AtUniverse *universe) : _purpose(UsdGeomTokens->render), _universe(universe) {
_renderDelegate = new HdArnoldRenderDelegate(true, TfToken("kick"), _universe);
TF_VERIFY(_renderDelegate);
_renderIndex = HdRenderIndex::New(_renderDelegate, HdDriverVector());
Expand Down Expand Up @@ -182,8 +179,7 @@ void HydraArnoldReader::ReadStage(UsdStageRefPtr stage,

AtNode *universeCamera = AiUniverseGetCamera(_universe);
SdfPath renderCameraPath;
GfVec2f sceneShutter(0.f, 0.f);


// Find the camera as its motion blur values influence how hydra generates the geometry
if (!arnoldRenderDelegate->GetProceduralParent()) {
if (universeCamera) {
Expand Down
1 change: 0 additions & 1 deletion libs/render_delegate/reader.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class HydraArnoldReader : public ProceduralReader {
HdEngine _engine;
HdRenderDelegate *_renderDelegate;
AtUniverse *_universe = nullptr;
bool _universeCreated = false;
HdRenderPassSharedPtr _syncPass;
HdRprimCollection _collection;
GfVec2f _shutter;
Expand Down
10 changes: 5 additions & 5 deletions libs/render_delegate/render_delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -456,13 +456,13 @@ const AtString& HydraArnoldAPI::GetPxrMtlxPath()

HdArnoldRenderDelegate::HdArnoldRenderDelegate(bool isBatch, const TfToken &context, AtUniverse *universe, AtSessionMode renderSessionType) :
_apiAdapter(this),
_isBatch(isBatch),
_context(context),
_universe(universe),
_procParent(nullptr),
_renderDelegateOwnsUniverse(universe==nullptr),
_renderSessionType(renderSessionType)
{
_renderSessionType(renderSessionType),
_context(context),
_isBatch(isBatch),
_renderDelegateOwnsUniverse(universe==nullptr)
{

_lightLinkingChanged.store(false, std::memory_order_release);
_meshLightsChanged.store(false, std::memory_order_release);
Expand Down
2 changes: 1 addition & 1 deletion libs/render_delegate/rprim.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class HdArnoldRprim : public HydraType {
/// @param id Path to the primitive.
HDARNOLD_API
HdArnoldRprim(const AtString& shapeType, HdArnoldRenderDelegate* renderDelegate, const SdfPath& id)
: HydraType(id), _renderDelegate(renderDelegate), _shape(shapeType, renderDelegate, id, HydraType::GetPrimId())
: HydraType(id), _shape(shapeType, renderDelegate, id, HydraType::GetPrimId()), _renderDelegate(renderDelegate)
{
}

Expand Down
2 changes: 1 addition & 1 deletion libs/render_delegate/shared_arrays.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ struct ArrayHolder : public ArrayOperations<ArrayHolder> {

AtArray* atArray = AiArrayMakeShared(nelements, nkeys, type, samples, ReleaseArrayCallback, this);
if (atArray) {
for (int i = 0; i < timeSamples.count; ++i) {
for (size_t i = 0; i < timeSamples.count; ++i) {
const VtValue& val = timeSamples.values[i];
if (val.template IsHolding<T>()) {
const T& arr = val.template UncheckedGet<T>();
Expand Down
2 changes: 1 addition & 1 deletion libs/render_delegate/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void HdArnoldSetTransform(AtNode* node, HdSceneDelegate* sceneDelegate, const Sd
xf.values.resize(transformKeys);
// If an amount of transform keys is provided, we must resample
// the times & values to match the new amount
for (size_t i = 0; i < transformKeys; ++i) {
for (int i = 0; i < transformKeys; ++i) {
xf.times[i] = timeStart + i * (timeEnd - timeStart) /
(static_cast<float>(transformKeys)-1.f);
xf.values[i] = xfOrig.Resample(xf.times[i]);
Expand Down
2 changes: 1 addition & 1 deletion libs/render_delegate/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ inline
bool IsVaryingTopology(const SampledTyped &xf) {
if (xf.count == 0) return false;
const auto& v0 = xf.values[0];
for (int i = 0; i < xf.count; ++i) {
for (size_t i = 0; i < xf.count; ++i) {
const auto& vi = xf.values[i];
if (vi.size() != v0.size()) {
return true;
Expand Down
3 changes: 1 addition & 2 deletions libs/translator/reader/read_geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ static inline bool _ReadPointsAndVelocities(const UsdGeomPointBased &geom, AtNod
}
}
// Make sure we have the right number of points before assigning them to arnold
if (points.size() == numKeys * numPoints) {
if (points.size() == size_t(numKeys * numPoints)) {
AiNodeSetArray(node, AtString(attrName), AiArrayConvert(numPoints, numKeys, AI_TYPE_VECTOR, points.data()));
}
// We need to set the motion start and motion end
Expand Down Expand Up @@ -1492,7 +1492,6 @@ AtNode* UsdArnoldReadPointInstancer::Read(const UsdPrim &prim, UsdArnoldReaderCo
protoLightIntensities.assign(protoPaths.size(), 1.f);

// Get the intensity value from the light primitive
float lightIntensity = 1.f;
UsdAttribute intensityAttr = protoPrim.GetAttribute(str::t_inputs_intensity);
VtValue intensityValue;
if (intensityAttr && intensityAttr.Get(&intensityValue, frame)) {
Expand Down
12 changes: 8 additions & 4 deletions libs/translator/reader/read_shader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,13 @@ class MaterialUsdReader : public MaterialReader
{
public:
MaterialUsdReader(UsdArnoldPrimReader& shaderReader, UsdArnoldReaderContext& context) :
MaterialReader(),
#ifdef ARNOLD_USD_MATERIAL_READER
_shaderReader(shaderReader),
#endif
_context(context),
_reader(context.GetReader()),
MaterialReader() {}
_reader(context.GetReader())
{}

AtNode* CreateArnoldNode(const char* nodeType, const char* nodeName) override
{
Expand Down Expand Up @@ -108,7 +111,9 @@ class MaterialUsdReader : public MaterialReader

}
private:
#ifdef ARNOLD_USD_MATERIAL_READER
UsdArnoldPrimReader& _shaderReader;
#endif
UsdArnoldReaderContext& _context;
UsdArnoldReader *_reader = nullptr;
};
Expand Down Expand Up @@ -176,11 +181,10 @@ AtNode* UsdArnoldReadShader::Read(const UsdPrim &prim, UsdArnoldReaderContext &c
return nullptr;

bool isArnoldShader = (TfStringStartsWith(id.GetString(), str::t_arnold_prefix.GetString()));
const AtNodeEntry* nentry = isArnoldShader ? AiNodeEntryLookUp(id.GetString().substr(7).c_str()) : nullptr;
const AtNodeEntry* nentry = isArnoldShader ? AiNodeEntryLookUp(AtString(id.GetString().substr(7).c_str())) : nullptr;

const std::vector<UsdShadeInput> shadeNodeInputs = shader.GetInputs();
InputAttributesList inputAttrs;
int index = 0;
if (!shadeNodeInputs.empty()) {
inputAttrs.clear();
inputAttrs.reserve(shadeNodeInputs.size());
Expand Down
4 changes: 2 additions & 2 deletions libs/translator/reader/read_shader.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ class UsdArnoldReadNodeGraph : public UsdArnoldPrimReader {

public:
UsdArnoldReadNodeGraph(UsdArnoldPrimReader& shaderReader) :
_shaderReader(shaderReader),
UsdArnoldPrimReader(AI_NODE_SHADER) {}
UsdArnoldPrimReader(AI_NODE_SHADER),
_shaderReader(shaderReader) {}

AtNode* Read(const UsdPrim &prim, UsdArnoldReaderContext &context) override;

Expand Down
19 changes: 3 additions & 16 deletions libs/translator/reader/read_skinning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,6 @@

PXR_NAMESPACE_USING_DIRECTIVE


TF_DEFINE_PRIVATE_TOKENS(
_tokens,
((xformOpTransform, "xformOp:transform"))
(Xform)
);


using DeformationFlags = enum {
DeformPointsWithLBS = 1 << 0,
DeformNormalsWithLBS = 1 << 1,
Expand Down Expand Up @@ -1575,21 +1567,16 @@ _ComputeTimeSamples(
// order for this work to be done in parallel the skinning adapters would
// need to be grouped such that that the same skel adapter isn't modified
// by multiple threads.
// for (const _SkinningAdapterRefPtr &adapter : skinningAdapters) {
if (skinningAdapter)
skinningAdapter->ExtendTimeSamples(
interval,
&skelTimesMap);
// }

// Each times array may now hold duplicate entries.
// Sort and remove dupes from each array.


std::sort(skelTimesMap.begin(), skelTimesMap.end());
skelTimesMap.erase(std::unique(skelTimesMap.begin(), skelTimesMap.end()),
skelTimesMap.end());

std::sort(skelTimesMap.begin(), skelTimesMap.end());
skelTimesMap.erase(std::unique(skelTimesMap.begin(), skelTimesMap.end()),
skelTimesMap.end());

// XXX: Skinning meshes are baked at each time sample at which joint
// transforms or blend shapes are authored. If the joint transforms
Expand Down
4 changes: 1 addition & 3 deletions libs/translator/reader/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,6 @@ unsigned int UsdArnoldReader::ReaderThread(void *data)

UsdArnoldReaderThreadContext &threadContext = threadData->threadContext;
UsdArnoldReader *reader = threadContext.GetReader();
const TimeSettings &time = reader->GetTimeSettings();
// Each thread context will have a stack of primvars vectors,
// which represent the primvars at the current level of hierarchy.
// Every time we find a Xform prim, we add an element to the stack
Expand All @@ -376,7 +375,6 @@ unsigned int UsdArnoldReader::ReaderThread(void *data)
// all nodes under a point instancer hierarchy need to be hidden. So during our
// traversal we want to count the amount of point instancers below the current hierarchy,
// so that we can re-enable visibility when the count is back to 0 (#458)
int pointInstancerCount = 0;
reader->TraverseStage(threadData->rootPrim, *threadData->context, threadData->threadId, threadData->threadCount, true, true, nullptr);

// Wait until all the jobs we started finished the translation
Expand Down Expand Up @@ -1280,7 +1278,7 @@ AtNode* UsdArnoldReaderThreadContext::LookupTargetNode(const char *targetName, c
// instanceable prim pointing to it
// Declare the user data
AiNodeDeclare(target, str::parent_instance, "constant STRING");
AiNodeSetStr(target, str::parent_instance, AiNodeGetName(source));
AiNodeSetStr(target, str::parent_instance, AtString(AiNodeGetName(source)));
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions libs/translator/reader/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ AtArray *ReadLocalMatrix(const UsdPrim &prim, const TimeSettings &time)
array = AiArrayAllocate(1, numKeys, AI_TYPE_MATRIX);
double timeStep = double(interval.GetMax() - interval.GetMin()) / double(numKeys - 1);
double timeVal = interval.GetMin();
for (size_t i = 0; i < numKeys; i++, timeVal += timeStep) {
for (int i = 0; i < numKeys; i++, timeVal += timeStep) {
if (ConvertAtMatrix(xformable, matrix, static_cast<float>(timeVal))) {
AiArraySetMtx(array, i, matrix);
}
Expand Down Expand Up @@ -782,11 +782,11 @@ struct PrimvarValueReader : public ValueReader
PrimvarValueReader(const UsdGeomPrimvar& primvar,
bool computeFlattened = false, PrimvarsRemapper *primvarsRemapper = nullptr,
TfToken primvarInterpolation = TfToken()) :
ValueReader(),
_primvar(primvar),
_computeFlattened(computeFlattened),
_primvarsRemapper(primvarsRemapper),
_primvarInterpolation(primvarInterpolation),
ValueReader()
_primvarInterpolation(primvarInterpolation)
{
}

Expand Down
1 change: 0 additions & 1 deletion libs/translator/writer/prim_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,6 @@ static void processMaterialBinding(AtNode* shader, AtNode* displacement, UsdPrim
// Write the surface shader under the material's scope.
// Here we only want to consider the last name in the prim
// hierarchy, so we're stripping the scope here
const char *prevName = AiNodeGetName(shader);
writer.WritePrimitive(shader);

UsdShadeOutput surfaceOutput = mat.CreateSurfaceOutput(arnoldContext);
Expand Down
4 changes: 0 additions & 4 deletions libs/translator/writer/write_arnold_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
//-*************************************************************************

PXR_NAMESPACE_USING_DIRECTIVE
TF_DEFINE_PRIVATE_TOKENS(
_tokens,
((frame, "arnold:frame"))
);

/**
* Write out any Arnold node to a generic "typed" USD primitive (eg
Expand Down
Loading

0 comments on commit 7bb1bb9

Please sign in to comment.