Commit 652a2e86 authored by Paolo Berto Durante's avatar Paolo Berto Durante

Merge branch 'dev_usdlatest' into 'master'

Updates to get this plugin building against Pixar's 18.09 release of USD

See merge request !1
parents 164d3ee7 10c36141
set(PXR_PREFIX pxr/imaging)
set(PXR_PACKAGE hdNSI)
if(NOT NSI_FOUND)
message(WARNING "Not building ${PXR_PACKAGE} because of missing dependency: 3delight NSI")
return()
endif()
pxr_plugin(hdNSI
LIBRARIES
arch
......@@ -17,7 +12,6 @@ pxr_plugin(hdNSI
hf
hd
hdx
usdGeom
${TBB_LIBRARIES}
INCLUDE_DIRS
......
......@@ -100,7 +100,7 @@ HdNSICurves::Finalize(HdRenderParam *renderParam)
}
HdDirtyBits
HdNSICurves::_GetInitialDirtyBits() const
HdNSICurves::GetInitialDirtyBitsMask() const
{
// The initial dirty bits control what data is available on the first
// run through _PopulateRtCurves(), so it should list every data item
......@@ -113,7 +113,7 @@ HdNSICurves::_GetInitialDirtyBits() const
| HdChangeTracker::DirtyVisibility
| HdChangeTracker::DirtyCullStyle
| HdChangeTracker::DirtyDoubleSided
| HdChangeTracker::DirtyRefineLevel
| HdChangeTracker::DirtyDisplayStyle
| HdChangeTracker::DirtySubdivTags
| HdChangeTracker::DirtyPrimvar
| HdChangeTracker::DirtyNormals
......@@ -408,7 +408,7 @@ HdNSICurves::_PopulateRtCurves(HdSceneDelegate* sceneDelegate,
////////////////////////////////////////////////////////////////////////
// 2. Resolve drawstyles
int refineLevel = GetRefineLevel(sceneDelegate);
int refineLevel = GetDisplayStyle(sceneDelegate).refineLevel;
bool doRefine = (refineLevel > 0);
////////////////////////////////////////////////////////////////////////
......
......@@ -115,6 +115,11 @@ public:
TfToken const& reprName,
bool forcedRepr) override;
// Inform the scene graph which state needs to be downloaded in the
// first Sync() call: in this case, topology and points data to build
// the geometry object in the NSI scene graph.
virtual HdDirtyBits GetInitialDirtyBitsMask() const override;
protected:
// Update the named repr object for this Rprim. Repr objects are
// created to support specific reprName tokens, and contain a list of
......@@ -126,11 +131,6 @@ protected:
TfToken const &reprName,
HdDirtyBits *dirtyBits) override;
// Inform the scene graph which state needs to be downloaded in the
// first Sync() call: in this case, topology and points data to build
// the geometry object in the NSI scene graph.
virtual HdDirtyBits _GetInitialDirtyBits() const override;
// This callback from Rprim gives the prim an opportunity to set
// additional dirty bits based on those already set. This is done
// before the dirty bits are passed to the scene delegate, so can be
......
......@@ -31,10 +31,10 @@
#include "pxr/imaging/hdNSI/renderParam.h"
#include "pxr/imaging/hdNSI/renderPass.h"
#include "pxr/imaging/hd/meshUtil.h"
#include "pxr/imaging/hd/smoothNormals.h"
#include "pxr/imaging/pxOsd/tokens.h"
#include "pxr/base/gf/matrix4f.h"
#include "pxr/base/gf/matrix4d.h"
#include "pxr/usd/usdGeom/tokens.h"
#include <sstream>
#include <iostream>
......@@ -107,7 +107,7 @@ HdNSIMesh::Finalize(HdRenderParam *renderParam)
}
HdDirtyBits
HdNSIMesh::_GetInitialDirtyBits() const
HdNSIMesh::GetInitialDirtyBitsMask() const
{
// The initial dirty bits control what data is available on the first
// run through _PopulateRtMesh(), so it should list every data item
......@@ -120,7 +120,7 @@ HdNSIMesh::_GetInitialDirtyBits() const
| HdChangeTracker::DirtyVisibility
| HdChangeTracker::DirtyCullStyle
| HdChangeTracker::DirtyDoubleSided
| HdChangeTracker::DirtyRefineLevel
| HdChangeTracker::DirtyDisplayStyle
| HdChangeTracker::DirtySubdivTags
| HdChangeTracker::DirtyPrimvar
| HdChangeTracker::DirtyNormals
......@@ -269,7 +269,7 @@ HdNSIMesh::_SetNSIMeshAttributes(std::shared_ptr<NSI::Context> nsi, bool asSubdi
// Set if this mesh is subdivision.
const TfToken &scheme = _topology.GetScheme();
asSubdiv |= (scheme == UsdGeomTokens->catmullClark);
asSubdiv |= (scheme == PxOsdOpenSubdivTokens->catmullClark);
if (asSubdiv) {
nsi->SetAttribute(_masterShapeHandle,
......@@ -425,7 +425,7 @@ HdNSIMesh::_PopulateRtMesh(HdSceneDelegate* sceneDelegate,
_faceVertexIndices = _topology.GetFaceVertexIndices();
_adjacency.BuildAdjacencyTable(&_topology);
_normals = _adjacency.ComputeSmoothNormals(_points.size(), _points.data());
_normals = Hd_SmoothNormals::ComputeSmoothNormals(&_adjacency, _points.size(), _points.data());
if (_topology.GetOrientation() == HdTokens->leftHanded) {
_leftHanded = 1;
......@@ -434,9 +434,9 @@ HdNSIMesh::_PopulateRtMesh(HdSceneDelegate* sceneDelegate,
if (HdChangeTracker::IsSubdivTagsDirty(*dirtyBits, id)) {
_topology.SetSubdivTags(sceneDelegate->GetSubdivTags(id));
}
if (HdChangeTracker::IsRefineLevelDirty(*dirtyBits, id)) {
if (HdChangeTracker::IsDisplayStyleDirty(*dirtyBits, id)) {
_topology = HdMeshTopology(_topology,
sceneDelegate->GetRefineLevel(id));
sceneDelegate->GetDisplayStyle(id).refineLevel);
}
if (HdChangeTracker::IsTransformDirty(*dirtyBits, id)) {
......@@ -477,7 +477,7 @@ HdNSIMesh::_PopulateRtMesh(HdSceneDelegate* sceneDelegate,
// The repr defines whether we should compute smooth normals for this mesh:
// per-vertex normals taken as an average of adjacent faces, and
// interpolated smoothly across faces.
_smoothNormals = desc.smoothNormals;
_smoothNormals = !desc.flatShadingEnabled;
// If the subdivision scheme is "none" or "bilinear", force us not to use
// smooth normals.
......@@ -513,7 +513,7 @@ HdNSIMesh::_PopulateRtMesh(HdSceneDelegate* sceneDelegate,
// If the refine level changed or the mesh was recreated, we need to pass
// the refine level into the NSI subdiv object.
if (newMesh || HdChangeTracker::IsRefineLevelDirty(*dirtyBits, id)) {
if (newMesh || HdChangeTracker::IsDisplayStyleDirty(*dirtyBits, id)) {
const int refineLevel = _topology.GetRefineLevel();
nsi->SetAttribute(_masterShapeHandle,
......
......@@ -115,6 +115,11 @@ public:
TfToken const& reprName,
bool forcedRepr) override;
// Inform the scene graph which state needs to be downloaded in the
// first Sync() call: in this case, topology and points data to build
// the geometry object in the NSI scene graph.
virtual HdDirtyBits GetInitialDirtyBitsMask() const override;
protected:
// Update the named repr object for this Rprim. Repr objects are
// created to support specific reprName tokens, and contain a list of
......@@ -126,11 +131,6 @@ protected:
TfToken const &reprName,
HdDirtyBits *dirtyBits) override;
// Inform the scene graph which state needs to be downloaded in the
// first Sync() call: in this case, topology and points data to build
// the geometry object in the NSI scene graph.
virtual HdDirtyBits _GetInitialDirtyBits() const override;
// This callback from Rprim gives the prim an opportunity to set
// additional dirty bits based on those already set. This is done
// before the dirty bits are passed to the scene delegate, so can be
......
......@@ -97,7 +97,7 @@ HdNSIPointCloud::Finalize(HdRenderParam *renderParam)
}
HdDirtyBits
HdNSIPointCloud::_GetInitialDirtyBits() const
HdNSIPointCloud::GetInitialDirtyBitsMask() const
{
// The initial dirty bits control what data is available on the first
// run through _PopulateRtPointCloud(), so it should list every data item
......@@ -110,7 +110,7 @@ HdNSIPointCloud::_GetInitialDirtyBits() const
| HdChangeTracker::DirtyVisibility
| HdChangeTracker::DirtyCullStyle
| HdChangeTracker::DirtyDoubleSided
| HdChangeTracker::DirtyRefineLevel
| HdChangeTracker::DirtyDisplayStyle
| HdChangeTracker::DirtySubdivTags
| HdChangeTracker::DirtyPrimvar
| HdChangeTracker::DirtyNormals
......
......@@ -116,6 +116,11 @@ public:
TfToken const& reprName,
bool forcedRepr) override;
// Inform the scene graph which state needs to be downloaded in the
// first Sync() call: in this case, topology and points data to build
// the geometry object in the NSI scene graph.
virtual HdDirtyBits GetInitialDirtyBitsMask() const override;
protected:
// Update the named repr object for this Rprim. Repr objects are
// created to support specific reprName tokens, and contain a list of
......@@ -127,11 +132,6 @@ protected:
TfToken const &reprName,
HdDirtyBits *dirtyBits) override;
// Inform the scene graph which state needs to be downloaded in the
// first Sync() call: in this case, topology and points data to build
// the geometry object in the NSI scene graph.
virtual HdDirtyBits _GetInitialDirtyBits() const override;
// This callback from Rprim gives the prim an opportunity to set
// additional dirty bits based on those already set. This is done
// before the dirty bits are passed to the scene delegate, so can be
......
......@@ -128,7 +128,7 @@ HdNSIRenderPass::_Execute(HdRenderPassStateSharedPtr const& renderPassState,
if (lib) {
#if defined(_WIN32)
PDspyRegisterDriverTable =
reinterpret_cast<PFNDspyRegisterDriverTable>(GetProcAddress(lib,
reinterpret_cast<PFNDspyRegisterDriverTable>(GetProcAddress((HMODULE)lib,
"DspyRegisterDriverTable"));
#else
PDspyRegisterDriverTable =
......@@ -344,7 +344,7 @@ void HdNSIRenderPass::_CreateNSICamera()
nsi->SetAttribute(_outputDriverHandle, NSI::StringArg("imagefilename", prefix));
}
nsi->Connect(_outputDriverHandle, "", _outputLayerHandle, "outputdrivers");
#ifdef _DEBUG
#ifdef NSI_DEBUG
std::string debugDriverHandle = prefix + "|debugDriver1";
{
nsi->SetAttribute(_outputDriverHandle, NSI::StringArg("drivername", "idisplay"));
......
......@@ -51,9 +51,24 @@ HdNSIRendererPlugin::DeleteRenderDelegate(HdRenderDelegate *renderDelegate)
bool
HdNSIRendererPlugin::IsSupported() const
{
// Nothing more to check for now, we assume if the plugin loads correctly
// it is supported.
return true;
static bool theSupportedFlag = false;
static bool theSupportTestedFlag = false;
if (!theSupportTestedFlag)
{
NSI::DynamicAPI nsi_api;
NSIContext_t nsi_ctx;
nsi_ctx = nsi_api.NSIBegin(0, nullptr);
if (nsi_ctx != NSI_BAD_CONTEXT)
{
nsi_api.NSIEnd(nsi_ctx);
theSupportedFlag = true;
}
theSupportTestedFlag = true;
}
return theSupportedFlag;
}
PXR_NAMESPACE_CLOSE_SCOPE
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment