Skip to content

Commit

Permalink
Merge pull request PixarAnimationStudios#2641 from pablode/typo-hgiin…
Browse files Browse the repository at this point in the history
…terop

Fix typo in hgiInterop CMakeLists.txt

(Internal change: 2306087)
  • Loading branch information
pixar-oss committed Nov 21, 2023
2 parents 0e11364 + 98d7b54 commit 6676799
Show file tree
Hide file tree
Showing 130 changed files with 4,063 additions and 2,328 deletions.
5 changes: 3 additions & 2 deletions extras/imaging/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
add_subdirectory(examples)

if (PXR_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
59 changes: 16 additions & 43 deletions pxr/base/tf/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,12 @@ TfHashAppend(HashState &h, std::pair<T, U> const &p)

// Support std::vector. std::vector<bool> specialized below.
template <class HashState, class T>
inline std::enable_if_t<!std::is_same<std::remove_const_t<T>, bool>::value>
inline void
TfHashAppend(HashState &h, std::vector<T> const &vec)
{
static_assert(!std::is_same_v<std::remove_cv_t<T>, bool>,
"Unexpected usage of vector of 'bool'."
"Expected explicit overload.");
h.AppendContiguous(vec.data(), vec.size());
}

Expand Down Expand Up @@ -126,15 +129,6 @@ TfHashAppend(HashState& h, std::map<Key, Value, Compare> const &elements)
h.AppendRange(std::begin(elements), std::end(elements));
}

// Support std::type_index. When TfHash support for std::hash is enabled,
// this explicit specialization will no longer be necessary.
template <class HashState>
inline void
TfHashAppend(HashState& h, std::type_index const &type_index)
{
return h.Append(type_index.hash_code());
}

// Support for hashing std::string.
template <class HashState>
inline void
Expand All @@ -151,22 +145,6 @@ TfHashAppend(HashState &h, const T* ptr) {
return h.Append(reinterpret_cast<uintptr_t>(ptr));
}

// Support for hashing std::shared_ptr. When TfHash support for std::hash is
// enabled, this explicit specialization will no longer be necessary.
template <class HashState, class T>
inline void
TfHashAppend(HashState &h, const std::shared_ptr<T>& ptr) {
h.Append(std::hash<std::shared_ptr<T>>{}(ptr));
}

// Support for hashing std::unique_ptr. When TfHash support for std::hash is
// enabled, this explicit specialization will no longer be necessary.
template <class HashState, class T>
inline void
TfHashAppend(HashState &h, const std::unique_ptr<T>& ptr) {
h.Append(std::hash<std::unique_ptr<T>>{}(ptr));
}

// We refuse to hash [const] char *. You're almost certainly trying to hash the
// pointed-to string and this will not do that (it will hash the pointer
// itself). To hash a c-style null terminated string, you can use
Expand Down Expand Up @@ -206,29 +184,24 @@ inline void TfHashAppend(HashState &h, TfCStrHashWrapper hcstr)
}

// Implementation detail: dispatch based on hash capability: Try TfHashAppend
// first, otherwise try hash_value. We'd like to otherwise try std::hash<T>,
// but std::hash<> is not SFINAE-friendly until c++17 and this code needs to
// support c++14 currently. We rely on a combination of expression SFINAE and
// establishing preferred order by passing a 0 constant and having the overloads
// take int (highest priority), long (next priority) and '...' (lowest
// priority).

// std::hash version, attempted last. Consider adding when we move to
// C++17 or newer.
/*
// first, otherwise try std::hash, followed by hash_value. We rely on a
// combination of expression SFINAE and establishing preferred order by passing
// a 0 constant and having the overloads take int (highest priority), long
// (next priority) and '...' (lowest priority).

// std::hash version, attempted second.
template <class HashState, class T>
inline auto Tf_HashImpl(HashState &h, T &&obj, ...)
inline auto Tf_HashImpl(HashState &h, T &&obj, long)
-> decltype(std::hash<typename std::decay<T>::type>()(
std::forward<T>(obj)), void())
{
TfHashAppend(
h, std::hash<typename std::decay<T>::type>()(std::forward<T>(obj)));
}
*/

// hash_value, attempted second.
// hash_value, attempted last.
template <class HashState, class T>
inline auto Tf_HashImpl(HashState &h, T &&obj, long)
inline auto Tf_HashImpl(HashState &h, T &&obj, ...)
-> decltype(hash_value(std::forward<T>(obj)), void())
{
TfHashAppend(h, hash_value(std::forward<T>(obj)));
Expand Down Expand Up @@ -437,9 +410,8 @@ class Tf_HashState : public Tf_HashStateAPI<Tf_HashState>
/// some STL types and types in Tf. TfHash uses three methods to attempt to
/// hash a passed object. First, TfHash tries to call TfHashAppend() on its
/// argument. This is the primary customization point for TfHash. If that is
/// not viable, TfHash makes an unqualified call to hash_value(). We would like
/// TfHash to try to use std::hash<T> next, but std::hash<T> is not
/// SFINAE-friendly until c++17, and this code needs to support c++14.
/// not viable, TfHash tries to call std::hash<T>{}(). Lastly, TfHash makes an
/// unqualified call to hash_value.
///
/// The best way to add TfHash support for user-defined types is to provide a
/// function overload like the following.
Expand Down Expand Up @@ -487,6 +459,7 @@ class Tf_HashState : public Tf_HashStateAPI<Tf_HashState>
/// \li TfEnum
/// \li const void*
/// \li types that provide overloads for TfHashAppend
/// \li types that provide overloads for std::hash
/// \li types that provide overloads for hash_value
///
/// The \c TfHash class can be used to instantiate a \c TfHashMap with \c string
Expand Down
13 changes: 13 additions & 0 deletions pxr/base/tf/testenv/hash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
#include "pxr/base/tf/token.h"
#include "pxr/base/tf/weakPtr.h"

#include <optional>
#include <set>
#include <string>
#include <variant>
#include <vector>

PXR_NAMESPACE_USING_DIRECTIVE
Expand Down Expand Up @@ -303,6 +305,17 @@ Test_TfHash()
// Validate support for std::unique_ptr
printf("hash(unique_ptr): %zu\n", h(std::make_unique<int>(7)));

// Validate support for std::optional
printf("hash(optional): %zu\n", h(std::make_optional<std::string>("xyz")));
TF_AXIOM(h(std::optional<std::string>("xyz")) ==
h(std::optional<std::string>("xyz")));

// Validate support for std::variant
printf("hash(variant): %zu\n",
h(std::variant<std::string, int, double>("abc")));
TF_AXIOM(h(std::variant<std::string, int, double>("abc")) ==
h(std::variant<std::string, int, double>("abc")));

TfHasher tfh;

_TestStatsOne(tfh, "TfHash");
Expand Down
9 changes: 5 additions & 4 deletions pxr/imaging/hd/dependenciesSchema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

#include "pxr/base/trace/trace.h"

// --(BEGIN CUSTOM CODE: Includes)--
// --(END CUSTOM CODE: Includes)--

PXR_NAMESPACE_OPEN_SCOPE

Expand Down Expand Up @@ -69,6 +71,7 @@ HdDependenciesSchema::GetEntries()




/*static*/
HdDependenciesSchema
HdDependenciesSchema::GetFromParent(
Expand All @@ -92,9 +95,7 @@ HdDependenciesSchema::GetSchemaToken()
const HdDataSourceLocator &
HdDependenciesSchema::GetDefaultLocator()
{
static const HdDataSourceLocator locator(
HdDependenciesSchemaTokens->__dependencies
);
static const HdDataSourceLocator locator(GetSchemaToken());
return locator;
}
PXR_NAMESPACE_CLOSE_SCOPE
PXR_NAMESPACE_CLOSE_SCOPE
6 changes: 5 additions & 1 deletion pxr/imaging/hd/dependenciesSchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
#include "pxr/imaging/hd/dependencySchema.h"


// --(BEGIN CUSTOM CODE: Includes)--
// --(END CUSTOM CODE: Includes)--

PXR_NAMESPACE_OPEN_SCOPE

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -67,6 +70,7 @@ class HdDependenciesSchema : public HdSchema

// --(END CUSTOM CODE: Schema Methods)--


/// Retrieves a container data source with the schema's default name token
/// "__dependencies" from the parent container and constructs a
/// HdDependenciesSchema instance.
Expand All @@ -90,4 +94,4 @@ class HdDependenciesSchema : public HdSchema

PXR_NAMESPACE_CLOSE_SCOPE

#endif
#endif
97 changes: 51 additions & 46 deletions pxr/imaging/hd/meshSchema.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,30 @@
////////////////////////////////////////////////////////////////////////

/* ************************************************************************** */
/* ** This file is generated by a script. Do not edit directly. Edit ** */
/* ** defs.py or the (*)Schema.template.cpp files to make changes. ** */
/* ** ** */
/* ** This file is generated by a script. ** */
/* ** ** */
/* ** Do not edit it directly (unless it is within a CUSTOM CODE section)! ** */
/* ** Edit hdGen/schema.py instead to make changes. ** */
/* ** ** */
/* ************************************************************************** */

#include "pxr/imaging/hd/meshSchema.h"
#include "pxr/imaging/hd/retainedDataSource.h"

#include "pxr/base/trace/trace.h"

// --(BEGIN CUSTOM CODE: Includes)--
// --(END CUSTOM CODE: Includes)--

PXR_NAMESPACE_OPEN_SCOPE

TF_DEFINE_PUBLIC_TOKENS(HdMeshSchemaTokens,
HDMESH_SCHEMA_TOKENS);
HD_MESH_SCHEMA_TOKENS);

// --(BEGIN CUSTOM CODE: Schema Methods)--
// --(END CUSTOM CODE: Schema Methods)--




Expand Down Expand Up @@ -86,36 +96,36 @@ HdMeshSchema::BuildRetained(
const HdBoolDataSourceHandle &doubleSided
)
{
TfToken names[5];
HdDataSourceBaseHandle values[5];
TfToken _names[5];
HdDataSourceBaseHandle _values[5];

size_t count = 0;
size_t _count = 0;
if (topology) {
names[count] = HdMeshSchemaTokens->topology;
values[count++] = topology;
_names[_count] = HdMeshSchemaTokens->topology;
_values[_count++] = topology;
}

if (subdivisionScheme) {
names[count] = HdMeshSchemaTokens->subdivisionScheme;
values[count++] = subdivisionScheme;
_names[_count] = HdMeshSchemaTokens->subdivisionScheme;
_values[_count++] = subdivisionScheme;
}

if (subdivisionTags) {
names[count] = HdMeshSchemaTokens->subdivisionTags;
values[count++] = subdivisionTags;
_names[_count] = HdMeshSchemaTokens->subdivisionTags;
_values[_count++] = subdivisionTags;
}

if (geomSubsets) {
names[count] = HdMeshSchemaTokens->geomSubsets;
values[count++] = geomSubsets;
_names[_count] = HdMeshSchemaTokens->geomSubsets;
_values[_count++] = geomSubsets;
}

if (doubleSided) {
names[count] = HdMeshSchemaTokens->doubleSided;
values[count++] = doubleSided;
_names[_count] = HdMeshSchemaTokens->doubleSided;
_values[_count++] = doubleSided;
}

return HdRetainedContainerDataSource::New(count, names, values);
return HdRetainedContainerDataSource::New(_count, _names, _values);
}

/*static*/
Expand All @@ -135,72 +145,67 @@ const TfToken &
HdMeshSchema::GetSchemaToken()
{
return HdMeshSchemaTokens->mesh;
}
}

/*static*/
const HdDataSourceLocator &
HdMeshSchema::GetDefaultLocator()
{
static const HdDataSourceLocator locator(
HdMeshSchemaTokens->mesh
);
static const HdDataSourceLocator locator(GetSchemaToken());
return locator;
}


/*static*/
const HdDataSourceLocator &
HdMeshSchema::GetTopologyLocator()
{
static const HdDataSourceLocator locator(
HdMeshSchemaTokens->mesh,
HdMeshSchemaTokens->topology
);
static const HdDataSourceLocator locator =
GetDefaultLocator().Append(
HdMeshSchemaTokens->topology);
return locator;
}

/*static*/
const HdDataSourceLocator &
HdMeshSchema::GetGeomSubsetsLocator()
HdMeshSchema::GetSubdivisionSchemeLocator()
{
static const HdDataSourceLocator locator(
HdMeshSchemaTokens->mesh,
HdMeshSchemaTokens->geomSubsets
);
static const HdDataSourceLocator locator =
GetDefaultLocator().Append(
HdMeshSchemaTokens->subdivisionScheme);
return locator;
}

/*static*/
const HdDataSourceLocator &
HdMeshSchema::GetDoubleSidedLocator()
HdMeshSchema::GetSubdivisionTagsLocator()
{
static const HdDataSourceLocator locator(
HdMeshSchemaTokens->mesh,
HdMeshSchemaTokens->doubleSided
);
static const HdDataSourceLocator locator =
GetDefaultLocator().Append(
HdMeshSchemaTokens->subdivisionTags);
return locator;
}

/*static*/
const HdDataSourceLocator &
HdMeshSchema::GetSubdivisionTagsLocator()
HdMeshSchema::GetGeomSubsetsLocator()
{
static const HdDataSourceLocator locator(
HdMeshSchemaTokens->mesh,
HdMeshSchemaTokens->subdivisionTags
);
static const HdDataSourceLocator locator =
GetDefaultLocator().Append(
HdMeshSchemaTokens->geomSubsets);
return locator;
}

/*static*/
const HdDataSourceLocator &
HdMeshSchema::GetSubdivisionSchemeLocator()
HdMeshSchema::GetDoubleSidedLocator()
{
static const HdDataSourceLocator locator(
HdMeshSchemaTokens->mesh,
HdMeshSchemaTokens->subdivisionScheme
);
static const HdDataSourceLocator locator =
GetDefaultLocator().Append(
HdMeshSchemaTokens->doubleSided);
return locator;
}


HdMeshSchema::Builder &
HdMeshSchema::Builder::SetTopology(
const HdContainerDataSourceHandle &topology)
Expand Down
Loading

0 comments on commit 6676799

Please sign in to comment.