From 1d6ff406633b3642fb0874d804bb0d2e2c615aa7 Mon Sep 17 00:00:00 2001 From: Luya Tshimbalanga Date: Mar 12 2022 04:10:22 +0000 Subject: Reenable USD support --- diff --git a/blender-embree-library.diff b/blender-embree-library.diff deleted file mode 100644 index 967f64c..0000000 --- a/blender-embree-library.diff +++ /dev/null @@ -1,32 +0,0 @@ -diff -ru blender-2.90.0.orig/build_files/cmake/Modules/FindEmbree.cmake blender-2.90.0/build_files/cmake/Modules/FindEmbree.cmake ---- blender-2.90.0.orig/build_files/cmake/Modules/FindEmbree.cmake 2020-08-31 05:03:18.000000000 -0700 -+++ blender-2.90.0/build_files/cmake/Modules/FindEmbree.cmake 2020-09-04 20:51:57.064441379 -0700 -@@ -79,10 +79,10 @@ - # all listed variables are TRUE - INCLUDE(FindPackageHandleStandardArgs) - FIND_PACKAGE_HANDLE_STANDARD_ARGS(Embree DEFAULT_MSG -- _embree_LIBRARIES EMBREE_INCLUDE_DIR) -+ EMBREE_LIBRARY EMBREE_INCLUDE_DIR) - - IF(EMBREE_FOUND) -- SET(EMBREE_LIBRARIES ${_embree_LIBRARIES}) -+ SET(EMBREE_LIBRARIES ${EMBREE_LIBRARY}) - SET(EMBREE_INCLUDE_DIRS ${EMBREE_INCLUDE_DIR}) - ENDIF(EMBREE_FOUND) - -diff -ru blender-2.90.0.orig/intern/cycles/blender/CMakeLists.txt blender-2.90.0/intern/cycles/blender/CMakeLists.txt ---- blender-2.90.0.orig/intern/cycles/blender/CMakeLists.txt 2020-08-31 04:59:44.000000000 -0700 -+++ blender-2.90.0/intern/cycles/blender/CMakeLists.txt 2020-09-04 20:40:25.631042062 -0700 -@@ -67,6 +67,12 @@ - ) - endif() - -+if(WITH_CYCLES_EMBREE) -+ list(APPEND LIB -+ ${EMBREE_LIBRARIES} -+ ) -+endif() -+ - set(ADDON_FILES - addon/__init__.py - addon/engine.py diff --git a/blender-usd-21_11-fix-D14184.diff b/blender-usd-21_11-fix-D14184.diff new file mode 100644 index 0000000..dfd67fe --- /dev/null +++ b/blender-usd-21_11-fix-D14184.diff @@ -0,0 +1,274 @@ +diff --git a/source/blender/io/usd/intern/usd_reader_light.cc b/source/blender/io/usd/intern/usd_reader_light.cc +--- a/source/blender/io/usd/intern/usd_reader_light.cc ++++ b/source/blender/io/usd/intern/usd_reader_light.cc +@@ -9,8 +9,6 @@ + #include "DNA_light_types.h" + #include "DNA_object_types.h" + +-#include +- + #include + #include + #include +@@ -40,14 +38,17 @@ + if (!prim_) { + return; + } ++#if PXR_VERSION >= 2111 ++ pxr::UsdLuxLightAPI light_api(prim_); ++#else ++ pxr::UsdLuxLight light_api(prim_); ++#endif + +- pxr::UsdLuxLight light_prim(prim_); +- +- if (!light_prim) { ++ if (!light_api) { + return; + } + +- pxr::UsdLuxShapingAPI shaping_api(light_prim); ++ pxr::UsdLuxShapingAPI shaping_api; + + /* Set light type. */ + +@@ -63,6 +64,8 @@ + else if (prim_.IsA()) { + blight->type = LA_LOCAL; + ++ shaping_api = pxr::UsdLuxShapingAPI(prim_); ++ + if (shaping_api && shaping_api.GetShapingConeAngleAttr().IsAuthored()) { + blight->type = LA_SPOT; + } +@@ -73,7 +76,7 @@ + + /* Set light values. */ + +- if (pxr::UsdAttribute intensity_attr = light_prim.GetIntensityAttr()) { ++ if (pxr::UsdAttribute intensity_attr = light_api.GetIntensityAttr()) { + float intensity = 0.0f; + if (intensity_attr.Get(&intensity, motionSampleTime)) { + blight->energy = intensity * this->import_params_.light_intensity_scale; +@@ -92,14 +95,14 @@ + light_prim.GetDiffuseAttr().Get(&diffuse, motionSampleTime); + #endif + +- if (pxr::UsdAttribute spec_attr = light_prim.GetSpecularAttr()) { ++ if (pxr::UsdAttribute spec_attr = light_api.GetSpecularAttr()) { + float spec = 0.0f; + if (spec_attr.Get(&spec, motionSampleTime)) { + blight->spec_fac = spec; + } + } + +- if (pxr::UsdAttribute color_attr = light_prim.GetColorAttr()) { ++ if (pxr::UsdAttribute color_attr = light_api.GetColorAttr()) { + pxr::GfVec3f color; + if (color_attr.Get(&color, motionSampleTime)) { + blight->r = color[0]; +diff --git a/source/blender/io/usd/intern/usd_reader_stage.cc b/source/blender/io/usd/intern/usd_reader_stage.cc +--- a/source/blender/io/usd/intern/usd_reader_stage.cc ++++ b/source/blender/io/usd/intern/usd_reader_stage.cc +@@ -18,7 +18,13 @@ + #include + #include + #include +-#include ++ ++#if PXR_VERSION >= 2111 ++# include ++# include ++#else ++# include ++#endif + + #include + +@@ -55,7 +61,12 @@ + if (params_.import_meshes && prim.IsA()) { + return new USDMeshReader(prim, params_, settings_); + } ++#if PXR_VERSION >= 2111 ++ if (params_.import_lights && (prim.IsA() || ++ prim.IsA())) { ++#else + if (params_.import_lights && prim.IsA()) { ++#endif + return new USDLightReader(prim, params_, settings_); + } + if (params_.import_volumes && prim.IsA()) { +@@ -82,7 +93,11 @@ + if (prim.IsA()) { + return new USDMeshReader(prim, params_, settings_); + } ++#if PXR_VERSION >= 2111 ++ if (prim.IsA() || prim.IsA()) { ++#else + if (prim.IsA()) { ++#endif + return new USDLightReader(prim, params_, settings_); + } + if (prim.IsA()) { +diff --git a/source/blender/io/usd/intern/usd_reader_xform.cc b/source/blender/io/usd/intern/usd_reader_xform.cc +--- a/source/blender/io/usd/intern/usd_reader_xform.cc ++++ b/source/blender/io/usd/intern/usd_reader_xform.cc +@@ -131,7 +131,7 @@ + return false; + } + +- if (prim_.IsInMaster()) { ++ if (prim_.IsInPrototype()) { + /* We don't consider prototypes to be root prims, + * because we never want to apply global scaling + * or rotations to the prototypes themselves. */ +diff --git a/source/blender/io/usd/intern/usd_writer_light.cc b/source/blender/io/usd/intern/usd_writer_light.cc +--- a/source/blender/io/usd/intern/usd_writer_light.cc ++++ b/source/blender/io/usd/intern/usd_writer_light.cc +@@ -33,7 +33,12 @@ + pxr::UsdTimeCode timecode = get_export_time_code(); + + Light *light = static_cast(context.object->data); +- pxr::UsdLuxLight usd_light; ++#if PXR_VERSION >= 2111 ++ pxr::UsdLuxLightAPI usd_light_api; ++#else ++ pxr::UsdLuxLight usd_light_api; ++ ++#endif + + switch (light->type) { + case LA_AREA: +@@ -42,21 +47,33 @@ + case LA_AREA_ELLIPSE: { /* An ellipse light will deteriorate into a disk light. */ + pxr::UsdLuxDiskLight disk_light = pxr::UsdLuxDiskLight::Define(stage, usd_path); + disk_light.CreateRadiusAttr().Set(light->area_size, timecode); +- usd_light = disk_light; ++#if PXR_VERSION >= 2111 ++ usd_light_api = disk_light.LightAPI(); ++#else ++ usd_light_api = disk_light; ++#endif + break; + } + case LA_AREA_RECT: { + pxr::UsdLuxRectLight rect_light = pxr::UsdLuxRectLight::Define(stage, usd_path); + rect_light.CreateWidthAttr().Set(light->area_size, timecode); + rect_light.CreateHeightAttr().Set(light->area_sizey, timecode); +- usd_light = rect_light; ++#if PXR_VERSION >= 2111 ++ usd_light_api = rect_light.LightAPI(); ++#else ++ usd_light_api = rect_light; ++#endif + break; + } + case LA_AREA_SQUARE: { + pxr::UsdLuxRectLight rect_light = pxr::UsdLuxRectLight::Define(stage, usd_path); + rect_light.CreateWidthAttr().Set(light->area_size, timecode); + rect_light.CreateHeightAttr().Set(light->area_size, timecode); +- usd_light = rect_light; ++#if PXR_VERSION >= 2111 ++ usd_light_api = rect_light.LightAPI(); ++#else ++ usd_light_api = rect_light; ++#endif + break; + } + } +@@ -64,12 +81,23 @@ + case LA_LOCAL: { + pxr::UsdLuxSphereLight sphere_light = pxr::UsdLuxSphereLight::Define(stage, usd_path); + sphere_light.CreateRadiusAttr().Set(light->area_size, timecode); +- usd_light = sphere_light; ++#if PXR_VERSION >= 2111 ++ usd_light_api = sphere_light.LightAPI(); ++#else ++ usd_light_api = sphere_light; ++#endif + break; + } +- case LA_SUN: +- usd_light = pxr::UsdLuxDistantLight::Define(stage, usd_path); ++ case LA_SUN: { ++ pxr::UsdLuxDistantLight distant_light = pxr::UsdLuxDistantLight::Define(stage, usd_path); ++ /* TODO(makowalski): set angle attribute here. */ ++#if PXR_VERSION >= 2111 ++ usd_light_api = distant_light.LightAPI(); ++#else ++ usd_light_api = distant_light; ++#endif + break; ++ } + default: + BLI_assert_msg(0, "is_supported() returned true for unsupported light type"); + } +@@ -85,10 +113,10 @@ + else { + usd_intensity = light->energy / 100.0f; + } +- usd_light.CreateIntensityAttr().Set(usd_intensity, timecode); ++ usd_light_api.CreateIntensityAttr().Set(usd_intensity, timecode); + +- usd_light.CreateColorAttr().Set(pxr::GfVec3f(light->r, light->g, light->b), timecode); +- usd_light.CreateSpecularAttr().Set(light->spec_fac, timecode); ++ usd_light_api.CreateColorAttr().Set(pxr::GfVec3f(light->r, light->g, light->b), timecode); ++ usd_light_api.CreateSpecularAttr().Set(light->spec_fac, timecode); + } + + } // namespace blender::io::usd +diff --git a/source/blender/io/usd/intern/usd_writer_material.cc b/source/blender/io/usd/intern/usd_writer_material.cc +--- a/source/blender/io/usd/intern/usd_writer_material.cc ++++ b/source/blender/io/usd/intern/usd_writer_material.cc +@@ -162,7 +162,7 @@ + created_shader = create_usd_preview_shader(usd_export_context, usd_material, input_node); + + preview_surface.CreateInput(input_spec.input_name, input_spec.input_type) +- .ConnectToSource(created_shader, input_spec.source_name); ++ .ConnectToSource(created_shader.ConnectableAPI(), input_spec.source_name); + } + else if (input_spec.set_default_value) { + /* Set hardcoded value. */ +@@ -216,7 +216,7 @@ + shader.CreateInput(usdtokens::metallic, pxr::SdfValueTypeNames->Float).Set(material->metallic); + + /* Connect the shader and the material together. */ +- usd_material.CreateSurfaceOutput().ConnectToSource(shader, usdtokens::surface); ++ usd_material.CreateSurfaceOutput().ConnectToSource(shader.ConnectableAPI(), usdtokens::surface); + } + + /* Return USD Preview Surface input map singleton. */ +@@ -292,12 +292,12 @@ + uv_shader.CreateInput(usdtokens::varname, pxr::SdfValueTypeNames->Token) + .Set(pxr::TfToken(uv_set)); + usd_tex_shader.CreateInput(usdtokens::st, pxr::SdfValueTypeNames->Float2) +- .ConnectToSource(uv_shader, usdtokens::result); ++ .ConnectToSource(uv_shader.ConnectableAPI(), usdtokens::result); + } + else { + uv_shader.CreateInput(usdtokens::varname, pxr::SdfValueTypeNames->Token).Set(default_uv); + usd_tex_shader.CreateInput(usdtokens::st, pxr::SdfValueTypeNames->Float2) +- .ConnectToSource(uv_shader, usdtokens::result); ++ .ConnectToSource(uv_shader.ConnectableAPI(), usdtokens::result); + } + } + +@@ -312,7 +312,7 @@ + if (uv_shader.GetPrim().IsValid()) { + uv_shader.CreateInput(usdtokens::varname, pxr::SdfValueTypeNames->Token).Set(default_uv); + usd_tex_shader.CreateInput(usdtokens::st, pxr::SdfValueTypeNames->Float2) +- .ConnectToSource(uv_shader, usdtokens::result); ++ .ConnectToSource(uv_shader.ConnectableAPI(), usdtokens::result); + } + } + } +@@ -487,7 +487,7 @@ + case SH_NODE_BSDF_DIFFUSE: + case SH_NODE_BSDF_PRINCIPLED: { + shader.CreateIdAttr(pxr::VtValue(usdtokens::preview_surface)); +- material.CreateSurfaceOutput().ConnectToSource(shader, usdtokens::surface); ++ material.CreateSurfaceOutput().ConnectToSource(shader.ConnectableAPI(), usdtokens::surface); + break; + } + + diff --git a/blender.spec b/blender.spec index 489db60..c3aa9b1 100644 --- a/blender.spec +++ b/blender.spec @@ -17,16 +17,12 @@ %ifarch x86_64 || aarch64 || ppc64le %global cyclesflag ON -# Availabel for x86_64 and aarch64 -# Temporairly disable support -#%%ifarch x86_64 || aarch64 -#%%bcond_with usd -#%%endif -# Only available on x86_64 -%ifarch x86_64 +# Only available on x86_64 and aarch64 +%ifarch x86_64 || aarch64 %bcond_without embree %bcond_without hidapi %bcond_without oidn +%bcond_without usd %else %bcond_with embree %bcond_with hidapi @@ -56,6 +52,10 @@ Patch1: %{name}-usd-pythonlibs-fix.diff # Force makesdna: force DNAstr to be 4 bytes aligned : fixes s390x LTO issue Patch2: %{name}-2.93.5-0001-Fix-T93425-makesdna-force-DNAstr-to-be-4-bytes-align.patch +# USD: Support building against USD 21.11+ +# https://developer.blender.org/D14184 +Patch3: %{name}-usd-21_11-fix-D14184.diff + # Development stuff BuildRequires: boost-devel %if %{with clang} @@ -137,7 +137,7 @@ BuildRequires: pkgconfig(xrender) BuildRequires: pkgconfig(ode) BuildRequires: pkgconfig(sdl2) %if %{with usd} -BuildRequires: usd-devel +BuildRequires: cmake(pxr) %endif BuildRequires: pkgconfig(xproto) @@ -285,7 +285,7 @@ sed -i "s/date_time/date_time python%{python3_version_nodots}/" \ -DWITH_SYSTEM_GLEW=ON \ %if %{with usd} -DWITH_USD=ON \ - -DUSD_LIBRARY=%{_libdir} \ + -DUSD_LIBRARY=%{_libdir}/libusd_usd_ms.so \ %else -DWITH_USD=OFF \ %endif