Fix various build issues and warnings on Linux #63

Merged
Brecht Van Lommel merged 2 commits from brecht/blender:hydra-build-linux into hydra-render 2023-07-13 20:26:51 +02:00
12 changed files with 63 additions and 36 deletions

View File

@ -931,6 +931,9 @@ set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_OPENVDB OFF)
set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_ALEMBIC OFF)
set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_CYCLES_OSL OFF)
# Hydra requires USD.
set_and_warn_dependency(WITH_USD WITH_HYDRA OFF)
# auto enable openimageio for cycles
if(WITH_CYCLES)
# auto enable llvm for cycles_osl

View File

@ -5,6 +5,18 @@ if(WIN32)
add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN -DBOOST_DEBUG_PYTHON)
endif()
# Precompiled Linux libs are made with GCC, and USD uses some extensions
# which lead to an incompatible ABI for Clang. Using those extensions with
# Clang as well works around the issue.
if(UNIX AND NOT APPLE)
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
if(EXISTS ${LIBDIR})
add_definitions(-DARCH_HAS_GNU_STL_EXTENSIONS)
add_cxx_flag("-Wno-deprecated")
endif()
endif()
endif()
# USD headers use deprecated TBB headers, silence warning.
add_definitions(-DTBB_SUPPRESS_DEPRECATED_MESSAGES=1)
@ -44,9 +56,21 @@ set(INC_SYS
${BOOST_INCLUDE_DIR}
${TBB_INCLUDE_DIR}
${GFLAGS_INCLUDE_DIRS}
${LIBDIR}/MaterialX/include
)
set(LIB
${Epoxy_LIBRARIES}
${PYTHON_LIBRARIES}
${BOOST_LIBRARIES}
${USD_LIBRARIES}
${TBB_LIBRARIES}
)
if(WITH_MATERIALX)
add_definitions(-DWITH_MATERIALX)
list(APPEND LIB MaterialXCore)
endif()
set(SRC
python.cc
@ -92,12 +116,6 @@ set(SRC
scene_delegate/volume.cc
)
set(LIB
${Epoxy_LIBRARIES}
${PYTHON_LIBRARIES}
${BOOST_LIBRARIES}
)
blender_add_lib(bf_render_hydra "${SRC}" "${INC}" "${INC_SYS}" "${LIB}")
add_dependencies(bf_render_hydra bf_rna)

View File

@ -33,7 +33,7 @@ static PyObject *register_plugins_func(PyObject * /*self*/, PyObject *args)
pyiter = PyObject_GetIter(pyplugin_dirs);
if (pyiter) {
while (pyitem = PyIter_Next(pyiter)) {
while ((pyitem = PyIter_Next(pyiter))) {
plugin_dirs.push_back(PyUnicode_AsUTF8(pyitem));
Py_DECREF(pyitem);
}
@ -87,7 +87,7 @@ static PyObject *engine_create_func(PyObject * /*self*/, PyObject *args)
}
if (engine) {
CLOG_INFO(LOG_RENDER_HYDRA, 1, "Engine %016llx %s", engine, engine_type);
CLOG_INFO(LOG_RENDER_HYDRA, 1, "Engine %p %s", engine, engine_type);
}
return PyLong_FromVoidPtr(engine);
}
@ -102,7 +102,7 @@ static PyObject *engine_free_func(PyObject * /*self*/, PyObject *args)
Engine *engine = (Engine *)PyLong_AsVoidPtr(pyengine);
delete engine;
CLOG_INFO(LOG_RENDER_HYDRA, 1, "Engine %016llx", engine);
CLOG_INFO(LOG_RENDER_HYDRA, 1, "Engine %p", engine);
Py_RETURN_NONE;
}
@ -117,7 +117,7 @@ static PyObject *engine_sync_func(PyObject * /*self*/, PyObject *args)
Depsgraph *depsgraph = (Depsgraph *)PyLong_AsVoidPtr(pydepsgraph);
bContext *context = (bContext *)PyLong_AsVoidPtr(pycontext);
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %016llx", engine);
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %p", engine);
engine->sync(depsgraph, context);
Py_RETURN_NONE;
@ -135,7 +135,7 @@ static PyObject *engine_sync_usd_func(PyObject * /*self*/, PyObject *args)
boost::python::extract<pxr::UsdStageRefPtr> extract(pystage);
pxr::UsdStagePtr stage = extract();
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %016llx", engine);
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %p", engine);
engine->sync_usd(stage);
Py_RETURN_NONE;
@ -152,7 +152,7 @@ static PyObject *engine_render_func(PyObject * /*self*/, PyObject *args)
Engine *engine = (Engine *)PyLong_AsVoidPtr(pyengine);
Depsgraph *depsgraph = (Depsgraph *)PyLong_AsVoidPtr(pydepsgraph);
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %016llx", engine);
CLOG_INFO(LOG_RENDER_HYDRA, 2, "Engine %p", engine);
/* Allow Blender to execute other Python scripts. */
Py_BEGIN_ALLOW_THREADS;
@ -173,7 +173,7 @@ static PyObject *engine_view_draw_func(PyObject * /*self*/, PyObject *args)
Depsgraph *depsgraph = (Depsgraph *)PyLong_AsVoidPtr(pydepsgraph);
bContext *context = (bContext *)PyLong_AsVoidPtr(pycontext);
CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %016llx", engine);
CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %p", engine);
/* Allow Blender to execute other Python scripts. */
Py_BEGIN_ALLOW_THREADS;
@ -211,7 +211,7 @@ static PyObject *engine_set_sync_setting_func(PyObject * /*self*/, PyObject *arg
Engine *engine = (Engine *)PyLong_AsVoidPtr(pyengine);
CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %016llx: %s", engine, key);
CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %p: %s", engine, key);
engine->set_sync_setting(key, get_setting_val(pyval));
Py_RETURN_NONE;
@ -227,7 +227,7 @@ static PyObject *engine_set_render_setting_func(PyObject * /*self*/, PyObject *a
Engine *engine = (Engine *)PyLong_AsVoidPtr(pyengine);
CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %016llx: %s", engine, key);
CLOG_INFO(LOG_RENDER_HYDRA, 3, "Engine %p: %s", engine, key);
engine->set_render_setting(key, get_setting_val(pyval));
Py_RETURN_NONE;

View File

@ -106,7 +106,7 @@ void RenderTaskDelegate::set_camera_and_viewport(pxr::SdfPath const &camera_id,
}
}
pxr::VtValue RenderTaskDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key)
pxr::VtValue RenderTaskDelegate::Get(pxr::SdfPath const & /*id*/, pxr::TfToken const &key)
{
if (key == pxr::HdTokens->params) {
return pxr::VtValue(task_params_);
@ -127,7 +127,7 @@ pxr::HdRenderBufferDescriptor RenderTaskDelegate::GetRenderBufferDescriptor(pxr:
return buffer_descriptors_[id];
}
pxr::TfTokenVector RenderTaskDelegate::GetTaskRenderTags(pxr::SdfPath const &task_id)
pxr::TfTokenVector RenderTaskDelegate::GetTaskRenderTags(pxr::SdfPath const & /*task_id*/)
{
return {pxr::HdRenderTagTokens->geometry};
}

View File

@ -273,7 +273,7 @@ pxr::SdfPath BlenderSceneDelegate::prim_id(ID *id, const char *prefix) const
{
/* Making id of object in form like <prefix>_<pointer in 16 hex digits format> */
char name[32];
snprintf(name, sizeof(name), "%s_%016llx", prefix, (uintptr_t)id);
snprintf(name, sizeof(name), "%s_%p", prefix, id);
return GetDelegateID().AppendElementString(name);
}

View File

@ -66,7 +66,7 @@ void CurvesData::update()
ID_LOG(1, "");
}
pxr::VtValue CurvesData::get_data(pxr::SdfPath const &id, pxr::TfToken const &key) const
pxr::VtValue CurvesData::get_data(pxr::SdfPath const & /* id */, pxr::TfToken const &key) const
{
if (key == pxr::HdTokens->points) {
return pxr::VtValue(vertices_);
@ -91,7 +91,7 @@ bool CurvesData::update_visibility()
return ret;
}
pxr::HdBasisCurvesTopology CurvesData::curves_topology(pxr::SdfPath const &id) const
pxr::HdBasisCurvesTopology CurvesData::curves_topology(pxr::SdfPath const & /* id */) const
{
return pxr::HdBasisCurvesTopology(pxr::HdTokens->linear,
pxr::TfToken(),

View File

@ -12,7 +12,7 @@ IdData::IdData(BlenderSceneDelegate *scene_delegate, ID *id, pxr::SdfPath const
{
}
pxr::VtValue IdData::get_data(pxr::TfToken const &key) const
pxr::VtValue IdData::get_data(pxr::TfToken const & /*key*/) const
{
return pxr::VtValue();
}

View File

@ -46,7 +46,7 @@ static std::string cache_image_file(Image *image,
opts.im_format = scene->r.im_format;
}
snprintf(file_name, sizeof(file_name), "img_%016llx%s", (uintptr_t)image, r_ext);
snprintf(file_name, sizeof(file_name), "img_%p%s", image, r_ext);
file_path = get_cache_file(file_name);
if (check_exist && BLI_exists(file_path.c_str())) {

View File

@ -163,7 +163,7 @@ void InstancerData::update_instance(Object *parent_ob, DupliObject *dupli)
inst->data = std::make_unique<LightData>(scene_delegate_, ob, p_id);
inst->data->init();
}
ID_LOG(2, "Light %s %d", inst->data->id->name, inst->transforms.size());
ID_LOG(2, "Light %s %d", inst->data->id->name, (int)inst->transforms.size());
inst->transforms.push_back(gf_matrix_from_transform(dupli->mat));
}
else {
@ -177,7 +177,7 @@ void InstancerData::update_instance(Object *parent_ob, DupliObject *dupli)
else {
inst->data->update();
}
ID_LOG(2, "Mesh %s %d", inst->data->id->name, mesh_transforms_.size());
ID_LOG(2, "Mesh %s %d", inst->data->id->name, (int)mesh_transforms_.size());
inst->indices.push_back(mesh_transforms_.size());
mesh_transforms_.push_back(gf_matrix_from_transform(dupli->mat));
}
@ -225,7 +225,7 @@ pxr::SdfPath InstancerData::object_prim_id(Object *object) const
{
/* Making id of object in form like <prefix>_<pointer in 16 hex digits format> */
char name[32];
snprintf(name, sizeof(name), "O_%016llx", (uint64_t)object);
snprintf(name, sizeof(name), "O_%p", object);
return prim_id.AppendElementString(name);
}

View File

@ -1,14 +1,18 @@
/* SPDX-License-Identifier: Apache-2.0
* Copyright 2011-2022 Blender Foundation */
#include "BLI_utildefines.h"
#include <pxr/base/arch/fileSystem.h>
#include <pxr/usd/ar/resolver.h>
#include <pxr/usd/ar/resolverContextBinder.h>
#include <pxr/usd/ar/resolverScopedCache.h>
#include <pxr/usd/usdMtlx/reader.h>
#include <pxr/usd/usdMtlx/utils.h>
#ifdef WITH_MATERIALX
# include <pxr/usd/usdMtlx/reader.h>
# include <pxr/usd/usdMtlx/utils.h>
#endif
#include <pxr/usd/usdShade/material.h>
#include <pxr/usd/usdShade/shader.h>
@ -20,8 +24,6 @@
#include "mtlx_hydra_adapter.h"
namespace mx = MaterialX;
namespace blender::render::hydra {
void hdmtlx_convert_to_materialnetworkmap(std::string const &mtlx_path,
@ -29,6 +31,7 @@ void hdmtlx_convert_to_materialnetworkmap(std::string const &mtlx_path,
pxr::TfTokenVector const &render_contexts,
pxr::HdMaterialNetworkMap *out)
{
#ifdef WITH_MATERIALX
if (mtlx_path.empty()) {
return;
}
@ -46,17 +49,17 @@ void hdmtlx_convert_to_materialnetworkmap(std::string const &mtlx_path,
pxr::UsdStageRefPtr stage = pxr::UsdStage::CreateInMemory(stage_id, context);
try {
mx::DocumentPtr doc = pxr::UsdMtlxReadDocument(mtlx_path);
MaterialX::DocumentPtr doc = pxr::UsdMtlxReadDocument(mtlx_path);
pxr::UsdMtlxRead(doc, stage);
}
catch (mx::ExceptionFoundCycle &x) {
catch (MaterialX::ExceptionFoundCycle &x) {
Tf_PostErrorHelper(pxr::TF_CALL_CONTEXT,
pxr::TF_DIAGNOSTIC_RUNTIME_ERROR_TYPE,
"MaterialX cycle found: %s\n",
x.what());
return;
}
catch (mx::Exception &x) {
catch (MaterialX::Exception &x) {
Tf_PostErrorHelper(pxr::TF_CALL_CONTEXT,
pxr::TF_DIAGNOSTIC_RUNTIME_ERROR_TYPE,
"MaterialX error: %s\n",
@ -78,6 +81,9 @@ void hdmtlx_convert_to_materialnetworkmap(std::string const &mtlx_path,
}
}
}
#else
UNUSED_VARS(mtlx_path, shader_source_types, render_contexts, out);
#endif
}
} // namespace blender::render::hydra

View File

@ -30,7 +30,7 @@ void SimpleLightTaskDelegate::set_camera_path(pxr::SdfPath const &camera_path)
task_params_.cameraPath = camera_path;
}
pxr::VtValue SimpleLightTaskDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key)
pxr::VtValue SimpleLightTaskDelegate::Get(pxr::SdfPath const & /*id*/, pxr::TfToken const &key)
{
if (key == pxr::HdTokens->params) {
return pxr::VtValue(task_params_);

View File

@ -217,12 +217,12 @@ void DrawTexture::free()
texture_ = nullptr;
}
void ViewportEngine::render(Depsgraph *depsgraph)
void ViewportEngine::render(Depsgraph * /* depsgraph */)
{
/* Empty function */
}
void ViewportEngine::render(Depsgraph *depsgraph, bContext *context)
void ViewportEngine::render(Depsgraph * /* depsgraph */, bContext *context)
{
ViewSettings view_settings(context);
if (view_settings.width() * view_settings.height() == 0) {